From 5aaf72f303f328c2b46a0773f91fd28c5f16fa98 Mon Sep 17 00:00:00 2001 From: eucyt Date: Tue, 24 Dec 2024 10:23:01 +0900 Subject: [PATCH 1/3] Support phpstan 2.0 --- composer.json | 2 +- .../MessageHandler/Flex/FlexSampleRestaurant.php | 2 +- .../MessageHandler/Flex/FlexSampleShopping.php | 2 +- .../EventHandler/MessageHandler/ImageMessageHandler.php | 2 +- .../EventHandler/MessageHandler/TextMessageHandler.php | 6 +++--- src/laravel/test/Facades/FacadesTest.php | 8 ++++---- src/parser/lib/EventRequestParser.php | 2 +- src/parser/test/EventRequestParserTest.php | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 1fac9ffc..eac621da 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "orchestra/testbench": "*", "guzzlehttp/guzzle": "^7.3", "guzzlehttp/psr7": "^1.7 || ^2.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^10.2" }, "autoload": { diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php index 7576c589..89dcf20d 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php @@ -49,7 +49,7 @@ use LINE\Constants\MessageType; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") */ class FlexSampleRestaurant { diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php index e3b5c174..62994e2c 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php @@ -43,7 +43,7 @@ use LINE\Constants\MessageType; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") */ class FlexSampleShopping { diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/ImageMessageHandler.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/ImageMessageHandler.php index f3306ea2..33537a2a 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/ImageMessageHandler.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/ImageMessageHandler.php @@ -30,7 +30,7 @@ use LINE\Webhook\Model\MessageEvent; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") */ class ImageMessageHandler implements EventHandler { diff --git a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/TextMessageHandler.php b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/TextMessageHandler.php index ad7b666b..4c68291e 100644 --- a/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/TextMessageHandler.php +++ b/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/TextMessageHandler.php @@ -57,9 +57,9 @@ use LINE\Webhook\Model\TextMessageContent; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") + * @SuppressWarnings("PHPMD.CyclomaticComplexity") + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ class TextMessageHandler implements EventHandler { diff --git a/src/laravel/test/Facades/FacadesTest.php b/src/laravel/test/Facades/FacadesTest.php index 50d6098c..c306df92 100644 --- a/src/laravel/test/Facades/FacadesTest.php +++ b/src/laravel/test/Facades/FacadesTest.php @@ -19,14 +19,14 @@ namespace LINE\Laravel\Tests\Facades; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") */ class FacadesTest extends \Orchestra\Testbench\TestCase { /** * Load package service provider * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.UnusedFormalParameter") * @param \Illuminate\Foundation\Application $app * @return array */ @@ -38,7 +38,7 @@ protected function getPackageProviders($app) /** * Load package alias * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.UnusedFormalParameter") * @param \Illuminate\Foundation\Application $app * @return array */ @@ -69,7 +69,7 @@ public function testConfigLoaded() /** * Testing LINEBot facade instance * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.UnusedFormalParameter") * @return void */ public function testLINEBotFacadeInstance() diff --git a/src/parser/lib/EventRequestParser.php b/src/parser/lib/EventRequestParser.php index e64bc275..5317560d 100644 --- a/src/parser/lib/EventRequestParser.php +++ b/src/parser/lib/EventRequestParser.php @@ -44,7 +44,7 @@ use LINE\Webhook\Model\UserMentionee; /** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings("PHPMD.CouplingBetweenObjects") */ class EventRequestParser { diff --git a/src/parser/test/EventRequestParserTest.php b/src/parser/test/EventRequestParserTest.php index 58f8eb69..28430f0b 100644 --- a/src/parser/test/EventRequestParserTest.php +++ b/src/parser/test/EventRequestParserTest.php @@ -1234,7 +1234,7 @@ public function testParseEventRequest() $this->assertEquals('__unknown__', $event->jsonSerialize()->type); // with unprocessed event body $this->assertEquals(12345678901234, $event->getTimestamp()); $this->assertEquals('active', $event->getMode()); - $this->assertTrue($source instanceof UserSource); + $this->assertInstanceOf(UserSource::class, $source); $this->assertEquals('userid', $source->getUserId()); $this->assertEquals('testwebhookeventid', $event->getWebhookEventId()); $this->assertFalse($event->getDeliveryContext()->getIsRedelivery()); From 84ea016be516800eb45e50cf46b6a0b95177bb5d Mon Sep 17 00:00:00 2001 From: eucyt Date: Tue, 24 Dec 2024 10:33:45 +0900 Subject: [PATCH 2/3] Remove duplicate assertion --- src/parser/test/EventRequestParserTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/parser/test/EventRequestParserTest.php b/src/parser/test/EventRequestParserTest.php index 28430f0b..7967bc92 100644 --- a/src/parser/test/EventRequestParserTest.php +++ b/src/parser/test/EventRequestParserTest.php @@ -1238,7 +1238,6 @@ public function testParseEventRequest() $this->assertEquals('userid', $source->getUserId()); $this->assertEquals('testwebhookeventid', $event->getWebhookEventId()); $this->assertFalse($event->getDeliveryContext()->getIsRedelivery()); - $this->assertEquals(true, $source instanceof UserSource); } { From 5d2c5db4e17c9a4602f641d01b70f0dc45bd1ff2 Mon Sep 17 00:00:00 2001 From: eucyt Date: Tue, 24 Dec 2024 10:55:29 +0900 Subject: [PATCH 3/3] Fix docs --- docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html | 8 ++++---- docs/classes/LINE-Parser-EventRequestParser.html | 2 +- .../classes/LINE-Parser-Tests-EventRequestParserTest.html | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html b/docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html index 608157d3..27954284 100644 --- a/docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html +++ b/docs/classes/LINE-Laravel-Tests-Facades-FacadesTest.html @@ -167,7 +167,7 @@
-

(PHPMD.CouplingBetweenObjects)

+

("PHPMD.CouplingBetweenObjects")

@@ -294,7 +294,7 @@
-

(PHPMD.UnusedFormalParameter)

+

("PHPMD.UnusedFormalParameter")

@@ -352,7 +352,7 @@
-

(PHPMD.UnusedFormalParameter)

+

("PHPMD.UnusedFormalParameter")

@@ -410,7 +410,7 @@
-

(PHPMD.UnusedFormalParameter)

+

("PHPMD.UnusedFormalParameter")

diff --git a/docs/classes/LINE-Parser-EventRequestParser.html b/docs/classes/LINE-Parser-EventRequestParser.html index 4ab2d6fd..c1e1a3fa 100644 --- a/docs/classes/LINE-Parser-EventRequestParser.html +++ b/docs/classes/LINE-Parser-EventRequestParser.html @@ -162,7 +162,7 @@
-

(PHPMD.CouplingBetweenObjects)

+

("PHPMD.CouplingBetweenObjects")

diff --git a/docs/classes/LINE-Parser-Tests-EventRequestParserTest.html b/docs/classes/LINE-Parser-Tests-EventRequestParserTest.html index 83b6fe14..d24c9fab 100644 --- a/docs/classes/LINE-Parser-Tests-EventRequestParserTest.html +++ b/docs/classes/LINE-Parser-Tests-EventRequestParserTest.html @@ -1223,7 +1223,7 @@