Skip to content

Commit

Permalink
Add return-types with help from DebugClassLoader in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 26, 2019
1 parent 72f6a97 commit 47b03af
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
45 changes: 45 additions & 0 deletions .github/patch-types.php
@@ -0,0 +1,45 @@
<?php

if (false === getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=1&php71-compat=0');
}

require __DIR__.'/../.phpunit/phpunit-8.3-0/vendor/autoload.php';

file_put_contents(__DIR__.'/../vendor/autoload.php', preg_replace('/^return (Composer.*);/m', <<<'EOTXT'
$loader = \1;
$loader->addClassMap(['Symfony\Component\Debug\Exception\FlattenException' => \dirname(__DIR__).'/src/Symfony/Component/Debug/Exception/FlattenException.php']);
return $loader;
EOTXT
, file_get_contents(__DIR__.'/../vendor/autoload.php')));

$loader = require __DIR__.'/../vendor/autoload.php';

Symfony\Component\ErrorHandler\DebugClassLoader::enable();

foreach ($loader->getClassMap() as $class => $file) {
switch (true) {
case false !== strpos(realpath($file), '/vendor/'):
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'):
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'):
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'):
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/Php74.php') && \PHP_VERSION_ID < 70400:
continue 2;
}

class_exists($class);
}

Symfony\Component\ErrorHandler\DebugClassLoader::disable();
18 changes: 9 additions & 9 deletions .travis.yml
Expand Up @@ -25,12 +25,7 @@ env:

matrix:
include:
- php: 7.1
env: php_extra="7.2"
- php: 7.3
env: deps=high
- php: 7.4snapshot
env: deps=low
fast_finish: true

cache:
Expand Down Expand Up @@ -79,10 +74,8 @@ before_install:
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
find ~/.phpenv -name xdebug.ini -delete
if [[ $TRAVIS_PHP_VERSION = 7.4* && $deps ]]; then
export PHPUNIT_X="$PHPUNIT_X,issue-32995"
elif [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
export PHPUNIT_X="$PHPUNIT --group issue-32995"
if [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
export PHPUNIT_X="$PHPUNIT_X,issue-32995,legacy"
fi
nanoseconds () {
Expand Down Expand Up @@ -163,6 +156,7 @@ before_install:
- |
# Install extra PHP extensions
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
continue
export PHP=$PHP
phpenv global $PHP
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
Expand Down Expand Up @@ -270,6 +264,12 @@ install:
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.6.0; composer require --dev --no-update mongodb/mongodb)
tfold 'composer update' $COMPOSER_UP
tfold 'phpunit install' ./phpunit install
rm vendor/symfony/contracts -Rf
ln -sd $(realpath src/Symfony/Contracts) vendor/symfony/contracts
composer install --optimize-autoloader
php .github/patch-types.php
if [[ $deps = high ]]; then
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
elif [[ $deps = low ]]; then
Expand Down
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -142,7 +142,6 @@
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
],
"exclude-from-classmap": [
"**/Tests/"
]
},
"autoload-dev": {
Expand Down

0 comments on commit 47b03af

Please sign in to comment.