Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes from PHPStan l2 #7136

Merged
merged 1 commit into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,5 @@ Example usage
$query = $em->createQuery("SELECT l FROM Geo\Entity\Location WHERE l.address = '1600 Amphitheatre Parkway, Mountain View, CA'");
$location = $query->getSingleResult();

/* @var Geo\ValueObject\Point */
/** @var Geo\ValueObject\Point $point */
$point = $location->getPoint();
3 changes: 1 addition & 2 deletions docs/en/cookbook/dql-custom-walkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The ``Paginate::count(Query $query)`` looks like:
{
static public function count(Query $query)
{
/* @var $countQuery Query */
/** @var Query $countQuery */
$countQuery = clone $query;

$countQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('DoctrineExtensions\Paginate\CountSqlWalker'));
Expand Down Expand Up @@ -212,4 +212,3 @@ understanding of the DQL Parser and Walkers, but may offer your
huge benefits with using vendor specific features. This would still
allow you write DQL queries instead of NativeQueries to make use of
vendor specific features.

2 changes: 1 addition & 1 deletion docs/en/cookbook/dql-user-defined-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ I'll skip the blah and show the code for this function:

$parser->match(Lexer::T_IDENTIFIER);

/* @var $lexer Lexer */
/** @var Lexer $lexer */
$lexer = $parser->getLexer();
$this->unit = $lexer->token['value'];

Expand Down
20 changes: 10 additions & 10 deletions docs/en/reference/second-level-cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ To enable the second-level-cache, you should provide a cache factory
.. code-block:: php

<?php
/* @var $config \Doctrine\ORM\Cache\RegionsConfiguration */
/* @var $cache \Doctrine\Common\Cache\Cache */
/** @var \Doctrine\ORM\Cache\RegionsConfiguration $config */
/** @var \Doctrine\Common\Cache\Cache $cache */

$factory = new \Doctrine\ORM\Cache\DefaultCacheFactory($config, $cache);

Expand Down Expand Up @@ -210,8 +210,8 @@ To specify a default lifetime for all regions or specify a different lifetime fo
.. code-block:: php

<?php
/* @var $config \Doctrine\ORM\Configuration */
/* @var $cacheConfig \Doctrine\ORM\Cache\CacheConfiguration */
/** @var \Doctrine\ORM\Configuration $config */
/** @var \Doctrine\ORM\Cache\CacheConfiguration $cacheConfig */
$cacheConfig = $config->getSecondLevelCacheConfiguration();
$regionConfig = $cacheConfig->getRegionsConfiguration();

Expand All @@ -228,7 +228,7 @@ By providing a cache logger you should be able to get information about all cach
.. code-block:: php

<?php
/* @var $config \Doctrine\ORM\Configuration */
/** @var \Doctrine\ORM\Configuration $config */
$logger = new \Doctrine\ORM\Cache\Logging\StatisticsCacheLogger();

// Cache logger
Expand Down Expand Up @@ -472,7 +472,7 @@ The query cache stores the results of the query but as identifiers, entity value
.. code-block:: php

<?php
/* @var $em \Doctrine\ORM\EntityManager */
/** @var \Doctrine\ORM\EntityManager $em */

// Execute database query, store query cache and entity cache
$result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
Expand All @@ -499,7 +499,7 @@ The Cache Mode controls how a particular query interacts with the second-level c
.. code-block:: php

<?php
/* @var $em \Doctrine\ORM\EntityManager */
/** @var \Doctrine\ORM\EntityManager $em */
// Will refresh the query cache and all entities the cache as it reads from the database.
$result1 = $em->createQuery('SELECT c FROM Country c ORDER BY c.name')
->setCacheMode(Cache::MODE_GET)
Expand Down Expand Up @@ -584,7 +584,7 @@ However, you can use the cache API to check / invalidate cache entries.
.. code-block:: php

<?php
/* @var $cache \Doctrine\ORM\Cache */
/** @var \Doctrine\ORM\Cache $cache */
$cache = $em->getCache();

$cache->containsEntity('Entity\State', 1) // Check if the cache exists
Expand Down Expand Up @@ -629,11 +629,11 @@ For performance reasons the cache API does not extract from composite primary ke
}

// Supported
/* @var $article Article */
/** @var Article $article */
$article = $em->find('Article', 1);

// Supported
/* @var $article Article */
/** @var Article $article */
$article = $em->find('Article', $article);

// Supported
Expand Down
3 changes: 1 addition & 2 deletions docs/en/reference/unitofwork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ will still end up with the same reference:

public function testIdentityMapReference()
{
/* @var $objectA EntityName|\ProxyManager\Proxy\GhostObjectInterface */
/** @var EntityName|\ProxyManager\Proxy\GhostObjectInterface $objectA */
$objectA = $this->entityManager->getReference(EntityName::class, 1);

self::assertInstanceOf(\ProxyManager\Proxy\GhostObjectInterface::class, $objectA);
Expand Down Expand Up @@ -198,4 +198,3 @@ ClassMetadataFactory
~~~~~~~~~~~~~~~~~~~~

tbr

5 changes: 3 additions & 2 deletions lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Doctrine\ORM\Cache;

use Doctrine\ORM\Cache\Persister\CachedPersister;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\PersistentCollection;
Expand Down Expand Up @@ -56,7 +57,7 @@ public function loadCacheEntry(
CollectionCacheEntry $entry,
PersistentCollection $collection
) {
/* @var $targetPersister \Doctrine\ORM\Cache\Persister\CachedPersister */
/** @var CachedPersister $targetPersister */
$association = $metadata->getProperty($key->association);
$targetPersister = $this->uow->getEntityPersister($association->getTargetEntity());
$targetRegion = $targetPersister->getCacheRegion();
Expand All @@ -68,7 +69,7 @@ public function loadCacheEntry(
return null;
}

/* @var $entityEntries \Doctrine\ORM\Cache\EntityCacheEntry[] */
/** @var EntityCacheEntry[] $entityEntries */
foreach ($entityEntries as $index => $entityEntry) {
$data = $entityEntry->resolveAssociationEntries($this->em);

Expand Down
3 changes: 1 addition & 2 deletions lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h
}

/**
* @param AssociationMetadata $assoc
* @param mixed[] $assocValue
* @param mixed[] $assocValue
*
* @return mixed[]|null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\ORM\Cache\CollectionHydrator;
use Doctrine\ORM\Cache\EntityCacheKey;
use Doctrine\ORM\Cache\Logging\CacheLogger;
use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister;
use Doctrine\ORM\Cache\Region;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\AssociationMetadata;
Expand Down Expand Up @@ -135,7 +136,7 @@ public function loadCollectionCache(PersistentCollection $collection, Collection
*/
public function storeCollectionCache(CollectionCacheKey $key, $elements)
{
/* @var $targetPersister CachedEntityPersister */
/** @var CachedEntityPersister $targetPersister */
$association = $this->sourceEntity->getProperty($key->association);
$targetPersister = $this->uow->getEntityPersister($this->targetEntity->getRootClassName());
$targetRegion = $targetPersister->getCacheRegion();
Expand Down Expand Up @@ -271,7 +272,7 @@ protected function evictCollectionCache(PersistentCollection $collection)
*/
protected function evictElementCache($targetEntity, $element)
{
/* @var $targetPersister CachedEntityPersister */
/** @var CachedEntityPersister $targetPersister */
$targetPersister = $this->uow->getEntityPersister($targetEntity);
$targetRegion = $targetPersister->getCacheRegion();
$key = new EntityCacheKey($targetEntity, $this->uow->getEntityIdentifier($element));
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DefaultMultiGetRegion extends DefaultRegion
*/
public function __construct($name, MultiGetCache $cache, $lifetime = 0)
{
/* @var $cache \Doctrine\Common\Cache\Cache */
/** @var Cache $cache */
parent::__construct($name, $cache, $lifetime);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ abstract protected function hydrateAllData();
* field names during this procedure as well as any necessary conversions on
* the values applied. Scalar values are kept in a specific key 'scalars'.
*
* @param mixed[] $data SQL Result Row.
* @param mixed[] &$id Dql-Alias => ID-Hash.
* @param mixed[] &$nonemptyComponents Does this DQL-Alias has at least one non NULL value?
* @param mixed[] $data SQL Result Row.
* @param mixed[] $id Dql-Alias => ID-Hash.
* @param mixed[] $nonemptyComponents Does this DQL-Alias has at least one non NULL value?
*
* @return mixed[] An array with all the fields (name => value) of the data row,
* grouped by their component alias.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private function getEntity(array $data, $dqlAlias)
*/
private function getEntityFromIdentityMap($className, array $data)
{
/* @var ClassMetadata $class */
/** @var ClassMetadata $class */
$class = $this->metadataCache[$className];
$id = $this->em->getIdentifierFlattener()->flattenIdentifier($class, $data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function loadMetadataForClass(
}

// Evaluate annotations on properties/fields
/* @var $reflProperty \ReflectionProperty */
/** @var \ReflectionProperty $reflProperty */
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($reflectionProperty->getDeclaringClass()->getName() !== $reflectionClass->getName()) {
continue;
Expand Down Expand Up @@ -569,7 +569,7 @@ private function convertReflectionPropertyToFieldMetadata(

break;

/* @todo If it is not supported, why does this exist? */
/** @todo If it is not supported, why does this exist? */
case isset($propertyAnnotations['Doctrine\ORM\Mapping\TableGenerator']):
throw Mapping\MappingException::tableIdGeneratorNotImplemented($className);
}
Expand Down Expand Up @@ -1064,7 +1064,7 @@ private function attachLifecycleCallbacks(
) : void {
// Evaluate @HasLifecycleCallbacks annotation
if (isset($classAnnotations[Annotation\HasLifecycleCallbacks::class])) {
/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$metadata->addLifecycleCallback($method->getName(), $callback);
Expand Down Expand Up @@ -1099,7 +1099,7 @@ private function attachEntityListeners(

$listenerClass = new \ReflectionClass($listenerClassName);

/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$metadata->addEntityListener($callback, $listenerClassName, $method->getName());
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function loadMetadataForClass(
}

// Evaluate annotations on properties/fields
/* @var $reflProperty \ReflectionProperty */
/** @var \ReflectionProperty $reflProperty */
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($reflectionProperty->getDeclaringClass()->getName() !== $reflectionClass->getName()) {
continue;
Expand Down Expand Up @@ -577,7 +577,7 @@ private function convertReflectionPropertyToFieldMetadata(

break;

/* @todo If it is not supported, why does this exist? */
/** @todo If it is not supported, why does this exist? */
case isset($propertyAnnotations['Doctrine\ORM\Mapping\TableGenerator']):
throw Mapping\MappingException::tableIdGeneratorNotImplemented($className);
}
Expand Down Expand Up @@ -1074,7 +1074,7 @@ private function attachLifecycleCallbacks(
) : void {
// Evaluate @HasLifecycleCallbacks annotation
if (isset($classAnnotations[Annotation\HasLifecycleCallbacks::class])) {
/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$metadata->addLifecycleCallback($method->getName(), $callback);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ private function attachEntityListeners(

$listenerClass = new \ReflectionClass($listenerClassName);

/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$metadata->addEntityListener($callback, $listenerClassName, $method->getName());
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/DriverChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function loadMetadataForClass(
Mapping\ClassMetadata $metadata,
Mapping\ClassMetadataBuildingContext $metadataBuildingContext
) {
/* @var $driver MappingDriver */
/** @var MappingDriver $driver */
foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
$driver->loadMetadataForClass($className, $metadata, $metadataBuildingContext);
Expand All @@ -95,7 +95,7 @@ public function getAllClassNames()
$classNames = [];
$driverClasses = [];

/* @var $driver MappingDriver */
/** @var MappingDriver $driver */
foreach ($this->drivers as $namespace => $driver) {
$oid = spl_object_id($driver);

Expand Down Expand Up @@ -124,7 +124,7 @@ public function getAllClassNames()
*/
public function isTransient($className)
{
/* @var $driver MappingDriver */
/** @var MappingDriver $driver */
foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
return $driver->isTransient($className);
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/NewAnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function loadMetadataForClass(
}

// Evaluate annotations on properties/fields
/* @var \ReflectionProperty $reflectionProperty */
/** @var \ReflectionProperty $reflectionProperty */
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($reflectionProperty->getDeclaringClass()->getClassName() !== $reflectionClass->getName()) {
continue;
Expand Down Expand Up @@ -263,7 +263,7 @@ private function convertClassAnnotationsToEntityClassMetadata(

$listenerClass = new \ReflectionClass($listenerClassName);

/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$classMetadata->addEntityListener($callback, $listenerClassName, $method->getName());
Expand All @@ -274,7 +274,7 @@ private function convertClassAnnotationsToEntityClassMetadata(

// Evaluate @HasLifecycleCallbacks annotation
if (isset($classAnnotations[Annotation\HasLifecycleCallbacks::class])) {
/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$classMetadata->addLifecycleCallback($method->getName(), $callback);
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function loadMetadataForClass(
Mapping\ClassMetadata $metadata,
Mapping\ClassMetadataBuildingContext $metadataBuildingContext
) {
/* @var \SimpleXMLElement $xmlRoot */
/** @var SimpleXMLElement $xmlRoot */
$xmlRoot = $this->getElement($className);

if ($xmlRoot->getName() === 'entity') {
Expand Down Expand Up @@ -658,7 +658,7 @@ public function loadMetadataForClass(

// Evaluate the listener using naming convention.
if ($listenerElement->count() === 0) {
/* @var $method \ReflectionMethod */
/** @var \ReflectionMethod $method */
foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $callback) {
$metadata->addEntityListener($callback, $listenerClassName, $method->getName());
Expand Down Expand Up @@ -689,7 +689,7 @@ private function parseOptions(SimpleXMLElement $options)
{
$array = [];

/* @var $option SimpleXMLElement */
/** @var SimpleXMLElement $option */
foreach ($options as $option) {
if ($option->count()) {
$value = $this->parseOptions($option->children());
Expand Down Expand Up @@ -859,7 +859,7 @@ private function getCascadeMappings(SimpleXMLElement $cascadeElement)
{
$cascades = [];

/* @var $action SimpleXmlElement */
/** @var SimpleXMLElement $action */
foreach ($cascadeElement->children() as $action) {
// According to the JPA specifications, XML uses "cascade-persist"
// instead of "persist". Here, both variations are supported
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/ORMInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public static function invalidIdentifierBindingEntity()
}

/**
* @param array $assoc
* @param mixed $actualValue
*
* @return self
Expand Down
Loading