-
-
Notifications
You must be signed in to change notification settings - Fork 930
chore: bump phpstan version #7239
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ parameters: | |
excludePaths: | ||
# uses larastan | ||
- src/Laravel | ||
- src/Symfony/Bundle/Command/OpenApiCommand.php | ||
# Symfony config | ||
- tests/Fixtures/app/config/config_swagger.php | ||
# Symfony cache | ||
|
@@ -33,10 +32,7 @@ parameters: | |
- src/Doctrine/*/vendor/* | ||
- src/*/vendor/* | ||
# Symfony 6 support | ||
- src/OpenApi/Serializer/CacheableSupportsMethodInterface.php | ||
- src/Serializer/CacheableSupportsMethodInterface.php | ||
- tests/Hal/Serializer/ItemNormalizerTest.php | ||
- tests/Symfony/Validator/Metadata/Property/ValidatorPropertyMetadataFactoryTest.php | ||
- src/Symfony/Bundle/ArgumentResolver/CompatibleValueResolverInterface.php | ||
earlyTerminatingMethodCalls: | ||
PHPUnit\Framework\Constraint\Constraint: | ||
|
@@ -75,6 +71,15 @@ parameters: | |
# Expected, due to backward compatibility | ||
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#' | ||
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#' | ||
- "#Call to function method_exists\\(\\) with GraphQL\\\\Type\\\\Definition\\\\Type&GraphQL\\\\Type\\\\Definition\\\\WrappingType and 'getInnermostType' will always evaluate to true\\.#" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of method_exists call added for BC, so I updated the ignored errors. |
||
- "#Call to function method_exists\\(\\) with Symfony\\\\Component\\\\Console\\\\Application and 'addCommand' will always evaluate to false\\.#" | ||
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#" | ||
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#" | ||
- '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#' | ||
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\Serializer\\\\\\\\Serializer' and 'getSupportedTypes' will always evaluate to true\\.#" | ||
- "#Call to function method_exists\\(\\) with Symfony\\\\Component\\\\Serializer\\\\Normalizer\\\\NormalizerInterface and 'getSupportedTypes' will always evaluate to true\\.#" | ||
- "#Call to function method_exists\\(\\) with Doctrine\\\\ODM\\\\MongoDB\\\\Configuration and 'setMetadataCache' will always evaluate to true\\.#" | ||
- "#Call to function method_exists\\(\\) with Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\|Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata and 'isChangeTrackingDef…' will always evaluate to true\\.#" | ||
- | ||
message: '#Instanceof between Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface and Symfony\\Component\\Serializer\\NameConverter\\MetadataAwareNameConverter will always evaluate to false\.#' | ||
paths: | ||
|
@@ -90,4 +95,28 @@ parameters: | |
- | ||
message: '#^Service "[^"]+" is private.$#' | ||
path: src | ||
- '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#' | ||
|
||
# Allow extra assertions in tests: https://github.com/phpstan/phpstan-strict-rules/issues/130 | ||
- '#^Call to (static )?method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#' | ||
|
||
# TODO For PHPStan 2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a list of errors which I'd like to fix in following PR. |
||
- | ||
path: tests/ | ||
identifier: function.alreadyNarrowedType | ||
- | ||
identifier: property.unusedType | ||
- | ||
identifier: return.unusedType | ||
- | ||
path: tests/ | ||
identifier: void.pure | ||
- | ||
identifier: varTag.nativeType | ||
- | ||
identifier: isset.offset | ||
- | ||
identifier: trait.unused | ||
- | ||
identifier: instanceof.alwaysTrue | ||
- | ||
identifier: catch.neverThrown |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c | |
$manager = $this->managerRegistry->getManagerForClass($entityClass); | ||
|
||
$repository = $manager->getRepository($entityClass); | ||
if (!method_exists($repository, 'createQueryBuilder')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $repository is always an EntityRepository according to PHPStan and I think it's right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes therefore we can remove that line instead of ignoring ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will cause some failure in tests because of
The fact is that
So I'm unsure how you want to solve/change this @soyuka |
||
if (!method_exists($repository, 'createQueryBuilder')) { // @phpstan-ignore-line function.alreadyNarrowedType | ||
throw new RuntimeException('The repository class must have a "createQueryBuilder" method.'); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c | |
} | ||
|
||
$repository = $manager->getRepository($entityClass); | ||
if (!method_exists($repository, 'createQueryBuilder')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same idea |
||
if (!method_exists($repository, 'createQueryBuilder')) { // @phpstan-ignore-line function.alreadyNarrowedType | ||
throw new RuntimeException('The repository class must have a "createQueryBuilder" method.'); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,6 @@ public function applyToCollection(array $requestBody, string $resourceClass, ?Op | |
if ( | ||
$operation | ||
&& null !== ($defaultOrder = $operation->getOrder()) | ||
&& \is_array($defaultOrder) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. operation->getOrder is array|null and we already checked null |
||
) { | ||
foreach ($defaultOrder as $property => $direction) { | ||
if (\is_int($property)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,10 +82,6 @@ public function provide(Operation $operation, array $uriVariables = [], array $c | |
return $item; | ||
} | ||
|
||
if (!\is_object($item)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getResourceFromIri returns an object (with native type) |
||
throw new \LogicException('Item from read provider should be a nullable object.'); | ||
} | ||
|
||
if (isset($context['graphql_context']) && !enum_exists($item::class)) { | ||
$context['graphql_context']['previous_object'] = clone $item; | ||
} | ||
|
@@ -124,6 +120,9 @@ private function getNormalizedFilters(array $args): array | |
$filters = $args; | ||
|
||
foreach ($filters as $name => $value) { | ||
// Prevent numeric keys like `'1'` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if I don't have a report from PHPStan with the cast strategy |
||
$name = (string) $name; | ||
|
||
if (\is_array($value)) { | ||
if (strpos($name, '_list')) { | ||
$name = substr($name, 0, \strlen($name) - \strlen('_list')); | ||
|
@@ -136,7 +135,7 @@ private function getNormalizedFilters(array $args): array | |
$filters[$name] = $this->getNormalizedFilters($value); | ||
} | ||
|
||
if (\is_string($name) && strpos($name, $this->nestingSeparator)) { | ||
if (strpos($name, $this->nestingSeparator)) { | ||
// Gives a chance to relations/nested fields. | ||
$index = array_search($name, array_keys($filters), true); | ||
$filters = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,8 +77,6 @@ private function buildOperationFromContext(bool $isMutation, bool $isSubscriptio | |
} | ||
} | ||
|
||
\assert($operation instanceof Operation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always true now |
||
|
||
return $operation; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
{ | ||
private function buildArrayValue(\SimpleXMLElement|array|null $resource, string $key, mixed $default = null): ?array | ||
{ | ||
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the param is is object will enfonce it's an SimpleXMLElement |
||
if (\is_object($resource)) { | ||
if (!isset($resource->{$key.'s'}->{$key})) { | ||
return $default; | ||
} | ||
|
@@ -61,7 +61,7 @@ | |
case 'integer': | ||
return (int) $resource[$key]; | ||
case 'bool': | ||
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) { | ||
if (\is_object($resource)) { | ||
return (bool) XmlUtils::phpize($resource[$key]); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ public function testParameterFactory(): void | |
$filterLocator->method('get')->willReturn(new class implements FilterInterface { | ||
public function getDescription(string $resourceClass): array | ||
{ | ||
// @phpstan-ignore-next-line return.type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we're passing volontary a wrong type to check it's handle in the method. |
||
return [ | ||
'hydra' => [ | ||
'property' => 'hydra', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those files doesn't exists and are reported by PHPStan v2 now.