Esempio n. 1
0
 /**
  * @param Stmt\ClassMethod|Stmt\Function_ $stmt
  * @param Context $context
  * @return bool
  */
 private function inspectParams(Stmt $stmt, Context $context)
 {
     /** @var \PhpParser\Node\Param $param */
     foreach ($stmt->getParams() as $param) {
         if ($param->name === 'this') {
             $context->notice('unexpected_use.this', sprintf('Method/Function %s can not have a parameter named "this".', $stmt->name), $param);
             return true;
         }
     }
     return false;
 }
Esempio n. 2
0
 /**
  * @param Stmt $func
  * @param Context $context
  * @return bool
  */
 public function pass(Stmt $func, Context $context)
 {
     $prevIsOptional = false;
     foreach ($func->getParams() as $param) {
         if ($prevIsOptional && $param->default === null) {
             $context->notice('optional-param-before-required', 'Optional parameter before required one is always required.', $func);
             return true;
         }
         $prevIsOptional = $param->default !== null;
     }
     return false;
 }