-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\Php; | ||
|
||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionIntersectionType; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionUnionType; | ||
use PHPStan\TrinaryLogic; | ||
|
||
interface BuiltinMethodReflection | ||
{ | ||
|
||
public function getName(): string; | ||
|
||
public function getReflection(): ReflectionMethod; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ondrejmirtes
Author
Member
|
||
|
||
public function getFileName(): ?string; | ||
|
||
public function getDeclaringClass(): ReflectionClass|ReflectionEnum; | ||
|
||
public function getStartLine(): ?int; | ||
|
||
Check failure on line 26 in src/Reflection/Php/BuiltinMethodReflection.php GitHub Actions / PHPStan (7.2, ubuntu-latest)
Check failure on line 26 in src/Reflection/Php/BuiltinMethodReflection.php GitHub Actions / PHPStan (7.2, windows-latest)
Check failure on line 26 in src/Reflection/Php/BuiltinMethodReflection.php GitHub Actions / PHPStan (7.3, ubuntu-latest)
Check failure on line 26 in src/Reflection/Php/BuiltinMethodReflection.php GitHub Actions / PHPStan (7.3, windows-latest)
|
||
public function getEndLine(): ?int; | ||
|
||
public function getDocComment(): ?string; | ||
|
||
public function isStatic(): bool; | ||
|
||
public function isPrivate(): bool; | ||
|
||
public function isPublic(): bool; | ||
|
||
public function getPrototype(): self; | ||
|
||
public function isDeprecated(): TrinaryLogic; | ||
|
||
public function isVariadic(): bool; | ||
|
||
public function getReturnType(): ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null; | ||
|
||
public function getTentativeReturnType(): ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null; | ||
|
||
/** | ||
* @return ReflectionParameter[] | ||
*/ | ||
public function getParameters(): array; | ||
|
||
public function isFinal(): bool; | ||
|
||
public function isInternal(): bool; | ||
|
||
public function isAbstract(): bool; | ||
|
||
public function returnsByReference(): TrinaryLogic; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\Php; | ||
|
||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionIntersectionType; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionNamedType; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionParameter; | ||
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionUnionType; | ||
use PHPStan\TrinaryLogic; | ||
|
||
class NativeBuiltinMethodReflection implements BuiltinMethodReflection | ||
{ | ||
|
||
public function __construct(private ReflectionMethod $reflection) | ||
{ | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->reflection->getName(); | ||
} | ||
|
||
public function getReflection(): ReflectionMethod | ||
{ | ||
return $this->reflection; | ||
} | ||
|
||
public function getFileName(): ?string | ||
{ | ||
$fileName = $this->reflection->getFileName(); | ||
if ($fileName === false) { | ||
return null; | ||
} | ||
|
||
return $fileName; | ||
} | ||
|
||
public function getDeclaringClass(): ReflectionClass|ReflectionEnum | ||
{ | ||
return $this->reflection->getDeclaringClass(); | ||
} | ||
|
||
public function getStartLine(): ?int | ||
{ | ||
$line = $this->reflection->getStartLine(); | ||
if ($line === false) { | ||
Check failure on line 49 in src/Reflection/Php/NativeBuiltinMethodReflection.php GitHub Actions / PHPStan (7.2, ubuntu-latest)
Check failure on line 49 in src/Reflection/Php/NativeBuiltinMethodReflection.php GitHub Actions / PHPStan (7.2, windows-latest)
Check failure on line 49 in src/Reflection/Php/NativeBuiltinMethodReflection.php GitHub Actions / PHPStan (7.3, ubuntu-latest)
Check failure on line 49 in src/Reflection/Php/NativeBuiltinMethodReflection.php GitHub Actions / PHPStan (7.3, windows-latest)
|
||
return null; | ||
} | ||
|
||
return $line; | ||
} | ||
|
||
public function getEndLine(): ?int | ||
{ | ||
$line = $this->reflection->getEndLine(); | ||
if ($line === false) { | ||
return null; | ||
} | ||
|
||
return $line; | ||
} | ||
|
||
public function getDocComment(): ?string | ||
{ | ||
$docComment = $this->reflection->getDocComment(); | ||
if ($docComment === false) { | ||
return null; | ||
} | ||
|
||
return $docComment; | ||
} | ||
|
||
public function isStatic(): bool | ||
{ | ||
return $this->reflection->isStatic(); | ||
} | ||
|
||
public function isPrivate(): bool | ||
{ | ||
return $this->reflection->isPrivate(); | ||
} | ||
|
||
public function isPublic(): bool | ||
{ | ||
return $this->reflection->isPublic(); | ||
} | ||
|
||
public function isConstructor(): bool | ||
{ | ||
return $this->reflection->isConstructor(); | ||
} | ||
|
||
public function getPrototype(): BuiltinMethodReflection | ||
{ | ||
return new self($this->reflection->getPrototype()); | ||
} | ||
|
||
public function isDeprecated(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createFromBoolean($this->reflection->isDeprecated()); | ||
} | ||
|
||
public function isFinal(): bool | ||
{ | ||
return $this->reflection->isFinal(); | ||
} | ||
|
||
public function isInternal(): bool | ||
{ | ||
return $this->reflection->isInternal(); | ||
} | ||
|
||
public function isAbstract(): bool | ||
{ | ||
return $this->reflection->isAbstract(); | ||
} | ||
|
||
public function isVariadic(): bool | ||
{ | ||
return $this->reflection->isVariadic(); | ||
} | ||
|
||
public function getReturnType(): ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null | ||
{ | ||
return $this->reflection->getReturnType(); | ||
} | ||
|
||
public function getTentativeReturnType(): ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null | ||
{ | ||
return $this->reflection->getTentativeReturnType(); | ||
} | ||
|
||
/** | ||
* @return ReflectionParameter[] | ||
*/ | ||
public function getParameters(): array | ||
{ | ||
return $this->reflection->getParameters(); | ||
} | ||
|
||
public function returnsByReference(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createFromBoolean($this->reflection->returnsReference()); | ||
} | ||
|
||
} |
@ondrejmirtes The methods returned nullable types before. Was the removal of the nullable types intentional as part of the revert commit?
Before:
ad6703d#diff-118ce1aee3922aeae65327b5e79f318af404a8ea22ed773ea31e3ab3e8a2c83bL19