Skip to content

Commit c01aea8

Browse files
authored
Merge pull request #1074 from dunglas/stanmaster
Fix PHPStan errors in master
2 parents b88d975 + d7aa12d commit c01aea8

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ parameters:
1414
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects Doctrine\\ORM\\Query\\Expr\\Base, Doctrine\\ORM\\Query\\Expr\\Join\[\] given#' # Fixed in Doctrine's master
1515
- '#Parameter \#1 \$rootNode of method ApiPlatform\\Core\\Bridge\\Symfony\\Bundle\\DependencyInjection\\Configuration::[a-zA-Z0-9]+\(\) expects Symfony\\Component\\Config\\Definition\\Builder\\ArrayNodeDefinition, Symfony\\Component\\Config\\Definition\\Builder\\ArrayNodeDefinition|Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition given#'
1616
- '#Parameter \#1 \$source of static method ApiPlatform\\Core\\Util\\RequestParser::parseRequestParams\(\) expects string, string\|resource given#'
17+
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'

src/Metadata/Extractor/XmlExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function getOperations(\SimpleXMLElement $resource, string $operationTyp
7575
$operationsParent = $operationType.'s';
7676

7777
if (!isset($resource->$operationsParent)) {
78-
return;
78+
return null;
7979
}
8080

8181
return $this->getAttributes($resource->$operationsParent, $operationType);

tests/Bridge/Doctrine/Orm/Filter/ExistsFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Tests\Doctrine\Orm\Filter;
14+
namespace ApiPlatform\Core\Tests\Bridge\Doctrine\Orm\Filter;
1515

1616
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
1717
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;

tests/Bridge/Doctrine/Util/IdentifierManagerTraitTest.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Core\Tests\Doctrine\Util;
14+
namespace ApiPlatform\Core\Tests\Bridge\Doctrine\Util;
1515

1616
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\IdentifierManagerTrait;
1717
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
@@ -26,21 +26,23 @@
2626
use Doctrine\DBAL\Types\Type as DBALType;
2727
use Doctrine\ORM\EntityManagerInterface;
2828

29-
class IdentifierManagerTraitImpl
29+
class IdentifierManagerTraitTest extends \PHPUnit_Framework_TestCase
3030
{
31-
use IdentifierManagerTrait {
32-
IdentifierManagerTrait::normalizeIdentifiers as public;
33-
}
34-
35-
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory)
31+
private function getIdentifierManagerTraitImpl(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory)
3632
{
37-
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
38-
$this->propertyMetadataFactory = $propertyMetadataFactory;
33+
return new class($propertyNameCollectionFactory, $propertyMetadataFactory) {
34+
use IdentifierManagerTrait {
35+
IdentifierManagerTrait::normalizeIdentifiers as public;
36+
}
37+
38+
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory)
39+
{
40+
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
41+
$this->propertyMetadataFactory = $propertyMetadataFactory;
42+
}
43+
};
3944
}
40-
}
4145

42-
class IdentifierManagerTraitTest extends \PHPUnit_Framework_TestCase
43-
{
4446
public function testSingleIdentifier()
4547
{
4648
list($propertyNameCollectionFactory, $propertyMetadataFactory) = $this->getMetadataFactories(Dummy::class, [
@@ -52,7 +54,7 @@ public function testSingleIdentifier()
5254
],
5355
]);
5456

55-
$identifierManager = new IdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
57+
$identifierManager = $this->getIdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
5658

5759
$this->assertEquals($identifierManager->normalizeIdentifiers(1, $objectManager, Dummy::class), ['id' => 1]);
5860
}
@@ -72,7 +74,7 @@ public function testCompositeIdentifier()
7274
],
7375
]);
7476

75-
$identifierManager = new IdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
77+
$identifierManager = $this->getIdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
7678

7779
$this->assertEquals($identifierManager->normalizeIdentifiers('ida=1;idb=2', $objectManager, Dummy::class), ['ida' => 1, 'idb' => 2]);
7880
}
@@ -96,7 +98,7 @@ public function testInvalidIdentifier()
9698
],
9799
]);
98100

99-
$identifierManager = new IdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
101+
$identifierManager = $this->getIdentifierManagerTraitImpl($propertyNameCollectionFactory, $propertyMetadataFactory);
100102

101103
$identifierManager->normalizeIdentifiers('idbad=1;idb=2', $objectManager, Dummy::class);
102104
}

0 commit comments

Comments
 (0)