This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
Add scope for PHP primitive types #389
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4d1ef95
Add `storage.primitive.php` scope for PHP primitive types
bakerkretzmar 688c886
Add primitive scope to typed properties and update tests
bakerkretzmar 92e6bbf
Add primitive scope to closure return types and update tests
bakerkretzmar 6478a28
Add primitive scope to arrow function return types and update tests
bakerkretzmar 2a938ff
Add primitive scope to function return types and update tests
bakerkretzmar 17e2c45
Add primitive scope to type casts and update tests
bakerkretzmar 7206557
Add primitive scope to function and method argument typehints and upd…
bakerkretzmar 484b025
Update more tests
bakerkretzmar 91373a0
Add primitive scope to array and callable argument typehints and upda…
bakerkretzmar e818c0a
Update scope to `storage.type.primitive.php`
bakerkretzmar 1bbb5a0
Add word boundaries to regex
bakerkretzmar 261e693
Fix missing quotes on keys
bakerkretzmar d1071b8
Consistent quotes in tests
bakerkretzmar 915ff09
Replace \b with ^...$ in regex
bakerkretzmar a097719
Remove parentheses from regex
bakerkretzmar 054d564
Revert to using \b in regex
bakerkretzmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tried this (especially in VS Code), but since you are only using this for nested matching, you could try using
^
and$
instead of the two\\b
. If it works exactly as before, you should consider using that form instead.While
\b
is mostly "fine", it's somewhat tricky thing to get right and sets a poor example to others. I cannot think of specific counterexamples from top of my head, but historically we have had to fix poor usages of\b
here, which is why I suggest avoiding it altogether whenever the replacement is trivial to understand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ingramz I'm not sure how unicode is treated in vscode, but in atom I couldn't abuse this with stuff like
stringʕ•ᴥ•ʔ
. However, this might be a problem in vscode or some other editor.Although it's rather edge case, replacing
\b
with^...$
is a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible example is using emojis like
int🐱
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I basically copy-pasted from other parts of the syntax to start with, so I appreciate this advice.
All the tests pass with
^(...)$
but interestingly, this doesn't work in VS Code. No clue why, it just doesn't tokenize properly. But if I remove the capturing group, so it really is just^...$
(no parentheses) then it works as expected.Is there any reason to keep those, or is removing them as I've done now fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without parentheses you have equivalent of:
(^array)|bool|callable|float|int|iterable|object|(string$)
so only array and string are broken then.Okay I dived into this and found cause microsoft/vscode-textmate#74 tl;dr only
$
is working somewhat correctly and all becausesubstring(line start, capture end)
is used for match, thus any start anchors are useless there.Even if
^..$
are better, implementation makes them useless in vscode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So would something like
(^array$)|(^bool$)|(^callable$)|...
work here? Or would it still break because^
doesn't work properly at all?@Ingramz it looks like
\\b
might be simpler after all if that's okay with you! 😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
^
is broken. And yes, in that case\b
is better. I wasn't aware of that until now and this explains some weird behaviors which I had in the past.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is broken in vscode then we have no other choice than to use
\b
. Thank you for trying it out and @KapitanOczywisty for finding the relevant issue. Rest of the pull request looks great now. I am however annoyed by this vscode's deviation from spec.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's frustrating. I've changed it back to
\b
.