The array has the following items:
'visibility' int|null T_PRIVATE, T_PROTECTED or T_PUBLIC
'static' bool
'abstract' bool
'final' bool
public getMethodAttributes ( integer $index ) : array | ||
$index | integer | Token index of the method (T_FUNCTION) |
return | array |
/** * @param Tokens $tokens * @param TokensAnalyzer $tokensAnalyzer * @param int $classStart * @param int $classEnd */ private function fixClass(Tokens $tokens, TokensAnalyzer $tokensAnalyzer, $classStart, $classEnd) { for ($index = $classEnd; $index > $classStart; --$index) { if (!$tokens[$index]->isGivenKind(T_FUNCTION) || $tokensAnalyzer->isLambda($index)) { continue; } $attributes = $tokensAnalyzer->getMethodAttributes($index); if (true === $attributes['abstract']) { $methodEnd = $tokens->getNextTokenOfKind($index, array(';')); } else { $methodStart = $tokens->getNextTokenOfKind($index, array('{')); $methodEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $methodStart, true); } $this->fixSpaceBelowMethod($tokens, $classEnd, $methodEnd); $this->fixSpaceAboveMethod($tokens, $classStart, $index); } }
/** * @dataProvider provideGetFunctionProperties */ public function testGetFunctionProperties($source, $index, $expected) { $tokens = Tokens::fromCode($source); $tokensAnalyzer = new TokensAnalyzer($tokens); $attributes = $tokensAnalyzer->getMethodAttributes($index); $this->assertSame($expected, $attributes); }