Skip to content

Bump PHPStan version #2267

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

Merged
merged 2 commits into from
Oct 23, 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
- *update-project-dependencies
- run:
name: Install PHPStan
command: composer global require phpstan/phpstan:0.10.1
command: composer global require phpstan/phpstan:0.10.5
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
- run:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install:
- echo extension=php_pdo_sqlite.dll >> php.ini
- echo memory_limit=3G >> php.ini
- cd %APPVEYOR_BUILD_FOLDER%
- composer install --no-interaction --no-progress
- composer install --no-interaction --no-progress --no-suggest

test_script:
- cd %APPVEYOR_BUILD_FOLDER%
Expand Down
2 changes: 1 addition & 1 deletion features/security/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ one of the most popular framework validation in the world.

The sending of security headers is ensured by [our "send security headers" functional test suite](send_security_headers.feature)
and the unit tests of the [`RespondListener`](../../tests/EventListener/RespondListenerTest.php), [`ExceptionAction`](../../tests/Action/ExceptionActionTest.php)
and [`ValidationExceptionListener`](../../tests/Bridge/Symfony/Validation/EventListener/ValidationExceptionListenerTest.php).
and [`ValidationExceptionListener`](../../tests/Bridge/Symfony/Validator/EventListener/ValidationExceptionListenerTest.php).

### JSON encoding

Expand Down
36 changes: 3 additions & 33 deletions src/Bridge/Doctrine/Orm/Util/QueryJoinParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,15 @@ public static function getClassMetadataFromJoinAlias(string $alias, QueryBuilder
*/
public static function getJoinRelationship(Join $join): string
{
static $relationshipProperty = null;
static $initialized = false;

if (!$initialized && !method_exists(Join::class, 'getJoin')) {
$relationshipProperty = new \ReflectionProperty(Join::class, '_join');
$relationshipProperty->setAccessible(true);

$initialized = true;
}

return (null === $relationshipProperty) ? $join->getJoin() : $relationshipProperty->getValue($join);
return $join->getJoin();
}

/**
* Gets the alias from a Join expression.
*/
public static function getJoinAlias(Join $join): string
{
static $aliasProperty = null;
static $initialized = false;

if (!$initialized && !method_exists(Join::class, 'getAlias')) {
$aliasProperty = new \ReflectionProperty(Join::class, '_alias');
$aliasProperty->setAccessible(true);

$initialized = true;
}

return (null === $aliasProperty) ? $join->getAlias() : $aliasProperty->getValue($join);
return $join->getAlias();
}

/**
Expand All @@ -139,16 +119,6 @@ public static function getJoinAlias(Join $join): string
*/
public static function getOrderByParts(OrderBy $orderBy): array
{
static $partsProperty = null;
static $initialized = false;

if (!$initialized && !method_exists(OrderBy::class, 'getParts')) {
$partsProperty = new \ReflectionProperty(OrderBy::class, '_parts');
$partsProperty->setAccessible(true);

$initialized = true;
}

return (null === $partsProperty) ? $orderBy->getParts() : $partsProperty->getValue($orderBy);
return $orderBy->getParts();
}
}
2 changes: 1 addition & 1 deletion src/DataProvider/SubresourceDataProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface SubresourceDataProviderInterface
*
* @throws ResourceClassNotSupportedException
*
* @return object|null
* @return array|object|null
*/
public function getSubresource(string $resourceClass, array $identifiers, array $context, string $operationName = null);
}
3 changes: 2 additions & 1 deletion src/GraphQl/Type/Definition/IterableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use GraphQL\Language\AST\ListValueNode;
use GraphQL\Language\AST\ObjectValueNode;
use GraphQL\Language\AST\StringValueNode;
use GraphQL\Language\AST\ValueNode;
use GraphQL\Type\Definition\ScalarType;
use GraphQL\Utils\Utils;

Expand Down Expand Up @@ -80,7 +81,7 @@ public function parseLiteral($valueNode, array $variables = null)
}

/**
* @param StringValueNode|BooleanValueNode|IntValueNode|FloatValueNode|ObjectValueNode|ListValueNode $valueNode
* @param StringValueNode|BooleanValueNode|IntValueNode|FloatValueNode|ObjectValueNode|ListValueNode|ValueNode $valueNode
*/
private function parseIterableLiteral($valueNode)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Swagger/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,7 @@ private function updateGetOperation(\ArrayObject $pathOperation, array $mimeType
],
],
];

if (!isset($pathOperation['parameters']) && $parameters = $this->getFiltersParameters($resourceClass, $operationName, $resourceMetadata, $definitions, $serializerContext)) {
$pathOperation['parameters'] = $parameters;
}
$pathOperation['parameters'] ?? $pathOperation['parameters'] = $this->getFiltersParameters($resourceClass, $operationName, $resourceMetadata, $definitions, $serializerContext);

if ($this->paginationEnabled && $resourceMetadata->getCollectionOperationAttribute($operationName, 'pagination_enabled', true, true)) {
$pathOperation['parameters'][] = $this->getPaginationParameters();
Expand Down
24 changes: 0 additions & 24 deletions tests/Bridge/Doctrine/Orm/Util/QueryJoinParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public function testGetJoinRelationshipWithClassJoin()
$this->assertEquals(RelatedDummy::class, QueryJoinParser::getJoinRelationship($join));
}

public function testGetJoinRelationshipWithReflection()
{
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
$methodExist->expects($this->any())->with(Join::class, 'getJoin')->willReturn('false');
$join = new Join('INNER_JOIN', 'a_1.relatedDummy', 'a_1', null, 'a_1.name = r.name');
$this->assertEquals('a_1.relatedDummy', QueryJoinParser::getJoinRelationship($join));
}

public function testGetJoinAliasWithJoin()
{
$join = new Join('INNER_JOIN', 'relatedDummy', 'a_1', null, 'a_1.name = r.name');
Expand All @@ -75,25 +67,9 @@ public function testGetJoinAliasWithClassJoin()
$this->assertEquals('a_1', QueryJoinParser::getJoinAlias($join));
}

public function testGetJoinAliasWithReflection()
{
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
$methodExist->expects($this->any())->with(Join::class, 'getAlias')->willReturn('false');
$join = new Join('INNER_JOIN', 'relatedDummy', 'a_1', null, 'a_1.name = r.name');
$this->assertEquals('a_1', QueryJoinParser::getJoinAlias($join));
}

public function testGetOrderByPartsWithOrderBy()
{
$orderBy = new OrderBy('name', 'asc');
$this->assertEquals(['name asc'], QueryJoinParser::getOrderByParts($orderBy));
}

public function testGetOrderByPartsWithReflection()
{
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
$methodExist->expects($this->any())->with(OrderBy::class, 'getParts')->willReturn('false');
$orderBy = new OrderBy('name', 'desc');
$this->assertEquals(['name desc'], QueryJoinParser::getOrderByParts($orderBy));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testCreate()

$propertyNameCollectionFactory = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
$propertyNameCollectionFactory->create(DummyTableInheritance::class, [])->willReturn(new PropertyNameCollection(['name']))->shouldBeCalled();
$propertyNameCollectionFactory->create(DummyTableInheritanceChild::class, [])->willReturn(new PropertyNameCollection(['nickname', 169]))->shouldBeCalled();
$propertyNameCollectionFactory->create(DummyTableInheritanceChild::class, [])->willReturn(new PropertyNameCollection(['nickname', '169']))->shouldBeCalled();

$factory = new InheritedPropertyNameCollectionFactory($resourceNameCollectionFactory->reveal(), $propertyNameCollectionFactory->reveal());
$metadata = $factory->create(DummyTableInheritance::class);
Expand Down