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\Console\Tests\Helper;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClassExistsMock;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\VarDumper\Dumper\CliDumper;

class DumperNativeFallbackTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(Dumper::class);
        ClassExistsMock::withMockedClasses([
            CliDumper::class => false,
        ]);
    }

    public static function tearDownAfterClass(): void
    {
        ClassExistsMock::withMockedClasses([]);
    }

    /**
     * @dataProvider provideVariables
     */
    public function testInvoke($variable, $primitiveString)
    {
        $dumper = new Dumper($this->createMock(OutputInterface::class));

        $this->assertSame($primitiveString, $dumper($variable));
    }

    public static function provideVariables()
    {
        return [
            [null, 'null'],
            [true, 'true'],
            [false, 'false'],
            [1, '1'],
            [-1.5, '-1.5'],
            ['string', '"string"'],
            [[1, '2'], "Array
(
    [0] => 1
    [1] => 2
)"],
            [new \stdClass(), "stdClass Object
(
)"],
        ];
    }
}
 ?>

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\Console\Tests\Helper;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClassExistsMock;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\VarDumper\Dumper\CliDumper;

class DumperNativeFallbackTest extends TestCase
{
    public static function setUpBeforeClass(): void
    {
        ClassExistsMock::register(Dumper::class);
        ClassExistsMock::withMockedClasses([
            CliDumper::class => false,
        ]);
    }

    public static function tearDownAfterClass(): void
    {
        ClassExistsMock::withMockedClasses([]);
    }

    /**
     * @dataProvider provideVariables
     */
    public function testInvoke($variable, $primitiveString)
    {
        $dumper = new Dumper($this->createMock(OutputInterface::class));

        $this->assertSame($primitiveString, $dumper($variable));
    }

    public static function provideVariables()
    {
        return [
            [null, 'null'],
            [true, 'true'],
            [false, 'false'],
            [1, '1'],
            [-1.5, '-1.5'],
            ['string', '"string"'],
            [[1, '2'], "Array\n(\n    [0] => 1\n    [1] => 2\n)"],
            [new \stdClass(), "stdClass Object\n(\n)"],
        ];
    }
}

Function Calls

None

Variables

None

Stats

MD5 803188bdc5b2bf3c6f5c2726130df509
Eval Count 0
Decode Time 96 ms