Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 22, 2019
1 parent 09f10d3 commit d066b06
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
33 changes: 33 additions & 0 deletions .github/patch-types.php
@@ -0,0 +1,33 @@
<?php

$prefix = 'Symfony\\';
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=1&php71-compat=0&class-prefix='.$prefix);

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

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

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

foreach ($loader->getClassMap() as $class => $file) {
switch (true) {
case 0 !== strpos($class, $prefix):
case 0 === strpos($class, 'Symfony\Polyfill\\'):
case 0 === strpos($class, 'Symfony\Component\Security\Acl\\'):
case false !== strpos($file, '/symfony/phpunit-bridge/'):
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/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/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
continue 2;
}

class_exists($class);
}

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

15 changes: 6 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 @@ -75,14 +70,12 @@ before_install:
cp .composer/* ~/.composer/
export PHPUNIT=$(readlink -f ./phpunit)
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi --optimize-autoloader'
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
if [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
export PHPUNIT_X="$PHPUNIT_X,issue-32995"
elif [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
export PHPUNIT_X="$PHPUNIT --group issue-32995"
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,9 @@ 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
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
6 changes: 4 additions & 2 deletions composer.json
Expand Up @@ -142,11 +142,13 @@
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
],
"exclude-from-classmap": [
"**/Tests/"
]
},
"autoload-dev": {
"files": [ "src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
"files": [
"src/Symfony/Component/Debug/Exception/FlattenException.php",
"src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
"repositories": [
{
Expand Down
7 changes: 4 additions & 3 deletions src/Symfony/Component/ErrorHandler/DebugClassLoader.php
Expand Up @@ -423,7 +423,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
}

if ($canAddReturnType = '' !== ($this->patchTypes['class-prefix'] ?? '') && 0 === strpos($class, $this->patchTypes['class-prefix'])) {
$canAddReturnType = false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
$canAddReturnType = ($this->patchTypes['force'] ?? false)
|| false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
|| $refl->isFinal()
|| $method->isFinal()
|| $method->isPrivate()
Expand Down Expand Up @@ -777,7 +778,7 @@ private function patchMethod(\ReflectionMethod $method, string $returnType, stri
}
}

if ('object' === $normalizedType && ($this->patchTypes['keep-compat-with-php71'] ?? false)) {
if ('object' === $normalizedType && ($this->patchTypes['php71-compat'] ?? false)) {
$returnType = implode('|', $returnType);

if ($method->getDocComment()) {
Expand Down Expand Up @@ -845,7 +846,7 @@ private static function getUseStatements(string $file): array

private function fixReturnStatements(\ReflectionMethod $method, ?string $returnType, int $i = 0)
{
if (($this->patchTypes['keep-compat-with-php71'] ?? false) && 'object' === ltrim($returnType, '?')) {
if (($this->patchTypes['php71-compat'] ?? false) && 'object' === ltrim($returnType, '?')) {
return;
}

Expand Down

0 comments on commit d066b06

Please sign in to comment.