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 declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien..
Decoded Output download
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <[email protected]>
* Dariusz Rumiski <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Tests\FixerConfiguration;
use PhpCsFixer\FixerConfiguration\DeprecatedFixerOption;
use PhpCsFixer\FixerConfiguration\FixerOption;
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
use PhpCsFixer\Tests\TestCase;
/**
* @internal
*
* @covers \PhpCsFixer\FixerConfiguration\FixerOptionBuilder
*/
final class FixerOptionBuilderTest extends TestCase
{
public function testSetDefault(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setDefault('baz'));
}
public function testSetAllowedTypes(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setAllowedTypes(['bool']));
}
public function testSetAllowedValues(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setAllowedValues(['baz']));
}
public function testSetNormalizer(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setNormalizer(static fn () => null));
}
public function testGetOption(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
$regularOption = $builder
->setDefault('baz')
->setAllowedTypes(['bool'])
->setAllowedValues([true, false])
->setNormalizer(static fn () => null)
->getOption()
;
self::assertInstanceOf(FixerOption::class, $regularOption);
$deprecationOption = $builder
->setDefault('baz')
->setAllowedTypes(['bool'])
->setAllowedValues([true, false])
->setNormalizer(static fn () => null)
->setDeprecationMessage('Deprecation message')
->getOption()
;
self::assertInstanceOf(DeprecatedFixerOption::class, $deprecationOption);
foreach ([$regularOption, $deprecationOption] as $option) {
self::assertSame('foo', $option->getName());
self::assertSame('Bar.', $option->getDescription());
self::assertTrue($option->hasDefault());
self::assertSame('baz', $option->getDefault());
self::assertSame(['bool'], $option->getAllowedTypes());
self::assertSame([true, false], $option->getAllowedValues());
self::assertInstanceOf(\Closure::class, $option->getNormalizer());
}
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <[email protected]>
* Dariusz Rumiski <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Tests\FixerConfiguration;
use PhpCsFixer\FixerConfiguration\DeprecatedFixerOption;
use PhpCsFixer\FixerConfiguration\FixerOption;
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
use PhpCsFixer\Tests\TestCase;
/**
* @internal
*
* @covers \PhpCsFixer\FixerConfiguration\FixerOptionBuilder
*/
final class FixerOptionBuilderTest extends TestCase
{
public function testSetDefault(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setDefault('baz'));
}
public function testSetAllowedTypes(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setAllowedTypes(['bool']));
}
public function testSetAllowedValues(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setAllowedValues(['baz']));
}
public function testSetNormalizer(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
self::assertSame($builder, $builder->setNormalizer(static fn () => null));
}
public function testGetOption(): void
{
$builder = new FixerOptionBuilder('foo', 'Bar.');
$regularOption = $builder
->setDefault('baz')
->setAllowedTypes(['bool'])
->setAllowedValues([true, false])
->setNormalizer(static fn () => null)
->getOption()
;
self::assertInstanceOf(FixerOption::class, $regularOption);
$deprecationOption = $builder
->setDefault('baz')
->setAllowedTypes(['bool'])
->setAllowedValues([true, false])
->setNormalizer(static fn () => null)
->setDeprecationMessage('Deprecation message')
->getOption()
;
self::assertInstanceOf(DeprecatedFixerOption::class, $deprecationOption);
foreach ([$regularOption, $deprecationOption] as $option) {
self::assertSame('foo', $option->getName());
self::assertSame('Bar.', $option->getDescription());
self::assertTrue($option->hasDefault());
self::assertSame('baz', $option->getDefault());
self::assertSame(['bool'], $option->getAllowedTypes());
self::assertSame([true, false], $option->getAllowedValues());
self::assertInstanceOf(\Closure::class, $option->getNormalizer());
}
}
}
Function Calls
None |
Stats
MD5 | dbed64b9da445b0c66a87cdbc59308ce |
Eval Count | 0 |
Decode Time | 124 ms |