LoginSignup
0
0

More than 5 years have passed since last update.

Symplify\CodingStandard 5系で追加されたFixerたち

Posted at

Symplify/CodingStandardに追加されたFixerたちを軽く紹介する。

PrivateMethodOrderByUseFixer v5.2.0

privateメソッドの定義の順番を、使われている順に合わせるよ。

 class SomeClass
 {
     public function run()
     {
         $this->call1();
         $this->call2();
     }

         $this->call2();
     }

-    private function call2()
+    private function call1()
     {
     }

-    private function call1()
+    private function call2()
     {
     }
 }

PropertyOrderByComplexityFixer v5.2.0

プロパティを可視性(publicprivate)で並び替えたあとに、型の複雑さ(プリミティブ→クラス)でも並び替えするよ。

 class SomeClass
 {
-    /** @var DateTime */
-    private $date;

     /** @var string */
     private $name;

+    /** @var int */
+    private $price;

+    /** @var DateTime */
+    private $date;

     /** @var Service */
     private $service;
-
-    /** @var int */
-    private $price;
 }

ParamReturnAndVarTagMalformsFixer v5.2.11

phpdocの@param@return@varの表記ゆれをなくすよ。

 /**
- * @param $name string
- * @return int $value
+ * @param string $name
+ * @return int
  */
 function someFunction($name)
 {
 }

 class SomeClass
 {
     /**
-     * @var int $property
+     * @var int
      */
     private $property;
 }

-/* @var int $value */
+/** @var int $value */
 $value = 5;

-/** @var $value int */
+/** @var int $value */
 $value = 5;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0