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\Fixer\LanguageConstruct;
use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
/**
* @author Dariusz Rumiski <[email protected]>
*
* @internal
*
* @covers \PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer
*
* @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer>
*
* @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer
*/
final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase
{
/**
* @param _AutogeneratedInputConfiguration $config
*
* @dataProvider provideFixCases
*/
public function testFix(string $expected, ?string $input, array $config): void
{
$this->fixer->configure($config);
$this->doTest($expected, $input);
}
public static function provideFixCases(): iterable
{
yield 'minimal case remove whitespace (default config)' => [
'<?php declare(ticks=1);',
'<?php declare(ticks= 1);',
[],
];
yield 'minimal case remove whitespace (no space config)' => [
'<?php declare(ticks=1);',
'<?php declare(ticks = 1);',
['space' => 'none'],
];
yield 'minimal case add whitespace' => [
'<?php declare(ticks = 1);',
'<?php declare(ticks=1);',
['space' => 'single'],
];
yield 'to much whitespace case add whitespace' => [
'<?php declare(ticks = 1);',
"<?php declare(ticks
= 1);",
['space' => 'single'],
];
yield 'repeating case remove whitespace (default config)' => [
'<?php declare(ticks=1);declare(ticks=1)?>',
'<?php declare(ticks= 1);declare(ticks= 1)?>',
[],
];
yield 'repeating case add whitespace' => [
'<?php declare ( ticks = 1 );declare( ticks = 1) ?>',
'<?php declare ( ticks=1 );declare( ticks =1) ?>',
['space' => 'single'],
];
yield 'minimal case add whitespace comments, single' => [
'<?php declare(ticks#
= #
1#
);',
'<?php declare(ticks#
=#
1#
);',
['space' => 'single'],
];
yield 'minimal case add whitespace comments, none' => [
'<?php declare(ticks#
=#
1#
);',
null,
['space' => 'none'],
];
yield 'declare having multiple directives, single' => [
'<?php declare(strict_types=1, ticks=1);',
'<?php declare(strict_types = 1, ticks = 1);',
[],
];
yield 'declare having multiple directives, none' => [
'<?php declare(strict_types = 1, ticks = 1);',
'<?php declare(strict_types=1, ticks=1);',
['space' => 'single'],
];
}
/**
* @param _AutogeneratedInputConfiguration $config
*
* @dataProvider provideInvalidConfigurationCases
*/
public function testInvalidConfiguration(array $config, string $expectedMessage): void
{
$this->expectException(InvalidFixerConfigurationException::class);
$this->expectExceptionMessage(sprintf('[declare_equal_normalize] Invalid configuration: %s', $expectedMessage));
$this->fixer->configure($config);
}
public static function provideInvalidConfigurationCases(): iterable
{
yield [
[1, 2],
'The options "0", "1" do not exist.',
];
yield [
['space' => 'tab'],
'The option "space" with value "tab" is invalid.',
];
}
}
?>
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\Fixer\LanguageConstruct;
use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
/**
* @author Dariusz Rumiski <[email protected]>
*
* @internal
*
* @covers \PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer
*
* @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer>
*
* @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer
*/
final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase
{
/**
* @param _AutogeneratedInputConfiguration $config
*
* @dataProvider provideFixCases
*/
public function testFix(string $expected, ?string $input, array $config): void
{
$this->fixer->configure($config);
$this->doTest($expected, $input);
}
public static function provideFixCases(): iterable
{
yield 'minimal case remove whitespace (default config)' => [
'<?php declare(ticks=1);',
'<?php declare(ticks= 1);',
[],
];
yield 'minimal case remove whitespace (no space config)' => [
'<?php declare(ticks=1);',
'<?php declare(ticks = 1);',
['space' => 'none'],
];
yield 'minimal case add whitespace' => [
'<?php declare(ticks = 1);',
'<?php declare(ticks=1);',
['space' => 'single'],
];
yield 'to much whitespace case add whitespace' => [
'<?php declare(ticks = 1);',
"<?php declare(ticks\n\t = 1);",
['space' => 'single'],
];
yield 'repeating case remove whitespace (default config)' => [
'<?php declare(ticks=1);declare(ticks=1)?>',
'<?php declare(ticks= 1);declare(ticks= 1)?>',
[],
];
yield 'repeating case add whitespace' => [
'<?php declare ( ticks = 1 );declare( ticks = 1) ?>',
'<?php declare ( ticks=1 );declare( ticks =1) ?>',
['space' => 'single'],
];
yield 'minimal case add whitespace comments, single' => [
'<?php declare(ticks#
= #
1#
);',
'<?php declare(ticks#
=#
1#
);',
['space' => 'single'],
];
yield 'minimal case add whitespace comments, none' => [
'<?php declare(ticks#
=#
1#
);',
null,
['space' => 'none'],
];
yield 'declare having multiple directives, single' => [
'<?php declare(strict_types=1, ticks=1);',
'<?php declare(strict_types = 1, ticks = 1);',
[],
];
yield 'declare having multiple directives, none' => [
'<?php declare(strict_types = 1, ticks = 1);',
'<?php declare(strict_types=1, ticks=1);',
['space' => 'single'],
];
}
/**
* @param _AutogeneratedInputConfiguration $config
*
* @dataProvider provideInvalidConfigurationCases
*/
public function testInvalidConfiguration(array $config, string $expectedMessage): void
{
$this->expectException(InvalidFixerConfigurationException::class);
$this->expectExceptionMessage(sprintf('[declare_equal_normalize] Invalid configuration: %s', $expectedMessage));
$this->fixer->configure($config);
}
public static function provideInvalidConfigurationCases(): iterable
{
yield [
[1, 2],
'The options "0", "1" do not exist.',
];
yield [
['space' => 'tab'],
'The option "space" with value "tab" is invalid.',
];
}
}
Function Calls
None |
Stats
MD5 | 523e22ae668320559620772a3c0d7079 |
Eval Count | 0 |
Decode Time | 117 ms |