10000 Add return-types with help from DebugClassLoader in the CI · symfony/symfony@11149a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11149a1

Browse files
Add return-types with help from DebugClassLoader in the CI
1 parent d887a0d commit 11149a1

File tree

3 files changed

+61
-7
lines changed

3 files changed

+61
-7
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: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
matrix:
2727
include:
2828
- php: 7.1
29-
env: php_extra="7.2"
29+
env: php_extra="7.2 7.4snapshot"
3030
- php: 7.3
3131
env: deps=high
3232
- php: 7.4snapshot
@@ -79,10 +79,8 @@ before_install:
7979
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
8080
find ~/.phpenv -name xdebug.ini -delete
8181
82-
if [[ $TRAVIS_PHP_VERSION = 7.4* && $deps ]]; then
82+
if [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
8383
export PHPUNIT_X="$PHPUNIT_X,issue-32995"
84-
elif [[ $TRAVIS_PHP_VERSION = 7.4* ]]; then
85-
export PHPUNIT_X="$PHPUNIT --group issue-32995"
8684
fi
8785
8886
nanoseconds () {
@@ -150,7 +148,7 @@ before_install:
150148
- |
151149
# php.ini configuration
152150
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
153-
phpenv global $PHP 2>/dev/null || (cd / && wget https://s3.amazonaws.com/travis-php-archives/binaries/ubuntu/14.04/x86_64/php-$PHP.tar.bz2 -O - | tar -xj)
151+
phpenv global $PHP 2>/dev/null || (cd / && wget https://storage.googleapis.com/travis-ci-language-archives/php/binaries/ubuntu/16.04/x86_64/php-$PHP.tar.bz2 -O - | tar -xj)
154152
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
155153
echo date.timezone = Europe/Paris >> $INI
156154
echo memory_limit = -1 >> $INI
@@ -262,7 +260,7 @@ install:
262260
run_tests () {
263261
set -e
264262
export PHP=$1
265-
if [[ $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
263+
if [[ $PHP != 7.4* && $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
266264
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
267265
break
268266
fi
@@ -279,6 +277,17 @@ install:
279277
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'"
280278
echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock
281279
else
280+
if [[ $PHP = 7.4* ]]; then
281+
# add return types before running the test suite
282+
rm vendor/symfony/contracts -Rf
283+
ln -sd $(realpath src/Symfony/Contracts) vendor/symfony/contracts
284+
sed -i 's/"\*\*\/Tests\/"//' composer.json
285+
composer install --optimize-autoloader
286+
php .github/patch-types.php
287+
php .github/patch-types.php # ensure the script is idempotent
288+
export PHPUNIT_X="$PHPUNIT_X,issue-32995,legacy"
289+
fi
290+
282291
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
283292
tfold src/Symfony/Component/Console.tty $PHPUNIT src/Symfony/Component/Console --group tty
284293
if [[ $PHP = ${MIN_PHP%.*} ]]; then

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function doDestroy($sessionId)
100100
}
101101

102102
/**
103-
* @return int
103+
* @return bool
104104
*/
105105
public function gc($maxlifetime)
106106
{

0 commit comments

Comments
 (0)
0