Skip to content

Consistently use php opening tag #74

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

Closed
wants to merge 1 commit into from

Conversation

ravage84
Copy link
Contributor

@ravage84 ravage84 commented Jun 1, 2023

Which is mandated by 3. Declare Statements, Namespace, and Import Statements, anyway.

Kinda "eat your own dog food".

Plus, it makes it even more clear in what file type context the code examples are.

Lastly, this also fixes thie following oddly looking (and unnecessary) whitespace in 7.1 Short Closures:

grafik

Which is mandated by "3. Declare Statements, Namespace, and Import Statements".
@Crell
Copy link
Collaborator

Crell commented Jun 1, 2023

I don't think this really applies here. I almost never see the PHP opening tags in markdown code blocks. The intent of the referenced section is that in a file you must start with the open tag, and use the long-tag version. That doesn't really apply to code snippets.

Leaving this open to see if anyone else on the team disagrees, but I'm voting won't-fix here.

@Crell
Copy link
Collaborator

Crell commented Jun 1, 2023

(The unnecessary extra line in that one code block can be fixed in a separate PR.)

@mbniebergall
Copy link

Including the opening PHP tag <?php is not standard for code snippets. See examples of no opening PHP tags at:

Some PSrs do include the opening tag, when conveying the context of the file, as seen in:

@alekitto
Copy link

alekitto commented Jun 1, 2023

I agree that the opening tag should not be mandatory for code snippets.
At the same time, I can see the inconsistency between the various PSRs: for example in PSR-3, the code block containing the interpolate function has an unnecessary opening tag, while the interface declarations (which are entire files) correctly have it.

I’m voting for wont-fix here, but probably we should define a general rule for code blocks/snippets

@KorvinSzanto
Copy link
Contributor

I don't see value in including the PHP tag in code snippets unless the snippet encompasses the entire file so I agree this isn't something we should do.

@samdark
Copy link
Member

samdark commented Jun 2, 2023

I agree that there's no sense in adding it in these cases.

@ravage84
Copy link
Contributor Author

ravage84 commented Jun 5, 2023

(The unnecessary extra line in that one code block can be fixed in a separate PR.)

Separate PR: #80

@ravage84
Copy link
Contributor Author

ravage84 commented Jun 5, 2023

[...] At the same time, I can see the inconsistency between the various PSRs: for example in PSR-3, the code block containing the interpolate function has an unnecessary opening tag, while the interface declarations (which are entire files) correctly have it.

Actually, I disagree on that specific one because it could be the full code of this file., as well.
Adding a php opening tag implicitly hints at that & frames the whole code.

grafik

https://www.php-fig.org/psr/psr-3/#12-message

This would be a prime example where I would expect the php opening tag

@ravage84
Copy link
Contributor Author

ravage84 commented Jun 5, 2023

While I like the consistency of having opening tags everywhere, I can see it being "too much", especially for one liners.

What do you think of the alternative in #81?

@ravage84 ravage84 closed this Jun 5, 2023
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.

6 participants