Skip to content

Commit 7e8f772

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Add Session Token to Amazon Mailer [ErrorHandler] Update TentativeTypes Prepare removing Doctrine Cache from remaining components [ErrorHandler] Add helper script to patch type declarations [Messenger] Do not reset services on WorkerRunningEvent anymore [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix
2 parents 5cb00c8 + c452183 commit 7e8f772

File tree

4 files changed

+100
-11
lines changed

4 files changed

+100
-11
lines changed

Internal/TentativeTypes.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class TentativeTypes
573573
'OCILob' => [
574574
'save' => 'bool',
575575
'import' => 'bool',
576-
'savefile' => 'bool',
576+
'saveFile' => 'bool',
577577
'load' => 'string|false',
578578
'read' => 'string|false',
579579
'eof' => 'bool',
@@ -586,11 +586,11 @@ class TentativeTypes
586586
'truncate' => 'bool',
587587
'erase' => 'int|false',
588588
'flush' => 'bool',
589-
'setbuffering' => 'bool',
590-
'getbuffering' => 'bool',
591-
'writetofile' => 'bool',
589+
'setBuffering' => 'bool',
590+
'getBuffering' => 'bool',
591+
'writeToFile' => 'bool',
592592
'export' => 'bool',
593-
'writetemporary' => 'bool',
593+
'writeTemporary' => 'bool',
594594
'close' => 'bool',
595595
'free' => 'bool',
596596
],
@@ -599,7 +599,7 @@ class TentativeTypes
599599
'append' => 'bool',
600600
'getElem' => 'string|float|null|false',
601601
'assign' => 'bool',
602-
'assignelem' => 'bool',
602+
'assignElem' => 'bool',
603603
'size' => 'int|false',
604604
'max' => 'int|false',
605605
'trim' => 'bool',
@@ -849,7 +849,6 @@ class TentativeTypes
849849
'inNamespace' => 'bool',
850850
'getNamespaceName' => 'string',
851851
'getShortName' => 'string',
852-
'getAttributes' => 'array',
853852
],
854853
'ReflectionProperty' => [
855854
'getName' => 'string',
@@ -868,7 +867,6 @@ class TentativeTypes
868867
'getType' => '?ReflectionType',
869868
'hasType' => 'bool',
870869
'getDefaultValue' => 'mixed',
871-
'getAttributes' => 'array',
872870
],
873871
'ReflectionClassConstant' => [
874872
'getName' => 'string',
@@ -879,7 +877,6 @@ class TentativeTypes
879877
'getModifiers' => 'int',
880878
'getDeclaringClass' => 'ReflectionClass',
881879
'getDocComment' => 'string|false',
882-
'getAttributes' => 'array',
883880
],
884881
'ReflectionParameter' => [
885882
'getName' => 'string',
@@ -900,7 +897,6 @@ class TentativeTypes
900897
'isDefaultValueConstant' => 'bool',
901898
'getDefaultValueConstantName' => '?string',
902899
'isVariadic' => 'bool',
903-
'getAttributes' => 'array',
904900
],
905901
'ReflectionType' => [
906902
'allowsNull' => 'bool',

Resources/bin/extract-tentative-return-types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* file that was distributed with this source code.
2828
*/
2929
30-
namespace Symfony\Component\ErrorHandler\Resources;
30+
namespace Symfony\Component\ErrorHandler\Internal;
3131
3232
/**
3333
* This class has been generated by extract-tentative-return-types.php.

Resources/bin/patch-type-declarations

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* This file is part of the Symfony package.
6+
*
7+
* (c) Fabien Potencier <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
if (\in_array('-h', $argv) || \in_array('--help', $argv)) {
14+
echo implode(PHP_EOL, [
15+
' Patches type declarations based on "@return" PHPDoc and triggers deprecations for',
16+
' incompatible method declarations.',
17+
'',
18+
' This assists you to make your package compatible with Symfony 6, but it can be used',
19+
' for any class/package.',
20+
'',
21+
' Available configuration via environment variables:',
22+
' SYMFONY_PATCH_TYPE_DECLARATIONS',
23+
' An url-encoded string to change the behavior of the script. Available parameters:',
24+
' - "force": any value enables deprecation notices - can be any of:',
25+
' - "phpdoc" to patch only docblock annotations',
26+
' - "2" to add all possible return types',
27+
' - "1" to add return types but only to tests/final/internal/private methods',
28+
' - "php": the target version of PHP - e.g. "7.1" doesn\'t generate "object" types',
29+
' - "deprecations": "1" to trigger a deprecation notice when a child class misses a',
30+
' return type while the parent declares an "@return" annotation',
31+
'',
32+
' SYMFONY_PATCH_TYPE_EXCLUDE',
33+
' A regex matched against the full path to the class - any match will be excluded',
34+
'',
35+
' Example: "SYMFONY_PATCH_TYPE_DECLARATIONS=php=7.4 ./patch-type-declarations"',
36+
]);
37+
exit;
38+
}
39+
40+
if (false === getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
41+
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=2');
42+
echo 'No SYMFONY_PATCH_TYPE_DECLARATIONS env var set, patching type declarations in all methods (run the command with "-h" for more information).'.PHP_EOL;
43+
}
44+
45+
if (is_file($autoload = __DIR__.'/../../../autoload.php')) {
46+
// noop
47+
} elseif (is_file($autoload = __DIR__.'/../../../../../autoload.php')) {
48+
// noop
49+
} else {
50+
echo PHP_EOL.' /!\ Cannot find the Composer autoloader, did you forget to run "composer install"?'.PHP_EOL;
51+
exit(1);
52+
}
53+
54+
if (is_file($phpunitAutoload = dirname($autoload).'/bin/.phpunit/phpunit/vendor/autoload.php')) {
55+
require $phpunitAutoload;
56+
}
57+
58+
$loader = require $autoload;
59+
60+
Symfony\Component\ErrorHandler\DebugClassLoader::enable();
61+
62+
$deprecations = [];
63+
set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations) {
64+
if (\E_USER_DEPRECATED !== $type) {
65+
return;
66+
}
67+
68+
[,,,,, $class,] = explode('"', $msg);
69+
$deprecations[$class][] = $msg;
70+
});
71+
72+
$exclude = getenv('SYMFONY_PATCH_TYPE_EXCLUDE') ?: null;
73+
foreach ($loader->getClassMap() as $class => $file) {
74+
if ($exclude && preg_match($exclude, realpath($file))) {
75+
continue;
76+
}
77+
78+
class_exists($class);
79+
}
80+
81+
Symfony\Component\ErrorHandler\DebugClassLoader::checkClasses();
82+
83+
foreach ($deprecations as $class => $classDeprecations) {
84+
echo $class.' ('.\count($classDeprecations).')'.PHP_EOL;
85+
echo implode(PHP_EOL, $classDeprecations).PHP_EOL.PHP_EOL;
86+
}
87+
88+
if ($deprecations && false !== strpos(getenv('SYMFONY_PATCH_TYPE_DECLARATIONS') ?? '', 'force')) {
89+
echo 'These deprecations might be fixed by the patch script, run this again to check for type deprecations.'.PHP_EOL;
90+
}

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
"/Tests/"
3232
]
3333
},
34+
"bin": [
35+
"Resources/bin/patch-type-declarations"
36+
],
3437
"minimum-stability": "dev"
3538
}

0 commit comments

Comments
 (0)