mirror of
https://github.com/symfony/symfony-docs.git
synced 2026-03-23 16:22:10 +01:00
Merge branch '7.2' into 7.3
* 7.2: Replace get_class() calls by ::class
This commit is contained in:
@@ -936,7 +936,7 @@ can change your code to do the configuration only once per class::
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
// What type of Mailer is this, a Mailer, a GoogleMailer, ... ?
|
||||
$class = get_class($this);
|
||||
$class = $this::class;
|
||||
|
||||
// Was configureOptions() executed before for this class?
|
||||
if (!isset(self::$resolversByClass[$class])) {
|
||||
|
||||
@@ -131,7 +131,7 @@ class exposes public methods to extract several types of information:
|
||||
$propertyInfo->getProperties($awesomeObject);
|
||||
|
||||
// Good!
|
||||
$propertyInfo->getProperties(get_class($awesomeObject));
|
||||
$propertyInfo->getProperties($awesomeObject::class);
|
||||
$propertyInfo->getProperties('Example\Namespace\YourAwesomeClass');
|
||||
$propertyInfo->getProperties(YourAwesomeClass::class);
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ You can make it convert to a ``DateTime`` instance by using the ``PARSE_DATETIME
|
||||
flag::
|
||||
|
||||
$date = Yaml::parse('2016-05-27', Yaml::PARSE_DATETIME);
|
||||
var_dump(get_class($date)); // DateTime
|
||||
var_dump($date::class); // DateTime
|
||||
|
||||
Dumping Multi-line Literal Blocks
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -68,7 +68,7 @@ level. For example::
|
||||
|
||||
// available methods: ->isSilent(), ->isQuiet(), ->isVerbose(), ->isVeryVerbose(), ->isDebug()
|
||||
if ($output->isVerbose()) {
|
||||
$output->writeln('User class: '.get_class($user));
|
||||
$output->writeln('User class: '.$user::class);
|
||||
}
|
||||
|
||||
// alternatively you can pass the verbosity level PHP constant to writeln()
|
||||
|
||||
@@ -447,7 +447,7 @@ by adding JOINs.
|
||||
$category = $product->getCategory();
|
||||
|
||||
// prints "Proxies\AppEntityCategoryProxy"
|
||||
dump(get_class($category));
|
||||
dump($category::class);
|
||||
die();
|
||||
|
||||
This proxy object extends the true ``Category`` object, and looks and
|
||||
|
||||
@@ -425,7 +425,7 @@ command will generate a nice skeleton to get you started::
|
||||
public function refreshUser(UserInterface $user): UserInterface
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new UnsupportedUserException(sprintf('Invalid user class "%s".', get_class($user)));
|
||||
throw new UnsupportedUserException(sprintf('Invalid user class "%s".', $user::class));
|
||||
}
|
||||
|
||||
// Return a User object after making sure its data is "fresh".
|
||||
|
||||
@@ -36,7 +36,7 @@ to handle their respective command when it is asked for::
|
||||
|
||||
public function handle(Command $command): mixed
|
||||
{
|
||||
$commandClass = get_class($command);
|
||||
$commandClass = $command::class;
|
||||
|
||||
if (!$handler = $this->handlerMap[$commandClass] ?? null) {
|
||||
return;
|
||||
@@ -94,7 +94,7 @@ in the service subscriber::
|
||||
|
||||
public function handle(Command $command): mixed
|
||||
{
|
||||
$commandClass = get_class($command);
|
||||
$commandClass = $command::class;
|
||||
|
||||
if ($this->locator->has($commandClass)) {
|
||||
$handler = $this->locator->get($commandClass);
|
||||
@@ -350,7 +350,7 @@ attribute::
|
||||
|
||||
public function handle(Command $command): mixed
|
||||
{
|
||||
$commandClass = get_class($command);
|
||||
$commandClass = $command::class;
|
||||
|
||||
if ($this->handlers->has($commandClass)) {
|
||||
$handler = $this->handlers->get($commandClass);
|
||||
|
||||
Reference in New Issue
Block a user