for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Solidifier\Defects;
use Solidifier\Defect;
use Solidifier\Visitors\ObjectType;
use PhpParser\Node\Stmt\ClassMethod;
class NotFluidSetter extends Defect
{
private
$objectType;
$objectType
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
class A { var $property; }
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.
public function __construct(ObjectType $objectType, ClassMethod $node)
parent::__construct($node);
$this->objectType = $objectType;
}
public function getMessage()
return sprintf(
'Method <type>%s</type>::<id>%s</id>() does not follow fluid interface',
$this->objectType->fullname,
$this->node->name
name
PhpParser\Node
instanceof
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Adding an additional type check:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeInterface $object) { if ($object instanceof SomeClass) { $a = $object->a; } }
Changing the type hint:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeClass $object) { $a = $object->a; }
);
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.