equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Reflection |
16 * @package Zend_Reflection |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: File.php 20904 2010-02-04 16:18:18Z matthew $ |
19 * @version $Id: File.php 24803 2012-05-14 12:23:46Z adamlundrigan $ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Reflection_Class |
23 * @see Zend_Reflection_Class |
24 */ |
24 */ |
30 require_once 'Zend/Reflection/Function.php'; |
30 require_once 'Zend/Reflection/Function.php'; |
31 |
31 |
32 /** |
32 /** |
33 * @category Zend |
33 * @category Zend |
34 * @package Zend_Reflection |
34 * @package Zend_Reflection |
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
37 */ |
37 */ |
38 class Zend_Reflection_File implements Reflector |
38 class Zend_Reflection_File implements Reflector |
39 { |
39 { |
40 /** |
40 /** |
84 * @return void |
84 * @return void |
85 */ |
85 */ |
86 public function __construct($file) |
86 public function __construct($file) |
87 { |
87 { |
88 $fileName = $file; |
88 $fileName = $file; |
89 |
89 |
90 if (($fileRealpath = realpath($fileName)) === false) { |
90 $fileRealpath = realpath($fileName); |
|
91 if ($fileRealpath) { |
|
92 // realpath() doesn't return false if Suhosin is included |
|
93 // see http://uk3.php.net/manual/en/function.realpath.php#82770 |
|
94 if (!file_exists($fileRealpath)) { |
|
95 $fileRealpath = false; |
|
96 } |
|
97 } |
|
98 |
|
99 if ($fileRealpath === false) { |
91 $fileRealpath = self::findRealpathInIncludePath($file); |
100 $fileRealpath = self::findRealpathInIncludePath($file); |
92 } |
101 } |
93 |
102 |
94 if (!$fileRealpath || !in_array($fileRealpath, get_included_files())) { |
103 if (!$fileRealpath || !in_array($fileRealpath, get_included_files())) { |
95 require_once 'Zend/Reflection/Exception.php'; |
104 require_once 'Zend/Reflection/Exception.php'; |
298 protected function _reflect() |
307 protected function _reflect() |
299 { |
308 { |
300 $contents = $this->_contents; |
309 $contents = $this->_contents; |
301 $tokens = token_get_all($contents); |
310 $tokens = token_get_all($contents); |
302 |
311 |
303 $functionTrapped = false; |
312 $functionTrapped = false; |
304 $classTrapped = false; |
313 $classTrapped = false; |
305 $requireTrapped = false; |
314 $requireTrapped = false; |
306 $openBraces = 0; |
315 $embeddedVariableTrapped = false; |
|
316 $openBraces = 0; |
307 |
317 |
308 $this->_checkFileDocBlock($tokens); |
318 $this->_checkFileDocBlock($tokens); |
309 |
319 |
310 foreach ($tokens as $token) { |
320 foreach ($tokens as $token) { |
311 /* |
321 /* |
328 // It's a symbol |
338 // It's a symbol |
329 // Maintain the count of open braces |
339 // Maintain the count of open braces |
330 if ($token == '{') { |
340 if ($token == '{') { |
331 $openBraces++; |
341 $openBraces++; |
332 } else if ($token == '}') { |
342 } else if ($token == '}') { |
333 $openBraces--; |
343 if ( $embeddedVariableTrapped ) { |
|
344 $embeddedVariableTrapped = false; |
|
345 } else { |
|
346 $openBraces--; |
|
347 } |
334 } |
348 } |
335 |
349 |
336 continue; |
350 continue; |
337 } |
351 } |
338 |
352 |
339 switch ($type) { |
353 switch ($type) { |
|
354 case T_STRING_VARNAME: |
|
355 case T_DOLLAR_OPEN_CURLY_BRACES: |
|
356 case T_CURLY_OPEN: |
|
357 $embeddedVariableTrapped = true; |
|
358 continue; |
|
359 |
340 // Name of something |
360 // Name of something |
341 case T_STRING: |
361 case T_STRING: |
342 if ($functionTrapped) { |
362 if ($functionTrapped) { |
343 $this->_functions[] = $value; |
363 $this->_functions[] = $value; |
344 $functionTrapped = false; |
364 $functionTrapped = false; |