Skip to content
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
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@
"illuminate/pagination": "^11.0 || ^12.0",
"illuminate/routing": "^11.0 || ^12.0",
"illuminate/support": "^11.0 || ^12.0",
"jangregor/phpstan-prophecy": "^1.0",
"jangregor/phpstan-prophecy": "^2.1.11",
"justinrainbow/json-schema": "^5.2.11",
"laravel/framework": "^11.0 || ^12.0",
"orchestra/testbench": "^9.1",
"phpspec/prophecy-phpunit": "^2.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpdoc-parser": "^1.29 || ^2.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "11.5.x-dev",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"ramsey/uuid": "^4.7",
Expand Down
39 changes: 34 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ parameters:
excludePaths:
# uses larastan
- src/Laravel
- src/Symfony/Bundle/Command/OpenApiCommand.php
Copy link
Contributor Author

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.

# Symfony config
- tests/Fixtures/app/config/config_swagger.php
# Symfony cache
Expand All @@ -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:
Expand Down Expand Up @@ -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\\.#"
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/State/CollectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes therefore we can remove that line instead of ignoring ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause some failure in tests because of testCannotCreateQueryBuilder

public function testCannotCreateQueryBuilder(): void
    {
        $this->expectException(RuntimeException::class);
        $this->expectExceptionMessage('The repository class must have a "createQueryBuilder" method.');

        $repositoryProphecy = $this->prophesize(ObjectRepository::class);

        $managerProphecy = $this->prophesize(ObjectManager::class);
        $managerProphecy->getRepository(OperationResource::class)->willReturn($repositoryProphecy->reveal())->shouldBeCalled();

        $managerRegistryProphecy = $this->prophesize(ManagerRegistry::class);
        $managerRegistryProphecy->getManagerForClass(OperationResource::class)->willReturn($managerProphecy->reveal())->shouldBeCalled();

        $dataProvider = new CollectionProvider($this->prophesize(ResourceMetadataCollectionFactoryInterface::class)->reveal(), $managerRegistryProphecy->reveal());
        $operation = (new GetCollection())->withClass(OperationResource::class)->withName('getCollection');
        $this->assertEquals([], $dataProvider->provide($operation));
    }

The fact is that

  • An entityManagerINterface always returns an EntityRepository which has the createQueryBuilder
  • The existing phpdoc say the manager for class is an EntityManagerInterface but it can theorically be a simple ObjectManager (which is the case tested in tests)
/** @var EntityManagerInterface|null $manager */
$manager = $this->managerRegistry->getManagerForClass($entityClass);

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.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/State/ItemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
}

$repository = $manager->getRepository($entityClass);
if (!method_exists($repository, 'createQueryBuilder')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.');
}

Expand Down
1 change: 0 additions & 1 deletion src/Elasticsearch/Extension/SortExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function applyToCollection(array $requestBody, string $resourceClass, ?Op
if (
$operation
&& null !== ($defaultOrder = $operation->getOrder())
&& \is_array($defaultOrder)
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)) {
Expand Down
9 changes: 4 additions & 5 deletions src/GraphQl/State/Provider/ReadProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
return $item;
}

if (!\is_object($item)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}
Expand Down Expand Up @@ -124,6 +120,9 @@ private function getNormalizedFilters(array $args): array
$filters = $args;

foreach ($filters as $name => $value) {
// Prevent numeric keys like `'1'`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if \is_string($name) was made for preventing this known issue with array.

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'));
Expand All @@ -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 =
Expand Down
2 changes: 0 additions & 2 deletions src/GraphQl/Tests/Serializer/SerializerContextBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ private function buildOperationFromContext(bool $isMutation, bool $isSubscriptio
}
}

\assert($operation instanceof Operation);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always true now


return $operation;
}

Expand Down
4 changes: 2 additions & 2 deletions src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
$serializerContext = ['resource_class' => $operation->getClass()];
$normalizer = $this->createMock(NormalizerInterface::class);
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: true)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, true)->willReturn($serializerContext);

Check warning on line 52 in src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php#L52

Added line #L52 was not covered by tests
$normalizer->expects($this->once())->method('normalize')->with($body, 'graphql', $serializerContext);
$processor = new NormalizeProcessor($normalizer, $serializerContextBuilder, new Pagination());
$processor->process($body, $operation, [], $context);
Expand All @@ -73,7 +73,7 @@
$normalizer = $this->prophesize(NormalizerInterface::class);

$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: true)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, true)->willReturn($serializerContext);

Check warning on line 76 in src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Processor/NormalizeProcessorTest.php#L76

Added line #L76 was not covered by tests
foreach ($collection as $v) {
$normalizer->normalize($v, 'graphql', $serializerContext)->willReturn(['normalized_item'])->shouldBeCalledOnce();
}
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
$denormalizer = $this->createMock(DenormalizerInterface::class);
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: false)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);

Check warning on line 36 in src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php#L36

Added line #L36 was not covered by tests
$denormalizer->expects($this->once())->method('denormalize')->with(['test'], 'dummy', 'graphql', $serializerContext)->willReturn(new \stdClass());
$provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
$provider->provide($operation, [], $context);
Expand All @@ -49,7 +49,7 @@
$decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
$denormalizer = $this->createMock(DenormalizerInterface::class);
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: false)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);

Check warning on line 52 in src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php#L52

Added line #L52 was not covered by tests
$denormalizer->expects($this->once())->method('denormalize')->with(['test'], 'dummy', 'graphql', $serializerContext)->willReturn(new \stdClass());
$provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
$provider->provide($operation, [], $context);
Expand All @@ -65,7 +65,7 @@
$decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
$denormalizer = $this->createMock(DenormalizerInterface::class);
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, normalization: false)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);

Check warning on line 68 in src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php#L68

Added line #L68 was not covered by tests
$denormalizer->expects($this->never())->method('denormalize')->with(['test'], 'dummy', 'graphql', $serializerContext)->willReturn(new \stdClass());
$provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
$provider->provide($operation, [], $context);
Expand All @@ -81,7 +81,7 @@
$decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
$denormalizer = $this->createMock(DenormalizerInterface::class);
$serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
$serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, normalization: false)->willReturn($serializerContext);
$serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);

Check warning on line 84 in src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php

View check run for this annotation

Codecov / codecov/patch

src/GraphQl/Tests/State/Provider/DenormalizeProviderTest.php#L84

Added line #L84 was not covered by tests
$denormalizer->expects($this->never())->method('denormalize')->with(['test'], 'dummy', 'graphql', $serializerContext)->willReturn(new \stdClass());
$provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
$provider->provide($operation, [], $context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
public function testEnum(): void
{
$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
$apiProperty = new ApiProperty(nativeType: Type::nullable(Type::enum(IntEnumAsIdentifier::class))); // @phpstan-ignore-line
$apiProperty = new ApiProperty(nativeType: Type::nullable(Type::enum(IntEnumAsIdentifier::class)));

Check warning on line 46 in src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php#L46

Added line #L46 was not covered by tests
$decorated = $this->createMock(PropertyMetadataFactoryInterface::class);
$decorated->expects($this->once())->method('create')->with(DummyWithEnum::class, 'intEnumAsIdentifier')->willReturn($apiProperty);
$schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory($resourceClassResolver, $decorated);
Expand Down Expand Up @@ -71,7 +71,7 @@
{
$resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
$apiProperty = new ApiProperty(
nativeType: Type::nullable(Type::enum(IntEnumAsIdentifier::class)), // @phpstan-ignore-line
nativeType: Type::nullable(Type::enum(IntEnumAsIdentifier::class)),

Check warning on line 74 in src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php#L74

Added line #L74 was not covered by tests
openapiContext: ['type' => 'object', 'properties' => ['alpha' => ['type' => 'integer']]],
);
$decorated = $this->createMock(PropertyMetadataFactoryInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Tests/SchemaFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$propertyMetadataFactoryProphecy->create(NotAResourceWithUnionIntersectTypes::class, 'ignoredProperty', Argument::cetera())->willReturn(
(new ApiProperty())
->withNativeType(Type::nullable(Type::string())) // @phpstan-ignore-line
->withNativeType(Type::nullable(Type::string()))

Check warning on line 280 in src/JsonSchema/Tests/SchemaFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/JsonSchema/Tests/SchemaFactoryTest.php#L280

Added line #L280 was not covered by tests
->withReadable(true)
->withSchema(['type' => ['string', 'null']])
);
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Extractor/ResourceExtractorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{
private function buildArrayValue(\SimpleXMLElement|array|null $resource, string $key, mixed $default = null): ?array
{
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the param is \SimpleXMLElement|array|null

is object will enfonce it's an SimpleXMLElement

if (\is_object($resource)) {
if (!isset($resource->{$key.'s'}->{$key})) {
return $default;
}
Expand Down Expand Up @@ -61,7 +61,7 @@
case 'integer':
return (int) $resource[$key];
case 'bool':
if (\is_object($resource) && $resource instanceof \SimpleXMLElement) {
if (\is_object($resource)) {

Check warning on line 64 in src/Metadata/Extractor/ResourceExtractorTrait.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Extractor/ResourceExtractorTrait.php#L64

Added line #L64 was not covered by tests
return (bool) XmlUtils::phpize($resource[$key]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@

$decoratedProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$fooPropertyMetadata = (new ApiProperty())
->withNativeType(Type::nullable(Type::array())) // @phpstan-ignore-line
->withNativeType(Type::nullable(Type::array()))

Check warning on line 75 in src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php#L75

Added line #L75 was not covered by tests
->withReadable(false)
->withWritable(true);
$decoratedProphecy->create(Dummy::class, 'foo', $context)->willReturn($fooPropertyMetadata);
$relatedDummyPropertyMetadata = (new ApiProperty())
->withNativeType(Type::nullable(Type::object(RelatedDummy::class)));
$decoratedProphecy->create(Dummy::class, 'relatedDummy', $context)->willReturn($relatedDummyPropertyMetadata);
$nameConvertedPropertyMetadata = (new ApiProperty())
->withNativeType(Type::nullable(Type::string())); // @phpstan-ignore-line
->withNativeType(Type::nullable(Type::string()));

Check warning on line 83 in src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php#L83

Added line #L83 was not covered by tests
$decoratedProphecy->create(Dummy::class, 'nameConverted', $context)->willReturn($nameConvertedPropertyMetadata);

$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
Expand Down Expand Up @@ -126,7 +126,7 @@
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
$resourceClassResolverProphecy->isResourceClass(DummyIgnoreProperty::class)->willReturn(true);

$ignoredPropertyMetadata = (new ApiProperty())->withNativeType(Type::nullable(Type::string())); // @phpstan-ignore-line
$ignoredPropertyMetadata = (new ApiProperty())->withNativeType(Type::nullable(Type::string()));

Check warning on line 129 in src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php#L129

Added line #L129 was not covered by tests

$options = [
'normalization_groups' => ['dummy'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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',
Expand Down
8 changes: 4 additions & 4 deletions src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
yield [Type::int(), [new LegacyType('int')]];
yield [Type::object(\stdClass::class), [new LegacyType('object', false, \stdClass::class)]];
yield [
Type::generic(Type::object('Foo'), Type::string(), Type::int()), // @phpstan-ignore-line
[new LegacyType('object', false, 'Foo', false, [new LegacyType('string')], new LegacyType('int'))],
Type::generic(Type::object(\stdClass::class), Type::string(), Type::int()),
[new LegacyType('object', false, 'stdClass', false, [new LegacyType('string')], new LegacyType('int'))],

Check warning on line 54 in src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php#L53-L54

Added lines #L53 - L54 were not covered by tests
];
yield [Type::nullable(Type::int()), [new LegacyType('int', true)]]; // @phpstan-ignore-line
yield [Type::nullable(Type::int()), [new LegacyType('int', true)]];

Check warning on line 56 in src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php#L56

Added line #L56 was not covered by tests
yield [Type::union(Type::int(), Type::string()), [new LegacyType('int'), new LegacyType('string')]];
yield [
Type::union(Type::int(), Type::string(), Type::null()),
Expand Down Expand Up @@ -97,7 +97,7 @@
[new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::int()), // @phpstan-ignore-line
];
yield [[new LegacyType('int', true)], Type::nullable(Type::int())]; // @phpstan-ignore-line
yield [[new LegacyType('int', true)], Type::nullable(Type::int())];

Check warning on line 100 in src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php

View check run for this annotation

Codecov / codecov/patch

src/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.php#L100

Added line #L100 was not covered by tests
yield [[new LegacyType('int'), new LegacyType('string')], Type::union(Type::int(), Type::string())];
yield [
[new LegacyType('int', true), new LegacyType('string', true)],
Expand Down
Loading
Loading