Skip to content

Commit 670dd85

Browse files
[ErrorHandler] improve DebugClassLoader patching logic
1 parent fea3574 commit 670dd85

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed

.github/patch-types.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
if (false === getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
4+
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=1&php71-compat=0');
5+
}
6+
7+
require __DIR__.'/../.phpunit/phpunit-8.3-0/vendor/autoload.php';
8+
9+
file_put_contents(__DIR__.'/../vendor/autoload.php', preg_replace('/^return (Composer.*);/m', <<<'EOTXT'
10+
$loader = \1;
11+
$loader->addClassMap(['Symfony\Component\Debug\Exception\FlattenException' => \dirname(__DIR__).'/src/Symfony/Component/Debug/Exception/FlattenException.php']);
12+
13+
return $loader;
14+
15+
EOTXT
16+
, file_get_contents(__DIR__.'/../vendor/autoload.php')));
17+
18+
$loader = require __DIR__.'/../vendor/autoload.php';
19+
20+
Symfony\Component\ErrorHandler\DebugClassLoader::enable();
21+
22+
foreach ($loader->getClassMap() as $class => $file) {
23+
switch (true) {
24+
case false !== strpos(realpath($file), '/vendor/'):
25+
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
26+
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
27+
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
28+
case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'):
29+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
30+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
31+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
32+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
33+
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
34+
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'):
35+
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'):
36+
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
37+
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
38+
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/Php74.php') && \PHP_VERSION_ID < 70400:
39+
continue 2;
40+
}
41+
42+
class_exists($class);
43+
}
44+
45+
Symfony\Component\ErrorHandler\DebugClassLoader::disable();

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ env:
2525

2626
matrix:
2727
include:
28-
- php: 7.1
29-
env: php_extra="7.2"
30-
- php: 7.3
31-
env: deps=high
3228
- php: 7.4snapshot
33-
env: deps=low
3429
fast_finish: true
3530

3631
cache:
@@ -79,10 +74,8 @@ before_install:
7974
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
8075
find ~/.phpenv -name xdebug.ini -delete
8176
82-
if [[ $TRAVIS_PHP_VERSION = 7.4* && $deps ]]; then
83-
export PHPUNIT_X="$PHPUNIT_X,issue-32995"
84-
elif [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
85-
export PHPUNIT_X="$PHPUNIT --group issue-32995"
77+
if [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
78+
export PHPUNIT_X="$PHPUNIT_X,issue-32995,legacy"
8679
fi
8780
8881
nanoseconds () {
@@ -163,6 +156,7 @@ before_install:
163156
- |
164157
# Install extra PHP extensions
165158
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
159+
continue
166160
export PHP=$PHP
167161
phpenv global $PHP
168162
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
@@ -270,6 +264,12 @@ install:
270264
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.6.0; composer require --dev --no-update mongodb/mongodb)
271265
tfold 'composer update' $COMPOSER_UP
272266
tfold 'phpunit install' ./phpunit install
267+
268+
rm vendor/symfony/contracts -Rf
269+
ln -sd $(realpath src/Symfony/Contracts) vendor/symfony/contracts
270+
composer install --optimize-autoloader
271+
php .github/patch-types.php
272+
273273
if [[ $deps = high ]]; then
274274
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
275275
elif [[ $deps = low ]]; then

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
143143
],
144144
"exclude-from-classmap": [
145-
"**/Tests/"
146145
]
147146
},
148147
"autoload-dev": {

0 commit comments

Comments
 (0)