rspec/rules/S2234/php/rule.adoc
2022-02-04 16:28:24 +00:00

52 lines
901 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

include::../description.adoc[]
== Noncompliant Code Example
[source,php]
----
public function divide($divisor, $dividend) {
return $divisor/$dividend;
}
public function doTheThing() {
$divisor = 15;
$dividend = 5;
$result = $this->divide($dividend, $divisor); // Noncompliant; operation succeeds, but result is unexpected
}
----
== Compliant Solution
[source,php]
----
public function divide($divisor, $dividend) {
return $divisor/$dividend;
}
public function doTheThing() {
$divisor = 15;
$dividend = 5;
$result = $this->divide($divisor, $dividend); // Compliant
}{code}
h4.  
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]