Merge branch '7.2' into 7.3

* 7.2:
  Replace get_class() calls by ::class
This commit is contained in:
Javier Eguiluz
2025-05-29 16:29:02 +02:00
7 changed files with 9 additions and 9 deletions

View File

@@ -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])) {

View File

@@ -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);

View File

@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -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()

View File

@@ -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

View File

@@ -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".

View File

@@ -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);