Skip to content

Commit d066b06

Browse files
-
1 parent 09f10d3 commit d066b06

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

.github/patch-types.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
$prefix = 'Symfony\\';
4+
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=1&php71-compat=0&class-prefix='.$prefix);
5+
6+
require __DIR__.'/../.phpunit/phpunit-8.3-0/vendor/autoload.php';
7+
8+
$loader = require __DIR__.'/../vendor/autoload.php';
9+
10+
Symfony\Component\ErrorHandler\DebugClassLoader::enable();
11+
12+
foreach ($loader->getClassMap() as $class => $file) {
13+
switch (true) {
14+
case 0 !== strpos($class, $prefix):
15+
case 0 === strpos($class, 'Symfony\Polyfill\\'):
16+
case 0 === strpos($class, 'Symfony\Component\Security\Acl\\'):
17+
case false !== strpos($file, '/symfony/phpunit-bridge/'):
18+
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
19+
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
20+
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
21+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
22+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
23+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
24+
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
25+
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
26+
continue 2;
27+
}
28+
29+
class_exists($class);
30+
}
31+
32+
Symfony\Component\ErrorHandler\DebugClassLoader::disable();
33+

.travis.yml

Lines changed: 6 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:
@@ -75,14 +70,12 @@ before_install:
7570
cp .composer/* ~/.composer/
7671
export PHPUNIT=$(readlink -f ./phpunit)
7772
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
78-
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
73+
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi --optimize-autoloader'
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
77+
if [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
8378
export PHPUNIT_X="$PHPUNIT_X,issue-32995"
84-
elif [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
85-
export PHPUNIT_X="$PHPUNIT --group issue-32995"
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,9 @@ 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+
php .github/patch-types.php
269+
273270
if [[ $deps = high ]]; then
274271
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
275272
elif [[ $deps = low ]]; then

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@
142142
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
143143
],
144144
"exclude-from-classmap": [
145-
"**/Tests/"
146145
]
147146
},
148147
"autoload-dev": {
149-
"files": [ "src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
148+
"files": [
149+
"src/Symfony/Component/Debug/Exception/FlattenException.php",
150+
"src/Symfony/Component/VarDumper/Resources/functions/dump.php"
151+
]
150152
},
151153
"repositories": [
152154
{

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
423423
}
424424

425425
if ($canAddReturnType = '' !== ($this->patchTypes['class-prefix'] ?? '') && 0 === strpos($class, $this->patchTypes['class-prefix'])) {
426-
$canAddReturnType = false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
426+
$canAddReturnType = ($this->patchTypes['force'] ?? false)
427+
|| false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR)
427428
|| $refl->isFinal()
428429
|| $method->isFinal()
429430
|| $method->isPrivate()
@@ -777,7 +778,7 @@ private function patchMethod(\ReflectionMethod $method, string $returnType, stri
777778
}
778779
}
779780

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

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

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

0 commit comments

Comments
 (0)