Skip to content

Commit

Permalink
Merge branch '2.9.x' into fix-typed-2.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Apr 18, 2021
2 parents 25270cb + 261a405 commit ddcc61c
Show file tree
Hide file tree
Showing 101 changed files with 3,844 additions and 635 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.0",
"phpstan/phpstan": "^0.12.18",
"doctrine/coding-standard": "^9.0",
"phpstan/phpstan": "^0.12.83",
"phpunit/phpunit": "^8.5|^9.4",
"squizlabs/php_codesniffer": "3.6.0",
"symfony/yaml": "^3.4|^4.0|^5.0",
"vimeo/psalm": "4.3.2"
"vimeo/psalm": "4.7.0"
},
"suggest": {
"symfony/yaml": "If you want to use YAML Metadata Mapping Driver"
Expand Down
5 changes: 5 additions & 0 deletions docs/en/reference/annotations-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,11 @@ Example:

@NamedNativeQuery
~~~~~~~~~~~~~~~~~

.. note::

Named Native Queries are deprecated as of version 2.9 and will be removed in ORM 3.0

Is used to specify a native SQL named query.
The NamedNativeQuery annotation can be applied to an entity or mapped superclass.

Expand Down
26 changes: 15 additions & 11 deletions docs/en/reference/native-sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ with inheritance hierarchies.
use Doctrine\ORM\Query\ResultSetMappingBuilder;
$sql = "SELECT u.id, u.name, a.id AS address_id, a.street, a.city " .
$sql = "SELECT u.id, u.name, a.id AS address_id, a.street, a.city " .
"FROM users u INNER JOIN address a ON u.address_id = a.id";
$rsm = new ResultSetMappingBuilder($entityManager);
Expand Down Expand Up @@ -265,7 +265,7 @@ detail:
<?php
/**
* Adds a meta column (foreign key or discriminator column) to the result set.
*
*
* @param string $alias
* @param string $columnAlias
* @param string $columnName
Expand Down Expand Up @@ -320,10 +320,10 @@ entity.
$rsm->addEntityResult('User', 'u');
$rsm->addFieldResult('u', 'id', 'id');
$rsm->addFieldResult('u', 'name', 'name');
$query = $this->_em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
The result would look like this:
Expand Down Expand Up @@ -356,10 +356,10 @@ thus owns the foreign key.
$rsm->addFieldResult('u', 'id', 'id');
$rsm->addFieldResult('u', 'name', 'name');
$rsm->addMetaResult('u', 'address_id', 'address_id');
$query = $this->_em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Foreign keys are used by Doctrine for lazy-loading purposes when
Expand All @@ -385,12 +385,12 @@ associations that are lazy.
$rsm->addFieldResult('a', 'address_id', 'id');
$rsm->addFieldResult('a', 'street', 'street');
$rsm->addFieldResult('a', 'city', 'city');
$sql = 'SELECT u.id, u.name, a.id AS address_id, a.street, a.city FROM users u ' .
'INNER JOIN address a ON u.address_id = a.id WHERE u.name = ?';
$query = $this->_em->createNativeQuery($sql, $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
In this case the nested entity ``Address`` is registered with the
Expand Down Expand Up @@ -420,10 +420,10 @@ to map the hierarchy (both use a discriminator column).
$rsm->addFieldResult('u', 'name', 'name');
$rsm->addMetaResult('u', 'discr', 'discr'); // discriminator column
$rsm->setDiscriminatorColumn('u', 'discr');
$query = $this->_em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Note that in the case of Class Table Inheritance, an example as
Expand All @@ -435,6 +435,10 @@ strategy but with native SQL it is your responsibility.
Named Native Query
------------------

.. note::

Named Native Queries are deprecated as of version 2.9 and will be removed in ORM 3.0

You can also map a native query using a named native query mapping.

To achieve that, you must describe the SQL resultset structure
Expand Down Expand Up @@ -789,7 +793,7 @@ followed by a dot ("."), followed by the name or the field or property of the pr
6:
name: address.country
column: a_country
If you retrieve a single entity and if you use the default mapping,
Expand Down
24 changes: 10 additions & 14 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Cache\Logging\CacheLogger;
use Doctrine\ORM\Cache\QueryCacheKey;
Expand Down Expand Up @@ -344,10 +344,9 @@ static function (Query\Parameter $parameter) use ($key): bool {
* Sets a collection of query parameters.
*
* @param ArrayCollection|mixed[] $parameters
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*
* @return static This query instance.
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*/
public function setParameters($parameters)
{
Expand Down Expand Up @@ -400,10 +399,9 @@ public function setParameter($key, $value, $type = null)
* @param mixed $value
*
* @return mixed[]|string|int|float|bool
* @psalm-return array|scalar
*
* @throws ORMInvalidArgumentException
*
* @psalm-return array|scalar
*/
public function processParameterValue($value)
{
Expand Down Expand Up @@ -983,10 +981,9 @@ public function iterate($parameters = null, $hydrationMode = null)
*
* @param ArrayCollection|mixed[] $parameters The query parameters.
* @param string|int|null $hydrationMode The hydration mode to use.
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*
* @return iterable<mixed>
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[] $parameters
*/
public function toIterable(iterable $parameters = [], $hydrationMode = null): iterable
{
Expand Down Expand Up @@ -1017,10 +1014,9 @@ public function toIterable(iterable $parameters = [], $hydrationMode = null): it
*
* @param ArrayCollection|mixed[]|null $parameters Query parameters.
* @param string|int|null $hydrationMode Processing mode to be used during the hydration process.
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
public function execute($parameters = null, $hydrationMode = null)
{
Expand All @@ -1036,10 +1032,9 @@ public function execute($parameters = null, $hydrationMode = null)
*
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
private function executeIgnoreQueryCache($parameters = null, $hydrationMode = null)
{
Expand Down Expand Up @@ -1097,10 +1092,9 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu
*
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*
* @return mixed
*
* @psalm-param ArrayCollection<int, Parameter>|mixed[]|null $parameters
*/
private function executeUsingQueryCache($parameters = null, $hydrationMode = null)
{
Expand Down Expand Up @@ -1211,7 +1205,9 @@ public function getResultCacheId()
/**
* Executes the query and returns a the resulting Statement object.
*
* @return Statement The executed database statement that holds the results.
* @return ResultStatement|int The executed database statement that holds
* the results, or an integer indicating how
* many rows were affected.
*/
abstract protected function _doExecute();

Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h
* @param mixed $assocValue
*
* @return mixed[]|null
*
* @psalm-return array{targetEntity: string, type: mixed, list?: array[], identifier?: array}|null
*/
private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue)
Expand Down
38 changes: 13 additions & 25 deletions lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl)
* is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
*
* @param bool $useSimpleAnnotationReader
* @psalm-param string|list<string> $paths
*
* @return AnnotationDriver
*
* @psalm-param string|list<string> $paths
*/
public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
{
Expand Down Expand Up @@ -209,9 +208,9 @@ public function getEntityNamespace($entityNamespaceAlias)
/**
* Sets the entity alias map.
*
* @return void
*
* @psalm-param array<string, string> $entityNamespaces
*
* @return void
*/
public function setEntityNamespaces(array $entityNamespaces)
{
Expand Down Expand Up @@ -350,13 +349,13 @@ public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
*
* @param string $name The name of the query.
*
* @throws ORMException
*
* @psalm-return array{string, ResultSetMapping} A tuple with the first
* element being the SQL
* string and the second
* element being the
* ResultSetMapping.
*
* @throws ORMException
*/
public function getNamedNativeQuery($name)
{
Expand Down Expand Up @@ -426,7 +425,6 @@ public function addCustomStringFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string
*/
public function getCustomStringFunction($name)
Expand All @@ -444,10 +442,10 @@ public function getCustomStringFunction($name)
*
* Any previously added string functions are discarded.
*
* @return void
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL string functions.
*
* @return void
*/
public function setCustomStringFunctions(array $functions)
{
Expand Down Expand Up @@ -479,7 +477,6 @@ public function addCustomNumericFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string
*/
public function getCustomNumericFunction($name)
Expand All @@ -497,10 +494,10 @@ public function getCustomNumericFunction($name)
*
* Any previously added numeric functions are discarded.
*
* @return void
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL numeric functions.
*
* @return void
*/
public function setCustomNumericFunctions(array $functions)
{
Expand All @@ -518,10 +515,9 @@ public function setCustomNumericFunctions(array $functions)
*
* @param string $name Function name.
* @param string|callable $className Class name or a callable that returns the function.
* @psalm-param class-string|callable $className
*
* @return void
*
* @psalm-param class-string|callable $className
*/
public function addCustomDatetimeFunction($name, $className)
{
Expand All @@ -534,7 +530,6 @@ public function addCustomDatetimeFunction($name, $className)
* @param string $name
*
* @return string|null
*
* @psalm-return ?class-string $name
*/
public function getCustomDatetimeFunction($name)
Expand All @@ -553,10 +548,9 @@ public function getCustomDatetimeFunction($name)
* Any previously added date/time functions are discarded.
*
* @param array $functions The map of custom DQL date/time functions.
* @psalm-param array<string, string> $functions
*
* @return void
*
* @psalm-param array<string, string> $functions
*/
public function setCustomDatetimeFunctions(array $functions)
{
Expand Down Expand Up @@ -587,7 +581,6 @@ public function setCustomHydrationModes($modes)
* @param string $modeName The hydration mode name.
*
* @return string|null The hydrator class name.
*
* @psalm-return ?class-string
*/
public function getCustomHydrationMode($modeName)
Expand All @@ -599,10 +592,9 @@ public function getCustomHydrationMode($modeName)
* Adds a custom hydration mode.
*
* @param string $modeName The hydration mode name.
* @psalm-param class-string $hydrator The hydrator class name.
*
* @return void
*
* @psalm-param class-string $hydrator The hydrator class name.
*/
public function addCustomHydrationMode($modeName, $hydrator)
{
Expand All @@ -613,10 +605,9 @@ public function addCustomHydrationMode($modeName, $hydrator)
* Sets a class metadata factory.
*
* @param string $cmfName
* @psalm-param class-string $cmfName
*
* @return void
*
* @psalm-param class-string $cmfName
*/
public function setClassMetadataFactoryName($cmfName)
{
Expand All @@ -625,7 +616,6 @@ public function setClassMetadataFactoryName($cmfName)

/**
* @return string
*
* @psalm-return class-string
*/
public function getClassMetadataFactoryName()
Expand Down Expand Up @@ -655,7 +645,6 @@ public function addFilter($name, $className)
*
* @return string|null The class name of the filter, or null if it is not
* defined.
*
* @psalm-return ?class-string
*/
public function getFilterClassName($name)
Expand Down Expand Up @@ -687,7 +676,6 @@ public function setDefaultRepositoryClassName($className)
* Get default repository class.
*
* @return string
*
* @psalm-return class-string
*/
public function getDefaultRepositoryClassName()
Expand Down
Loading

0 comments on commit ddcc61c

Please sign in to comment.