From 604b316151e2de8885cd690d8fb4f409aed4742c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E7=9D=BF=E6=B6=9B?= Date: Fri, 20 Jul 2018 16:22:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=B1=BB=E6=95=B0=E7=BB=84=E4=B8=AD?= =?UTF-8?q?=E9=94=AE=E5=90=8D=E6=98=AF=E9=AD=94=E6=9C=AF=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E8=A7=A6=E5=8F=91warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Changes/v5dot6/IncompPropertyArray.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Changes/v5dot6/IncompPropertyArray.php b/src/Changes/v5dot6/IncompPropertyArray.php index 8d74c9e..cfba2a0 100644 --- a/src/Changes/v5dot6/IncompPropertyArray.php +++ b/src/Changes/v5dot6/IncompPropertyArray.php @@ -6,6 +6,7 @@ use PhpParser\Node\Expr; use PhpParser\Node\Scalar; use PhpParser\Node\Stmt; +use PhpParser\Node\Scalar\MagicConst; class IncompPropertyArray extends AbstractChange { @@ -41,7 +42,9 @@ public function leaveNode($node) } } elseif ($stmt instanceof Stmt\ClassConst) { foreach ($stmt->consts as $const) { - if ($const->value instanceof Scalar) { + if ($const->value instanceof MagicConst) { + $const_table['self::'.$const->name] = $const->value->getName(); + } elseif ($const->value instanceof Scalar) { $const_table['self::'.$const->name] = $const->value->value; } } From b890bc8e3853eacadb7c68b9af18f72f4adb3e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E7=9D=BF=E6=B6=9B?= Date: Fri, 20 Jul 2018 16:22:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=B1=BB=E6=95=B0=E7=BB=84=E4=B8=AD?= =?UTF-8?q?=E9=94=AE=E5=90=8D=E6=98=AF=E9=AD=94=E6=9C=AF=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E8=A7=A6=E5=8F=91warning=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Changes/v5dot6/IncompPropertyArrayTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Changes/v5dot6/IncompPropertyArrayTest.php b/tests/Changes/v5dot6/IncompPropertyArrayTest.php index eb58329..115e331 100644 --- a/tests/Changes/v5dot6/IncompPropertyArrayTest.php +++ b/tests/Changes/v5dot6/IncompPropertyArrayTest.php @@ -91,6 +91,18 @@ class Sample 'third' => 0, ); } +EOC; + $this->assertNotSpot($code); + + // MagicConst trigger warning + $code = <<<'EOC' +class Sample +{ + const LOGTAG = __FUNCTION__; + public $data = array( + self::LOGTAG => 1 + ); +} EOC; $this->assertNotSpot($code); } From ca2302e34699c750a400ea0a60a1827a1ca79117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E7=9D=BF=E6=B6=9B?= Date: Fri, 20 Jul 2018 16:34:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=8E=AB=E5=90=8D=E5=85=B6=E5=A6=99?= =?UTF-8?q?=E7=9A=84=E6=B2=A1=E9=80=9A=E8=BF=87=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Changes/v5dot6/IncompPropertyArray.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Changes/v5dot6/IncompPropertyArray.php b/src/Changes/v5dot6/IncompPropertyArray.php index cfba2a0..02306c6 100644 --- a/src/Changes/v5dot6/IncompPropertyArray.php +++ b/src/Changes/v5dot6/IncompPropertyArray.php @@ -3,10 +3,10 @@ namespace PhpMigration\Changes\v5dot6; use PhpMigration\Changes\AbstractChange; +use PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Expr; use PhpParser\Node\Scalar; use PhpParser\Node\Stmt; -use PhpParser\Node\Scalar\MagicConst; class IncompPropertyArray extends AbstractChange { From 684671ab69e54a9d4101eae4ba55b50acf2fc531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E7=9D=BF=E6=B6=9B?= Date: Fri, 20 Jul 2018 16:39:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=8E=AB=E5=90=8D=E5=85=B6=E5=A6=99?= =?UTF-8?q?=E7=9A=84=E6=B2=A1=E9=80=9A=E8=BF=87=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Changes/v5dot6/IncompPropertyArray.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Changes/v5dot6/IncompPropertyArray.php b/src/Changes/v5dot6/IncompPropertyArray.php index 02306c6..3824119 100644 --- a/src/Changes/v5dot6/IncompPropertyArray.php +++ b/src/Changes/v5dot6/IncompPropertyArray.php @@ -3,7 +3,6 @@ namespace PhpMigration\Changes\v5dot6; use PhpMigration\Changes\AbstractChange; -use PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Expr; use PhpParser\Node\Scalar; use PhpParser\Node\Stmt; @@ -42,7 +41,7 @@ public function leaveNode($node) } } elseif ($stmt instanceof Stmt\ClassConst) { foreach ($stmt->consts as $const) { - if ($const->value instanceof MagicConst) { + if ($const->value instanceof Scalar\MagicConst) { $const_table['self::'.$const->name] = $const->value->getName(); } elseif ($const->value instanceof Scalar) { $const_table['self::'.$const->name] = $const->value->value;