rspec/rules/S2048/php/rule.adoc

64 lines
1.3 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Shared coding conventions allow teams to collaborate effectively.
This rule checks that when
* an assignment is too long to fit on one line, the line break is inserted before the ``++=++`` rather than after, and the second line of the statement is indented from the first.
* an object operator is the first thing on the line, it is indented from the previous line.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,php]
2021-04-28 16:49:39 +02:00
----
$variable_with_a_very_very_long_name = classInstance.method1().method2().
method3(); // Noncompliant, linebreak after '='
$variable_with_a_very_very_long_name
= classInstance.method1().method2().method3(); // Noncompliant, 2nd line not indented
$a = classInstance.method1().method2().method3()
->property1; // Noncompliant,
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,php]
2021-04-28 16:49:39 +02:00
----
$variable_with_a_very_very_long_name
= classInstance.method1().method2().method3();
$a = classInstance.method1().method2().method3()
->property1;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Indent this line {n} spaces.
* Break this assignment before "=", not after.
=== Parameters
.number_of_spaces
****
----
4
----
The number of spaces the second line should be intended from the first.
****
endif::env-github,rspecator-view[]