8000 [Intl] deprecate polyfills in favor of symfony/polyfill-intl-icu by nicolas-grekas · Pull Request #38974 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Intl] deprecate polyfills in favor of symfony/polyfill-intl-icu #38974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"symfony/intl": "^4.4|^5.0",
"symfony/options-resolver": "^5.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-icu": "^1.21",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.15",
"symfony/property-access": "^5.0.8",
Expand All @@ -48,7 +49,6 @@
"symfony/error-handler": "<4.4.5",
"symfony/framework-bundle": "<4.4",
"symfony/http-kernel": "<4.4",
"symfony/intl": "<4.4",
"symfony/translation": "<4.4",
"symfony/translation-contracts": "<1.1.7",
"symfony/twig-bridge": "<4.4"
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Intl/Collator/Collator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class Collator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class AmPmTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class DayOfWeekTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class DayOfYearTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class DayTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class FullTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour1200Transformer extends HourTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour1201Transformer extends HourTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour2400Transformer extends HourTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class Hour2401Transformer extends HourTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class HourTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class MinuteTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class MonthTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class QuarterTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class SecondTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class TimezoneTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @author Igor Wiedler <igor@wiedler.ch>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class YearTransformer extends Transformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class IntlDateFormatter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class MethodArgumentNotImplementedException extends NotImplementedException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class MethodArgumentValueNotImplementedException extends NotImplementedException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class MethodNotImplementedException extends NotImplementedException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Base exception class for not implemented behaviors of the intl extension in the Locale component.
*
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
class NotImplementedException extends RuntimeException
{
Expand Down
32 changes: 32 additions & 0 deletions src/Symfony/Component/Intl/Globals/IntlGlobals.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@

namespace Symfony\Component\Intl\Globals;

use Symfony\Polyfill\Intl\Icu\Icu;

/**
* Provides fake static versions of the global functions in the intl extension.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class IntlGlobals
{
Expand Down Expand Up @@ -61,6 +65,12 @@ abstract class IntlGlobals
*/
public static function isFailure(int $errorCode): bool
{
if (class_exists(Icu::class)) {
return Icu::isFailure($errorCode);
}

trigger_deprecation('symfony/intl', '5.3', 'Polyfills are deprecated, try running "composer require symfony/polyfill-intl-icu ^1.21" instead.');

return isset(self::$errorCodes[$errorCode])
&& $errorCode > self::U_ZERO_ERROR;
}
Expand All @@ -74,6 +84,12 @@ public static function isFailure(int $errorCode): bool
*/
public static function getErrorCode()
{
if (class_exists(Icu::class)) {
return Icu::getErrorCode();
}

trigger_deprecation('symfony/intl', '5.3', 'Polyfills are deprecated, try running "composer require symfony/polyfill-intl-icu ^1.21" instead.');

return self::$errorCode;
}

Expand All @@ -84,6 +100,12 @@ public static function getErrorCode()
*/
public static function getErrorMessage(): string
{
if (class_exists(Icu::class)) {
return Icu::getErrorMessage();
}

trigger_deprecation('symfony/intl', '5.3', 'Polyfills are deprecated, try running "composer require symfony/polyfill-intl-icu ^1.21" instead.');

return self::$errorMessage;
}

Expand All @@ -94,6 +116,12 @@ public static function getErrorMessage(): string
*/
public static function getErrorName(int $code): string
{
if (class_exists(Icu::class)) {
return Icu::getErrorName($code);
}

trigger_deprecation('symfony/intl', '5.3', 'Polyfills are deprecated, try running "composer require symfony/polyfill-intl-icu ^1.21" instead.');

return self::$errorCodes[$code] ?? '[BOGUS UErrorCode]';
}

Expand All @@ -107,6 +135,10 @@ public static function getErrorName(int $code): string
*/
public static function setError(int $code, string $message = '')
{
if (class_exists(Icu::class)) {
return Icu::setError($code, $message);
}

if (!isset(self::$errorCodes[$code])) {
throw new \InvalidArgumentException(sprintf('No such error code: "%s".', $code));
}
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Intl/Locale/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @author Bernhard Schussek <bschussek@gmail.com>
4E34 *
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class Locale
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*
* @deprecated since Symfony 5.3, use symfony/polyfill-intl-icu ^1.21 instead
*/
abstract class NumberFormatter
{
Expand Down
8 changes: 1 addition & 7 deletions src/Symfony/Component/Intl/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
Intl Component
=============

A PHP replacement layer for the C intl extension that also provides access to
the localization data of the ICU library.

The replacement layer is limited to the locale "en". If you want to use other
locales, you should [install the intl PHP extension][0] instead.
This package provides access to the CLDR localization data of the ICU library.

Resources
---------
Expand All @@ -17,5 +13,3 @@ Resources
in the [main Symfony repository](https://github.com/symfony/symfony)
* [Docker images with intl support](https://hub.docker.com/r/jakzal/php-intl)
(for the Intl component development)

[0]: https://php.net/intl.setup
37 changes: 37 additions & 0 deletions src/Symfony/Component/Intl/Resources/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\Intl\Globals\IntlGlobals;

if (!function_exists('intl_is_failure')) {
function intl_is_failure($error_code)
{
return IntlGlobals::isFailure($error_code);
}
}
if (!function_exists('intl_get_error_code')) {
function intl_get_error_code()
{
return IntlGlobals::getErrorCode();
}
}
if (!function_exists('intl_get_error_message')) {
function intl_get_error_message()
{
return IntlGlobals::getErrorMessage();
}
}
if (!function_exists('intl_error_name')) {
function intl_error_name($error_code)
{
return IntlGlobals::getErrorName($error_code);
}
}
Loading
0