Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Find traits with TokenArrayScanner
Browse files Browse the repository at this point in the history
Added T_TRAIT next to T_CLASS and T_INTERFACE.

For php 5.3 T_TRAIT gets defined to not get any errors.
  • Loading branch information
danez authored and Daniel Tschinder committed Aug 21, 2013
1 parent 22db9a5 commit be3f9b2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion library/Zend/Code/Scanner/TokenArrayScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ protected function scan()
throw new Exception\RuntimeException('No tokens were provided');
}

/**
* Define PHP 5.4 'trait' token constant.
*/
if (!defined('T_TRAIT')) {
define('T_TRAIT', 42001);
}

/**
* Variables & Setup
*/
Expand Down Expand Up @@ -552,6 +559,7 @@ protected function scan()
case T_ABSTRACT:
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:

$infos[$infoIndex] = array(
'type' => ($tokenType === T_FUNCTION) ? 'function' : 'class',
Expand All @@ -573,7 +581,7 @@ protected function scan()

// process the name
if ($infos[$infoIndex]['shortName'] == ''
&& (($tokenType === T_CLASS || $tokenType === T_INTERFACE) && $infos[$infoIndex]['type'] === 'class'
&& (($tokenType === T_CLASS || $tokenType === T_INTERFACE || $tokenType === T_TRAIT) && $infos[$infoIndex]['type'] === 'class'
|| ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function'))
) {
$infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1];
Expand Down

0 comments on commit be3f9b2

Please sign in to comment.