for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* TNoUnserializeClassBehaviorTrait class file.
*
* @author Brad Anderson <[email protected]>
* @link https://github.com/pradosoft/prado
* @license https://github.com/pradosoft/prado/blob/master/LICENSE
*/
namespace Prado\Util\Behaviors;
use Prado\Util\TCallChain;
* TNoUnserializeClassBehaviorTrait class.
* When this trait is used by an IClassBehavior, upon the owner being unserialized
* (via magic method __wakeup and dyWakeUp) this trait removes itself from its owner.
* This trait is used to deprecate serialized objects' IClassBehavior. By re-serializing
* the object can be saved without the deprecated behavior.
* @since 4.2.3
trait TNoUnserializeClassBehaviorTrait
{
* This is raised when an owner is completed its unserialize() method call to
* __wakeup. This method removes its behavior from the owner.
* @param object $owner The owner of he behavior raising the dynamic event.
* @param TCallChain $chain The chain of dynamic event method handlers.
public function dyWakeUp(object $owner, TCallChain $chain)
if ($index = array_search($this, $owner->getBehaviors())) {
$owner->detachBehavior($index);
}
return $chain->dyWakeUp();
$chain->dyWakeUp()
Prado\TComponent::dyWakeUp()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.