diff --git a/.travis.yml b/.travis.yml index f342aaa72..d0bac31e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ matrix: - php: 5.6 - php: 7.0 - php: 7.1 + - php: 7.2 + - php: nightly fast_finish: true before_install: diff --git a/README.md b/README.md index cf1b2e73c..9c9aed2e0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ Polyfills are provided for: `mbstring.func_overload` is required; - the `spl_object_id` and `stream_isatty` functions introduced in PHP 7.2; - the `sapi_windows_vt100_support` function (Windows only) introduced in PHP 7.2; -- the `PHP_OS_FAMILY` constant introduced in PHP 7.2. +- the `PHP_OS_FAMILY` constant introduced in PHP 7.2; +- the `is_countable` function introduced in PHP 7.3. It is strongly recommended to upgrade your PHP version and/or install the missing extensions whenever possible. This polyfill should be used only when there is no @@ -58,6 +59,7 @@ should **not** `require` the `symfony/polyfill` package, but the standalone ones - `symfony/polyfill-php70` for using the PHP 7.0 functions, - `symfony/polyfill-php71` for using the PHP 7.1 functions, - `symfony/polyfill-php72` for using the PHP 7.2 functions, +- `symfony/polyfill-php73` for using the PHP 7.3 functions, - `symfony/polyfill-iconv` for using the iconv functions, - `symfony/polyfill-intl-grapheme` for using the `grapheme_*` functions, - `symfony/polyfill-intl-icu` for using the intl functions and classes, diff --git a/composer.json b/composer.json index 9888e38f6..a7df660a5 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "symfony/polyfill-php70": "self.version", "symfony/polyfill-php71": "self.version", "symfony/polyfill-php72": "self.version", + "symfony/polyfill-php73": "self.version", "symfony/polyfill-iconv": "self.version", "symfony/polyfill-intl-grapheme": "self.version", "symfony/polyfill-intl-icu": "self.version", @@ -50,6 +51,7 @@ "src/Php70/bootstrap.php", "src/Php71/bootstrap.php", "src/Php72/bootstrap.php", + "src/Php73/bootstrap.php", "src/Iconv/bootstrap.php", "src/Intl/Grapheme/bootstrap.php", "src/Intl/Icu/bootstrap.php", @@ -65,7 +67,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Apcu/composer.json b/src/Apcu/composer.json index 54ea2b857..4ab8674b6 100644 --- a/src/Apcu/composer.json +++ b/src/Apcu/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Iconv/composer.json b/src/Iconv/composer.json index 9478ff716..6e089b9c2 100644 --- a/src/Iconv/composer.json +++ b/src/Iconv/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Intl/Grapheme/composer.json b/src/Intl/Grapheme/composer.json index cb213e259..affbbc7cb 100644 --- a/src/Intl/Grapheme/composer.json +++ b/src/Intl/Grapheme/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Intl/Icu/composer.json b/src/Intl/Icu/composer.json index d92b12feb..408ef7019 100644 --- a/src/Intl/Icu/composer.json +++ b/src/Intl/Icu/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Intl/Normalizer/composer.json b/src/Intl/Normalizer/composer.json index 1782c285c..a4a0df9ce 100644 --- a/src/Intl/Normalizer/composer.json +++ b/src/Intl/Normalizer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Mbstring/composer.json b/src/Mbstring/composer.json index 4febcdd5c..49b720dd8 100644 --- a/src/Mbstring/composer.json +++ b/src/Mbstring/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php54/composer.json b/src/Php54/composer.json index 867178c1f..1e39de99a 100644 --- a/src/Php54/composer.json +++ b/src/Php54/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php55/composer.json b/src/Php55/composer.json index fe9a1c1b8..c328bbe24 100644 --- a/src/Php55/composer.json +++ b/src/Php55/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php56/composer.json b/src/Php56/composer.json index 8bc3906e0..87de14ebb 100644 --- a/src/Php56/composer.json +++ b/src/Php56/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php70/composer.json b/src/Php70/composer.json index 88ff357a5..871045d2a 100644 --- a/src/Php70/composer.json +++ b/src/Php70/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php71/composer.json b/src/Php71/composer.json index c64709b93..cfda16017 100644 --- a/src/Php71/composer.json +++ b/src/Php71/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php72/composer.json b/src/Php72/composer.json index b58c88a34..b499b1d09 100644 --- a/src/Php72/composer.json +++ b/src/Php72/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Php73/LICENSE b/src/Php73/LICENSE new file mode 100644 index 000000000..ad399a798 --- /dev/null +++ b/src/Php73/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2018 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Php73/README.md b/src/Php73/README.md new file mode 100644 index 000000000..0995b439b --- /dev/null +++ b/src/Php73/README.md @@ -0,0 +1,14 @@ +Symfony Polyfill / Php73 +======================== + +This component provides functions added to PHP 7.3 core: + +- [`is_countable`](https://php.net/is_countable) + +More information can be found in the +[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). + +License +======= + +This library is released under the [MIT license](LICENSE). diff --git a/src/Php73/bootstrap.php b/src/Php73/bootstrap.php new file mode 100644 index 000000000..9a5895051 --- /dev/null +++ b/src/Php73/bootstrap.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (PHP_VERSION_ID < 70300) { + if (!function_exists('is_countable')) { + function is_countable($var) { + return is_array($var) || $var instanceof Countable; + } + } +} diff --git a/src/Php73/composer.json b/src/Php73/composer.json new file mode 100644 index 000000000..555792b6b --- /dev/null +++ b/src/Php73/composer.json @@ -0,0 +1,31 @@ +{ + "name": "symfony/polyfill-php73", + "type": "library", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "keywords": ["polyfill", "shim", "compatibility", "portable"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "psr-4": { "Symfony\\Polyfill\\Php73\\": "" }, + "files": [ "bootstrap.php" ] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + } +} diff --git a/src/Util/composer.json b/src/Util/composer.json index f7787e7fe..133968f80 100644 --- a/src/Util/composer.json +++ b/src/Util/composer.json @@ -24,7 +24,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/src/Xml/composer.json b/src/Xml/composer.json index 858350591..83228069e 100644 --- a/src/Xml/composer.json +++ b/src/Xml/composer.json @@ -23,7 +23,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } } } diff --git a/tests/Mbstring/MbstringTest.php b/tests/Mbstring/MbstringTest.php index f85ee8b4c..27d09f179 100644 --- a/tests/Mbstring/MbstringTest.php +++ b/tests/Mbstring/MbstringTest.php @@ -176,7 +176,7 @@ public function testEncodeNumericEntityWarnsOnInvalidEncodingType() */ public function testEncodeNumericEntityWarnsOnInvalidIsHexType() { - $this->setExpectedException('PHPUnit\Framework\Error\Warning', 'expects parameter 4 to be boolean'); + $this->setExpectedException('PHPUnit\Framework\Error\Warning', 'expects parameter 4 to be bool'); mb_encode_numericentity('déjà', array(0x0, 0x10ffff, 0x0, 0x1fffff), 'UTF-8', new \stdClass()); } diff --git a/tests/Php73/Php73Test.php b/tests/Php73/Php73Test.php new file mode 100644 index 000000000..c3f49811a --- /dev/null +++ b/tests/Php73/Php73Test.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Tests\Php73; + +use PHPUnit\Framework\TestCase; + +/** + * @author Gabriel Caruso + */ +class Php73Test extends TestCase +{ + /** + * @covers Symfony\Polyfill\Php73\Php73::is_countable + */ + public function testIsCountable() + { + $this->assertTrue(is_countable(array(1, 2, '3'))); + $this->assertTrue(is_countable(new \ArrayIterator(array('foo', 'bar', 'baz')))); + $this->assertTrue(is_countable(new \ArrayIterator())); + $this->assertFalse(is_countable(new \stdClass())); + } + + /** + * @covers Symfony\Polyfill\Php73\Php73::is_countable + * @requires PHP 5.5 + */ + public function testIsCountableForGenerator() + { + require 'generator.php'; + + $this->assertFalse(is_countable(genOneToTen())); + } +} diff --git a/tests/Php73/generator.php b/tests/Php73/generator.php new file mode 100644 index 000000000..8101b006a --- /dev/null +++ b/tests/Php73/generator.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Polyfill\Tests\Php73; + +function genOneToTen() +{ + for ($i = 1; $i <= 10; ++$i) { + yield $i; + } +}