for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Patsura Dmitry https://github.com/ovr <[email protected]>
*/
namespace PHPSA\Analyzer\Pass\Statement\MagicMethod;
use PhpParser\Node\Stmt\ClassMethod;
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
use PHPSA\Check;
use PHPSA\Context;
class GetParametersCheck implements AnalyzerPassInterface
{
use DefaultMetadataPassTrait;
* @param ClassMethod $methodStmt
* @param Context $context
* @return bool
public function pass(ClassMethod $methodStmt, Context $context)
if ($methodStmt->name == '__get') {
if (count($methodStmt->params) == 0) {
$context->notice(
'magic.get.wrong-parameters',
'Magic method __get must take 1 parameter at least',
$methodStmt,
Check::CHECK_SAFE
);
}
if ($methodStmt->name == '__set') {
if (count($methodStmt->params) < 2) {
'Magic method __set must take 2 parameters at least',
if ($methodStmt->name == '__clone') {
if (count($methodStmt->params) > 0) {
'Magic method __clone cannot accept arguments',
* @return array
public function getRegister()
return [
\PhpParser\Node\Stmt\ClassMethod::class
];