Skip to content

Commit e565c6d

Browse files
Merge branch '3.3' into 3.4
* 3.3: [travis] fix minor php7.0 version [travis] add ldap.so for php70 [HttpFoundation] Fix logic when JsonSerializable is missing [travis] update to trusty Don't use return on Assert::markTestSkipped. Create directories recursively in the PHPUnit bridge [Dotenv] Add a BC break note Fix ArrayInput::toString() for VALUE_IS_ARRAY options/args [ExpressionLanguage] throws an exception on calling uncallable method
2 parents 1022bb4 + 5f5ed69 commit e565c6d

File tree

10 files changed

+56
-24
lines changed

10 files changed

+56
-24
lines changed

.travis.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: php
22

3-
dist: precise
3+
dist: trusty
44
sudo: false
55

66
git:
@@ -20,16 +20,14 @@ env:
2020

2121
matrix:
2222
include:
23-
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
2423
- php: hhvm-3.18
2524
sudo: required
26-
dist: trusty
2725
group: edge
2826
- php: 5.5
2927
- php: 5.6
3028
- php: 7.1
3129
env: deps=high
32-
- php: 7.0
30+
- php: 7.0.8
3331
env: deps=low
3432
fast_finish: true
3533

@@ -104,7 +102,6 @@ before_install:
104102
echo opcache.enable_cli = 1 >> $INI
105103
echo hhvm.jit = 0 >> $INI
106104
echo apc.enable_cli = 1 >> $INI
107-
echo extension = ldap.so >> $INI
108105
echo extension = redis.so >> $INI
109106
echo extension = memcached.so >> $INI
110107
[[ $PHP = 5.* ]] && echo extension = memcache.so >> $INI
@@ -131,6 +128,11 @@ before_install:
131128
132129
- |
133130
# Install extra PHP extensions
131+
if [[ ! $skip && $PHP = 7.0.* ]]; then
132+
wget https://github.com/symfony/binary-utils/releases/download/v0.1/ldap-php70.tar.bz2
133+
tar -xjf ldap-php70.tar.bz2
134+
echo extension = $(pwd)/ldap.so >> $INI
135+
fi
134136
if [[ ! $skip && $PHP = 5.* ]]; then
135137
([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") &&
136138
tfold ext.apcu4 'echo yes | pecl install -f apcu-4.0.11'
@@ -195,10 +197,7 @@ install:
195197
elif [[ $deps = high ]]; then
196198
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
197199
elif [[ $deps = low ]]; then
198-
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'" &&
199-
# Test the PhpUnit bridge on PHP 5.3, using the original phpunit script
200-
tfold src/Symfony/Bridge/PhpUnit \
201-
"cd src/Symfony/Bridge/PhpUnit && wget https://phar.phpunit.de/phpunit-4.8.phar && phpenv global 5.3 && composer update --no-progress --ansi && php phpunit-4.8.phar"
200+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
202201
elif [[ $PHP = hhvm* ]]; then
203202
$PHPUNIT --exclude-group benchmark,intl-data
204203
else

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') || ($COMPOSER = rt
4141
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__)."\n".getenv('SYMFONY_PHPUNIT_REMOVE') !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) {
4242
// Build a standalone phpunit without symfony/yaml nor prophecy by default
4343

44-
@mkdir($PHPUNIT_DIR);
44+
@mkdir($PHPUNIT_DIR, 0777, true);
4545
chdir($PHPUNIT_DIR);
4646
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
4747
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));

src/Symfony/Component/Console/Input/ArrayInput.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,15 @@ public function __toString()
112112
$params = array();
113113
foreach ($this->parameters as $param => $val) {
114114
if ($param && '-' === $param[0]) {
115-
$params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
115+
if (is_array($val)) {
116+
foreach ($val as $v) {
117+
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
118+
}
119+
} else {
120+
$params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
121+
}
116122
} else {
117-
$params[] = $this->escapeToken($val);
123+
$params[] = is_array($val) ? array_map(array($this, 'escapeToken'), $val) : $this->escapeToken($val);
118124
}
119125
}
120126

src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,8 @@ public function testToString()
167167
{
168168
$input = new ArrayInput(array('-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"));
169169
$this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);
170+
171+
$input = new ArrayInput(array('-b' => array('bval_1', 'bval_2'), '--f' => array('fval_1', 'fval_2')));
172+
$this->assertSame('-b=bval_1 -b=bval_2 --f=fval_1 --f=fval_2', (string) $input);
170173
}
171174
}

src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testTypeConversions($key, $value, $supported)
5151
public function testTypeConversionsWithNativePhp($key, $value, $supported)
5252
{
5353
if (defined('HHVM_VERSION_ID')) {
54-
return $this->markTestSkipped();
54+
$this->markTestSkipped();
5555
}
5656

5757
if (!$supported) {

src/Symfony/Component/Dotenv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ CHANGELOG
44
3.3.0
55
-----
66

7+
* [BC BREAK] Since v3.3.7, the latest Dotenv files override the previous ones. Real env vars are not affected and are not overridden.
78
* added the component

src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ public function evaluate($functions, $values)
8282
if (!is_object($obj)) {
8383
throw new \RuntimeException('Unable to get a property on a non-object.');
8484
}
85+
if (!is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
86+
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_class($obj)));
87+
}
8588

86-
return call_user_func_array(array($obj, $this->nodes['attribute']->attributes['value']), $this->nodes['arguments']->evaluate($functions, $values));
89+
return call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
8790

8891
case self::ARRAY_CALL:
8992
$array = $this->nodes['node']->evaluate($functions, $values);

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ public function testRegisterAfterEval($registerCallback)
242242
$registerCallback($el);
243243
}
244244

245+
/**
246+
* @expectedException \RuntimeException
247+
* @expectedExceptionMessageRegExp /Unable to call method "\w+" of object "\w+"./
248+
*/
249+
public function testCallBadCallable()
250+
{
251+
$el = new ExpressionLanguage();
252+
$el->evaluate('foo.myfunction()', array('foo' => new \stdClass()));
253+
}
254+
245255
/**
246256
* @dataProvider getRegisterCallbacks
247257
* @expectedException \LogicException

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,22 @@ public function setData($data = array())
145145
// If only PHP did the same...
146146
$data = json_encode($data, $this->encodingOptions);
147147
} else {
148-
try {
149-
// PHP 5.4 and up wrap exceptions thrown by JsonSerializable
150-
// objects in a new exception that needs to be removed.
151-
// Fortunately, PHP 5.5 and up do not trigger any warning anymore.
152-
$data = json_encode($data, $this->encodingOptions);
153-
} catch (\Exception $e) {
154-
if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
155-
throw $e->getPrevious() ?: $e;
148+
if (!interface_exists('JsonSerializable', false)) {
149+
set_error_handler(function () { return false; });
150+
try {
151+
$data = @json_encode($data, $this->encodingOptions);
152+
} finally {
153+
restore_error_handler();
154+
}
155+
} else {
156+
try {
157+
$data = json_encode($data, $this->encodingOptions);
158+
} catch (\Exception $e) {
159+
if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
160+
throw $e->getPrevious() ?: $e;
161+
}
162+
throw $e;
156163
}
157-
throw $e;
158164
}
159165
}
160166

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ public function testSetContent()
228228
*/
229229
public function testSetContentJsonSerializeError()
230230
{
231+
if (!interface_exists('JsonSerializable', false)) {
232+
$this->markTestSkipped('JsonSerializable is required.');
233+
}
234+
231235
$serializable = new JsonSerializableObject();
232236

233237
JsonResponse::create($serializable);
@@ -242,7 +246,7 @@ public function testSetComplexCallback()
242246
}
243247
}
244248

245-
if (interface_exists('JsonSerializable')) {
249+
if (interface_exists('JsonSerializable', false)) {
246250
class JsonSerializableObject implements \JsonSerializable
247251
{
248252
public function jsonSerialize()

0 commit comments

Comments
 (0)