Skip to content

Commit 9af7354

Browse files
Merge branch '2.7' into 2.8
* 2.7: Make .travis.yml more readable Fold Travis CI output by component Add trhows PHPDoc in Application::run [Debug] Set exit status to 255 on error [HttpFoundation] Store IANA's RNG files in the repository [HttpFoundation] Fix getClientIp @return docblock Add @throws phpdoc unify PHPUnit config files
2 parents f5609e8 + bc6128b commit 9af7354

File tree

13 files changed

+383
-93
lines changed

13 files changed

+383
-93
lines changed

.travis.yml

Lines changed: 119 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,55 +40,127 @@ cache:
4040
services: mongodb
4141

4242
before_install:
43-
- stty cols 120
44-
- PHP=$TRAVIS_PHP_VERSION
45-
# Matrix lines for intermediate PHP versions are skipped for pull requests
46-
- if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi
47-
# A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line
48-
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi
49-
- if [[ ! $PHP = hhvm* ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi
50-
- if [[ ! $skip ]]; then echo date.timezone = Europe/Paris >> $INI_FILE; fi
51-
- if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi
52-
- if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi
53-
- if [[ ! $skip ]]; then echo opcache.enable_cli = 1 >> $INI_FILE; fi
54-
- if [[ ! $skip ]]; then echo hhvm.jit = 0 >> $INI_FILE; fi
55-
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi
56-
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi
57-
- if [[ ! $skip && $PHP = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.11 && echo apc.enable_cli = 1 >> $INI_FILE); fi
58-
- if [[ ! $skip && $PHP = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.6 && echo apc.enable_cli = 1 >> $INI_FILE); fi
59-
- if [[ ! $deps && $PHP = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi
60-
- if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi
61-
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi
62-
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
63-
- if [[ ! $skip ]]; then [ -d ~/.composer ] || mkdir ~/.composer; cp .composer/* ~/.composer/; fi
64-
- if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi
43+
- |
44+
# General configuration
45+
stty cols 120
46+
PHP=$TRAVIS_PHP_VERSION
47+
[ -d ~/.composer ] || mkdir ~/.composer
48+
cp .composer/* ~/.composer/
49+
export PHPUNIT=$(readlink -f ./phpunit)
50+
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
51+
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
52+
53+
# tfold is a helper to create folded reports
54+
tfold () {
55+
title=$1
56+
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
57+
shift
58+
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
59+
bash -xc "$*" 2>&1 &&
60+
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
61+
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
62+
}
63+
export -f tfold
64+
65+
# php.ini configuration
66+
if [[ $PHP = hhvm* ]]; then
67+
INI=/etc/hhvm/php.ini
68+
else
69+
INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
70+
phpenv config-rm xdebug.ini || echo "xdebug not available"
71+
fi
72+
echo date.timezone = Europe/Paris >> $INI
73+
echo memory_limit = -1 >> $INI
74+
echo session.gc_probability = 0 >> $INI
75+
echo opcache.enable_cli = 1 >> $INI
76+
echo hhvm.jit = 0 >> $INI
77+
echo apc.enable_cli = 1 >> $INI
78+
echo extension = ldap.so >> $INI
79+
[[ $PHP = 5.* ]] && echo extension = mongo.so >> $INI
80+
[[ $PHP = 5.* ]] && echo extension = memcache.so >> $INI
81+
82+
# Matrix lines for intermediate PHP versions are skipped for pull requests
83+
if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then
84+
deps=skip
85+
skip=1
86+
else
87+
COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
88+
fi
89+
90+
- |
91+
# Install sigchild-enabled PHP to test the Process component on the lowest PHP matrix line
92+
if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then
93+
wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj &&
94+
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
95+
fi
96+
97+
- |
98+
# Install extra PHP extensions
99+
if [[ ! $skip && $PHP = 5.* ]]; then
100+
([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") &&
101+
tfold ext.memcached pecl install -f memcached-2.1.0 &&
102+
tfold ext.apcu4 'echo yes | pecl install -f apcu-4.0.11'
103+
elif [[ ! $skip && $PHP = 7.* ]]; then
104+
tfold ext.apcu5 'echo yes | pecl install -f apcu-5.1.6'
105+
fi
65106
66107
install:
67-
- if [[ ! $skip && $deps ]]; then cp composer.json composer.json.orig; fi
68-
- if [[ ! $skip && $deps ]]; then echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json; fi
69-
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
70-
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
71-
- if [[ ! $skip && $deps ]]; then php .github/build-packages.php HEAD^ $COMPONENTS; fi
72-
- if [[ ! $skip && $deps ]]; then mv composer.json composer.json.phpunit; mv composer.json.orig composer.json; fi
73-
- if [[ ! $skip && ! $deps ]]; then php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit; fi
74-
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
75-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
76-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
77-
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
78-
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi
79-
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
80-
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
81-
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
82-
- if [[ ! $skip ]]; then composer update --no-suggest; fi
108+
- |
109+
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
110+
if [[ ! $deps ]]; then
111+
php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit
112+
elif [[ ! $skip ]]; then
113+
export SYMFONY_DEPRECATIONS_HELPER=weak &&
114+
cp composer.json composer.json.orig &&
115+
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json &&
116+
php .github/build-packages.php HEAD^ $COMPONENTS &&
117+
mv composer.json composer.json.phpunit &&
118+
mv composer.json.orig composer.json
119+
fi
120+
121+
- |
122+
# For the master branch, when deps=high, the version before master is checked out and tested with the locally patched components
123+
if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then
124+
SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//) &&
125+
git fetch origin $SYMFONY_VERSION &&
126+
git checkout -m FETCH_HEAD &&
127+
COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
128+
elif [[ ! $skip ]]; then
129+
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
130+
fi
131+
132+
- |
133+
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
134+
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]] && LEGACY=,legacy
135+
136+
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
137+
if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
138+
139+
- if [[ ! $skip ]]; then $COMPOSER_UP; fi
83140
- if [[ ! $skip ]]; then ./phpunit install; fi
84-
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
141+
- |
142+
# phpinfo
143+
if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
144+
145+
- |
146+
run_tests () {
147+
set -e
148+
if [[ $skip ]]; then
149+
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
150+
elif [[ $deps = high ]]; then
151+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
152+
elif [[ $deps = low ]]; then
153+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
154+
elif [[ $PHP = hhvm* ]]; then
155+
$PHPUNIT --exclude-group benchmark,intl-data
156+
else
157+
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
158+
tfold tty-group $PHPUNIT --group tty
159+
if [[ $PHP = ${MIN_PHP%.*} ]]; then
160+
echo -e "1\\n0" | xargs -I{} bash -c "tfold src/Symfony/Component/Process.sigchild{} ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/"
161+
fi
162+
fi
163+
}
85164
86165
script:
87-
- REPORT=' && echo -e "\\e[32mOK\\e[0m {}\\n\\n" || (echo -e "\\e[41mKO\\e[0m {}\\n\\n" && $(exit 1))'
88-
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
89-
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'"$REPORT"; fi
90-
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
91-
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
92-
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
93-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --no-suggest --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY"$REPORT"; fi
94-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --no-suggest --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'"$REPORT"; fi
166+
- (run_tests)

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function setDispatcher(EventDispatcherInterface $dispatcher)
106106
* @param OutputInterface $output An Output instance
107107
*
108108
* @return int 0 if everything went fine, or an error code
109+
*
110+
* @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
109111
*/
110112
public function run(InputInterface $input = null, OutputInterface $output = null)
111113
{

src/Symfony/Component/Console/Command/Command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
205205
*
206206
* @return int The command exit code
207207
*
208+
* @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.
209+
*
208210
* @see setCode()
209211
* @see execute()
210212
*/

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class ErrorHandler
103103
private static $stackedErrors = array();
104104
private static $stackedErrorLevels = array();
105105
private static $toStringException = null;
106+
private static $exitCode = 0;
106107

107108
/**
108109
* Same init value as thrownErrors.
@@ -547,6 +548,9 @@ public function handleError($type, $message, $file, $line)
547548
*/
548549
public function handleException($exception, array $error = null)
549550
{
551+
if (null === $error) {
552+
self::$exitCode = 255;
553+
}
550554
if (!$exception instanceof \Exception) {
551555
$exception = new FatalThrowableError($exception);
552556
}
@@ -632,7 +636,7 @@ public static function handleFatalError(array $error = null)
632636
return;
633637
}
634638

635-
if (null === $error) {
639+
if ($exit = null === $error) {
636640
$error = error_get_last();
637641
}
638642

@@ -656,15 +660,21 @@ public static function handleFatalError(array $error = null)
656660
} else {
657661
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
658662
}
659-
} elseif (!isset($exception)) {
660-
return;
661663
}
662664

663665
try {
664-
$handler->handleException($exception, $error);
666+
if (isset($exception)) {
667+
self::$exitCode = 255;
668+
$handler->handleException($exception, $error);
669+
}
665670
} catch (FatalErrorException $e) {
666671
// Ignore this re-throw
667672
}
673+
674+
if ($exit && self::$exitCode) {
675+
$exitCode = self::$exitCode;
676+
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
677+
}
668678
}
669679

670680
/**

src/Symfony/Component/ExpressionLanguage/phpunit.xml.dist

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
56
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
127
bootstrap="vendor/autoload.php"
138
failOnRisky="true"
149
failOnWarning="true"

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ public function getClientIps()
837837
* ("Client-Ip" for instance), configure it via "setTrustedHeaderName()" with
838838
* the "client-ip" key.
839839
*
840-
* @return string The client IP address
840+
* @return string|null The client IP address
841841
*
842842
* @see getClientIps()
843843
* @see http://en.wikipedia.org/wiki/X-Forwarded-For

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public function ianaCodesReasonPhrasesProvider()
908908
)));
909909

910910
$ianaHttpStatusCodes->load('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml');
911-
if (!$ianaHttpStatusCodes->relaxNGValidate('https://www.iana.org/assignments/http-status-codes/http-status-codes.rng')) {
911+
if (!$ianaHttpStatusCodes->relaxNGValidate(__DIR__.'/schema/http-status-codes.rng')) {
912912
self::fail('Invalid IANA\'s HTTP status code list.');
913913
}
914914

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version='1.0'?>
2+
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
3+
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
4+
ns="http://www.iana.org/assignments">
5+
6+
<include href="iana-registry.rng"/>
7+
8+
<start>
9+
<element name="registry">
10+
<ref name="registryMeta"/>
11+
<element name="registry">
12+
<ref name="registryMeta"/>
13+
<zeroOrMore>
14+
<element name="record">
15+
<optional>
16+
<attribute name="date"><ref name="genericDate"/></attribute>
17+
</optional>
18+
<optional>
19+
<attribute name="updated"><ref name="genericDate"/></attribute>
20+
</optional>
21+
<element name="value"><ref name="genericRange"/></element>
22+
<element name="description"><text/></element>
23+
<ref name="references"/>
24+
</element>
25+
</zeroOrMore>
26+
</element>
27+
<ref name="people"/>
28+
</element>
29+
</start>
30+
31+
</grammar>

0 commit comments

Comments
 (0)