Skip to content

Commit

Permalink
Fix method signatures for ReflectionProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Jan 16, 2022
1 parent 3c726e7 commit 4f1f5f7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stubs/Reflection.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ class ReflectionProperty implements Reflector
* @psalm-mutation-free
*/
public function getType() : ?ReflectionType {}

/**
* @param object|null $object
* @return mixed
*/
public function getValue($object = null) {}

/**
* @param mixed $objectOrValue
* @param mixed $value
*/
public function setValue($objectOrValue, $value = null): void {}
}

class ReflectionMethod implements Reflector
Expand Down
24 changes: 24 additions & 0 deletions tests/MethodSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,30 @@ public function __soapCall(
$this->analyzeFile('somefile.php', new Context());
}

public function testExtendReflectionPropertyOnPhp8(): void
{
$this->project_analyzer->setPhpVersion('8.0', 'tests');

$this->addFile(
'MyReflectionProperty.php',
'<?php
class MyReflectionProperty extends ReflectionProperty
{
public function getValue(?object $object = null): mixed
{
return parent::getValue($object);
}
public function setValue(mixed $objectOrValue, mixed $value = null): void
{
parent::setValue($objectOrValue, $value);
}
}'
);

$this->analyzeFile('MyReflectionProperty.php', new Context());
}

/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
*/
Expand Down

0 comments on commit 4f1f5f7

Please sign in to comment.