Merge branch '5.0'
* 5.0: [DependencyInjection] Fix binding tagged services to containers [ProxyManager] fix generating proxies for root-namespaced classes [DoctrineBridge] Cleanup 3.4 legacy [DI] skip looking for config class when the extension class is anonymous Fix typo Docs - Update debug section of UPGRADE guides for 4.4 and 5.0 versions. Fix invalid typehint for subject in is_granted Twig function [Dotenv] FIX missing getenv [HttpFoundation] fix pdo session handler for sqlsrv [HttpClient][Psr18Client] Remove Psr18ExceptionTrait [HttpKernel] ignore failuresgenerated by opcache.restrict_api
This commit is contained in:
commit
4e5b15353d
@ -19,6 +19,7 @@ Debug
|
||||
-----
|
||||
|
||||
* Deprecated the component in favor of the `ErrorHandler` component
|
||||
* Replace uses of `Symfony\Component\Debug\Debug` by `Symfony\Component\ErrorHandler\Debug`
|
||||
|
||||
Config
|
||||
------
|
||||
|
@ -60,6 +60,7 @@ Debug
|
||||
-----
|
||||
|
||||
* Removed the component in favor of the `ErrorHandler` component
|
||||
* Replace uses of `Symfony\Component\Debug\Debug` by `Symfony\Component\ErrorHandler\Debug`
|
||||
|
||||
DependencyInjection
|
||||
-------------------
|
||||
|
@ -54,17 +54,13 @@ abstract class ManagerRegistry extends AbstractManagerRegistry
|
||||
}
|
||||
$manager->setProxyInitializer(\Closure::bind(
|
||||
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
|
||||
if (isset($this->normalizedIds[$normalizedId = strtolower($name)])) { // BC with DI v3.4
|
||||
$name = $this->normalizedIds[$normalizedId];
|
||||
}
|
||||
if (isset($this->aliases[$name])) {
|
||||
$name = $this->aliases[$name];
|
||||
}
|
||||
if (isset($this->fileMap[$name])) {
|
||||
$wrappedInstance = $this->load($this->fileMap[$name]);
|
||||
} else {
|
||||
$method = $this->methodMap[$name] ?? 'get'.strtr($name, $this->underscoreMap).'Service'; // BC with DI v3.4
|
||||
$wrappedInstance = $this->{$method}(false);
|
||||
$wrappedInstance = $this->{$this->methodMap[$name]}(false);
|
||||
}
|
||||
|
||||
$manager->setProxyInitializer(null);
|
||||
|
@ -81,6 +81,7 @@ EOF;
|
||||
public function getProxyCode(Definition $definition): string
|
||||
{
|
||||
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
|
||||
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
|
||||
|
||||
if (version_compare(self::getProxyManagerVersion(), '2.2', '<')) {
|
||||
$code = preg_replace(
|
||||
|
@ -21,5 +21,5 @@ class LazyServiceProjectServiceContainer extends Container
|
||||
}
|
||||
}
|
||||
|
||||
class stdClass_%s extends %SstdClass implements \ProxyManager\%s
|
||||
class stdClass_%s extends \stdClass implements \ProxyManager\%s
|
||||
{%a}%A
|
||||
|
@ -31,7 +31,10 @@ final class SecurityExtension extends AbstractExtension
|
||||
$this->securityChecker = $securityChecker;
|
||||
}
|
||||
|
||||
public function isGranted($role, object $object = null, string $field = null): bool
|
||||
/**
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function isGranted($role, $object = null, string $field = null): bool
|
||||
{
|
||||
if (null === $this->securityChecker) {
|
||||
return false;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
@ -126,8 +127,8 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue)));
|
||||
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, %s, %s, %s or ServiceLocatorArgument, %s given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,11 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$class = \get_class($this);
|
||||
|
||||
if (false !== strpos($class, "\0")) {
|
||||
return null; // ignore anonymous classes
|
||||
}
|
||||
|
||||
$class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
|
||||
$class = $container->getReflectionClass($class);
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass;
|
||||
@ -35,6 +36,7 @@ class ResolveBindingsPassTest extends TestCase
|
||||
|
||||
$bindings = [
|
||||
CaseSensitiveClass::class => new BoundArgument(new Reference('foo')),
|
||||
'Psr\Container\ContainerInterface $container' => new BoundArgument(new ServiceLocatorArgument([]), true, BoundArgument::INSTANCEOF_BINDING),
|
||||
'iterable $objects' => new BoundArgument(new TaggedIteratorArgument('tag.name'), true, BoundArgument::INSTANCEOF_BINDING),
|
||||
];
|
||||
|
||||
@ -49,7 +51,13 @@ class ResolveBindingsPassTest extends TestCase
|
||||
$pass = new ResolveBindingsPass();
|
||||
$pass->process($container);
|
||||
|
||||
$this->assertEquals([0 => new Reference('foo'), 1 => '123', 4 => new TaggedIteratorArgument('tag.name')], $definition->getArguments());
|
||||
$expected = [
|
||||
0 => new Reference('foo'),
|
||||
1 => '123',
|
||||
3 => new ServiceLocatorArgument([]),
|
||||
4 => new TaggedIteratorArgument('tag.name'),
|
||||
];
|
||||
$this->assertEquals($expected, $definition->getArguments());
|
||||
$this->assertEquals([['setSensitiveClass', [new Reference('foo')]]], $definition->getMethodCalls());
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use Psr\Container\ContainerInterface;
|
||||
*/
|
||||
class NamedArgumentsDummy
|
||||
{
|
||||
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $interface, iterable $objects)
|
||||
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $container, iterable $objects)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ final class Dotenv
|
||||
} elseif (isset($this->values[$name])) {
|
||||
$value = $this->values[$name];
|
||||
} else {
|
||||
$value = '';
|
||||
$value = (string) getenv($name);
|
||||
}
|
||||
|
||||
if ('' === $value && isset($matches['default_value']) && '' !== $matches['default_value']) {
|
||||
|
@ -443,6 +443,17 @@ class DotenvTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetVariablesValueFromGetenv()
|
||||
{
|
||||
putenv('Foo=Bar');
|
||||
|
||||
$dotenv = new Dotenv(true);
|
||||
$values = $dotenv->parse('Foo=${Foo}');
|
||||
$this->assertSame('Bar', $values['Foo']);
|
||||
|
||||
putenv('Foo');
|
||||
}
|
||||
|
||||
public function testNoDeprecationWarning()
|
||||
{
|
||||
$dotenv = new Dotenv(true);
|
||||
|
@ -190,7 +190,7 @@ final class Psr18Client implements ClientInterface, RequestFactoryInterface, Str
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait Psr18ExceptionTrait
|
||||
class Psr18NetworkException extends \RuntimeException implements NetworkExceptionInterface
|
||||
{
|
||||
private $request;
|
||||
|
||||
@ -206,18 +206,21 @@ trait Psr18ExceptionTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Psr18NetworkException extends \RuntimeException implements NetworkExceptionInterface
|
||||
{
|
||||
use Psr18ExceptionTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Psr18RequestException extends \InvalidArgumentException implements RequestExceptionInterface
|
||||
{
|
||||
use Psr18ExceptionTrait;
|
||||
private $request;
|
||||
|
||||
public function __construct(TransportExceptionInterface $e, RequestInterface $request)
|
||||
{
|
||||
parent::__construct($e->getMessage(), 0, $e);
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function getRequest(): RequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
}
|
||||
|
@ -869,10 +869,10 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
$mergeStmt->bindParam(2, $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(3, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindValue(4, time() + $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(4, time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->bindParam(5, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindValue(6, time() + $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(6, time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(5, time(), \PDO::PARAM_INT);
|
||||
$mergeStmt->bindParam(6, $data, \PDO::PARAM_LOB);
|
||||
$mergeStmt->bindValue(7, time() + $maxlifetime, \PDO::PARAM_INT);
|
||||
$mergeStmt->bindValue(8, time(), \PDO::PARAM_INT);
|
||||
} else {
|
||||
$mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
|
||||
$mergeStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
|
||||
|
@ -401,13 +401,11 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
* ini_set('session.save_path', '/tmp');
|
||||
*
|
||||
* or pass in a \SessionHandler instance which configures session.save_handler in the
|
||||
* constructor, for a template see NativeFileSessionHandler or use handlers in
|
||||
* composer package drak/native-session
|
||||
* constructor, for a template see NativeFileSessionHandler.
|
||||
*
|
||||
* @see https://php.net/session-set-save-handler
|
||||
* @see https://php.net/sessionhandlerinterface
|
||||
* @see https://php.net/sessionhandler
|
||||
* @see https://github.com/zikula/NativeSession
|
||||
*
|
||||
* @param AbstractProxy|\SessionHandlerInterface|null $saveHandler
|
||||
*
|
||||
|
@ -471,7 +471,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
}
|
||||
|
||||
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
opcache_invalidate($this->getPath(), true);
|
||||
@opcache_invalidate($this->getPath(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user