[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\DependencyInjection\LazyProxy; 13 14 /** 15 * @author Nicolas Grekas <p@tchwork.com> 16 * 17 * @internal 18 */ 19 class ProxyHelper 20 { 21 /** 22 * @return string|null The FQCN or builtin name of the type hint, or null when the type hint references an invalid self|parent context 23 */ 24 public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false) 25 { 26 if ($p instanceof \ReflectionParameter) { 27 if (method_exists($p, 'getType')) { 28 $type = $p->getType(); 29 } elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $p, $type)) { 30 $name = $type = $type[1]; 31 32 if ('callable' === $name || 'array' === $name) { 33 return $noBuiltin ? null : $name; 34 } 35 } 36 } else { 37 $type = method_exists($r, 'getReturnType') ? $r->getReturnType() : null; 38 } 39 if (!$type) { 40 return null; 41 } 42 43 $types = []; 44 45 foreach ($type instanceof \ReflectionUnionType ? $type->getTypes() : [$type] as $type) { 46 $name = $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type; 47 48 if (!\is_string($type) && $type->isBuiltin()) { 49 if (!$noBuiltin) { 50 $types[] = $name; 51 } 52 continue; 53 } 54 55 $lcName = strtolower($name); 56 $prefix = $noBuiltin ? '' : '\\'; 57 58 if ('self' !== $lcName && 'parent' !== $lcName) { 59 $types[] = '' !== $prefix ? $prefix.$name : $name; 60 continue; 61 } 62 if (!$r instanceof \ReflectionMethod) { 63 continue; 64 } 65 if ('self' === $lcName) { 66 $types[] = $prefix.$r->getDeclaringClass()->name; 67 } else { 68 $types[] = ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null; 69 } 70 } 71 72 return $types ? implode('|', $types) : null; 73 } 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |