Only add PHP opening tag when the following rule of thumb are met#81
Closed
ravage84 wants to merge 1 commit intophp-fig:masterfrom
Closed
Only add PHP opening tag when the following rule of thumb are met#81ravage84 wants to merge 1 commit intophp-fig:masterfrom
ravage84 wants to merge 1 commit intophp-fig:masterfrom
Conversation
Add PHP opening tags when all requirements are met: - Tne [mandatory class namespace](https://www.php-fig.org/psr/psr-1/#3-namespace-and-class-names) is defined or no class or interface respectively is defined - All necessary classes & functions are imported - All necessary variables & constants are defined - All necessary structures are visible or hinted at with a comment - All statements and/or structures are related to each other - Or the PHP opening tag is essential to the code example Do not add PHP opening tags when: - Only one or many unrelated statements are shown - Only one or many unrelated functions are shown - Only one or many unrelated methods are shown - Only one or many unrelated classes or interfaces respectively are shown - Only one or many unrelated other structures, such as an if-clause or match expression, are shown
Crell
reviewed
Jun 5, 2023
|
|
||
| ```php | ||
| <?php | ||
|
|
Collaborator
There was a problem hiding this comment.
I'd leave this one. We're talking about the use statements, which happen at a very specific place in the file, so I think it's fine to leave here.
Contributor
|
Suggest shorten the list when need add PHP opening tag to several items:
In otherwise cases |
Collaborator
|
Looks like nothing is happening here. |
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
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.
While I like the consistency of having opening tags everywhere (as in #74), I can see it being "too much", especially for one liners.
What do you think of the following rule of thumb proposal?
Add PHP opening tags when all requirements are met:
Do not add PHP opening tags when: