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

Make sure that PhpStormStubsSourceStubber updates constants based on current runtime environment, when outdated or not defined in stubs #778

Merged
merged 1 commit into from
Sep 20, 2021

Conversation

kukulich
Copy link
Collaborator

No description provided.

@Ocramius
Copy link
Member

I don't understand this patch: can the commit description be expanded a bit? 😅

@kukulich
Copy link
Collaborator Author

Stubs are often outdated or constants have different values on different systems, see comment for method updateConstantValue (the comment was already there - it just moved now)

So we already update the constant value based on the real value (based on constant() call).

The current version only updates constants in stubs defined by define() call. The patch fixes it so all types of constants are updated - class constants and constants defined by const keyword too.

I've spotted this when preparing PHP 8.1 version - some constants change in PHP 8.1.

Added missing support for class constants and constants defined by "const" keyword.
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM 🚢


$stubberReflection = new CoreReflectionClass($sourceStubber);

$stubDirectoryReflection = $stubberReflection->getProperty('stubsDirectory');
Copy link
Member

Choose a reason for hiding this comment

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

Hacky :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, two hours of creating this test :D

Copy link
Member

Choose a reason for hiding this comment

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

I know the feeling - having one of those come up for me too, on a client project :-\

@Ocramius Ocramius added this to the 5.0.0 milestone Sep 20, 2021
@Ocramius Ocramius changed the title PhpStormStubsSourceStubber has to update value of all types of constants Make sure that PhpStormStubsSourceStubber updates constants based on current runtime environment, when outdated or not defined in stubs Sep 20, 2021
@Ocramius Ocramius self-assigned this Sep 20, 2021
@Ocramius Ocramius merged commit b6a3be6 into Roave:5.0.x Sep 20, 2021
@kukulich kukulich deleted the phpstorm-stubs branch September 21, 2021 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants