Skip to content

Commit

Permalink
Merge branch '2.15' into 2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfalque committed Jun 4, 2020
2 parents c0f3b0a + 382e00e commit 0d06f47
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ jobs:
<<: *STANDARD_TEST_JOB
stage: Test
php: 7.1
name: 7.1 | Symfony 4.1
name: 7.1 | Symfony ~4.1.0
env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="~4.1.0"

-
<<: *STANDARD_TEST_JOB
stage: Test
php: 7.2
name: 7.2 | Symfony 5.0
name: 7.2 | Symfony ^5.0
env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="^5.0"

-
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
"phpunitgoodpractices/traits": "^1.8",
"symfony/phpunit-bridge": "^4.3 || ^5.0",
"symfony/phpunit-bridge": "^5.1",
"symfony/yaml": "^3.0 || ^4.0 || ^5.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bin/checkbashisms --version

echo λλλ shellcheck
if [ ! -x bin/shellcheck ]; then
wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-${VERSION_SC}.linux.x86_64.tar.xz" \
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${VERSION_SC}/shellcheck-${VERSION_SC}.linux.x86_64.tar.xz" \
| tar -xJv -O shellcheck-${VERSION_SC}/shellcheck \
> bin/shellcheck
chmod u+x bin/shellcheck
Expand Down
2 changes: 1 addition & 1 deletion php-cs-fixer
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

if (getenv('PHP_CS_FIXER_FUTURE_MODE')) {
error_reporting(-1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
}

if (defined('HHVM_VERSION_ID')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class Application extends BaseApplication
public function __construct()
{
if (!getenv('PHP_CS_FIXER_FUTURE_MODE')) {
error_reporting(-1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
}

parent::__construct('PHP CS Fixer', self::VERSION);
Expand Down
10 changes: 5 additions & 5 deletions tests/Fixer/CastNotation/LowercaseCastFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace PhpCsFixer\Tests\Fixer\CastNotation;

use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author SpacePossum
Expand All @@ -23,6 +24,8 @@
*/
final class LowercaseCastFixerTest extends AbstractFixerTestCase
{
use ExpectDeprecationTrait;

/**
* @param string $expected
* @param null|string $input
Expand Down Expand Up @@ -55,14 +58,11 @@ public function testFix74($expected, $input = null)
* @dataProvider provideFixDeprecatedCases
* @requires PHP 7.4
* @group legacy
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
*/
public function testFix74Deprecated($expected, $input = null)
{
$this->expectDeprecation('The (real) cast is deprecated, use (float) instead');

$this->doTest($expected, $input);
}

Expand Down
6 changes: 5 additions & 1 deletion tests/Fixer/CastNotation/ShortScalarCastFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace PhpCsFixer\Tests\Fixer\CastNotation;

use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author SpacePossum
Expand All @@ -23,6 +24,8 @@
*/
final class ShortScalarCastFixerTest extends AbstractFixerTestCase
{
use ExpectDeprecationTrait;

/**
* @param string $expected
* @param null|string $input
Expand Down Expand Up @@ -55,10 +58,11 @@ public function testFix74($expected, $input = null)
* @dataProvider provideFixDeprecatedCases
* @requires PHP 7.4
* @group legacy
* @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
*/
public function testFix74Deprecated($expected, $input = null)
{
$this->expectDeprecation('The (real) cast is deprecated, use (float) instead');

$this->doTest($expected, $input);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Fixer/Comment/HeaderCommentFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public function testLegacyMisconfiguration()
public function testMisconfiguration($configuration, $exceptionMessage)
{
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
$this->expectExceptionMessage('[header_comment] '.$exceptionMessage);
$this->expectExceptionMessageRegExp("#^\\[header_comment\\] {$exceptionMessage}$#");

$this->configureFixerWithAliasedOptions($configuration);
}
Expand All @@ -528,35 +528,35 @@ public function provideMisconfigurationCases()
[[], 'Missing required configuration: The required option "header" is missing.'],
[
['header' => 1],
'Invalid configuration: The option "header" with value 1 is expected to be of type "string", but is of type "integer".',
'Invalid configuration: The option "header" with value 1 is expected to be of type "string", but is of type "(int|integer)"\.',
],
[
[
'header' => '',
'comment_type' => 'foo',
],
'Invalid configuration: The option "comment_type" with value "foo" is invalid. Accepted values are: "PHPDoc", "comment".',
'Invalid configuration: The option "comment_type" with value "foo" is invalid\. Accepted values are: "PHPDoc", "comment"\.',
],
[
[
'header' => '',
'comment_type' => new \stdClass(),
],
'Invalid configuration: The option "comment_type" with value stdClass is invalid. Accepted values are: "PHPDoc", "comment".',
'Invalid configuration: The option "comment_type" with value stdClass is invalid\. Accepted values are: "PHPDoc", "comment"\.',
],
[
[
'header' => '',
'location' => new \stdClass(),
],
'Invalid configuration: The option "location" with value stdClass is invalid. Accepted values are: "after_open", "after_declare_strict".',
'Invalid configuration: The option "location" with value stdClass is invalid\. Accepted values are: "after_open", "after_declare_strict"\.',
],
[
[
'header' => '',
'separate' => new \stdClass(),
],
'Invalid configuration: The option "separate" with value stdClass is invalid. Accepted values are: "both", "top", "bottom", "none".',
'Invalid configuration: The option "separate" with value stdClass is invalid\. Accepted values are: "both", "top", "bottom", "none"\.',
],
];
}
Expand Down
10 changes: 3 additions & 7 deletions tests/Fixer/ControlStructure/YodaStyleFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,7 @@ public function testComplexConfiguration()
public function testInvalidConfig(array $config, $expectedMessage)
{
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
$this->expectExceptionMessageRegExp(sprintf(
'#^\[%s\] %s$#',
$this->fixer->getName(),
preg_quote($expectedMessage, '#')
));
$this->expectExceptionMessageRegExp("#^\\[{$this->fixer->getName()}\\] {$expectedMessage}$#");

$this->fixer->configure($config);
}
Expand All @@ -715,8 +711,8 @@ public function testInvalidConfig(array $config, $expectedMessage)
public function provideInvalidConfigurationCases()
{
return [
[['equal' => 2], 'Invalid configuration: The option "equal" with value 2 is expected to be of type "bool" or "null", but is of type "integer".'],
[['_invalid_' => true], 'Invalid configuration: The option "_invalid_" does not exist. Defined options are: "always_move_variable", "equal", "identical", "less_and_greater".'],
[['equal' => 2], 'Invalid configuration: The option "equal" with value 2 is expected to be of type "bool" or "null", but is of type "(int|integer)"\.'],
[['_invalid_' => true], 'Invalid configuration: The option "_invalid_" does not exist\. Defined options are: "always_move_variable", "equal", "identical", "less_and_greater"\.'],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/LanguageConstruct/IsNullFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testConfigurationWrongOption()
public function testConfigurationWrongValue()
{
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
$this->expectExceptionMessage('[is_null] Invalid configuration: The option "use_yoda_style" with value -1 is expected to be of type "bool", but is of type "integer".');
$this->expectExceptionMessageRegExp('#^\[is_null\] Invalid configuration: The option "use_yoda_style" with value -1 is expected to be of type "bool", but is of type "(int|integer)"\.$#');
$this->fixer->configure(['use_yoda_style' => -1]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public function testWrongConfigTypeForOperators()
{
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
$this->expectExceptionMessageRegExp(
'/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "boolean"\.$/'
'/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "(bool|boolean)"\.$/'
);

$this->fixer->configure(['operators' => true]);
Expand Down
41 changes: 28 additions & 13 deletions tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,47 @@ public function testConfigureRejectsUnknownConfigurationKey()
/**
* @dataProvider provideConfigureRejectsInvalidConfigurationValueCases
*
* @param mixed $value
* @param mixed $value
* @param string $expectedMessage
*/
public function testConfigureRejectsInvalidConfigurationValue($value)
public function testConfigureRejectsInvalidConfigurationValue($value, $expectedMessage)
{
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidConfigurationException::class);
$this->expectExceptionMessage(sprintf(
'expected to be of type "bool", but is of type "%s".',
\is_object($value) ? \get_class($value) : \gettype($value)
));
$this->expectExceptionMessageRegExp($expectedMessage);

$this->fixer->configure([
'only_untyped' => $value,
]);
}

/**
* @return array
* @return iterable<string, array>
*/
public function provideConfigureRejectsInvalidConfigurationValueCases()
{
return [
'null' => [null],
'int' => [1],
'array' => [[]],
'float' => [0.1],
'object' => [new \stdClass()],
yield 'null' => [
null,
'#expected to be of type "bool", but is of type "(null|NULL)"\.$#',
];

yield 'int' => [
1,
'#expected to be of type "bool", but is of type "(int|integer)"\.$#',
];

yield 'array' => [
[],
'#expected to be of type "bool", but is of type "array"\.$#',
];

yield 'float' => [
0.1,
'#expected to be of type "bool", but is of type "(float|double)"\.$#',
];

yield 'object' => [
new \stdClass(),
'#expected to be of type "bool", but is of type "stdClass"\.$#',
];
}

Expand Down

0 comments on commit 0d06f47

Please sign in to comment.