Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -17,7 +17,7 @@ use Symfony\Component\DependencyInjection\Definition;
/**
* {@inheritdoc}
*
* Noop proxy instantiator - simply produces the real service instead of a proxy instance.
* Noop proxy instantiator - produces the real service instead of a proxy instance.
*
* @author Marco Pivetta <ocramius@gmail.com>
*/

View File

@@ -30,12 +30,11 @@ interface DumperInterface
/**
* Generates the code to be used to instantiate a proxy in the dumped factory code.
*
* @param Definition $definition
* @param string $id Service identifier
* @param string $id Service identifier
*
* @return string
*/
public function getProxyFactoryCode(Definition $definition, $id);
public function getProxyFactoryCode(Definition $definition, $id/**, $factoryCode = null */);
/**
* Generates the code for the lazy proxy.

View File

@@ -17,6 +17,8 @@ use Symfony\Component\DependencyInjection\Definition;
* Null dumper, negates any proxy code generation for any given service definition.
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @final since version 3.3
*/
class NullDumper implements DumperInterface
{
@@ -31,7 +33,7 @@ class NullDumper implements DumperInterface
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null)
{
return '';
}

View File

@@ -0,0 +1,64 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\LazyProxy;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class ProxyHelper
{
/**
* @return string|null The FQCN or builtin name of the type hint, or null when the type hint references an invalid self|parent context
*/
public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false)
{
if ($p instanceof \ReflectionParameter) {
if (method_exists($p, 'getType')) {
$type = $p->getType();
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $p, $type)) {
$name = $type = $type[1];
if ('callable' === $name || 'array' === $name) {
return $noBuiltin ? null : $name;
}
}
} else {
$type = method_exists($r, 'getReturnType') ? $r->getReturnType() : null;
}
if (!$type) {
return null;
}
if (!\is_string($type)) {
$name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
if ($type->isBuiltin()) {
return $noBuiltin ? null : $name;
}
}
$lcName = strtolower($name);
$prefix = $noBuiltin ? '' : '\\';
if ('self' !== $lcName && 'parent' !== $lcName) {
return $prefix.$name;
}
if (!$r instanceof \ReflectionMethod) {
return null;
}
if ('self' === $lcName) {
return $prefix.$r->getDeclaringClass()->name;
}
return ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null;
}
}