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 assert syntax #120

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 4 commits into phpstan:1.4.x from rvanvelzen:assert
May 4, 2022
Merged

Add assert syntax #120

ondrejmirtes merged 4 commits into phpstan:1.4.x from rvanvelzen:assert
May 4, 2022

Conversation

Copy link
Contributor

@rvanvelzen rvanvelzen commented Apr 29, 2022
edited
Loading


yield [
'invalid $this->method()',
'/** @phpstan-assert Type $this->method() */',
Copy link
Contributor Author

@rvanvelzen rvanvelzen Apr 29, 2022

Choose a reason for hiding this comment

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

This would be a nice future addition

Copy link

@ZebulanStanphill ZebulanStanphill May 9, 2022

Choose a reason for hiding this comment

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

Does this mean the current implementation doesn't support class props (e.g. $this->myProp), or are you only talking about methods?

Copy link
Contributor Author

@rvanvelzen rvanvelzen May 10, 2022

Choose a reason for hiding this comment

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

Any syntax other than plain variables hasn't been implemented yet. It will definitely happen in the future.

ZebulanStanphill reacted with thumbs up emoji
@rvanvelzen rvanvelzen marked this pull request as draft May 2, 2022 09:43
Copy link
Contributor Author

I've actually got a more-or-less working implementation with this, but I think allowing more complicated expression (e.g. $this->getSomething()) isn't too hard and would at least be nice to support here.

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.

Yes, it'd be nice to have properties and methods too :) Thank you!

Copy link
Member

BTW @rvanvelzen Did you start working on the counterpart in phpstan-src? If not then I can merge this as it is, get it working in phpstan-src (I have some ideas about that), and we can do methods+properties as follow-up PRs :) What do you think?

@rvanvelzen rvanvelzen marked this pull request as ready for review May 3, 2022 17:48
Copy link
Contributor Author

I did work on it a bit but feel free to get it working :)

@ondrejmirtes ondrejmirtes merged commit 6cafed9 into phpstan:1.4.x May 4, 2022
Copy link
Member

Thank you!

@rvanvelzen rvanvelzen deleted the assert branch May 17, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

+1 more reviewer

@ZebulanStanphill ZebulanStanphill ZebulanStanphill 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 によって変換されたページ (->オリジナル) /