Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\PhpDumper;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper;
use Symfony\Component\DependencyInjection\Tests\Fixtures\ReadOnlyClass;
class LazyServiceDumperTest extends TestCase
{
public function testProxyInterface()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(ContainerInterface::class))->setLazy(true);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('function get(', $dumper->getProxyCode($definition));
}
public function testFinalClassInterface()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(TestContainer::class))
->setLazy(true)
->addTag('proxy', ['interface' => ContainerInterface::class]);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('function get(', $dumper->getProxyCode($definition));
}
public function testInvalidClass()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(\stdClass::class))
->setLazy(true)
->addTag('proxy', ['interface' => ContainerInterface::class]);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "proxy" tag for service "stdClass": class "stdClass" doesn\'t implement "Psr\Container\ContainerInterface".');
$dumper->getProxyCode($definition);
}
/**
* @requires PHP 8.3
*/
public function testReadonlyClass()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(ReadOnlyClass::class))->setLazy(true);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('readonly class ReadOnlyClassGhost', $dumper->getProxyCode($definition));
}
}
final class TestContainer implements ContainerInterface
{
public function has(string $key): bool
{
return true;
}
public function get(string $key): string
{
return $key;
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\LazyProxy\PhpDumper;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper;
use Symfony\Component\DependencyInjection\Tests\Fixtures\ReadOnlyClass;
class LazyServiceDumperTest extends TestCase
{
public function testProxyInterface()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(ContainerInterface::class))->setLazy(true);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('function get(', $dumper->getProxyCode($definition));
}
public function testFinalClassInterface()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(TestContainer::class))
->setLazy(true)
->addTag('proxy', ['interface' => ContainerInterface::class]);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('function get(', $dumper->getProxyCode($definition));
}
public function testInvalidClass()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(\stdClass::class))
->setLazy(true)
->addTag('proxy', ['interface' => ContainerInterface::class]);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid "proxy" tag for service "stdClass": class "stdClass" doesn\'t implement "Psr\Container\ContainerInterface".');
$dumper->getProxyCode($definition);
}
/**
* @requires PHP 8.3
*/
public function testReadonlyClass()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(ReadOnlyClass::class))->setLazy(true);
$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('readonly class ReadOnlyClassGhost', $dumper->getProxyCode($definition));
}
}
final class TestContainer implements ContainerInterface
{
public function has(string $key): bool
{
return true;
}
public function get(string $key): string
{
return $key;
}
}
Function Calls
None |
Stats
MD5 | 29a6d63488ef3d16ba6d600fb2aa6092 |
Eval Count | 0 |
Decode Time | 95 ms |