Skip to content

Commit

Permalink
minor #54790 [TypeInfo] end/current instead of array_pop (soyuka)
Browse files Browse the repository at this point in the history
This PR was merged into the 7.1 branch.

Discussion
----------

[TypeInfo] end/current instead of array_pop

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

We don't need to modify the array here, I think it's a micro-optimization to use `end` and `current` instead of changing an array size.

Commits
-------

e36b82d [TypeInfo] end/current instead of array_pop
  • Loading branch information
fabpot committed May 1, 2024
2 parents c168c2c + e36b82d commit 1119ab6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public function createFromClassName(string $calledClassName, ?string $declaringC
$calledClassPath = explode('\\', $calledClassName);
$declaringClassPath = explode('\\', $declaringClassName);

$declaringClassReflection = (self::$reflectionClassCache[$declaringClassName] ??= new \ReflectionClass($declaringClassName));
$declaringClassReflection = self::$reflectionClassCache[$declaringClassName] ??= new \ReflectionClass($declaringClassName);

$typeContext = new TypeContext(
array_pop($calledClassPath),
array_pop($declaringClassPath),
end($calledClassPath),
end($declaringClassPath),
trim($declaringClassReflection->getNamespaceName(), '\\'),
$this->collectUses($declaringClassReflection),
);
Expand Down

0 comments on commit 1119ab6

Please sign in to comment.