2021-04-28 16:49:39 +02:00
``++$this++`` refers to the current class instance. But static methods can be accessed without instantiating the class, and ``++$this++`` is not available to them. Using ``++$this++`` in a static context will result in a fatal error at runtime.
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
class Clazz {
$name=NULL; // instance variable
public static function foo(){
if ($this->name != NULL) {
// ...
}
}
}
----
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
class Clazz {
$name=NULL; // instance variable
public static function foo($nameParam){
if ($nameParam != NULL) {
// ...
}
}
}
----
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]