[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework (http://framework.zend.com/) 4 * 5 * @link http://github.com/zendframework/zf2 for the canonical source repository 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 7 * @license http://framework.zend.com/license/new-bsd New BSD License 8 */ 9 10 namespace Zend\Code\Scanner; 11 12 use stdClass; 13 use Zend\Code\Exception; 14 15 /** 16 * Shared utility methods used by scanners 17 */ 18 class Util 19 { 20 /** 21 * Resolve imports 22 * 23 * @param string $value 24 * @param null|string $key 25 * @param \stdClass $data 26 * @return void 27 * @throws Exception\InvalidArgumentException 28 */ 29 public static function resolveImports(&$value, $key = null, stdClass $data = null) 30 { 31 if (!is_object($data) 32 || !property_exists($data, 'uses') 33 || !property_exists($data, 'namespace') 34 ) { 35 throw new Exception\InvalidArgumentException(sprintf( 36 '%s expects a data object containing "uses" and "namespace" properties; on or both missing', 37 __METHOD__ 38 )); 39 } 40 41 if ($data->namespace && !$data->uses && strlen($value) > 0 && $value{0} != '\\') { 42 $value = $data->namespace . '\\' . $value; 43 44 return; 45 } 46 47 if (!$data->uses || strlen($value) <= 0 || $value{0} == '\\') { 48 $value = ltrim($value, '\\'); 49 50 return; 51 } 52 53 if ($data->namespace || $data->uses) { 54 $firstPart = $value; 55 if (($firstPartEnd = strpos($firstPart, '\\')) !== false) { 56 $firstPart = substr($firstPart, 0, $firstPartEnd); 57 } else { 58 $firstPartEnd = strlen($firstPart); 59 } 60 61 if (array_key_exists($firstPart, $data->uses)) { 62 $value = substr_replace($value, $data->uses[$firstPart], 0, $firstPartEnd); 63 64 return; 65 } 66 67 if ($data->namespace) { 68 $value = $data->namespace . '\\' . $value; 69 70 return; 71 } 72 } 73 } 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |