|
@@ -332,12 +332,14 @@ EOT
|
|
|
/**
|
|
|
* @param string $expected
|
|
|
* @param null|string $input
|
|
|
+ * @param array $configuration
|
|
|
*
|
|
|
* @dataProvider provideFix71Cases
|
|
|
* @requires PHP 7.1
|
|
|
*/
|
|
|
- public function testFix71($expected, $input = null)
|
|
|
+ public function testFix71(array $configuration, $expected, $input = null)
|
|
|
{
|
|
|
+ $this->fixer->configure($configuration);
|
|
|
$this->doTest($expected, $input);
|
|
|
}
|
|
|
|
|
@@ -345,13 +347,14 @@ EOT
|
|
|
{
|
|
|
return [
|
|
|
[
|
|
|
+ [],
|
|
|
<<<'EOT'
|
|
|
<?php
|
|
|
|
|
|
class Foo
|
|
|
{
|
|
|
- public const C1 = 1;
|
|
|
const C2 = 2;
|
|
|
+ public const C1 = 1;
|
|
|
public const C3 = 3;
|
|
|
protected const C4 = 4;
|
|
|
private const C5 = 5;
|
|
@@ -363,10 +366,37 @@ EOT
|
|
|
class Foo
|
|
|
{
|
|
|
private const C5 = 5;
|
|
|
+ const C2 = 2;
|
|
|
public const C1 = 1;
|
|
|
protected const C4 = 4;
|
|
|
+ public const C3 = 3;
|
|
|
+}
|
|
|
+EOT
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ ['sortAlgorithm' => 'alpha'],
|
|
|
+ <<<'EOT'
|
|
|
+<?php
|
|
|
+
|
|
|
+class Foo
|
|
|
+{
|
|
|
+ public const C1 = 1;
|
|
|
const C2 = 2;
|
|
|
public const C3 = 3;
|
|
|
+ protected const C4 = 4;
|
|
|
+ private const C5 = 5;
|
|
|
+}
|
|
|
+EOT
|
|
|
+ , <<<'EOT'
|
|
|
+<?php
|
|
|
+
|
|
|
+class Foo
|
|
|
+{
|
|
|
+ private const C5 = 5;
|
|
|
+ const C2 = 2;
|
|
|
+ public const C1 = 1;
|
|
|
+ protected const C4 = 4;
|
|
|
+ public const C3 = 3;
|
|
|
}
|
|
|
EOT
|
|
|
],
|
|
@@ -596,6 +626,171 @@ EOT
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param array $configuration
|
|
|
+ * @param string $input
|
|
|
+ * @param string $expected
|
|
|
+ *
|
|
|
+ * @dataProvider provideSortingConfigurationCases
|
|
|
+ */
|
|
|
+ public function testFixWithSortingAlhorithm(array $configuration, $input, $expected)
|
|
|
+ {
|
|
|
+ $this->fixer->configure($configuration);
|
|
|
+ $this->doTest($expected, $input);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function provideSortingConfigurationCases()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ [
|
|
|
+ [
|
|
|
+ 'order' => [
|
|
|
+ 'property_public_static',
|
|
|
+ 'method_public',
|
|
|
+ 'method_private',
|
|
|
+ ],
|
|
|
+ 'sortAlgorithm' => 'alpha',
|
|
|
+ ],
|
|
|
+ <<<'EOT'
|
|
|
+<?php
|
|
|
+class Example
|
|
|
+{
|
|
|
+ public function D(){}
|
|
|
+ public static $pubStatProp2;
|
|
|
+ public function B1(){}
|
|
|
+ public function B2(){}
|
|
|
+ private function E(){}
|
|
|
+ public static $pubStatProp1;
|
|
|
+ public function A(){}
|
|
|
+ public function C(){}
|
|
|
+ public function C1(){}
|
|
|
+}
|
|
|
+EOT
|
|
|
+ ,
|
|
|
+ <<<'EOT'
|
|
|
+<?php
|
|
|
+class Example
|
|
|
+{
|
|
|
+ public static $pubStatProp1;
|
|
|
+ public static $pubStatProp2;
|
|
|
+ public function A(){}
|
|
|
+ public function B1(){}
|
|
|
+ public function B2(){}
|
|
|
+ public function C(){}
|
|
|
+ public function C1(){}
|
|
|
+ public function D(){}
|
|
|
+ private function E(){}
|
|
|
+}
|
|
|
+EOT
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ [
|
|
|
+ 'order' => [
|
|
|
+ 'use_trait',
|
|
|
+ 'constant',
|
|
|
+ 'property_public_static',
|
|
|
+ 'property_protected_static',
|
|
|
+ 'property_private_static',
|
|
|
+ 'property_public',
|
|
|
+ 'property_protected',
|
|
|
+ 'property_private',
|
|
|
+ 'construct',
|
|
|
+ 'destruct',
|
|
|
+ 'magic',
|
|
|
+ 'method_public_static',
|
|
|
+ 'method_protected_static',
|
|
|
+ 'method_private_static',
|
|
|
+ 'method_public',
|
|
|
+ 'method_protected',
|
|
|
+ 'method_private',
|
|
|
+ ],
|
|
|
+ 'sortAlgorithm' => 'alpha',
|
|
|
+ ],
|
|
|
+ <<<'EOT'
|
|
|
+<?php
|
|
|
+class Foo
|
|
|
+{
|
|
|
+ private static function privStatFunc() {}
|
|
|
+ protected static $protStatProp;
|
|
|
+ use BazTrait;
|
|
|
+ public static $pubStatProp2;
|
|
|
+ public $pubProp3;
|
|
|
+ use BarTrait;
|
|
|
+ public function __toString() {}
|
|
|
+ protected function protFunc() {}
|
|
|
+ protected $protProp;
|
|
|
+ function pubFunc2() {}
|
|
|
+ public $pubProp1;
|
|
|
+ public function __destruct() {}
|
|
|
+ var $pubProp2;
|
|
|
+ public function __magicB() {}
|
|
|
+ const C2 = 2;
|
|
|
+ public static $pubStatProp1;
|
|
|
+ public function __magicA() {}
|
|
|
+ private static $privStatProp;
|
|
|
+ static function pubStatFunc2() {}
|
|
|
+ public function pubFunc3(int $b, int $c) {
|
|
|
+ $a = $b*$c;
|
|
|
+
|
|
|
+ return $a % 4;
|
|
|
+ }
|
|
|
+ private $privProp;
|
|
|
+ const C1 = 1;
|
|
|
+ public static function pubStatFunc3() {
|
|
|
+ return $this->privFunc();
|
|
|
+ }
|
|
|
+ public function pubFunc1() {}
|
|
|
+ public static function pubStatFunc1() {}
|
|
|
+ private function privFunc() {}
|
|
|
+ protected function __construct() {}
|
|
|
+ protected static function protStatFunc() {}
|
|
|
+}
|
|
|
+EOT
|
|
|
+ ,
|
|
|
+ <<<'EOT'
|
|
|
+<?php
|
|
|
+class Foo
|
|
|
+{
|
|
|
+ use BarTrait;
|
|
|
+ use BazTrait;
|
|
|
+ const C1 = 1;
|
|
|
+ const C2 = 2;
|
|
|
+ public static $pubStatProp1;
|
|
|
+ public static $pubStatProp2;
|
|
|
+ protected static $protStatProp;
|
|
|
+ private static $privStatProp;
|
|
|
+ public $pubProp1;
|
|
|
+ var $pubProp2;
|
|
|
+ public $pubProp3;
|
|
|
+ protected $protProp;
|
|
|
+ private $privProp;
|
|
|
+ protected function __construct() {}
|
|
|
+ public function __destruct() {}
|
|
|
+ public function __magicA() {}
|
|
|
+ public function __magicB() {}
|
|
|
+ public function __toString() {}
|
|
|
+ public static function pubStatFunc1() {}
|
|
|
+ static function pubStatFunc2() {}
|
|
|
+ public static function pubStatFunc3() {
|
|
|
+ return $this->privFunc();
|
|
|
+ }
|
|
|
+ protected static function protStatFunc() {}
|
|
|
+ private static function privStatFunc() {}
|
|
|
+ public function pubFunc1() {}
|
|
|
+ function pubFunc2() {}
|
|
|
+ public function pubFunc3(int $b, int $c) {
|
|
|
+ $a = $b*$c;
|
|
|
+
|
|
|
+ return $a % 4;
|
|
|
+ }
|
|
|
+ protected function protFunc() {}
|
|
|
+ private function privFunc() {}
|
|
|
+}
|
|
|
+EOT
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
public function testWrongConfig()
|
|
|
{
|
|
|
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
|