Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for internal classes that overload offset access #3725

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

Merged
ondrejmirtes merged 7 commits into phpstan:1.12.x from Girgias:easy-offset-access-fixes
Dec 17, 2024

Conversation

@Girgias
Copy link
Contributor

@Girgias Girgias commented Dec 11, 2024

Quick fix for phpstan/phpstan#12235 as DOMNodeList already doesn't complain about incorrect writes it makes sense to have the same behaviour for the other internal classes until PHPStan uses the access mode of the offset.

Copy link
Member

Please add a regression test to NonexistentOffsetInArrayDimFetchRuleTest, thanks.

Girgias reacted with thumbs up emoji

@Girgias Girgias changed the base branch from 2.0.x to 1.12.x December 12, 2024 04:27
@Girgias Girgias force-pushed the easy-offset-access-fixes branch from 1875d6c to bff963c Compare December 12, 2024 04:27
Copy link
Contributor Author

Girgias commented Dec 12, 2024
edited
Loading

Tests added, and rebased to 1.12.x.

One set of tests are case which should fail, but currently cannot.

@@ -0,0 +1,74 @@
<?php // lint >= 8.4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't seem to be working? Not sure why however.

Copy link
Member

@ondrejmirtes ondrejmirtes Dec 12, 2024

Choose a reason for hiding this comment

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

This only works in /nsrt/. But here you're in a rule test. Which means you need to call $this->markTestSkipped() in the test based on PHP_VERSION_ID. There are many existing tests that do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This only works in /nsrt/. But here you're in a rule test. Which means you need to call $this->markTestSkipped() in the test based on PHP_VERSION_ID. There are many existing tests that do this.

Remember I tried to introduce a new annotation syntax that would allow us to use the same skip system for all data files? (main gotcha was data files that required ranges and additional conditions for skipping). The current system is cumbersome and unintuitive. Would you like to revisit my idea? I can provide a sample PR on which to discuss it.

Copy link
Member

@ondrejmirtes ondrejmirtes Dec 12, 2024

Choose a reason for hiding this comment

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

The current system works very well in my opinion :)

One day we might be able to test the rules in a similar way we test inferred types (by discovering and filtering files in a directory) but today is not that day.

Copy link
Contributor Author

Girgias commented Dec 17, 2024

@ondrejmirtes is there anything else I need to do? :)

<?php
/**
* All of these offset accesses are invalid
* ++ and -- are also disallowed in general are they operate "by ref"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* ++ and -- are also disallowed in general are they operate "by ref"
* ++ and -- are also disallowed in general as they operate "by ref"

<?php
/**
* All of these offset accesses are invalid
* ++ and -- are also disallowed in general are they operate "by ref"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* ++ and -- are also disallowed in general are they operate "by ref"
* ++ and -- are also disallowed in general as they operate "by ref"

@ondrejmirtes ondrejmirtes merged commit b66058f into phpstan:1.12.x Dec 17, 2024
16 checks passed
Copy link
Member

Thank you!

Girgias reacted with heart emoji

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

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes approved these changes

+2 more reviewers

@staabm staabm staabm left review comments

@thg2k thg2k thg2k left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /