10000 Merge branch '3.4' into 4.1 · symfony/symfony@694178e · GitHub
[go: up one dir, main page]

Skip to content

Commit 694178e

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

File tree

9 files changed

+82
-58
lines changed

9 files changed

+82
-58
lines changed

.travis.yml

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@ 8000 @ -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 3 -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 3 -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
@@ -151,7 +153,7 @@ before_install:
151153
tfold ext.libsodium tpecl libsodium sodium.so $INI
152154
tfold ext.mongodb tpecl mongodb-1.5.0 mongodb.so $INI
153155
tfold ext.amqp tpecl amqp-1.9.3 amqp.so $INI
154-
fi
156+
done
155157
156158
- |
157159
# Load fixtures
@@ -165,7 +167,7 @@ install:
165167
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
166168
if [[ ! $deps ]]; then
167169
php .github/build-packages.php HEAD^ src/Symfony/Bridge/PhpUnit
168-
elif [[ ! $skip ]]; then
170+
else
169171
export SYMFONY_DEPRECATIONS_HELPER=weak &&
170172
cp composer.json composer.json.orig &&
171173
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json &&
@@ -181,7 +183,7 @@ install:
181183
git fetch origin $SYMFONY_VERSION &&
182184
git checkout -m FETCH_HEAD &&
183185
COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
184-
elif [[ ! $skip ]]; then
186+
else
185187
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
186188
fi
187189
@@ -190,33 +192,36 @@ install:
190192
[[ $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
191193
192194
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
193-
if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
195+
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
194196
195-
if [[ ! $skip ]]; then
196-
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
197-
fi
198-
199-
- if [[ ! $skip ]]; then $COMPOSER_UP; fi
200-
- if [[ ! $skip ]]; then ./phpunit install; fi
201197
- php -i
202198

203199
- |
204200
run_tests () {
205201
set -e
206-
if [[ $skip ]]; then
202+
export PHP=$1
203+
if [[ $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
207204
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
208-
elif [[ $deps = high ]]; then
205+
break
206+
fi
207+
phpenv global $PHP
208+
tfold 'composer update' $COMPOSER_UP
209+
tfold 'phpunit install' ./phpunit install
210+
if [[ $PHP = 7.* ]]; then
211+
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
212+
fi
213+
if [[ $deps = high ]]; then
209214
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
210215
elif [[ $deps = low ]]; then
211216
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
212217
else
213218
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
214-
tfold tty-group $PHPUNIT --group tty
219+
tfold src/Symfony/Component/Console.tty $PHPUNIT src/Symfony/Component/Console --group tty
215220
if [[ $PHP = $MIN_PHP ]]; then
216221
tfold src/Symfony/Component/Process.sigchild SYMFONY_DEPRECATIONS_HELPER=weak php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/
217222
fi
218223
fi
219224
}
220225
221226
script:
222-
- (run_tests)
227+
- 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 + 1241 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
@@ -87,6 +87,8 @@ public function typesProvider()
8787
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
8888
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
8989
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),
90+
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),
91+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
9092
array('a', array(new Type(Type::BUILTIN_TYPE_INT)), 'A.', null),
9193
array('b', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), 'B.', null),
9294
array('c', array(new Type(Type::BUILTIN_TYPE_BOOL, true)), null, null),
@@ -126,6 +128,8 @@ public function typesWithCustomPrefixesProvider()
126128
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
127129
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
128130
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),
131+
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),
132+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
129133
array('a', null, 'A.', null),
130134
array('b', null, 'B.', null),
131135
array('c', array(new Type(Type::BUILTIN_TYPE_BOOL, true)), null, null),
@@ -164,6 +168,8 @@ public function typesWithNoPrefixesProvider()
164168
array('bal', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')), null, null),
165169
array('parent', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy')), null, null),
166170
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),
171+
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),
172+
array('mixedCollection', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, null, null)), null, null),
167173
array('a', null, 'A.', null),
168174
array('b', null, 'B.', null),
169175
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',
@@ -77,6 +79,8 @@ public function testGetPropertiesWithCustomPrefixes()
7779
'bal',
7880
'parent',
7981
'collection',
82+
'nestedCollection',
83+
'mixedCollection',
8084
'B',
8185
'Guid',
8286
'g',
@@ -108,6 +112,8 @@ public function testGetPropertiesWithNoPrefixes()
108112
'bal',
109113
'parent',
110114
'collection',
115+
'nestedCollection',
116+
'mixedCollection',
111117
'B',
112118
'Guid',
113119
'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
@@ -87,27 +87,25 @@ private function createType(string $docType, bool $nullable): ?Type
8787
return null;
8888
}
8989

90-
if ($collection = '[]' === substr($docType, -2)) {
91-
$docType = substr($docType, 0, -2);
92-
}
93-
94-
$docType = $this->normalizeType($docType);
95-
list($phpType, $class) = $this->getPhpTypeAndClass($docType);
96-
97-
$array = 'array' === $docType;
98-
99-
if ($collection || $array) {
100-
if ($array || 'mixed' === $docType) {
90+
if ('[]' === substr($docType, -2)) {
91+
if ('mixed[]' === $docType) {
10192
$collectionKeyType = null;
10293
$collectionValueType = null;
10394
} else {
10495
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
105-
$collectionValueType = new Type($phpType, $nullable, $class);
96+
$collectionValueType = $this->createType(substr($docType, 0, -2), $nullable);
10697
}
10798

10899
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
109100
}
110101

102+
$docType = $this->normalizeType($docType);
103+
list($phpType, $class) = $this->getPhpTypeAndClass($docType);
104+
105+
if ('array' === $docType) {
106+
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, null, null);
107+
}
108+
111109
return new Type($phpType, $nullable, $class);
112110
}
113111

0 commit comments

Comments
 (0)
0