Skip to content

Commit cf62eaf

Browse files
Merge remote-tracking branch 'origin/4.4' into 5.1
* origin/4.4: Fix CS Add a warning comment on ldap empty password Bump Symfony version to 4.4.14 Update VERSION for 4.4.13 Update CHANGELOG for 4.4.13 [PhpunitBridge] Fix deprecation type detection
2 parents 462ff99 + 3dc86fc commit cf62eaf

File tree

6 files changed

+120
-3
lines changed

6 files changed

+120
-3
lines changed

DeprecationErrorHandler/Deprecation.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ private static function getVendors()
270270
if (file_exists($v.'/composer/installed.json')) {
271271
self::$vendors[] = $v;
272272
$loader = require $v.'/autoload.php';
273-
$paths = self::getSourcePathsFromPrefixes(array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4()));
273+
$paths = self::addSourcePathsFromPrefixes(
274+
array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4()),
275+
$paths
276+
);
274277
}
275278
}
276279
}
@@ -286,15 +289,17 @@ private static function getVendors()
286289
return self::$vendors;
287290
}
288291

289-
private static function getSourcePathsFromPrefixes(array $prefixesByNamespace)
292+
private static function addSourcePathsFromPrefixes(array $prefixesByNamespace, array $paths)
290293
{
291294
foreach ($prefixesByNamespace as $prefixes) {
292295
foreach ($prefixes as $prefix) {
293296
if (false !== realpath($prefix)) {
294-
yield realpath($prefix);
297+
$paths[] = realpath($prefix);
295298
}
296299
}
297300
}
301+
302+
return $paths;
298303
}
299304

300305
/**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
require_once __DIR__.'/composer/autoload_real.php';
4+
5+
return ComposerAutoloaderInitFakeBis::getLoader();
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
class ComposerLoaderFakeBis
4+
{
5+
public function getPrefixes()
6+
{
7+
return [];
8+
}
9+
10+
public function getPrefixesPsr4()
11+
{
12+
return [
13+
'foo\\lib\\' => [__DIR__.'/../foo/lib/'],
14+
];
15+
}
16+
17+
public function loadClass($className)
18+
{
19+
foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) {
20+
if (strpos($className, $prefix) !== 0) {
21+
continue;
22+
}
23+
24+
foreach ($baseDirs as $baseDir) {
25+
$file = str_replace([$prefix, '\\'], [$baseDir, '/'], $className.'.php');
26+
if (file_exists($file)) {
27+
require $file;
28+
}
29+
}
30+
}
31+
}
32+
}
33+
34+
class ComposerAutoloaderInitFakeBis
35+
{
36+
private static $loader;
37+
38+
public static function getLoader()
39+
{
40+
if (null === self::$loader) {
41+
self::$loader = new ComposerLoaderFakeBis();
42+
spl_autoload_register([self::$loader, 'loadClass']);
43+
}
44+
45+
return self::$loader;
46+
}
47+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"just here": "for the detection"}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace foo\lib;
4+
5+
class SomeOtherService
6+
{
7+
public function deprecatedApi()
8+
{
9+
@trigger_error(
10+
__FUNCTION__.' from foo is deprecated! You should stop relying on it!',
11+
E_USER_DEPRECATED
12+
);
13+
}
14+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Test DeprecationErrorHandler with multiple autoload files
3+
--FILE--
4+
<?php
5+
6+
$k = 'SYMFONY_DEPRECATIONS_HELPER';
7+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[self]=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+
20+
eval(<<<'EOPHP'
21+
namespace PHPUnit\Util;
22+
23+
class Test
24+
{
25+
public static function getGroups()
26+
{
27+
return array();
28+
}
29+
}
30+
EOPHP
31+
);
32+
33+
require __DIR__.'/fake_vendor/autoload.php';
34+
require __DIR__.'/fake_vendor_bis/autoload.php';
35+
36+
(new \App\Services\AppService())->directDeprecations();
37+
?>
38+
--EXPECTF--
39+
Remaining direct deprecation notices (2)
40+
41+
1x: deprecatedApi is deprecated! You should stop relying on it!
42+
1x in AppService::directDeprecations from App\Services
43+
44+
1x: deprecatedApi from foo is deprecated! You should stop relying on it!
45+
1x in AppService::directDeprecations from App\Services

0 commit comments

Comments
 (0)