File tree Expand file tree Collapse file tree 1 file changed +29
-9
lines changed Expand file tree Collapse file tree 1 file changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -40,18 +40,38 @@ class MethodDeclaration extends Node implements FunctionLike {
4040 // FunctionBody
4141 'compoundStatementOrSemicolon '
4242 ];
43+
44+ public function hasModifier (int $ targetModifier ) : bool {
45+ if ($ this ->modifiers === null ) {
46+ return false ;
47+ }
48+ foreach ($ this ->modifiers as $ modifier ) {
49+ if ($ modifier ->kind === $ targetModifier ) {
50+ return true ;
51+ }
52+ }
53+ return false ;
54+ }
4355
4456 public function isStatic () : bool {
45- if ($ this ->modifiers === null ) {
46- return false ;
47- }
48- foreach ($ this ->modifiers as $ modifier ) {
49- if ($ modifier ->kind === TokenKind::StaticKeyword) {
50- return true ;
51- }
52- }
53- return false ;
57+ return $ this ->hasModifier (TokenKind::StaticKeyword);
5458 }
59+
60+ public function isPublic () : bool {
61+ return $ this ->hasModifier (TokenKind::PublicKeyword);
62+ }
63+
64+ public function isProtected () : bool {
65+ return $ this ->hasModifier (TokenKind::ProtectedKeyword);
66+ }
67+
68+ public function isPrivate () : bool {
69+ return $ this ->hasModifier (TokenKind::PrivateKeyword);
70+ }
71+
72+ public function isAbstract () : bool {
73+ return $ this ->hasModifier (TokenKind::AbstractKeyword);
74+ }
5575
5676 public function getName () {
5777 return $ this ->name ->getText ($ this ->getFileContents ());
You can’t perform that action at this time.
0 commit comments