Thanks to visit codestin.com
Credit goes to github.com

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
fix extracting mixed type-hinted property types
  • Loading branch information
xabbuh committed Feb 12, 2021
commit be6432ee4c2a22ddbe2cfc884235caf09039278f
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public function getTypes($class, $property, array $context = []): ?array
try {
$reflectionProperty = new \ReflectionProperty($class, $property);
$type = $reflectionProperty->getType();
if (null !== $type) {
return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass());
if (null !== $type && $types = $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass())) {
return $types;
}
} catch (\ReflectionException $e) {
// noop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function php80TypesProvider()
['string', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Stringable'), new Type(Type::BUILTIN_TYPE_STRING)]],
['payload', null],
['data', null],
['mixedProperty', null],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Php80Dummy
{
public mixed $mixedProperty;

public function getFoo(): array|null
{
}
Expand Down