Skip to content

Commit fc195dc

Browse files
Merge branch '2.8' into 3.2
* 2.8: 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 [PropertyInfo] Remove a useless call to count() in SerializerExtractor [PropertyInfo] Prevent returning int values in some cases. [HttpFoundation] Fix getClientIp @return docblock Add @throws phpdoc unify PHPUnit config files
2 parents c9a614e + 9af7354 commit fc195dc

File tree

17 files changed

+406
-106
lines changed

17 files changed

+406
-106
lines changed

.travis.yml

Lines changed: 132 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,63 +42,140 @@ services:
4242
- redis-server
4343

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

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public function setDispatcher(EventDispatcherInterface $dispatcher)
101101
* @param OutputInterface $output An Output instance
102102
*
103103
* @return int 0 if everything went fine, or an error code
104+
*
105+
* @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
104106
*/
105107
public function run(InputInterface $input = null, OutputInterface $output = null)
106108
{

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

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

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class ErrorHandler
100100
private static $stackedErrors = array();
101101
private static $stackedErrorLevels = array();
102102
private static $toStringException = null;
103+
private static $exitCode = 0;
103104

104105
/**
105106
* Registers the error handler.
@@ -511,6 +512,9 @@ public function handleError($type, $message, $file, $line)
511512
*/
512513
public function handleException($exception, array $error = null)
513514
{
515+
if (null === $error) {
516+
self::$exitCode = 255;
517+
}
514518
if (!$exception instanceof \Exception) {
515519
$exception = new FatalThrowableError($exception);
516520
}
@@ -589,7 +593,7 @@ public static function handleFatalError(array $error = null)
589593
return;
590594
}
591595

592-
if (null === $error) {
596+
if ($exit = null === $error) {
593597
$error = error_get_last();
594598
}
595599

@@ -613,15 +617,21 @@ public static function handleFatalError(array $error = null)
613617
} else {
614618
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
615619
}
616-
} elseif (!isset($exception)) {
617-
return;
618620
}
619621

620622
try {
621-
$handler->handleException($exception, $error);
623+
if (isset($exception)) {
624+
self::$exitCode = 255;
625+
$handler->handleException($exception, $error);
626+
}
622627
} catch (FatalErrorException $e) {
623628
// Ignore this re-throw
624629
}
630+
631+
if ($exit && self::$exitCode) {
632+
$exitCode = self::$exitCode;
633+
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
634+
}
625635
}
626636

627637
/**

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
@@ -824,7 +824,7 @@ public function getClientIps()
824824
* ("Client-Ip" for instance), configure it via "setTrustedHeaderName()" with
825825
* the "client-ip" key.
826826
*
827-
* @return string The client IP address
827+
* @return string|null The client IP address
828828
*
829829
* @see getClientIps()
830830
* @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
@@ -931,7 +931,7 @@ public function ianaCodesReasonPhrasesProvider()
931931
)));
932932

933933
$ianaHttpStatusCodes->load('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml');
934-
if (!$ianaHttpStatusCodes->relaxNGValidate('https://www.iana.org/assignments/http-status-codes/http-status-codes.rng')) {
934+
if (!$ianaHttpStatusCodes->relaxNGValidate(__DIR__.'/schema/http-status-codes.rng')) {
935935
self::fail('Invalid IANA\'s HTTP status code list.');
936936
}
937937

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)