
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.
52 lines
958 B
Plaintext
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[]
|