rspec/rules/S4284/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

52 lines
958 B
Plaintext

== Why is this an issue?
PHP lets you make static calls to non-static methods, ex: ``++A::f();++``. But the fact that you can doesn't mean you _should_. While such calls will work when there's no ``++$this++`` reference in the called method, a fatal error will occur when there is. Furthermore, such calls have been deprecated in PHP 7, and their support may be removed from future releases.
=== Noncompliant code example
[source,php]
----
class A {
function f() {
// ...
}
}
A::f(); // Noncompliant, "f" is non-static
----
=== Compliant solution
[source,php]
----
class A {
function f() {
// ...
}
}
$a = new A();
$a->f();
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use an object instance to call this non-static method.
=== Highlighting
The class name that should be replaced by an object instance variable.
endif::env-github,rspecator-view[]