/** * @param \PhpParser\Node\Stmt $context * @return int */ public static function getForContext(Stmt $context) { if ($context->isPublic()) { return Class_::MODIFIER_PUBLIC; } elseif ($context->isProtected()) { return Class_::MODIFIER_PROTECTED; } else { return Class_::MODIFIER_PRIVATE; } }
/** * @param Stmt $stmt * @param Context $context * @return bool */ public function pass(Stmt $stmt, Context $context) { // if it is private, protected or public return false if ($stmt->isPrivate() || $stmt->isProtected() || ($stmt->type & Class_::MODIFIER_PUBLIC) !== 0) { return false; } if ($stmt instanceof Property) { $context->notice('missing_visibility', 'Class property was defined with the deprecated var keyword. Use a visibility modifier instead.', $stmt); } elseif ($stmt instanceof ClassMethod) { $context->notice('missing_visibility', 'Class method was defined without a visibility modifier.', $stmt); } return true; }