rspec/rules/S1757/php/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

62 lines
1.3 KiB
Plaintext

== Why is this an issue?
The `<?php` tag is used to explicitly mark the start of PHP code in a file.
It is considered the recommended and portable way to open PHP blocks.
On the other hand, the `<?=` tag is a shorthand for `<?php` echo and is specifically used to output variables or expressions directly without using the echo statement.
Not using these tags can make the code less readable and harder to maintain, as it deviates from the standard conventions followed by most PHP developers.
=== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
<?
$foo = 1;
?>
----
=== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
<?php
$foo = 1;
?>
----
== Resources
=== Documentation
* https://www.php.net/manual/en/language.basic-syntax.phptags.php[PHP Manual - PHP tags]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Change this opening tag to either "<?php" or "<?=".
=== Highlighting
* primary: first NC tag
* secondary: subsequent NC tags
** message: none
'''
== Comments And Links
(visible only on this page)
=== on 12 Oct 2015, 12:03:58 Ann Campbell wrote:
Highlighting added [~linda.martin]. See what you think.
=== on 12 Nov 2015, 18:25:01 Linda Martin wrote:
\[~ann.campbell.2] Perfect! Thanks.
endif::env-github,rspecator-view[]