Since $__depth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__depth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
Since $__maxDepth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__maxDepth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
The call to ToArray::___toArray() has too many arguments starting with $maxDepth.
This check compares calls to functions or methods with their respective definitions.
If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the
check may pick up the wrong definition and report false positives. One codebase
where this has been known to happen is Wordpress.
In this case you can add the @ignorePhpDoc
annotation to the duplicate definition and it will be ignored.
Loading history...
27
}
28
29
/**
30
* Convert object to array.
31
*
32
* @param $subject
33
* @return array|null
34
*/
35
1
public function ___toArray($subject)
36
{
37
1
$callback = $this->__getToArrayCallBack();
38
39
1
return $callback($subject);
40
}
41
42
/**
43
* Generate a callback to transform object to array.
Since $__depth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__depth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
Since $__depth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__depth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
Since $__maxDepth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__maxDepth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
Since $__depth is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $__depth to at least protected.
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the getSomeVariable() on that sub-class, you will receive
a runtime error:
classYourSubClassextendsYourClass{}YourSubClass::getSomeVariable();// Will cause an access error.
In the case above, it makes sense to update SomeClass to use self instead:
classSomeClass{privatestatic$someVariable;publicstaticfunctiongetSomeVariable(){returnself::$someVariable;// self works fine with private.}}
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: