8000 Rely on memoized variable · symfony/symfony@14cd6d6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14cd6d6

Browse files
committed
Rely on memoized variable
1 parent 50fb72f commit 14cd6d6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public static function register($mode = 0)
5757
return;
5858
}
5959

60-
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use ($mode) {
61-
$mode = self::getMode($mode);
60+
self::computeMode($mode);
61+
62+
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) {
63+
$mode = self::$mode;
6264
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
6365
$ErrorHandler = self::utilPrefix().'ErrorHandler';< 10000 /div>
6466

@@ -143,8 +145,8 @@ public static function register($mode = 0)
143145
}
144146
} else {
145147
self::$isRegistered = true;
146-
register_shutdown_function(function () use ($mode, $deprecationHandler) {
147-
$mode = self::getMode($mode);
148+
register_shutdown_function(function () use ($deprecationHandler) {
149+
$mode = self::$mode;
148150
if (isset($mode[0]) && '/' === $mode[0]) {
149151
return;
150152
}
@@ -251,13 +253,11 @@ private static function hasColorSupport()
251253

252254
/**
253255
* @param mixed $mode
254-
*
255-
* @return mixed
256256
*/
257-
private static function getMode($mode)
257+
private static function computeMode($mode)
258258
{
259259
if (false !== self::$mode) {
260-
return self::$mode;
260+
return;
261261
}
262262
if (false === $mode) {
263263
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
@@ -270,7 +270,7 @@ private static function getMode($mode)
270270
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
271271
}
272272

273-
return self::$mode = $mode;
273+
self::$mode = $mode;
274274
}
275275

276276
/**

0 commit comments

Comments
 (0)
0