Skip to content
Open
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
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"doctrine/inflector": "^1.0 || ^2.0",
"fig/link-util": "^1.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/container": "^1.0",
"psr/container": "^1.0 || ^2.0",
"symfony/http-foundation": "^4.4 || ^5.1",
"symfony/http-kernel": "^4.4 || ^5.1",
"symfony/property-access": "^3.4.19 || ^4.4 || ^5.1",
Expand All @@ -30,7 +30,7 @@
"behat/behat": "^3.1",
"behat/mink": "^1.7",
"doctrine/annotations": "^1.7",
"doctrine/cache": "^1.11",
"doctrine/cache": "^1.11 || ^2.1",
"doctrine/common": "^2.11 || ^3.0",
"doctrine/data-fixtures": "^1.2.2",
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
Expand All @@ -42,16 +42,16 @@
"friends-of-behat/mink-extension": "^2.2",
"friends-of-behat/symfony-extension": "^2.1",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"jangregor/phpstan-prophecy": "^0.8",
"jangregor/phpstan-prophecy": "^1.0",
"justinrainbow/json-schema": "^5.2.1",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.1",
"phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.4",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.65",
"phpstan/phpstan-doctrine": "^0.12.7",
"phpstan/phpstan-phpunit": "^0.12.4",
"phpstan/phpstan-symfony": "^0.12.4",
"psr/log": "^1.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ramsey/uuid": "^3.7 || ^4.0",
"ramsey/uuid-doctrine": "^1.4",
"soyuka/contexts": "^3.3.1",
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ parameters:
symfony:
container_xml_path: tests/Fixtures/app/var/cache/test/AppKernelTestDebugContainer.xml
constant_hassers: false
doctrine:
objectManagerLoader: tests/Fixtures/app/object-manager.php
bootstrapFiles:
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
# We're aliasing classes for phpunit in this file, it needs to be added here see phpstan/#2194
- src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubset.php
- tests/Fixtures/app/AppKernel.php
excludes_analyse:
excludePaths:
# Symfony cache
- tests/Fixtures/app/var/cache
# Deprecated integrations (will be removed in API Platform 3)
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/ApiFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(
) {
if (\is_array($filterClass)) { /** @phpstan-ignore-line Doctrine annotations */
$options = $filterClass;
$this->filterClass = $options['value'] ?? null;
$this->filterClass = $options['value'] ?? null; /** @phpstan-ignore-line Doctrine annotations */
unset($options['value']);

foreach ($options as $key => $value) {
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,6 @@ public function __construct(
}
}

$this->hydrateAttributes($description ?? []);
$this->hydrateAttributes($description ?? []); // @phpstan-ignore-line
}
}
10 changes: 6 additions & 4 deletions src/Annotation/ApiSubresource.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ final class ApiSubresource
*/
public function __construct($maxDepth = null)
{
if (!\is_array($maxDepth)) { // @phpstan-ignore-line
$this->maxDepth = $maxDepth;
} else {
$this->maxDepth = $maxDepth['maxDepth'] ?? null;
if (\is_array($maxDepth)) { // @phpstan-ignore-line
$this->maxDepth = $maxDepth['maxDepth'] ?? null; // @phpstan-ignore-line

return;
}

$this->maxDepth = $maxDepth;
}
}
7 changes: 2 additions & 5 deletions src/Bridge/Doctrine/MongoDbOdm/CollectionDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ public function getCollection(string $resourceClass, string $operationName = nul
/** @var DocumentManager $manager */
$manager = $this->managerRegistry->getManagerForClass($resourceClass);

/** @var DocumentRepository $repository */
$repository = $manager->getRepository($resourceClass);
if (!$repository instanceof DocumentRepository) {
throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $resourceClass, DocumentRepository::class));
}

$aggregationBuilder = $repository->createAggregationBuilder();
foreach ($this->collectionExtensions as $extension) {
$extension->applyToCollection($aggregationBuilder, $resourceClass, $operationName, $context);
Expand All @@ -79,6 +76,6 @@ public function getCollection(string $resourceClass, string $operationName = nul
$attribute = $resourceMetadata->getCollectionOperationAttribute($operationName, 'doctrine_mongodb', [], true);
$executeOptions = $attribute['execute_options'] ?? [];

return $aggregationBuilder->hydrate($resourceClass)->execute($executeOptions);
return $aggregationBuilder->hydrate($resourceClass)->getAggregation($executeOptions)->getIterator();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
throw new RuntimeException(sprintf('The manager for "%s" must be an instance of "%s".', $resourceClass, DocumentManager::class));
}

/**
* @var DocumentRepository
*/
$repository = $manager->getRepository($resourceClass);
if (!$repository instanceof DocumentRepository) {
throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $resourceClass, DocumentRepository::class));
}

$resultsAggregationBuilder = $repository->createAggregationBuilder()->skip($offset);
if ($limit > 0) {
$resultsAggregationBuilder->limit($limit);
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/DummyObjectWithConstructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
class DummyObjectWithConstructor
{
private $foo;
private $bar;
private $foo; // @phpstan-ignore-line
private $bar; // @phpstan-ignore-line

public function __construct(string $foo, \stdClass $bar)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Document/VoDummyInspection.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class VoDummyInspection
*/
private $performed;

private $attributeWithoutConstructorEquivalent;
private $attributeWithoutConstructorEquivalent; /** @phpstan-ignore-line Intentionally non-serialized value */

public function __construct(bool $accepted, VoDummyCar $car, DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '')
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Document/WithJsonDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class WithJsonDummy
{
/**
* @var int
* @var int|null
*
* @ODM\Id(strategy="INCREMENT", type="int", nullable=true)
* @ODM\Id(strategy="INCREMENT", type="int")
*/
private $id;

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class User extends AbstractSecurityUser
*
* @Groups({"user"})
*/
private $username;
private $username; /** @phpstan-ignore-line Used through serialization group */

public function getId(): int
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/VoDummyInspection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VoDummyInspection
private $accepted;

/**
* @var VoDummyCar
* @var VoDummyCar|null
*
* @ORM\ManyToOne(targetEntity="VoDummyCar", inversedBy="inspections")
* @Groups({"inspection_read", "inspection_write"})
Expand All @@ -56,7 +56,7 @@ class VoDummyInspection
*/
private $performed;

private $attributeWithoutConstructorEquivalent;
private $attributeWithoutConstructorEquivalent; /** @phpstan-ignore-line Intentionally non-serialized value */

public function __construct(bool $accepted, VoDummyCar $car, DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '')
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Entity/VoDummyVehicle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class VoDummyVehicle
private $make;

/**
* @var VoDummyInsuranceCompany
* @var VoDummyInsuranceCompany|null
*
* @ORM\ManyToOne(targetEntity="VoDummyInsuranceCompany", cascade={"persist"})
* @Groups({"car_read", "car_write"})
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/TestBundle/Entity/WithJsonDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class WithJsonDummy
{
/**
* @var int
* @var int|null
*
* @ORM\Column(type="integer", nullable=true)
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
Expand Down
5 changes: 3 additions & 2 deletions tests/Fixtures/app/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Debug\Debug as LegacyDebug;
use Symfony\Component\ErrorHandler\Debug;

set_time_limit(0);

Expand All @@ -15,7 +16,7 @@ $env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'test'
$debug = ($_SERVER['APP_DEBUG'] ?? false) && !$input->hasParameterOption('--no-debug', true) && 'prod' !== $env;

if ($debug) {
Debug::enable();
class_exists(Debug::class) ? Debug::enable() : LegacyDebug::enable();
}

error_reporting(\E_ALL & ~\E_USER_DEPRECATED);
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/app/object-manager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// See https://github.com/phpstan/phpstan-doctrine#configuration

$kernel = new AppKernel($_SERVER['APP_ENV'] ?? 'test', (bool) ($_SERVER['APP_DEBUG'] ?? false));
$kernel->boot();
return $kernel->getContainer()->get('doctrine')->getManager();
7 changes: 5 additions & 2 deletions tests/Swagger/Serializer/DocumentationNormalizerV3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,10 @@ public function testLegacyNormalizeWithCustomFormatsDefinedAtOperationLevel(): v
$this->doTestNormalizeWithCustomFormatsDefinedAtOperationLevel($formatProviderProphecy->reveal());
}

private function doTestNormalizeWithCustomFormatsDefinedAtOperationLevel(OperationAwareFormatsProviderInterface $formatsProvider = null): void
/**
* @param array|OperationAwareFormatsProviderInterface $formatsProvider
*/
private function doTestNormalizeWithCustomFormatsDefinedAtOperationLevel($formatsProvider = null): void
{
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), 'Test API', 'This is a test API.', '1.2.3');

Expand Down Expand Up @@ -3264,7 +3267,7 @@ public function testNormalizeOpenApi()
'page',
false,
'itemsPerPage',
$formatsProvider ?? [],
[],
false,
'pagination',
['spec_version' => 3],
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/SortTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testArrayRecursiveSort(): void

$sortTrait->arrayRecursiveSort($array, 'sort');

$this->assertSame([
$this->assertSame([ /** @phpstan-ignore-line PHPStan bug with pass by reference */
'first',
'second',
[
Expand Down