Merge branch '2.7' into 2.8

* 2.7:
  [travis] update to trusty
  Fix ArrayInput::toString() for VALUE_IS_ARRAY options/args
  [ExpressionLanguage] throws an exception on calling uncallable method
This commit is contained in:
Nicolas Grekas 2017-09-06 18:32:38 +02:00
commit c3f14708f4
9 changed files with 43 additions and 22 deletions

View File

@ -1,6 +1,6 @@
language: php
dist: precise
dist: trusty
sudo: false
git:
@ -13,17 +13,14 @@ addons:
env:
global:
- MIN_PHP=5.3.9
- MIN_PHP=5.4.9
- SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/versions/5.6/bin/php
matrix:
include:
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
- php: hhvm-3.18
sudo: required
dist: trusty
group: edge
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
@ -99,7 +96,6 @@ before_install:
echo opcache.enable_cli = 1 >> $INI
echo hhvm.jit = 0 >> $INI
echo apc.enable_cli = 1 >> $INI
echo extension = ldap.so >> $INI
[[ $PHP = 5.* ]] && echo extension = memcache.so >> $INI
if [[ $PHP = 5.* ]]; then
echo extension = mongo.so >> $INI

View File

@ -17,8 +17,8 @@ init:
install:
- mkdir c:\php && cd c:\php
- appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/cacert.pem
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-5.3.11-nts-Win32-VC9-x86.zip
- 7z x php-5.3.11-nts-Win32-VC9-x86.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-5.3.9-nts-Win32-VC9-x86.zip
- 7z x php-5.3.9-nts-Win32-VC9-x86.zip -y >nul
- appveyor DownloadFile https://raw.githubusercontent.com/symfony/binary-utils/master/ICU-51.2-dlls.zip
- 7z x ICU-51.2-dlls.zip -y >nul
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.1.3-Win32-VC14-x86.zip
@ -62,7 +62,7 @@ test_script:
- cd c:\php && 7z x php-7.1.3-Win32-VC14-x86.zip -y >nul && copy /Y php.ini-min php.ini
- cd c:\projects\symfony
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!
- cd c:\php && 7z x php-5.3.11-nts-Win32-VC9-x86.zip -y >nul && copy /Y php.ini-min php.ini
- cd c:\php && 7z x php-5.3.9-nts-Win32-VC9-x86.zip -y >nul && copy /Y php.ini-min php.ini
- cd c:\projects\symfony
- SET SYMFONY_PHPUNIT_SKIPPED_TESTS=phpunit.skipped
- php phpunit src\Symfony --exclude-group benchmark,intl-data || SET X=!errorlevel!

View File

@ -24,19 +24,19 @@
"symfony/polyfill-php70": "~1.0"
},
"require-dev": {
"symfony/browser-kit": "~2.4|~3.0.0",
"symfony/browser-kit": "~2.7|~3.0.0",
"symfony/console": "~2.7|~3.0.0",
"symfony/css-selector": "^2.0.5|~3.0.0",
"symfony/dom-crawler": "^2.0.5|~3.0.0",
"symfony/css-selector": "^2.7|~3.0.0",
"symfony/dom-crawler": "^2.7|~3.0.0",
"symfony/form": "^2.8.18",
"symfony/framework-bundle": "^2.8.18",
"symfony/http-foundation": "~2.7|~3.0.0",
"symfony/twig-bundle": "~2.7|~3.1.0",
"symfony/twig-bridge": "^2.7.4|~3.1.0",
"symfony/process": "^2.0.5|~3.0.0",
"symfony/process": "^2.7|~3.0.0",
"symfony/validator": "~2.7.25|^2.8.18|~3.2.5",
"symfony/yaml": "^2.0.5|~3.0.0",
"symfony/expression-language": "~2.6|~3.0.0",
"symfony/yaml": "^2.7|~3.0.0",
"symfony/expression-language": "~2.7|~3.0.0",
"doctrine/doctrine-bundle": "~1.2",
"twig/twig": "~1.34|~2.4"
},

View File

@ -104,9 +104,15 @@ class ArrayInput extends Input
$params = array();
foreach ($this->parameters as $param => $val) {
if ($param && '-' === $param[0]) {
$params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
if (is_array($val)) {
foreach ($val as $v) {
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
}
} else {
$params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
}
} else {
$params[] = $this->escapeToken($val);
$params[] = is_array($val) ? array_map(array($this, 'escapeToken'), $val) : $this->escapeToken($val);
}
}

View File

@ -140,5 +140,8 @@ class ArrayInputTest extends TestCase
{
$input = new ArrayInput(array('-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"));
$this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);
$input = new ArrayInput(array('-b' => array('bval_1', 'bval_2'), '--f' => array('fval_1', 'fval_2')));
$this->assertSame('-b=bval_1 -b=bval_2 --f=fval_1 --f=fval_2', (string) $input);
}
}

View File

@ -82,8 +82,11 @@ class GetAttrNode extends Node
if (!is_object($obj)) {
throw new \RuntimeException('Unable to get a property on a non-object.');
}
if (!is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_class($obj)));
}
return call_user_func_array(array($obj, $this->nodes['attribute']->attributes['value']), $this->nodes['arguments']->evaluate($functions, $values));
return call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
case self::ARRAY_CALL:
$array = $this->nodes['node']->evaluate($functions, $values);

View File

@ -163,6 +163,16 @@ class ExpressionLanguageTest extends TestCase
$registerCallback($el);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessageRegExp /Unable to call method "\w+" of object "\w+"./
*/
public function testCallBadCallable()
{
$el = new ExpressionLanguage();
$el->evaluate('foo.myfunction()', array('foo' => new \stdClass()));
}
/**
* @dataProvider getRegisterCallbacks
* @expectedException \LogicException

View File

@ -121,7 +121,7 @@ class JsonResponse extends Response
$data = json_encode($data, $this->encodingOptions);
} else {
try {
if (\PHP_VERSION_ID < 50400) {
if (!interface_exists('JsonSerializable', false)) {
// PHP 5.3 triggers annoying warnings for some
// types that can't be serialized as JSON (INF, resources, etc.)
// but doesn't provide the JsonSerializable interface.
@ -153,7 +153,7 @@ class JsonResponse extends Response
if (\PHP_VERSION_ID < 50500) {
restore_error_handler();
}
if (\PHP_VERSION_ID >= 50400 && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
if (interface_exists('JsonSerializable', false) && 'Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
throw $e->getPrevious() ?: $e;
}
throw $e;

View File

@ -206,10 +206,13 @@ class JsonResponseTest extends TestCase
/**
* @expectedException \Exception
* @expectedExceptionMessage This error is expected
* @requires PHP 5.4
*/
public function testSetContentJsonSerializeError()
{
if (!interface_exists('JsonSerializable', false)) {
$this->markTestSkipped('JsonSerializable is required.');
}
$serializable = new JsonSerializableObject();
JsonResponse::create($serializable);
@ -224,7 +227,7 @@ class JsonResponseTest extends TestCase
}
}
if (interface_exists('JsonSerializable')) {
if (interface_exists('JsonSerializable', false)) {
class JsonSerializableObject implements \JsonSerializable
{
public function jsonSerialize()