Skip to content

Commit

Permalink
Fix compatibility issue, update class_alias to use DummyClassForClass…
Browse files Browse the repository at this point in the history
…ExistsCheck

Replaced instances of \stdClass in class_alias calls with DummyClassForClassExistsCheck as before php 8.3 only user created class can be aliased.
  • Loading branch information
Tibor Rac committed Nov 3, 2024
1 parent fba862a commit e0a7656
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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.
*/

namespace Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures;

class DummyClassForClassExistsCheck
{
}
9 changes: 5 additions & 4 deletions Tests/DependencyInjection/MonologExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\FooProcessor;
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\FooProcessorWithPriority;
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\RedeclareMethodProcessor;
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\DummyClassForClassExistsCheck;
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\ServiceWithChannel;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -189,7 +190,7 @@ public function testExceptionWhenUsingGelfWithoutPublisherHostname()
public function testExceptionWhenUsingLegacyGelfImplementationWithUnsupportedEncoder(): void
{
if (!class_exists('Gelf\MessagePublisher')) {
class_alias(\stdClass::class, 'Gelf\MessagePublisher');
class_alias(DummyClassForClassExistsCheck::class, 'Gelf\MessagePublisher');
}

$container = new ContainerBuilder();
Expand All @@ -206,7 +207,7 @@ class_alias(\stdClass::class, 'Gelf\MessagePublisher');
public function testLegacyGelfImplementationEncoderOption(array $config): void
{
if (!class_exists('Gelf\MessagePublisher')) {
class_alias(\stdClass::class, 'Gelf\MessagePublisher');
class_alias(DummyClassForClassExistsCheck::class, 'Gelf\MessagePublisher');
}

$container = $this->getContainer($config);
Expand Down Expand Up @@ -234,7 +235,7 @@ public function encoderOptionsProvider(): array
public function testExceptionWhenUsingGelfWithInvalidEncoder(): void
{
if (!class_exists('Gelf\Transport\UdpTransport')) {
class_alias(\stdClass::class, 'Gelf\Transport\UdpTransport');
class_alias(DummyClassForClassExistsCheck::class, 'Gelf\Transport\UdpTransport');
}

$container = new ContainerBuilder();
Expand All @@ -251,7 +252,7 @@ class_alias(\stdClass::class, 'Gelf\Transport\UdpTransport');
public function testGelfWithEncoder($encoderValue, $expectedClass): void
{
if (!class_exists('Gelf\Transport\UdpTransport')) {
class_alias(\stdClass::class, 'Gelf\Transport\UdpTransport');
class_alias(DummyClassForClassExistsCheck::class, 'Gelf\Transport\UdpTransport');
}

$container = $this->getContainer([['handlers' => ['gelf' => ['type' => 'gelf', 'publisher' => ['hostname' => 'localhost', 'encoder' => $encoderValue]]]]]);
Expand Down

0 comments on commit e0a7656

Please sign in to comment.