FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add syntax for subtraction type by rvanvelzen · Pull Request #240 · phpstan/phpdoc-parser · GitHub

Add syntax for subtraction type - #240

Draft
rvanvelzen wants to merge 1 commit into
phpstan:1.23.xfrom
rvanvelzen:subtraction-type
Draft

Add syntax for subtraction type#240
rvanvelzen wants to merge 1 commit into
phpstan:1.23.xfrom
rvanvelzen:subtraction-type

Conversation

Copy link
Copy Markdown
Contributor

This is a preliminary syntax implementation for subtraction type syntax.

Merging now isn't necessary because the work in phpstan-src is far from done. Any feedback is still appreciated though.

Copy link
Copy Markdown
Member
  1. We have to get rid of all Type inheritance before this is possible to do: https://phpstan.org/blog/why-is-instanceof-type-wrong-and-getting-deprecated
  2. I'm not sure we need a new syntax for this and how it should look like. We could do this simply with subtract-from<X, Y> generics.

),
],
[
'string~int~float',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

One non-parentheised expression should not allow more than one ~ to prevent associativity ambiguity as not standartized not needed.

As you can see, currently float is even missing in the parsed type.

Lexer::TOKEN_SUBTRACTION,
],
[
'(string&int)~float',

mvorisek Sep 8, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These cases should be tested:

  • A|B~C (expected A|(B~C))
  • A~B|C (expected (A~B)|C)
  • A&B~C (expected syntax error?)
  • A~B&C (expected syntax error?)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL