-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix return type of parent calls for SplHeap
- Loading branch information
1 parent
f083c2e
commit 0ef3c87
Showing
9 changed files
with
159 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- Reflection/ReflectionProperty.php 2023-09-07 12:59:56.000000000 +0200 | ||
+++ Reflection/ReflectionProperty.php 2023-09-15 13:24:07.900736741 +0200 | ||
@@ -248,7 +248,7 @@ | ||
* Gets property type | ||
* | ||
* @link https://php.net/manual/en/reflectionproperty.gettype.php | ||
- * @return ReflectionNamedType|ReflectionUnionType|null Returns a {@see ReflectionType} if the | ||
+ * @return ReflectionType|null Returns a {@see ReflectionType} if the | ||
* property has a type, and {@see null} otherwise. | ||
* @since 7.4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types=1); // lint >= 8.1 | ||
|
||
namespace Bug7162; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
|
||
/** | ||
* @param class-string<\BackedEnum> $enumClassString | ||
*/ | ||
public static function casesWithLabel(string $enumClassString): void | ||
{ | ||
foreach ($enumClassString::cases() as $unitEnum) { | ||
assertType('BackedEnum', $unitEnum); | ||
} | ||
} | ||
} | ||
|
||
enum Test{ | ||
case ONE; | ||
} | ||
|
||
/** | ||
* @phpstan-template TEnum of \UnitEnum | ||
* @phpstan-param TEnum $case | ||
*/ | ||
function dumpCases(\UnitEnum $case) : void{ | ||
assertType('array<TEnum of UnitEnum (function Bug7162\\dumpCases(), argument)>', $case::cases()); | ||
} | ||
|
||
function dumpCases2(Test $case) : void{ | ||
assertType('array{Bug7162\\Test::ONE}', $case::cases()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bug9867; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** @extends \SplMinHeap<\DateTime> */ | ||
class MyMinHeap extends \SplMinHeap | ||
{ | ||
public function test(): void | ||
{ | ||
assertType('DateTime', parent::current()); | ||
assertType('DateTime', parent::extract()); | ||
assertType('DateTime', parent::top()); | ||
} | ||
|
||
public function insert(mixed $value): bool | ||
{ | ||
assertType('DateTime', $value); | ||
|
||
return parent::insert($value); | ||
} | ||
|
||
protected function compare(mixed $value1, mixed $value2) | ||
{ | ||
assertType('DateTime', $value1); | ||
assertType('DateTime', $value2); | ||
|
||
return parent::compare($value1, $value2); | ||
} | ||
} | ||
|
||
/** @extends \SplMaxHeap<\DateTime> */ | ||
class MyMaxHeap extends \SplMaxHeap | ||
{ | ||
public function test(): void | ||
{ | ||
assertType('DateTime', parent::current()); | ||
assertType('DateTime', parent::extract()); | ||
assertType('DateTime', parent::top()); | ||
} | ||
|
||
public function insert(mixed $value): bool | ||
{ | ||
assertType('DateTime', $value); | ||
|
||
return parent::insert($value); | ||
} | ||
|
||
protected function compare(mixed $value1, mixed $value2) | ||
{ | ||
assertType('DateTime', $value1); | ||
assertType('DateTime', $value2); | ||
|
||
return parent::compare($value1, $value2); | ||
} | ||
} | ||
|
||
/** @extends \SplHeap<\DateTime> */ | ||
abstract class MyHeap extends \SplHeap | ||
{ | ||
public function test(): void | ||
{ | ||
assertType('DateTime', parent::current()); | ||
assertType('DateTime', parent::extract()); | ||
assertType('DateTime', parent::top()); | ||
} | ||
|
||
public function insert(mixed $value): bool | ||
{ | ||
assertType('DateTime', $value); | ||
|
||
return parent::insert($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace ReflectionTypeTest; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function test( | ||
\ReflectionProperty $reflectionProperty, | ||
\ReflectionFunctionAbstract $reflectionFunctionAbstract, | ||
\ReflectionParameter $reflectionParameter | ||
){ | ||
assertType('ReflectionType|null', $reflectionProperty->getType()); | ||
assertType('ReflectionType|null', $reflectionFunctionAbstract->getReturnType()); | ||
assertType('ReflectionType|null', $reflectionParameter->getType()); | ||
} |