Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  [Validator] Add Catalan and Spanish translation for `WordCount` constraint"
  [DependencyInjection] Do not try to load default method name on interface
  [PropertyInfo] Fix nullable value returned from extractFromMutator on CollectionType
  • Loading branch information
fabpot committed Jul 26, 2024
2 parents 7177b61 + edaea9d commit ee413c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Extractor/ReflectionExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private function extractFromMutator(string $class, string $property): ?array
$type = $this->extractFromReflectionType($reflectionType, $reflectionMethod->getDeclaringClass());

if (1 === \count($type) && \in_array($prefix, $this->arrayMutatorPrefixes)) {
$type = [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), $type[0])];
$type = [new Type(Type::BUILTIN_TYPE_ARRAY, $this->isNullableProperty($class, $property), null, true, new Type(Type::BUILTIN_TYPE_INT), $type[0])];
}

return $type;
Expand Down
1 change: 1 addition & 0 deletions Tests/Extractor/ReflectionExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ public function testTypedProperties()
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))], $this->extractor->getTypes(Php74Dummy::class, 'stringCollection'));
$this->assertEquals([new Type(Type::BUILTIN_TYPE_INT, true)], $this->extractor->getTypes(Php74Dummy::class, 'nullableWithDefault'));
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)], $this->extractor->getTypes(Php74Dummy::class, 'collection'));
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class))], $this->extractor->getTypes(Php74Dummy::class, 'nullableTypedCollection'));
}

/**
Expand Down
7 changes: 7 additions & 0 deletions Tests/Fixtures/Php74Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ class Php74Dummy
private ?int $nullableWithDefault = 1;
public array $collection = [];

/** @var Dummy[]|null */
public ?array $nullableTypedCollection = null;

public function addStringCollection(string $string): void
{
}

public function removeStringCollection(string $string): void
{
}

public function addNullableTypedCollection(Dummy $dummy): void
{
}
}

0 comments on commit ee413c2

Please sign in to comment.