-
Notifications
You must be signed in to change notification settings - Fork 30k
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
PHP Snippets Quality of Life and Continuity #174889
Conversation
- Sorted snippets by snippet title for discoverability - Removed all doc comments from non 'doc_' prefixed snippets - Added doc_trait for continuity with other patterns - Updated snippet prefixes - Add kvp to keyval - Prefixed fun with class_ - Changed doc_param to doc_var - Qualified 'con' to 'constructor' to not be confused with const - Updated class snippet to default the 'class' placeholder to the file's base name - Add snippet choices for private, public, protected where appropriate - Add an additional tab stop to end of functions for additional args/params - Remove array kvps since arrays can be associative or just values
- Add fun for a general function out of scope of class - Add fun_anonymous for anonymous functions - Add fun_arrow for arrow functions
- Add match expression - Add Attribute snippets - Add sensitive parameter - Add attribute target - Add attribute with target - Rename class_const to const - Add Dynamic Property Class snippet - Add enum snippets - Basic Enum - Backed Enum - foreach enum
@microsoft-github-policy-service agree |
My fork was out of sync. I have synced the fork and merged vscode/main into my branch |
This seems like a lot of work. In the future, you might want to open an issue so that we can have a discussion about what you want to add before you do a lot of work to write the code. I'm not sure I want to merge this. Some of these snippets are really detailed and specific. I think it's nice for us to offer basic snippets for the most common scenarios out of the box, but I think that most of these would be better suited for a php snippet extension. Have you considered that? |
Unfortunately, when I rebased I lost the commit messages, but in short, there is nothing really specific to 'me' or my needs here. I'm all for taking whatever offenders you think out, but the goal with this PR is to align PHP snippets with PHP 8 features. < PHP 8 is reaching end of life and there are no snippets to bridge the gap out-of-box. This also makes the PHP doc strategy consistent, some snippets had a prefix some others didn't. I'm willing to filter and adjust if you can point to some ones that may not be suitable for the community at large, I'm not married to these by any means so if you have feedback, I'd consider this discussion just as valuable. But at minimum, there should be some PHP 8 support out-of-box imo. I think for starters, the heredoc and nowdoc and super global snippets aren't necessary. I'm okay with removing those personally. Everything else was updated for the purposes to be used across all versions of PHP agnostically. For example, the parameter snippets are way out of date, because we have type hints now and we have promoted parameters. Classes also need to be updated because not every class needs a constructor signature and so forth. I think if anything I'm removing a lot of the 'explicit' use cases of these snippets, If by extension, you mean me create one, sure I could, but I don't see the difference in creating one and adding it here; at a high level anyways. Again, open to suggestions, I know you have a lot of users to think about and that's fair |
Sorry for the slow response. I think that for our builtin snippets, we want to stick to snippets that just cover the most common usages of general language constructs. We don't want to try to be exhaustive for every possible for- eg we'll take a If you can do a pass to remove snippets that might fit that description then I will take another look. The other snippets can go in a user's snippets files or a snippets extension. |
Do you plan to work on this more @soulshined? |
Oops. sorry I missed the last email notification about it. I will adjust based on your feedback! I should have time tomorrow or wednesday evening
|
- Remove heredoc - Remove nowdoc - Remove php super global snippets - Remove namespace_path - Remove ethis (echo $this->) - Remove try/catch finally
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 trimmed the snippets a bit more, just removing ones that I feel don't add much or are a variation of another snippet.
@roblourens no issues here; just a fair warning you removed a majority of existing ones prior to my changes (ultimately like you said, people will have to add to their personal snippets as they see fit anyways) but I think at minimum we need to add back the throws exception snippet and the 2 constructors. Here's the file prior to my changes: https://github.com/soulshined/vscode/blob/d5e12a12ddcdbffa565ea36aec17d94df7c9f3d9/extensions/php/snippets/php.code-snippets Additionally, some 'variations' come at a cost. the class snippet that existed prior to mine never accounted for promotion style constructors or chaining parameters etc. I'll leave that up to you to decide. I'm not married to anything just adding color that the old php syntax is far from php 8 snytax (yet the new 'variants' are backwards compatible, err i tried my best to be) |
Oops, I meant to check for that, I will at least add back the ones that were previously existing. Thanks. I will put back one constructor snippet. I think having both is just a level of detail that we don't need built in but would make sense in an extension for snippet power users. |
That shouldn't have been deleted in #174889 And also bring back one constructor snippet
That shouldn't have been deleted in #174889 And also bring back one constructor snippet
Qualify of Life
doc_
keyval
snippet if it's an associative arraydoc_param
to more accurately describe it's intentNew Snippets
try_finally
param
Used to chain params for any function
functions
fun
Users should use
param
to chain parametersfun_anonymous
fun_arrow
constructor_promotion
Users can use
property_promoted
to chain promotion properties in a constructorspaceship
property
goto
const
namespace
use_as
use_group
use_fun
use_const
match
refAttributes ref
attr
attr_with_target
attr_target
Enum ref
enum
enum_backed
foreach_enum
Dynamic Properties Class