Merge branch '5.2' into 5.x

* 5.2:
  [Security] Fix event propagation for globally registered security events
  Add missing `@return` annotations to fix deprecations on PHP 8
  [ProxyManagerBridge] fix PHP notice, switch to "friendsofphp/proxy-manager-lts"
  allow null values in form helpers
  Add RememberMe Badge to LoginLinkAuthenticator
This commit is contained in:
Nicolas Grekas 2020-12-23 16:46:09 +01:00
commit b3de641fd4
52 changed files with 192 additions and 120 deletions

View File

@ -149,7 +149,7 @@ before_install:
if [[ $PHP = 8.* ]]; then
tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI
else
tfold ext.mongodb tpecl mongodb-1.6.16 mongodb.so $INI
tfold ext.mongodb tpecl mongodb-1.8.1 mongodb.so $INI
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
tfold ext.amqp tpecl amqp-1.10.2 amqp.so $INI
fi
@ -215,13 +215,6 @@ install:
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' -printf '%h\n' | sort)
fi
- |
# Set composer's platform to php 7.4 if we're on php 8.
if [[ $PHP = 8.* ]]; then
composer config platform.php 7.4.99
export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
fi
- |
# Install symfony/flex
if [[ $deps = low ]]; then
@ -262,7 +255,7 @@ install:
fi
phpenv global $PHP
rm vendor/composer/package-versions-deprecated -Rf
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer config platform.ext-mongodb 1.6.99; composer require --dev --no-update mongodb/mongodb ~1.5.0)
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer config platform.ext-mongodb 1.8.99; composer require --dev --no-update mongodb/mongodb ^1.8.1)
tfold 'composer update' $COMPOSER_UP
tfold 'phpunit install' ./phpunit install
if [[ $deps = high ]]; then
@ -279,7 +272,7 @@ install:
git fetch --depth=2 origin $SYMFONY_VERSION
git checkout -m FETCH_HEAD
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.6.99; composer require --dev --no-update mongodb/mongodb)
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.8.99; composer require --dev --no-update mongodb/mongodb)
[[ ! $COMPONENTS ]] || tfold 'phpunit install' SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 ./phpunit install
[[ ! $COMPONENTS ]] || echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" || X=1
fi

View File

@ -18,6 +18,7 @@
"require": {
"php": ">=7.2.5",
"ext-xml": "*",
"friendsofphp/proxy-manager-lts": "^1.0",
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "^2",
"twig/twig": "^2.10|^3.0",
@ -122,7 +123,6 @@
"masterminds/html5": "^2.6",
"monolog/monolog": "^1.25.1|^2",
"nyholm/psr7": "^1.0",
"ocramius/proxy-manager": "^2.1",
"paragonie/sodium_compat": "^1.8",
"pda/pheanstalk": "^4.0",
"php-http/httplug": "^1.0|^2.0",

View File

@ -18,6 +18,8 @@ class StringWrapperType extends StringType
{
/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
@ -26,6 +28,8 @@ class StringWrapperType extends StringType
/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{

View File

@ -43,6 +43,8 @@ class DoctrineFooType extends Type
/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
@ -58,6 +60,8 @@ class DoctrineFooType extends Type
/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{

View File

@ -83,6 +83,8 @@ class ConsoleFormatter implements FormatterInterface
/**
* {@inheritdoc}
*
* @return mixed
*/
public function formatBatch(array $records)
{
@ -95,6 +97,8 @@ class ConsoleFormatter implements FormatterInterface
/**
* {@inheritdoc}
*
* @return mixed
*/
public function format(array $record)
{

View File

@ -26,6 +26,11 @@ class VarDumperFormatter implements FormatterInterface
$this->cloner = $cloner ?: new VarCloner();
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function format(array $record)
{
$record['context'] = $this->cloner->cloneVar($record['context']);
@ -34,6 +39,11 @@ class VarDumperFormatter implements FormatterInterface
return $record;
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function formatBatch(array $records)
{
foreach ($records as $k => $record) {

View File

@ -48,7 +48,11 @@ class RuntimeInstantiator implements InstantiatorInterface
$proxy->setProxyInitializer(null);
return true;
}
},
[
'fluentSafe' => $definition->hasTag('proxy'),
'skipDestructor' => true,
]
);
}
}

View File

@ -11,87 +11,26 @@
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
use Laminas\Code\Generator\ClassGenerator;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator as BaseGenerator;
use Symfony\Component\DependencyInjection\Definition;
use Zend\Code\Generator\ClassGenerator;
/**
* @internal
*/
class LazyLoadingValueHolderGenerator extends BaseGenerator
{
private $fluentSafe = false;
public function setFluentSafe(bool $fluentSafe)
{
$this->fluentSafe = $fluentSafe;
}
/**
* {@inheritdoc}
*/
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = []): void
{
parent::generate($originalClass, $classGenerator);
parent::generate($originalClass, $classGenerator, $proxyOptions);
foreach ($classGenerator->getMethods() as $method) {
$body = preg_replace(
'/(\$this->initializer[0-9a-f]++) && \1->__invoke\(\$this->(valueHolder[0-9a-f]++), (.*?), \1\);/',
'$1 && ($1->__invoke(\$$2, $3, $1) || 1) && $this->$2 = \$$2;',
$method->getBody()
);
$body = str_replace('(new \ReflectionClass(get_class()))', '$reflection', $body);
$body = str_replace('$reflection = $reflection ?: ', '$reflection = $reflection ?? ', $body);
$body = str_replace('$reflection ?? $reflection = ', '$reflection ?? ', $body);
if ($originalClass->isInterface()) {
$body = str_replace('get_parent_class($this)', var_export($originalClass->name, true), $body);
$body = preg_replace_callback('/\n\n\$realInstanceReflection = [^{]++\{([^}]++)\}\n\n.*/s', function ($m) {
$r = '';
foreach (explode("\n", $m[1]) as $line) {
$r .= "\n".substr($line, 4);
if (0 === strpos($line, ' return ')) {
break;
}
}
return $r;
}, $body);
}
if ($this->fluentSafe) {
$indent = $method->getIndentation();
$method->setIndentation('');
$code = $method->generate();
if (null !== $docBlock = $method->getDocBlock()) {
$code = substr($code, \strlen($docBlock->generate()));
}
$refAmp = (strpos($code, '&') ?: \PHP_INT_MAX) <= strpos($code, '(') ? '&' : '';
$body = preg_replace(
'/\nreturn (\$this->valueHolder[0-9a-f]++)(->[^;]++);$/',
"\nif ($1 === \$returnValue = {$refAmp}$1$2) {\n \$returnValue = \$this;\n}\n\nreturn \$returnValue;",
$body
);
$method->setIndentation($indent);
}
if (0 === strpos($originalClass->getFilename(), __FILE__)) {
$body = str_replace(var_export($originalClass->name, true), '__CLASS__', $body);
$method->setBody(str_replace(var_export($originalClass->name, true), '__CLASS__', $method->getBody()));
}
$method->setBody($body);
}
if ($classGenerator->hasMethod('__destruct')) {
$destructor = $classGenerator->getMethod('__destruct');
$body = $destructor->getBody();
$newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body);
if ($body === $newBody) {
throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method "%s::__destruct()".', $originalClass->name));
}
$destructor->setBody($newBody);
}
if (0 === strpos($originalClass->getFilename(), __FILE__)) {

View File

@ -11,9 +11,7 @@
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
use ProxyManager\Exception\ExceptionInterface;
use ProxyManager\Generator\ClassGenerator;
use ProxyManager\Generator\MethodGenerator;
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
@ -84,18 +82,6 @@ EOF;
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
if (!method_exists(MethodGenerator::class, 'fromReflectionWithoutBodyAndDocBlock')) { // proxy-manager < 2.2
$code = preg_replace(
'/((?:\$(?:this|initializer|instance)->)?(?:publicProperties|initializer|valueHolder))[0-9a-f]++/',
'${1}'.$this->getIdentifierSuffix($definition),
$code
);
}
if (!is_subclass_of(ExceptionInterface::class, 'Throwable')) { // proxy-manager < 2.5
$code = preg_replace('/ \\\\Closure::bind\(function ((?:& )?\(\$instance(?:, \$value)?\))/', ' \Closure::bind(static function \1', $code);
}
return $code;
}
@ -114,8 +100,10 @@ EOF;
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
$class = $this->proxyGenerator->getProxifiedClass($definition);
$this->proxyGenerator->setFluentSafe($definition->hasTag('proxy'));
$this->proxyGenerator->generate(new \ReflectionClass($class), $generatedClass);
$this->proxyGenerator->generate(new \ReflectionClass($class), $generatedClass, [
'fluentSafe' => $definition->hasTag('proxy'),
'skipDestructor' => true,
]);
return $generatedClass;
}

View File

@ -11,4 +11,4 @@ Resources
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)
[1]: https://github.com/Ocramius/ProxyManager
[1]: https://github.com/FriendsOfPHP/proxy-manager-lts

View File

@ -16,7 +16,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->dummy()) {
$returnValue = $this;
return $this;
}
return $returnValue;
@ -27,7 +27,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummyRef', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
if ($this->valueHolder%s === $returnValue = & $this->valueHolder%s->dummyRef()) {
$returnValue = $this;
return $this;
}
return $returnValue;
@ -38,7 +38,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'sunny', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->sunny()) {
$returnValue = $this;
return $this;
}
return $returnValue;
@ -96,7 +96,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
$targetObject = $this->valueHolder%s;
return $targetObject->$name = $value;
$targetObject->$name = $value; return $targetObject->$name;
}
public function __isset($name)

View File

@ -18,15 +18,12 @@
"require": {
"php": ">=7.2.5",
"composer/package-versions-deprecated": "^1.8",
"symfony/dependency-injection": "^5.0",
"ocramius/proxy-manager": "~2.1"
"friendsofphp/proxy-manager-lts": "^1.0",
"symfony/dependency-injection": "^5.0"
},
"require-dev": {
"symfony/config": "^4.4|^5.0"
},
"conflict": {
"zendframework/zend-eventmanager": "2.6.0"
},
"autoload": {
"psr-4": { "Symfony\\Bridge\\ProxyManager\\": "" },
"exclude-from-classmap": [

View File

@ -111,7 +111,7 @@ final class FormExtension extends AbstractExtension
return $view->vars['value'];
}
public function getFieldLabel(FormView $view): string
public function getFieldLabel(FormView $view): ?string
{
return $this->createFieldTranslation(
$view->vars['label'],
@ -120,7 +120,7 @@ final class FormExtension extends AbstractExtension
);
}
public function getFieldHelp(FormView $view): string
public function getFieldHelp(FormView $view): ?string
{
return $this->createFieldTranslation(
$view->vars['help'],
@ -164,7 +164,7 @@ final class FormExtension extends AbstractExtension
}
}
private function createFieldTranslation(?string $value, array $parameters, $domain): string
private function createFieldTranslation(?string $value, array $parameters, $domain): ?string
{
if (!$this->translator || !$value || false === $domain) {
return $value;

View File

@ -74,7 +74,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
/**
* Gets a container parameter by its name.
*
* @return mixed
* @return array|bool|float|int|string|null
*/
protected function getParameter(string $name)
{

View File

@ -58,6 +58,8 @@ class TestContainer extends Container
/**
* {@inheritdoc}
*
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{

View File

@ -13,14 +13,18 @@ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\Event\LoginFailureEvent;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
use Symfony\Component\Security\Http\Event\LogoutEvent;
use Symfony\Component\Security\Http\SecurityEvents;
/**
* Makes sure all event listeners on the global dispatcher are also listening
* to events on the firewall-specific dipatchers.
* to events on the firewall-specific dispatchers.
*
* This compiler pass must be run after RegisterListenersPass of the
* EventDispatcher component.
@ -31,7 +35,18 @@ use Symfony\Component\Security\Http\Event\LogoutEvent;
*/
class RegisterGlobalSecurityEventListenersPass implements CompilerPassInterface
{
private static $eventBubblingEvents = [CheckPassportEvent::class, LoginFailureEvent::class, LoginSuccessEvent::class, LogoutEvent::class];
private static $eventBubblingEvents = [
CheckPassportEvent::class,
LoginFailureEvent::class,
LoginSuccessEvent::class,
LogoutEvent::class,
AuthenticationSuccessEvent::class,
InteractiveLoginEvent::class,
// When events are registered by their name
AuthenticationEvents::AUTHENTICATION_SUCCESS,
SecurityEvents::INTERACTIVE_LOGIN,
];
/**
* {@inheritdoc}

View File

@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
use Symfony\Component\Security\Http\Event\LogoutEvent;
@ -53,13 +54,15 @@ class RegisterGlobalSecurityEventListenersPassTest extends TestCase
$this->container->register('app.security_listener', \stdClass::class)
->addTag('kernel.event_listener', ['method' => 'onLogout', 'event' => LogoutEvent::class])
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20]);
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20])
->addTag('kernel.event_listener', ['method' => 'onAuthenticationSuccess', 'event' => AuthenticationEvents::AUTHENTICATION_SUCCESS]);
$this->container->compile();
$this->assertListeners([
[LogoutEvent::class, ['app.security_listener', 'onLogout'], 0],
[LoginSuccessEvent::class, ['app.security_listener', 'onLoginSuccess'], 20],
[AuthenticationEvents::AUTHENTICATION_SUCCESS, ['app.security_listener', 'onAuthenticationSuccess'], 0],
]);
}
@ -79,6 +82,7 @@ class RegisterGlobalSecurityEventListenersPassTest extends TestCase
[LogoutEvent::class, [TestSubscriber::class, 'onLogout'], -200],
[CheckPassportEvent::class, [TestSubscriber::class, 'onCheckPassport'], 120],
[LoginSuccessEvent::class, [TestSubscriber::class, 'onLoginSuccess'], 0],
[AuthenticationEvents::AUTHENTICATION_SUCCESS, [TestSubscriber::class, 'onAuthenticationSuccess'], 0],
]);
}
@ -95,17 +99,20 @@ class RegisterGlobalSecurityEventListenersPassTest extends TestCase
$this->container->register('app.security_listener', \stdClass::class)
->addTag('kernel.event_listener', ['method' => 'onLogout', 'event' => LogoutEvent::class])
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20]);
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20])
->addTag('kernel.event_listener', ['method' => 'onAuthenticationSuccess', 'event' => AuthenticationEvents::AUTHENTICATION_SUCCESS]);
$this->container->compile();
$this->assertListeners([
[LogoutEvent::class, ['app.security_listener', 'onLogout'], 0],
[LoginSuccessEvent::class, ['app.security_listener', 'onLoginSuccess'], 20],
[AuthenticationEvents::AUTHENTICATION_SUCCESS, ['app.security_listener', 'onAuthenticationSuccess'], 0],
], 'security.event_dispatcher.main');
$this->assertListeners([
[LogoutEvent::class, ['app.security_listener', 'onLogout'], 0],
[LoginSuccessEvent::class, ['app.security_listener', 'onLoginSuccess'], 20],
[AuthenticationEvents::AUTHENTICATION_SUCCESS, ['app.security_listener', 'onAuthenticationSuccess'], 0],
], 'security.event_dispatcher.api');
}
@ -122,13 +129,15 @@ class RegisterGlobalSecurityEventListenersPassTest extends TestCase
$this->container->register('app.security_listener', \stdClass::class)
->addTag('kernel.event_listener', ['method' => 'onLogout', 'event' => LogoutEvent::class, 'dispatcher' => 'security.event_dispatcher.main'])
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20]);
->addTag('kernel.event_listener', ['method' => 'onLoginSuccess', 'event' => LoginSuccessEvent::class, 'priority' => 20])
->addTag('kernel.event_listener', ['method' => 'onAuthenticationSuccess', 'event' => AuthenticationEvents::AUTHENTICATION_SUCCESS]);
$this->container->compile();
$this->assertListeners([
[LogoutEvent::class, ['app.security_listener', 'onLogout'], 0],
[LoginSuccessEvent::class, ['app.security_listener', 'onLoginSuccess'], 20],
[AuthenticationEvents::AUTHENTICATION_SUCCESS, ['app.security_listener', 'onAuthenticationSuccess'], 0],
], 'security.event_dispatcher.main');
}
@ -146,7 +155,8 @@ class RegisterGlobalSecurityEventListenersPassTest extends TestCase
}
$foundListeners = array_uintersect($expectedListeners, $actualListeners, function (array $a, array $b) {
return $a === $b;
// PHP internally sorts all the arrays first, so returning proper 1 / -1 values is crucial
return $a <=> $b;
});
$this->assertEquals($expectedListeners, $foundListeners);
@ -161,6 +171,7 @@ class TestSubscriber implements EventSubscriberInterface
LogoutEvent::class => ['onLogout', -200],
CheckPassportEvent::class => ['onCheckPassport', 120],
LoginSuccessEvent::class => 'onLoginSuccess',
AuthenticationEvents::AUTHENTICATION_SUCCESS => 'onAuthenticationSuccess',
];
}
}

View File

@ -43,6 +43,8 @@ final class CacheItem implements ItemInterface
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get()
{

View File

@ -66,6 +66,8 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($key, $default = null)
{

View File

@ -34,6 +34,8 @@ class ServiceLocator extends BaseServiceLocator
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{

View File

@ -109,7 +109,7 @@ class Container implements ContainerInterface, ResetInterface
*
* @param string $name The parameter name
*
* @return mixed The parameter value
* @return array|bool|float|int|string|null The parameter value
*
* @throws InvalidArgumentException if the parameter is not defined
*/

View File

@ -71,7 +71,7 @@ interface ContainerInterface extends PsrContainerInterface
*
* @param string $name The parameter name
*
* @return mixed The parameter value
* @return array|bool|float|int|string|null The parameter value
*
* @throws InvalidArgumentException if the parameter is not defined
*/

View File

@ -1512,6 +1512,9 @@ EOF;
$code = <<<'EOF'
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (isset($this->buildParameters[$name])) {

View File

@ -33,6 +33,11 @@ class ServiceLocator implements ServiceProviderInterface
private $externalId;
private $container;
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{
if (!$this->externalId) {

View File

@ -532,6 +532,9 @@ class DecoratedServiceLocator implements ServiceProviderInterface
$this->locator = $locator;
}
/**
* @return mixed
*/
public function get($id)
{
return $this->locator->get($id);

View File

@ -56,6 +56,9 @@ class ProjectServiceContainer extends Container
return $this->services['test'] = new \stdClass(['only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end', 'new line' => 'string with '."\n".'new line']);
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -56,6 +56,9 @@ class ProjectServiceContainer extends Container
return $this->services['test'] = new \stdClass(('file://'.\dirname(__DIR__, 1)), [('file://'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]);
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -71,6 +71,9 @@ class ProjectServiceContainer extends Container
return $instance;
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -67,6 +67,9 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container
return $this->services['test'] = new ${($_ = $this->getEnv('FOO')) && false ?: "_"}($this->getEnv('Bar'), 'foo'.$this->getEnv('string:FOO').'baz', $this->getEnv('int:Baz'));
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class ProjectServiceContainer extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -823,6 +823,9 @@ class ProjectServiceContainer extends Container
return $instance;
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (isset($this->buildParameters[$name])) {

View File

@ -421,6 +421,9 @@ class ProjectServiceContainer extends Container
return new \SimpleFactoryClass('foo');
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -476,6 +476,9 @@ class ProjectServiceContainer extends Container
return new \SimpleFactoryClass('foo');
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (isset($this->buildParameters[$name])) {

View File

@ -91,6 +91,9 @@ class ProjectServiceContainer extends Container
return new \Bar\FooClass(new \Bar\FooLazyClass());
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (isset($this->buildParameters[$name])) {

View File

@ -60,6 +60,9 @@ class ProjectServiceContainer extends Container
return $instance;
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_CsvParameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -69,6 +69,9 @@ class ProjectServiceContainer extends Container
return $this->services['foo'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? ($this->privates['bar_%env(BAR)%'] = new \stdClass())), ['baz_'.$this->getEnv('string:BAR') => new \stdClass()]);
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -421,6 +421,9 @@ class Symfony_DI_PhpDumper_Errored_Definition extends Container
return new \SimpleFactoryClass('foo');
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -89,6 +89,9 @@ class ProjectServiceContainer extends Container
return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3());
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_JsonParameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_QueryStringParameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -74,6 +74,9 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container
]);
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -78,6 +78,9 @@ class Symfony_DI_PhpDumper_Test_Unsupported_Characters extends Container
return $this->services['foo*/oh-no'] = new \FooClass();
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -43,6 +43,9 @@ class Symfony_DI_PhpDumper_Test_UrlParameters extends Container
];
}
/**
* @return array|bool|float|int|string|null
*/
public function getParameter(string $name)
{
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || \array_key_exists($name, $this->parameters))) {

View File

@ -37,7 +37,9 @@ class TranslationFilesTest extends TestCase
{
$document = new \DOMDocument();
$document->loadXML(file_get_contents($filePath));
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader(true);
}
$errors = XliffUtils::validateSchema($document);

View File

@ -36,7 +36,9 @@ class TranslationFilesTest extends TestCase
{
$document = new \DOMDocument();
$document->loadXML(file_get_contents($filePath));
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader(true);
}
$errors = XliffUtils::validateSchema($document);

View File

@ -17,6 +17,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
@ -69,7 +70,7 @@ final class LoginLinkAuthenticator extends AbstractAuthenticator implements Inte
return $user;
}),
[]
[new RememberMeBadge()]
);
}

View File

@ -17,6 +17,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authenticator\LoginLinkAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\HttpUtils;
@ -105,6 +106,17 @@ class LoginLinkAuthenticatorTest extends TestCase
$this->authenticator->authenticate($request);
}
public function testPassportBadges()
{
$this->setUpAuthenticator();
$request = Request::create('/login/link/check?stuff=1&user=weaverryan');
$passport = $this->authenticator->authenticate($request);
$this->assertTrue($passport->hasBadge(RememberMeBadge::class));
}
private function setUpAuthenticator(array $options = [])
{
$this->authenticator = new LoginLinkAuthenticator($this->loginLinkHandler, new HttpUtils(), $this->successHandler, $this->failureHandler, $options);

View File

@ -36,7 +36,9 @@ class TranslationFilesTest extends TestCase
{
$document = new \DOMDocument();
$document->loadXML(file_get_contents($filePath));
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader(true);
}
$errors = XliffUtils::validateSchema($document);

View File

@ -50,6 +50,8 @@ trait ServiceLocatorTrait
/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{