Skip to content

Commit f652f4e

Browse files
committedMar 19, 2021
Merge branch '4.4' into 5.2
* 4.4: [HttpKernel] do is_file check before include [PhpUnitBridge] fix reporting deprecations from DebugClassLoader [FrameworkBundle] skip deprecation in integration tests
2 parents e71b916 + cf3a3e5 commit f652f4e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
 

‎DeprecationErrorHandler/Deprecation.php

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function __construct($message, array $trace, $file)
8383
$this->triggeringFile = isset($trace[1 + $j]['args'][1]) ? realpath($trace[1 + $j]['args'][1]) : (new \ReflectionClass($class))->getFileName();
8484
$this->getOriginalFilesStack();
8585
array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]);
86+
87+
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "([^:]++))/', $message, $m) || preg_match('/^(?:The|Method) "([^":]++)/', $message, $m)) {
88+
$this->triggeringFile = (new \ReflectionClass($m[1]))->getFileName();
89+
array_unshift($this->originalFilesStack, $this->triggeringFile);
90+
}
8691
}
8792

8893
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Test that a deprecation from the DebugClassLoader triggered by an app class extending a vendor one is considered direct.
3+
--FILE--
4+
<?php
5+
6+
$k = 'SYMFONY_DEPRECATIONS_HELPER';
7+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=0');
8+
putenv('ANSICON');
9+
putenv('ConEmuANSI');
10+
putenv('TERM');
11+
12+
$vendor = __DIR__;
13+
while (!file_exists($vendor.'/vendor')) {
14+
$vendor = dirname($vendor);
15+
}
16+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
17+
require PHPUNIT_COMPOSER_INSTALL;
18+
require_once __DIR__.'/../../bootstrap.php';
19+
eval(<<<'EOPHP'
20+
namespace PHPUnit\Util;
21+
22+
class Test
23+
{
24+
public static function getGroups()
25+
{
26+
return array();
27+
}
28+
}
29+
EOPHP
30+
);
31+
require __DIR__.'/fake_vendor/autoload.php';
32+
33+
\Symfony\Component\ErrorHandler\DebugClassLoader::enable();
34+
new \App\Services\ExtendsDeprecatedFromVendor();
35+
36+
?>
37+
--EXPECTF--
38+
Remaining direct deprecation notices (1)
39+
40+
1x: The "App\Services\ExtendsDeprecatedFromVendor" class extends "fcy\lib\DeprecatedClass" that is deprecated.
41+
1x in DebugClassLoader::loadClass from Symfony\Component\ErrorHandler
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace App\Services;
4+
5+
use fcy\lib\DeprecatedClass;
6+
7+
final class ExtendsDeprecatedFromVendor extends DeprecatedClass
8+
{
9+
}

0 commit comments

Comments
 (0)
Please sign in to comment.