Skip to content

Commit 7b0b73c

Browse files
Merge branch '4.1'
* 4.1: [travis] fix CI for sigchild+Process fix merge [travis] merge "same Symfony version" jobs in one fix merge 🐛 Fix typo Remove the Expires header when calling Response::expire() Allow multidimensional collection in property info Allow multidimensional collection in property info
2 parents dd2f830 + 694178e commit 7b0b73c

File tree

10 files changed

+81
-59
lines changed

10 files changed

+81
-59
lines changed

.travis.yml

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,19 @@ services:
4545
before_install:
4646
- |
4747
# General configuration
48+
set -e
4849
stty cols 120
4950
mkdir /tmp/slapd
5051
slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 &
51-
PHP=$TRAVIS_PHP_VERSION
5252
[ -d ~/.composer ] || mkdir ~/.composer
5353
cp .composer/* ~/.composer/
5454
export PHPUNIT=$(readlink -f ./phpunit)
5555
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5656
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
57+
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
58+
find ~/.phpenv -name xdebug.ini -delete
5759
58-
nanoseconds() {
60+
nanoseconds () {
5961
local cmd="date"
6062
local format="+%s%N"
6163
local os=$(uname)
@@ -70,7 +72,7 @@ before_install:
7072
7173
# tfold is a helper to create folded reports
7274
tfold () {
73-
local title=$1
75+
local title="🐘 $PHP $1"
7476
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
7577
shift
7678
local id=$(printf %08x $(( RANDOM * RANDOM )))
@@ -90,17 +92,6 @@ before_install:
9092
}
9193
export -f tfold
9294
93-
# php.ini configuration
94-
INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
95-
phpenv config-rm xdebug.ini || echo "xdebug not available"
96-
echo date.timezone = Europe/Paris >> $INI
97-
echo memory_limit = -1 >> $INI
98-
echo session.gc_probability = 0 >> $INI
99-
echo opcache.enable_cli = 1 >> $INI
100-
echo apc.enable_cli = 1 >> $INI
101-
echo extension = redis.so >> $INI
102-
echo extension = memcached.so >> $INI
103-
10495
# tpecl is a helper to compile and cache php extensions
10596
tpecl () {
10697
local ext_name=$1
@@ -112,31 +103,42 @@ before_install:
112103
if [[ -e $ext_cache/$ext_so ]]; then
113104
echo extension = $ext_cache/$ext_so >> $INI
114105
else
106+
rm ~/.pearrc /tmp/pear 2>/dev/null || true
115107
mkdir -p $ext_cache
116108
echo yes | pecl install -f $ext_name &&
117109
cp $ext_dir/$ext_so $ext_cache
118110
fi
119111
}
120112
export -f tpecl
121113
122-
# Matrix lines for intermediate PHP versions are skipped for pull requests
123-
if [[ ! $deps && ! $PHP = $MIN_PHP && $TRAVIS_PULL_REQUEST != false ]]; then
124-
deps=skip
125-
skip=1
126-
else
127-
COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
128-
fi
129-
130114
- |
131115
# Install sigchild-enabled PHP to test the Process component on the lowest PHP matrix line
132-
if [[ ! $deps && $PHP = $MIN_PHP && ! -d php-$MIN_PHP/sapi ]]; then
116+
if [[ ! $deps && $TRAVIS_PHP_VERSION = $MIN_PHP && ! -d php-$MIN_PHP/sapi ]]; then
133117
wget http://php.net/get/php-$MIN_PHP.tar.bz2/from/this/mirror -O - | tar -xj &&
134118
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
135119
fi
136120
121+
- |
122+
# php.ini configuration
123+
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
124+
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)
125+
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
126+
echo date.timezone = Europe/Paris >> $INI
127+
echo memory_limit = -1 >> $INI
128+
echo session.gc_probability = 0 >> $INI
129+
echo opcache.enable_cli = 1 >> $INI
130+
echo apc.enable_cli = 1 >> $INI
131+
echo extension = redis.so >> $INI
132+
echo extension = memcached.so >> $INI
133+
done
134+
137135
- |
138136
# Install extra PHP extensions
139-
if [[ ! $skip ]]; then
137+
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
138+
export PHP=$PHP
139+
phpenv global $PHP
140+
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
141+
140142
# Install librabbitmq
141143
wget http://ftp.debian.org/debian/pool/main/libr/librabbitmq/librabbitmq-dev_0.5.2-2_amd64.deb
142144
wget http://ftp.debian.org/debian/pool/main/libr/librabbitmq/librabbitmq1_0.5.2-2_amd64.deb
@@ -152,7 +154,7 @@ before_install:
152154
tfold ext.mongodb tpecl mongodb-1.5.0 mongodb.so $INI
153155
tfold ext.amqp tpecl amqp-1.9.3 amqp.so $INI
154156
tfold ext.igbinary tpecl igbinary-2.0.6 igbinary.so $INI
155-
fi
157+
done
156158
157159
- |
158160
# Load fixtures
@@ -166,7 +168,7 @@ install:
166168
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
167169
if [[ ! $deps ]]; then
168170
php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit
169-
elif [[ ! $skip ]]; then
171+
else
170172
export SYMFONY_DEPRECATIONS_HELPER=weak &&
171173
cp composer.json composer.json.orig &&
172174
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json &&
@@ -182,7 +184,7 @@ install:
182184
git fetch origin $SYMFONY_VERSION &&
183185
git checkout -m FETCH_HEAD &&
184186
COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
185-
elif [[ ! $skip ]]; then
187+
else
186188
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
187189
fi
188190
@@ -191,33 +193,34 @@ install:
191193
[[ $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
192194
193195
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
194-
if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
195-
196-
if [[ ! $skip ]]; then
197-
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
198-
fi
196+
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
199197
200-
- if [[ ! $skip ]]; then $COMPOSER_UP; fi
201-
- if [[ ! $skip ]]; then ./phpunit install; fi
202198
- php -i
203199

204200
- |
205201
run_tests () {
206202
set -e
207-
if [[ $skip ]]; then
203+
export PHP=$1
204+
if [[ $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
208205
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
209-
elif [[ $deps = high ]]; then
206+
break
207+
fi
208+
phpenv global $PHP
209+
tfold 'composer update' $COMPOSER_UP
210+
tfold 'phpunit install' ./phpunit install
211+
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
212+
if [[ $deps = high ]]; then
210213
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
211214
elif [[ $deps = low ]]; then
212215
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
213216
else
214217
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
215-
tfold tty-group $PHPUNIT --group tty
218+
tfold src/Symfony/Component/Console.tty $PHPUNIT src/Symfony/Component/Console --group tty
216219
if [[ $PHP = $MIN_PHP ]]; then
217220
tfold src/Symfony/Component/Process.sigchild SYMFONY_DEPRECATIONS_HELPER=weak php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/
218221
fi
219222
fi
220223
}
221224
222225
script:
223-
- (run_tests)
226+
- for PHP in $TRAVIS_PHP_VERSION $php_extra; do (run_tests $PHP); done

src/Symfony/Component/Debug/Tests/phpt/decorate_exception_hander.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ Did you forget a "use" statement for another namespace?"
3838
["line":protected]=>
3939
int(%d)
4040
["trace":"Exception":private]=>
41-
array(0) {
42-
}
41+
array(%d) {%A}
4342
["previous":"Exception":private]=>
4443
NULL
4544
["severity":protected]=>

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ public function expire()
689689
{
690690
if ($this->isFresh()) {
691691
$this->headers->set('Age', $this->getMaxAge());
692+
$this->headers->remove('Expires');
692693
}
693694

694695
return $this;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ public function testExpire()
362362
$response->headers->set('Expires', -1);
363363
$response->expire();
364364
$this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired');
365+
366+
$response = new Response();
367+
$response->headers->set('Expires', date(DATE_RFC2822, time() + 600));
368+
$response->expire();
369+
$this->assertNull($response->headers->get('Expires'), '->expire() removes the Expires header when the response is fresh');
365370
}
366371

367372
public function testGetTtl()

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,6 @@ public function testExitCodeCommandFailed()
450450
$this->assertGreaterThan(0, $process->getExitCode());
451451
}
452452

453-
/**
454-
* @group tty
455-
*/
456453
public function testTTYCommand()
457454
{
458455
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -468,9 +465,6 @@ public function testTTYCommand()
468465
$this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
469466
}
470467

471-
/**
472-
* @group tty
473-
*/
474468
public function testTTYCommandExitCode()
475469
{
476470
if ('\\' === \DIRECTORY_SEPARATOR) {

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function typesProvider()
7878
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
7979
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
8080
array('collection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
81+
array('nestedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING, false)))), null, null),
82+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
8183
array('a', array(new Type(Type::BUILTIN_TYPE_INT)), 'A.', null),
8284
array('b', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), 'B.', null),
8385
array('c', array(new Type(Type::BUILTIN_TYPE_BOOL, true)), null, null),
@@ -160,6 +162,8 @@ public function typesWithCustomPrefixesProvider()
160162
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
161163
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
162164
array('collection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
165+
array('nestedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING, false)))), null, null),
166+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
163167
array('a', null, 'A.', null),
164168
array('b', null, 'B.', null),
165169
array('c', array(new Type(Type::BUILTIN_TYPE_BOOL, true)), null, null),
@@ -198,6 +202,8 @@ public function typesWithNoPrefixesProvider()
198202
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
199203
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
200204
array('collection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
205+
array('nestedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING, false)))), null, null),
206+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
201207
array('a', null, 'A.', null),
202208
array('b', null, 'B.', null),
203209
array('c', null, null, null),

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function testGetProperties()
3838
'bal',
3939
'parent',
4040
'collection',
41+
'nestedCollection',
42+
'mixedCollection',
4143
'B',
4244
'Guid',
4345
'g',
@@ -80,6 +82,8 @@ public function testGetPropertiesWithCustomPrefixes()
8082
'bal',
8183
'parent',
8284
'collection',
85+
'nestedCollection',
86+
'mixedCollection',
8387
'B',
8488
'Guid',
8589
'g',
@@ -114,6 +118,8 @@ public function testGetPropertiesWithNoPrefixes()
114118
'bal',
115119
'parent',
116120
'collection',
121+
'nestedCollection',
122+
'mixedCollection',
117123
'B',
118124
'Guid',
119125
'g',

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ class Dummy extends ParentDummy
4646
*/
4747
public $collection;
4848

49+
/**
50+
* @var string[][]
51+
*/
52+
public $nestedCollection;
53+
54+
/**
55+
* @var mixed[]
56+
*/
57+
public $mixedCollection;
58+
4959
/**
5060
* @var ParentDummy
5161
*/

src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,25 @@ private function createType(DocType $type, bool $nullable): ?Type
103103
return null;
104104
}
105105

106-
if ($collection = '[]' === substr($docType, -2)) {
107-
$docType = substr($docType, 0, -2);
108-
}
109-
110-
$docType = $this->normalizeType($docType);
111-
list($phpType, $class) = $this->getPhpTypeAndClass($docType);
112-
113-
$array = 'array' === $docType;
114-
115-
if ($collection || $array) {
116-
if ($array || 'mixed' === $docType) {
106+
if ('[]' === substr($docType, -2)) {
107+
if ('mixed[]' === $docType) {
117108
$collectionKeyType = null;
118109
$collectionValueType = null;
119110
} else {
120111
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
121-
$collectionValueType = new Type($phpType, $nullable, $class);
112+
$collectionValueType = $this->createType(substr($docType, 0, -2), $nullable);
122113
}
123114

124115
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
125116
}
126117

118+
$docType = $this->normalizeType($docType);
119+
list($phpType, $class) = $this->getPhpTypeAndClass($docType);
120+
121+
if ('array' === $docType) {
122+
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, null, null);
123+
}
124+
127125
return new Type($phpType, $nullable, $class);
128126
}
129127

src/Symfony/Component/VarDumper/Resources/css/htmlDescriptor.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pre.sf-dump {
102102
margin-bottom: 0;
103103
}
104104
.hidden {
105-
display: none; !important
105+
display: none !important;
106106
}
107107
.dumped-tag > .sf-dump {
108108
display: inline-block;

0 commit comments

Comments
 (0)