This PR was squashed before being merged into the 4.3-dev branch (closes #28846).
Discussion
----------
[Intl] Simplify API
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #18368
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/issues/11221
Simplifies the Intl API. It greatly reduces the no. of boilerplate classes in this component. Very over complicated, much wow :)
Solving (IMHO):
```php
class LanguageBundle extends LanguageDataProvider implements LanguageBundleInterface
```
Which seems very over complicated just to provide static data.
```php
// before
Intl::getLanguageBundle()->getLanguageName() // string | null
// after
Languages::getName() // string
Languages::exists() // bool
```
I left out Canonicalization on puropose, that's a new topic to me.
- [x] Languages
- [x] Locales
- [x] Currencies
- [x] Regions
- [x] Scripts
- [ ] Timezones (#28831)
- [x] Update constraints
- [x] Update form types
Thoughts?
Commits
-------
d6b67d469a
[Intl] Simplify API
9.2 KiB
UPGRADE FROM 4.2 to 4.3
BrowserKit
- Renamed
Client
toAbstractBrowser
- Marked
Response
final. - Deprecated
Response::buildHeader()
- Deprecated
Response::getStatus()
, useResponse::getStatusCode()
instead
Cache
- The
psr/simple-cache
dependency has been removed - runcomposer require psr/simple-cache
if you need it. - Deprecated all PSR-16 adapters, use
Psr16Cache
orSymfony\Contracts\Cache\CacheInterface
implementations instead. - Deprecated
SimpleCacheAdapter
, usePsr16Adapter
instead.
Config
- Deprecated using environment variables with
cannotBeEmpty()
if the value is validated withvalidate()
- Deprecated the
root()
method inTreeBuilder
, pass the root node information to the constructor instead
DependencyInjection
-
Deprecated support for non-string default env() parameters
Before:
parameters: env(NAME): 1.5
After:
parameters: env(NAME): '1.5'
Doctrine Bridge
- Passing an
IdReader
to theDoctrineChoiceLoader
when the query cannot be optimized with single id field has been deprecated, passnull
instead - Not passing an
IdReader
to theDoctrineChoiceLoader
when the query can be optimized with single id field has been deprecated
Dotenv
- First parameter of
Dotenv::__construct()
will be changed fromtrue
tofalse
in Symfony 5.0. A deprecation warning is triggered if no parameter is provided. Use$usePutenv = true
to upgrade without breaking changes.
EventDispatcher
- The signature of the
EventDispatcherInterface::dispatch()
method should be updated todispatch($event, string $eventName = null)
, not doing so is deprecated - The
Event
class has been deprecated, useSymfony\Contracts\EventDispatcher\Event
instead
Form
- Using the
format
option ofDateType
andDateTimeType
when thehtml5
option is enabled is deprecated. - Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated and will lead to an exception in 5.0.
- Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons is deprecated and will lead to an exception in 5.0.
- Using the
date_format
,date_widget
, andtime_widget
options of theDateTimeType
when thewidget
option is set tosingle_text
is deprecated.
FrameworkBundle
- Not passing the project directory to the constructor of the
AssetsInstallCommand
is deprecated. This argument will be mandatory in 5.0. - Deprecated the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
- The
generate()
method of theUrlGenerator
class can return an empty string instead of null.
HttpFoundation
- The
MimeTypeGuesserInterface
andExtensionGuesserInterface
interfaces have been deprecated, useSymfony\Component\Mime\MimeTypesInterface
instead. - The
MimeType
andMimeTypeExtensionGuesser
classes have been deprecated, useSymfony\Component\Mime\MimeTypes
instead. - The
FileBinaryMimeTypeGuesser
class has been deprecated, useSymfony\Component\Mime\FileBinaryMimeTypeGuesser
instead. - The
FileinfoMimeTypeGuesser
class has been deprecated, useSymfony\Component\Mime\FileinfoMimeTypeGuesser
instead.
HttpKernel
- Renamed
Client
toHttpKernelBrowser
- Renamed
FilterControllerArgumentsEvent
toControllerArgumentsEvent
- Renamed
FilterControllerEvent
toControllerEvent
- Renamed
FilterResponseEvent
toResponseEvent
- Renamed
GetResponseEvent
toRequestEvent
- Renamed
GetResponseForControllerResultEvent
toViewEvent
- Renamed
GetResponseForExceptionEvent
toExceptionEvent
- Renamed
PostResponseEvent
toTerminateEvent
- Deprecated
TranslatorListener
in favor ofLocaleAwareListener
Intl
- Deprecated
ResourceBundle
namespace - Deprecated
Intl::getCurrencyBundle()
, useCurrencies
instead - Deprecated
Intl::getLanguageBundle()
, useLanguages
orScripts
instead - Deprecated
Intl::getLocaleBundle()
, useLocales
instead - Deprecated
Intl::getRegionBundle()
, useRegions
instead
Messenger
Amqp
transport does not throw\AMQPException
anymore, catchTransportException
instead.- Deprecated the
LoggingMiddleware
class, pass a logger toSendMessageMiddleware
instead.
Routing
- The
generator_base_class
,generator_cache_class
,matcher_base_class
, andmatcher_cache_class
router options have been deprecated. - Implementing
Serializable
forRoute
andCompiledRoute
is deprecated; if you serialize them, please ensure your unserialization logic can recover from a failure related to an updated serialization format
Security
-
The
Role
andSwitchUserRole
classes are deprecated and will be removed in 5.0. Use strings for roles instead. -
The
getReachableRoles()
method of theRoleHierarchyInterface
is deprecated and will be removed in 5.0. Role hierarchies must implement thegetReachableRoleNames()
method instead and return roles as strings. -
The
getRoles()
method of theTokenInterface
is deprecated. Tokens must implement thegetRoleNames()
method instead and return roles as strings. -
The
ListenerInterface
is deprecated, turn your listeners into callables instead. -
The
Firewall::handleRequest()
method is deprecated, useFirewall::callListeners()
instead. -
The
AbstractToken::serialize()
,AbstractToken::unserialize()
,AuthenticationException::serialize()
andAuthenticationException::unserialize()
methods are now final, use__serialize()
and__unserialize()
instead.Before:
public function serialize() { return [$this->myLocalVar, parent::serialize()]; } public function unserialize($serialized) { [$this->myLocalVar, $parentSerialized] = unserialize($serialized); parent::unserialize($parentSerialized); }
After:
public function __serialize(): array { return [$this->myLocalVar, parent::__serialize()]; } public function __unserialize(array $data): void { [$this->myLocalVar, $parentData] = $data; parent::__unserialize($parentData); }
-
The
Argon2iPasswordEncoder
class has been deprecated, useSodiumPasswordEncoder
instead. -
Not implementing the methods
__serialize
and__unserialize
in classes implementing theTokenInterface
is deprecated
SecurityBundle
- Configuring encoders using
argon2i
as algorithm has been deprecated, usesodium
instead.
TwigBridge
- deprecated the
$requestStack
and$requestContext
arguments of theHttpFoundationExtension
, pass aSymfony\Component\HttpFoundation\UrlHelper
instance as the only argument instead
Workflow
-
initial_place
is deprecated in favour ofinitial_marking
.Before:
framework: workflows: article: initial_place: draft
After:
framework: workflows: article: initial_marking: [draft]
-
MarkingStoreInterface::setMarking()
will have a third argument in Symfony 5.0.Before:
class MyMarkingStore implements MarkingStoreInterface { public function setMarking($subject, Marking $marking) { } }
After:
class MyMarkingStore implements MarkingStoreInterface { public function setMarking($subject, Marking $marking , array $context = []) { } }
-
MultipleStateMarkingStore
is deprecated. UseMethodMarkingStore
instead.Before:
framework: workflows: type: workflow article: marking_store: type: multiple arguments: states
After:
framework: workflows: type: workflow article: marking_store: type: method property: states
-
SingleStateMarkingStore
is deprecated. UseMethodMarkingStore
instead.Before:
framework: workflows: article: marking_store: arguments: state
After:
framework: workflows: type: state_machine article: marking_store: type: method property: state
-
Using a workflow with a single state marking is deprecated. Use a state machine instead.
Before:
framework: workflows: article: type: workflow marking_store: type: single_state
After:
framework: workflows: article: type: state_machine marking_store: # type: single_state # Since the single_state marking store is deprecated, use method instead type: method
Yaml
- Using a mapping inside a multi-line string is deprecated and will throw a
ParseException
in 5.0.