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\Property;
use PhpParser\Node\Stmt\Class_;
class PublicClass extends Defect
{
public function getMessage()
return sprintf(
'Class <id>%s</id> is mainly public : maybe it is over responsible',
$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; }
);
}
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: