Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use const instead of properties #2815

Merged
merged 1 commit into from Jan 3, 2024

Conversation

zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Dec 9, 2023

No description provided.

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@zonuexe zonuexe changed the base branch from 1.11.x to 1.10.x December 9, 2023 08:58
@@ -91,8 +89,8 @@ private function getPreliminarilyResolvedTypeFromFunctionCall(
return TypeUtils::toBenevolentUnion($defaultReturnType);
}

if ($subjectArgumentType->isNonEmptyString()->yes() && array_key_exists($functionReflection->getName(), $this->functionsReplacePosition)) {
$replaceArgumentPosition = $this->functionsReplacePosition[$functionReflection->getName()];
if ($subjectArgumentType->isNonEmptyString()->yes() && isset(self::FUNCTIONS_REPLACE_POSITION[$functionReflection->getName()])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change from array_key_exists to isset()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly there is no rational reason to replace array_key_exists() with isset to shave off a few bytes. Although both compile to a ZEND_ARRAY_KEY_EXISTS instruction rather than a function call, array_key_exists() has a very slight performance advantage since it avoids the cost of a null check.

@ondrejmirtes ondrejmirtes merged commit 95bea51 into phpstan:1.10.x Jan 3, 2024
424 of 426 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@zonuexe zonuexe deleted the refactor/class-const branch January 7, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants