Skip to content
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

Use objects, not strings, for assertions #7410

Merged
merged 5 commits into from Jan 20, 2022
Merged

Conversation

muglug
Copy link
Collaborator

@muglug muglug commented Jan 17, 2022

It's a big addition, but this would make it slightly easier to track where assertions were being used in the codebase, and removes a lot of checks for $assertion[0] === '!' etc.

@orklah
Copy link
Collaborator

orklah commented Jan 17, 2022

This looks really good!

@orklah
Copy link
Collaborator

orklah commented Jan 20, 2022

Hi @muglug ! Do you think you'll finish this soon? I'd really like having this in the alpha for Psalm 5!

@muglug
Copy link
Collaborator Author

muglug commented Jan 20, 2022

Yup, should have unit tests passing today

@muglug muglug force-pushed the muglug-assertiontype-object branch from 284c23a to a707303 Compare January 20, 2022 21:04
@muglug muglug force-pushed the muglug-assertiontype-object branch from a707303 to 52aeeb2 Compare January 20, 2022 21:06
@orklah
Copy link
Collaborator

orklah commented Jan 20, 2022

Sorry, my last merge on master broke CI. I'll fix that

@orklah orklah added PR: Need review release:internal The PR will be included in 'Internal changes' section of the release notes and removed PR: Needs work labels Jan 20, 2022
@muglug muglug marked this pull request as ready for review January 20, 2022 21:22
@muglug muglug changed the title WIP: Use objects, not strings, for assertions Use objects, not strings, for assertions Jan 20, 2022
@orklah
Copy link
Collaborator

orklah commented Jan 20, 2022

Could you add some details on UPDGRADE.md to explain that the old Assertion was renamed and other BC breaks introduced?

@orklah
Copy link
Collaborator

orklah commented Jan 20, 2022

every call to getAssertionString is now with $exact to true. Can we drop the param?

@orklah
Copy link
Collaborator

orklah commented Jan 20, 2022

This makes so many things looks a lot more clearer! Very cool! Thanks :)

@muglug muglug merged commit 0a81f8c into master Jan 20, 2022
@muglug muglug deleted the muglug-assertiontype-object branch January 20, 2022 22:33

public function __toString(): string
{
return '!non-empty';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@muglug Is this a BC break regarding projects (including Assert tools) that used empty or !empty as a docblock assertion?

Is there a reason why you didn't kept it as empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can be “empty”, but that should have no impact on the parsing of assertions either way — do you have an example of failing code?

Copy link
Collaborator

@orklah orklah Feb 1, 2022

Choose a reason for hiding this comment

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

Somehow it still works? https://psalm.dev/r/bb6d82a6a3 https://psalm.dev/r/90da8dba12

I didn't expect that. What is the system that parses assertion strings into Assertion objects?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@orklah It's the scanner.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks! I never had to tweak here before... Weird, I thought there would have been a direct link between internal assertion names and user assertions ones. But this answer my question! Thanks both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Need review release:internal The PR will be included in 'Internal changes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants