From 868a50103c50680e72c834244e8f77e20ae8156d Mon Sep 17 00:00:00 2001 From: Nico Schoenmaker Date: Mon, 26 Feb 2018 16:23:01 +0100 Subject: [PATCH] Fixed php7.2 deprecation --- .travis.yml | 1 + lib/yaml/sfYamlInline.class.php | 5 ++++- test/lib/yaml/sfYamlInlineTest.php | 35 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/lib/yaml/sfYamlInlineTest.php diff --git a/.travis.yml b/.travis.yml index 4a1728fc8c..f3c8a3432b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: php php: + - 7.2 - 7.1 - 7.0 - 5.6 diff --git a/lib/yaml/sfYamlInline.class.php b/lib/yaml/sfYamlInline.class.php index 2d016274fa..7fc074f273 100644 --- a/lib/yaml/sfYamlInline.class.php +++ b/lib/yaml/sfYamlInline.class.php @@ -99,11 +99,14 @@ static public function dump($value) static protected function dumpArray($value) { // array + $fn = function ($v, $w) { + return ((int) $v) + ((int) $w); + }; $keys = array_keys($value); if ( (1 == count($keys) && '0' == $keys[0]) || - (count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return ((int) $v) + ((int) $w);'), 0) == count($keys) * (count($keys) - 1) / 2)) + (count($keys) > 1 && array_reduce($keys, $fn, 0) == count($keys) * (count($keys) - 1) / 2)) { $output = array(); foreach ($value as $val) diff --git a/test/lib/yaml/sfYamlInlineTest.php b/test/lib/yaml/sfYamlInlineTest.php new file mode 100644 index 0000000000..ff88b9f635 --- /dev/null +++ b/test/lib/yaml/sfYamlInlineTest.php @@ -0,0 +1,35 @@ + 'b'], '{ a: b }'] + ]; + } +}