Skip to content

Commit

Permalink
fix: readd nullable type to interface for Carbon
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Nov 21, 2023
1 parent 6ebb026 commit 0c63972
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Reflection/Php/BuiltinMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface BuiltinMethodReflection

public function getName(): string;

public function getReflection(): ReflectionMethod;
public function getReflection(): ?ReflectionMethod;

public function getFileName(): ?string;

Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Php/NativeBuiltinMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getName(): string
return $this->reflection->getName();
}

public function getReflection(): ReflectionMethod
public function getReflection(): ?ReflectionMethod
{
return $this->reflection;
}
Expand Down
30 changes: 18 additions & 12 deletions src/Reflection/Php/PhpClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,18 +628,20 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
$stubPhpDocPair = $this->findMethodPhpDocIncludingAncestors($fileDeclaringClass, $methodReflection->getName(), array_map(static fn (ReflectionParameter $parameter): string => $parameter->getName(), $methodReflection->getParameters()));
$phpDocBlockClassReflection = $fileDeclaringClass;

$methodDeclaringClass = $methodReflection->getReflection()->getBetterReflection()->getDeclaringClass();

if ($stubPhpDocPair === null && $methodDeclaringClass->isTrait()) {
if (! $methodReflection->getDeclaringClass()->isTrait() || $methodDeclaringClass->getName() !== $methodReflection->getDeclaringClass()->getName()) {
$stubPhpDocPair = $this->findMethodPhpDocIncludingAncestors(
$this->reflectionProviderProvider->getReflectionProvider()->getClass($methodDeclaringClass->getName()),
$methodReflection->getName(),
array_map(
static fn (ReflectionParameter $parameter): string => $parameter->getName(),
$methodReflection->getParameters(),
),
);
if ($methodReflection->getReflection() !== null) {
$methodDeclaringClass = $methodReflection->getReflection()->getBetterReflection()->getDeclaringClass();

if ($stubPhpDocPair === null && $methodDeclaringClass->isTrait()) {
if (! $methodReflection->getDeclaringClass()->isTrait() || $methodDeclaringClass->getName() !== $methodReflection->getDeclaringClass()->getName()) {
$stubPhpDocPair = $this->findMethodPhpDocIncludingAncestors(
$this->reflectionProviderProvider->getReflectionProvider()->getClass($methodDeclaringClass->getName()),
$methodReflection->getName(),
array_map(
static fn (ReflectionParameter $parameter): string => $parameter->getName(),
$methodReflection->getParameters(),
),
);
}
}
}

Expand Down Expand Up @@ -871,6 +873,10 @@ private function findMethodTrait(
BuiltinMethodReflection $methodReflection,
): ?string
{
if ($methodReflection->getReflection() === null) {
return null;
}

$declaringClass = $methodReflection->getReflection()->getBetterReflection()->getDeclaringClass();
if ($declaringClass->isTrait()) {
if ($methodReflection->getDeclaringClass()->isTrait() && $declaringClass->getName() === $methodReflection->getDeclaringClass()->getName()) {
Expand Down

0 comments on commit 0c63972

Please sign in to comment.