8000 Merge branch '5.2' into 5.x · symfony/symfony@b3de641 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3de641

Browse files
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
2 parents 14a3730 + b53600d commit b3de641

File tree

52 files changed

+192
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+192
-120
lines changed

.travis.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ before_install:
149149
if [[ $PHP = 8.* ]]; then
150150
tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI
151151
else
152-
tfold ext.mongodb tpecl mongodb-1.6.16 mongodb.so $INI
152+
tfold ext.mongodb tpecl mongodb-1.8.1 mongodb.so $INI
153153
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
154154
tfold ext.amqp tpecl amqp-1.10.2 amqp.so $INI
155155
fi
@@ -215,13 +215,6 @@ install:
215215
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' -printf '%h\n' | sort)
216216
fi
217217
218-
- |
219-
# Set composer's platform to php 7.4 if we're on php 8.
220-
if [[ $PHP = 8.* ]]; then
221-
composer config platform.php 7.4.99
222-
export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
223-
fi
224-
225218
- |
226219
# Install symfony/flex
227220
if [[ $deps = low ]]; then
@@ -262,7 +255,7 @@ install:
262255
fi
263256
phpenv global $PHP
264257
rm vendor/composer/package-versions-deprecated -Rf
265-
([[ $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)
258+
([[ $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)
266259
tfold 'composer update' $COMPOSER_UP
267260
tfold 'phpunit install' ./phpunit install
268261
if [[ $deps = high ]]; then
@@ -279,7 +272,7 @@ install:
279272
git fetch --depth=2 origin $SYMFONY_VERSION
280273
git checkout -m FETCH_HEAD
281274
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
282-
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.6.99; composer require --dev --no-update mongodb/mongodb)
275+
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.8.99; composer require --dev --no-update mongodb/mongodb)
283276
[[ ! $COMPONENTS ]] || tfold 'phpunit install' SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 ./phpunit install
284277
[[ ! $COMPONENTS ]] || echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" || X=1
285278
fi

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"require": {
1919
"php": ">=7.2.5",
2020
"ext-xml": "*",
21+
"friendsofphp/proxy-manager-lts": "^1.0",
2122
"doctrine/event-manager": "~1.0",
2223
"doctrine/persistence": "^2",
2324
"twig/twig": "^2.10|^3.0",
@@ -122,7 +123,6 @@
122123
"masterminds/html5": "^2.6",
123124
"monolog/monolog": "^1.25.1|^2",
124125
"nyholm/psr7": "^1.0",
125-
"ocramius/proxy-manager": "^2.1",
126126
"paragonie/sodium_compat": "^1.8",
127127
"pda/pheanstalk": "^4.0",
128128
"php-http/httplug": "^1.0|^2.0",

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapperType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class StringWrapperType extends StringType
1818
{
1919
/**
2020
* {@inheritdoc}
21+
*
22+
* @return mixed
2123
*/
2224
public function convertToDatabaseValue($value, AbstractPlatform $platform)
2325
{
@@ -26,6 +28,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
2628

2729
/**
2830
* {@inheritdoc}
31+
*
32+
* @return mixed
2933
*/
3034
public function convertToPHPValue($value, AbstractPlatform $platform)
3135
{

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
4343

4444
/**
4545
* {@inheritdoc}
46+
*
47+
* @return mixed
4648
*/
4749
public function convertToDatabaseValue($value, AbstractPlatform $platform)
4850
{
@@ -58,6 +60,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
5860

5961
/**
6062
* {@inheritdoc}
63+
*
64+
* @return mixed
6165
*/
6266
public function convertToPHPValue($value, AbstractPlatform $platform)
6367
{

src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public function __construct(array $options = [])
8383

8484
/**
8585
* {@inheritdoc}
86+
*
87+
* @return mixed
8688
*/
8789
public function formatBatch(array $records)
8890
{
@@ -95,6 +97,8 @@ public function formatBatch(array $records)
9597

9698
/**
9799
* {@inheritdoc}
100+
*
101+
* @return mixed
98102
*/
99103
public function format(array $record)
100104
{

src/Symfony/Bridge/Monolog/Formatter/VarDumperFormatter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function __construct(VarCloner $cloner = null)
2626
$this->cloner = $cloner ?: new VarCloner();
2727
}
2828

29+
/**
30+
* {@inheritdoc}
31+
*
32+
* @return mixed
33+
*/
2934
public function format(array $record)
3035
{
3136
$record['context'] = $this->cloner->cloneVar($record['context']);
@@ -34,6 +39,11 @@ public function format(array $record)
3439
return $record;
3540
}
3641

42+
/**
43+
* {@inheritdoc}
44+
*
45+
* @return mixed
46+
*/
3747
public function formatBatch(array $records)
3848
{
3949
foreach ($records as $k => $record) {

src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator
4848
$proxy->setProxyInitializer(null);
4949

5050
retur D306 n true;
51-
}
51+
},
52+
[
53+
'fluentSafe' => $definition->hasTag('proxy'),
54+
'skipDestructor' => true,
55+
]
5256
);
5357
}
5458
}

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,87 +11,26 @@
1111

1212
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
1313

14+
use Laminas\Code\Generator\ClassGenerator;
1415
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator as BaseGenerator;
1516
use Symfony\Component\DependencyInjection\Definition;
16-
use Zend\Code\Generator\ClassGenerator;
1717

1818
/**
1919
* @internal
2020
*/
2121
class LazyLoadingValueHolderGenerator extends BaseGenerator
2222
{
23-
private $fluentSafe = false;
24-
25-
public function setFluentSafe(bool $fluentSafe)
26-
{
27-
$this->fluentSafe = $fluentSafe;
28-
}
29-
3023
/**
3124
* {@inheritdoc}
3225
*/
33-
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
26+
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = []): void
3427
{
35-
parent::generate($originalClass, $classGenerator);
28+
parent::generate($originalClass, $classGenerator, $proxyOptions);
3629

3730
foreach ($classGenerator->getMethods() as $method) {
38-
$body = preg_replace(
39-
'/(\$this->initializer[0-9a-f]++) && \1->__invoke\(\$this->(valueHolder[0-9a-f]++), (.*?), \1\);/',
40-
'$1 && ($1->__invoke(\$$2, $3, $1) || 1) && $this->$2 = \$$2;',
41-
$method->getBody()
42-
);
43-
$body = str_replace('(new \ReflectionClass(get_class()))', '$reflection', $body);
44-
$body = str_replace('$reflection = $reflection ?: ', '$reflection = $reflection ?? ', $body);
45-
$body = str_replace('$reflection ?? $reflection = ', '$reflection ?? ', $body);
46-
47-
if ($originalClass->isInterface()) {
48-
$body = str_replace('get_parent_class($this)', var_export($originalClass->name, true), $body);
49-
$body = preg_replace_callback('/\n\n\$realInstanceReflection = [^{]++\{([^}]++)\}\n\n.*/s', function ($m) {
50-
$r = '';
51-
foreach (explode("\n", $m[1]) as $line) {
52-
$r .= "\n".substr($line, 4);
53-
if (0 === strpos($line, ' return ')) {
54-
break;
55-
}
56-
}
57-
58-
return $r;
59-
}, $body);
60-
}
61-
62-
if ($this->fluentSafe) {
63-
$indent = $method->getIndentation();
64-
$method->setIndentation('');
65-
$code = $method->generate();
66-
if (null !== $docBlock = $method->getDocBlock()) {
67-
$code = substr($code, \strlen($docBlock->generate()));
68-
}
69-
$refAmp = (strpos($code, '&') ?: \PHP_INT_MAX) <= strpos($code, '(') ? '&' : '';
70-
$body = preg_replace(
71-
'/\nreturn (\$this->valueHolder[0-9a-f]++)(->[^;]++);$/',
72-
"\nif ($1 === \$returnValue = {$refAmp}$1$2) {\n \$returnValue = \$this;\n}\n\nreturn \$returnValue;",
73-
$body
74-
);
75-
$method->setIndentation($indent);
76-
}
77-
7831
if (0 === strpos($originalClass->getFilename(), __FILE__)) {
79-
$body = str_replace(var_export($originalClass->name, true), '__CLASS__', $body);
80-
}
81-
82-
$method->setBody($body);
83-
}
84-
85-
if ($classGenerator->hasMethod('__destruct')) {
86-
$destructor = $classGenerator->getMethod('__destruct');
87-
$body = $destructor->getBody();
88-
$newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body);
89-
90-
if ($body === $newBody) {
91-
throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method "%s::__destruct()".', $originalClass->name));
32+
$method->setBody(str_replace(var_export($originalClass->name, true), '__CLASS__', $method->getBody()));
9233
}
93-
94-
$destructor->setBody($newBody);
9534
}
9635

9736
if (0 === strpos($originalClass->getFilename(), __FILE__)) {

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
1313

14-
use ProxyManager\Exception\ExceptionInterface;
1514
use ProxyManager\Generator\ClassGenerator;
16-
use ProxyManager\Generator\MethodGenerator;
1715
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
1816
use Symfony\Component\DependencyInjection\Definition;
1917
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
@@ -84,18 +82,6 @@ public function getProxyCode(Definition $definition): string
8482
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
8583
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
8684

87-
if (!method_exists(MethodGenerator::class, 'fromReflectionWithoutBodyAndDocBlock')) { // proxy-manager < 2.2
88-
$code = preg_replace(
89-
'/((?:\$(?:this|initializer|instance)->)?(?:publicProperties|initializer|valueHolder))[0-9a-f]++/',
90-
'${1}'.$this->getIdentifierSuffix($definition),
91-
$code
92-
);
93-
}
94-
95-
if (!is_subclass_of(ExceptionInterface::class, 'Throwable')) { // proxy-manager < 2.5
96-
$code = preg_replace('/ \\\\Closure::bind\(function ((?:& )?\(\$instance(?:, \$value)?\))/', ' \Closure::bind(static function \1', $code);
97-
}
98-
9985
return $code;
10086
}
10187

@@ -114,8 +100,10 @@ private function generateProxyClass(Definition $definition): ClassGenerator
114100
$generatedClass = new ClassGenerator($this->getProxyClassName($definition));
115101
$class = $this->proxyGenerator->getProxifiedClass($definition);
116102

117-
$this->proxyGenerator->setFluentSafe($definition->hasTag('proxy'));
118-
$this->proxyGenerator->generate(new \ReflectionClass($class), $generatedClass);
103+
$this->proxyGenerator->generate(new \ReflectionClass($class), $generatedClass, [
104+
'fluentSafe' => $definition->hasTag('proxy'),
105+
'skipDestructor' => true,
106+
]);
119107

120108
return $generatedClass;
121109
}

src/Symfony/Bridge/ProxyManager/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Resources
1111
[send Pull Requests](https://github.com/symfony/symfony/pulls)
1212
in the [main Symfony repository](https://github.com/symfony/symfony)
1313

14-
[1]: https://github.com/Ocramius/ProxyManager
14+
[1]: https://github.com/FriendsOfPHP/proxy-manager-lts

0 commit comments

Comments
 (0)
0