Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet changed the base branch from 1.12.x to 1.11.x August 9, 2024 12:32
@phpstan-bot
Copy link
Collaborator

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

@VincentLanglet VincentLanglet force-pushed the improveTypeSpecificer branch from 3b4d594 to 87b3684 Compare August 9, 2024 19:11
$this->createFunctionCall('is_string', 'bar'),
),
[],
['$foo' => 'int'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since bar is an object

$this->scope = $this->scope->assignVariable('bar', new ObjectType('Bar'), new ObjectType('Bar'));

we can be sure foo is an int.

I added the same test with is_int($foo) || is_string($mixed) to reproduce the old behavior.

[
new Expr\Empty_(new Variable('array')),
[
'$array' => 'array{}|null',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since array is defined as an non nullable array

$this->scope = $this->scope->assignVariable('array', new ArrayType(new MixedType(), new MixedType()), new ArrayType(new MixedType(), new MixedType()));

we can be sure it's an array.

@staabm
Copy link
Contributor

staabm commented Oct 23, 2025

@VincentLanglet do you remember why you closed this PR?

I think this fix would be useful to fix a few of the ~1200 errors

@VincentLanglet
Copy link
Contributor Author

@VincentLanglet do you remember why you closed this PR?

I think this fix would be useful to fix a few of the ~1200 errors

No I don't... Maybe it wasn't working ?

You can try to reopen it on 2.1.x to see the result of the build

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.

array_key_exist inference is lost when adding a false condition

3 participants