Conversation
|
@heyanlong This is for license check for PHP, welcome to provide feedback. |
|
@emschu hey, thanks for bringing this up. Is it allowed to have multiple <?php
/**
* header license comments
*/
?>
<?php
// some real codes
?>If it's valid, maybe we can simple use the following comment style config, - id: PHP
start: |
<?php
/*
middle: ' *'
end: |
*/
?>multi-line strings in yaml is rather legit and normal. |
|
@kezhenxu94 Yes, your example is a valid php script syntax. You can read about this topic here.
For this reason I think it is not a good idea to generally add a php closing tag after the license header in PHP files as this could cause trouble with whitespace or output buffering in pure php files (pure means: non-template PHP code, e.g. class definitions etc.). I will think about this problem next week again. Enjoy the weekend! |
kezhenxu94
left a comment
There was a problem hiding this comment.
Looks good to me now, thanks @emschu !! 🙇🏻
This is a preview to add support for PHP header comments with minimal code changes. I'm not sure if it is a good idea to change the
CommentStylestruct this way by adding two new propertiesensure_afterorensure_before.My idea is composing the header license text by ensure_after + header + ensure_before - if the RegEx provided in
afteryields no results.Are there other (script) languages which require a similar behaviour?
What do you think about this? Or do you want to discuss this in a dedicated issue?
Some notes:
declare(strict_types=[0|1]);has to be omitted or it has to be the very first statement in the script, which is pretty common in modern PHP code.short_open_taginphp.ini.<?phpthen can be written as<?, but even withshort_open_tags set toOn<?phpis still a valid start of a PHP code block.