Skip to content

Conversation

@MartinMystikJonas
Copy link
Contributor

No description provided.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

The new ConstantStringType($file) part is repeated here. I'd like the code to change so that the last line call looks like this:

return $this->usePathConstantsAsConstantString ? $stringType : $stringType->generalize(GeneralizePrecision::moreSpecific());

@ondrejmirtes ondrejmirtes merged commit 0f1ba7f into phpstan:1.9.x Dec 16, 2022
@ondrejmirtes
Copy link
Member

Please remind me - why would need this again? It's causing problems with phpstan/phpstan#12203.

@thg2k
Copy link
Contributor

thg2k commented Dec 9, 2024

@ondrejmirtes I think there is something explained here: phpstan/phpstan#8454 (reply in thread)

@MartinMystikJonas
Copy link
Contributor Author

MartinMystikJonas commented Dec 12, 2024

It was needed when we evaluated paths to latte tempaltes with expressions containing DIR. Type was resolved as generic string not COnstantString with evaluated value. So I implemented this to be able to turn on treating results of expressions with DIR as constantString so it can be evaluated later. It seems like problem described in phpstan/phpstan#12203 is basically same thing we encountered. So this is not causing that problem but is solution to similar problem.

@ondrejmirtes
Copy link
Member

I'd say this option shouldn't be needed. We should always strive for the type to be as precise as possible, and only degrade it (generalize it) in contexts where the precise type is counter-productive.

@MartinMystikJonas
Copy link
Contributor Author

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants