Skip to content

Comments

Fix SimplXmlElement and GMP casts#5020

Open
VincentLanglet wants to merge 3 commits intophpstan:2.1.xfrom
VincentLanglet:casts
Open

Fix SimplXmlElement and GMP casts#5020
VincentLanglet wants to merge 3 commits intophpstan:2.1.xfrom
VincentLanglet:casts

Conversation

@VincentLanglet
Copy link
Contributor

Closes phpstan/phpstan#14136

I tried https://3v4l.org/BtQlq#v8.4.18

Fun fact, I discovered that GMP is not castable to bool for PHP < 8.4
See https://wiki.php.net/rfc/fix_up_bcmath_number_class

But:

  • Currently ObjectType::toBool was returning ConstantBoolean(true), so returning a BooleanType is still better (cause for PHP >= 8.4 it can be false !)
  • boolval is defined as accepting mixed in the resourceMap
  • There is currently no way to do a condition about the PHPVersion inside ObjectType::toBool
  • Nobody reported the issue yet

So I think it's a good enough improvement yet.

@VincentLanglet VincentLanglet marked this pull request as ready for review February 21, 2026 18:20
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

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.

4 participants