phpcsFile->getTokens(); $attribute = $this->getTargetToken('/* testLiveCoding */', T_ATTRIBUTE); $expectedTokenCodesAttribute1 = [ 'T_ATTRIBUTE', 'T_STRING', 'T_ATTRIBUTE_END', 'T_WHITESPACE', ]; $lengthAttribute1 = count($expectedTokenCodesAttribute1); $map = array_map( function ($token) use ($attribute, $lengthAttribute1) { if ($token['code'] !== T_WHITESPACE) { $this->assertArrayHasKey('attribute_closer', $token); $this->assertSame(($attribute + 2), $token['attribute_closer']); } return $token['type']; }, array_slice($tokens, $attribute, $lengthAttribute1) ); $this->assertSame($expectedTokenCodesAttribute1, $map); $expectedTokenCodesAttribute2 = [ 'T_ATTRIBUTE', 'T_STRING', 'T_WHITESPACE', 'T_FUNCTION', ]; $lengthAttribute2 = count($expectedTokenCodesAttribute2); $map = array_map( function ($token) { if ($token['code'] === T_ATTRIBUTE) { $this->assertArrayHasKey('attribute_closer', $token); $this->assertNull($token['attribute_closer']); } else { $this->assertArrayNotHasKey('attribute_closer', $token); } return $token['type']; }, array_slice($tokens, ($attribute + $lengthAttribute1), $lengthAttribute2) ); $this->assertSame($expectedTokenCodesAttribute2, $map); }//end testInvalidAttribute() }//end class