Skip to content

Commit

Permalink
Fix phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
moririnson committed May 1, 2023
1 parent 4661c93 commit 3544b41
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static function createBodyInfoBlock(): FlexBox
]),
],
]);

return new FlexBox([
'type' => ComponentType::BOX,
'layout' => ComponentLayout::VERTICAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function handle()
$this->replyMessage($replyToken, $templateMessage);
break;
case 'imagemap':
$richMessageUrl = UrlBuilder::buildUrl($this->req, ['static', 'rich']);
$richMessageUrl = UrlBuilder::buildUrl($this->req, ['static', 'rich']);
$imagemapMessage = new ImagemapMessage([
'type' => MessageType::IMAGEMAP,
'baseUrl' => $richMessageUrl,
Expand Down Expand Up @@ -353,7 +353,7 @@ public function handle()
$this->replyMessage($replyToken, $imagemapMessage);
break;
case 'restaurant':
$this->replyMessage($replyToken, FlexSampleRestaurant::get());
$this->replyMessage($replyToken, FlexSampleRestaurant::get());
break;
case 'shopping':
$this->replyMessage($replyToken, FlexSampleShopping::get());
Expand Down Expand Up @@ -472,7 +472,8 @@ private function sendProfile($replyToken, $userId)
);
}

private function replyText(string $replyToken, string $text) {
private function replyText(string $replyToken, string $text)
{
$textMessage = (new TextMessage(['text' => $text, 'type' => MessageType::TEXT]));
return $this->replyMessage($replyToken, $textMessage);
}
Expand Down
25 changes: 25 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="PHP_CodeSniffer"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>The coding standard for line-bot-sdk-php.</description>

<file>src/constants</file>
<file>src/laravel</file>
<file>src/parser</file>
<file>examples/EchoBot/src</file>
<file>examples/EchoBot/public</file>
<file>examples/KitchenSink/src</file>
<file>examples/KitchenSink/public</file>

<arg name="basepath" value="."/>
<arg name="colors"/>
<arg name="parallel" value="75"/>
<arg value="np"/>

<!-- Use PSR-12 Standard: https://www.php-fig.org/psr/psr-12/ -->
<rule ref="PSR12">
<!-- TODO: Enable this rule once we require PHP version >= 7.1 -->
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
</rule>
</ruleset>
21 changes: 14 additions & 7 deletions src/Laravel/lib/LINEBotServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public function register()
$this->bindMessagingBlobApi();
}

private function bindChannelAccessTokenApi() {
private function bindChannelAccessTokenApi()
{
$this->app->bind('line-bot-channel-access-token-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new ChannelAccessTokenConfiguration();
Expand All @@ -70,7 +71,8 @@ private function bindChannelAccessTokenApi() {
});
}

private function bindInsightApi() {
private function bindInsightApi()
{
$this->app->bind('line-bot-insight-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new InsightConfiguration();
Expand All @@ -82,7 +84,8 @@ private function bindInsightApi() {
});
}

private function bindLiffApi() {
private function bindLiffApi()
{
$this->app->bind('line-bot-liff-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new LiffConfiguration();
Expand All @@ -94,7 +97,8 @@ private function bindLiffApi() {
});
}

private function bindManageAudienceApi() {
private function bindManageAudienceApi()
{
$this->app->bind('line-bot-manage-audience-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new ManageAudienceConfiguration();
Expand All @@ -106,7 +110,8 @@ private function bindManageAudienceApi() {
});
}

private function bindManageAudienceBlobApi() {
private function bindManageAudienceBlobApi()
{
$this->app->bind('line-bot-manage-audience-blob-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new ManageAudienceConfiguration();
Expand All @@ -118,7 +123,8 @@ private function bindManageAudienceBlobApi() {
});
}

private function bindMessagingApi() {
private function bindMessagingApi()
{
$this->app->bind('line-bot-messaging-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new MessagingApiConfiguration();
Expand All @@ -130,7 +136,8 @@ private function bindMessagingApi() {
});
}

private function bindMessagingBlobApi() {
private function bindMessagingBlobApi()
{
$this->app->bind('line-bot-messaging-blob-api', function ($app) {
$httpClient = $app->make('line-bot-http-client');
$config = new MessagingApiConfiguration();
Expand Down
6 changes: 3 additions & 3 deletions src/parser/lib/EventRequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class EventRequestParser
'group' => 'LINE\Webhook\Model\GroupSource',
'room' => 'LINE\Webhook\Model\RoomSource',
];

private static $thingsContentType2class = [
'link' => '\LINE\Webhook\Model\LinkThingsContent',
'unlink' => '\LINE\Webhook\Model\UnlinkThingsContent',
Expand Down Expand Up @@ -218,7 +218,7 @@ private static function parseMessageContent($eventData): MessageContent
$contentProvider = new ContentProvider($eventData['message']['contentProvider']);
$message->setContentProvider($contentProvider);
}

if ($message instanceof TextMessageContent) {
$emojis = array_map(function ($emoji) {
return new Emoji($emoji);
Expand Down Expand Up @@ -265,7 +265,7 @@ private static function parseSource($eventData): Source
$sourceClass = self::$sourceType2class[$sourceType];
return new $sourceClass($eventData['source']);
}

/**
* @param array $eventData
* @return ThingsContent
Expand Down
1 change: 1 addition & 0 deletions src/parser/lib/Source/UnknownSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

namespace LINE\Parser\Source;

use LINE\Webhook\Model\Source;

/**
Expand Down
1 change: 1 addition & 0 deletions src/parser/lib/ThingsContent/UnknownThingsContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

namespace LINE\Parser\Source;

use LINE\Webhook\Model\Source;
use LINE\Webhook\Model\ThingsContent;

Expand Down
28 changes: 14 additions & 14 deletions src/parser/test/EventRequestParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(12345678901234, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand All @@ -912,7 +912,7 @@ public function testParseEventRequest()
// image
$event = $events[1];
$source = $event->getSource();
$this->assertTrue($source instanceOf GroupSource);
$this->assertTrue($source instanceof GroupSource);
$this->assertEquals('groupid', $source->getGroupId());
$this->assertEquals(null, $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
Expand Down Expand Up @@ -944,7 +944,7 @@ public function testParseEventRequest()
// audio (group event & it has user ID)
$event = $events[2];
$source = $event->getSource();
$this->assertTrue($source instanceOf GroupSource);
$this->assertTrue($source instanceof GroupSource);
$this->assertEquals('groupid', $source->getGroupId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand All @@ -967,7 +967,7 @@ public function testParseEventRequest()
// video
$event = $events[3];
$source = $event->getSource();
$this->assertTrue($source instanceOf RoomSource);
$this->assertTrue($source instanceof RoomSource);
$this->assertEquals('roomid', $source->getRoomId());
$this->assertEquals(null, $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
Expand All @@ -993,7 +993,7 @@ public function testParseEventRequest()
// audio
$event = $events[4];
$source = $event->getSource();
$this->assertTrue($source instanceOf RoomSource);
$this->assertTrue($source instanceof RoomSource);
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand Down Expand Up @@ -1153,7 +1153,7 @@ public function testParseEventRequest()
$this->assertEquals('bid', $event->getBeacon()->getHwid());
$this->assertEquals('enter', $event->getBeacon()->getType());
$this->assertEquals(
"1234567890abcdef",
"1234567890abcdef",
$event->getBeacon()->getDm()
);
}
Expand All @@ -1171,7 +1171,7 @@ public function testParseEventRequest()
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
$this->assertEquals(true, $source instanceOf UserSource);
$this->assertEquals(true, $source instanceof UserSource);
}

{
Expand Down Expand Up @@ -1371,7 +1371,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(12345678901234, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand Down Expand Up @@ -1415,7 +1415,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(1462629479859, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('U4af4980629...', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand All @@ -1439,7 +1439,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(1462629479859, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('U0123456789abcd0123456789abcdef', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand All @@ -1462,7 +1462,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(1462629479859, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('U0123456789abcd0123456789abcdef', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertFalse($event->getDeliveryContext()->getIsRedelivery());
Expand All @@ -1480,7 +1480,7 @@ public function testParseEventRequest()
// Only included when multiple images are sent simultaneously.
$event = $events[36];
$source = $event->getSource();
$this->assertTrue($source instanceOf GroupSource);
$this->assertTrue($source instanceof GroupSource);
$this->assertEquals('groupid', $source->getGroupId());
$this->assertEquals(null, $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
Expand All @@ -1507,7 +1507,7 @@ public function testParseEventRequest()
// However, it won't be included if the sender is using LINE 11.15 or earlier for Android.
$event = $events[37];
$source = $event->getSource();
$this->assertTrue($source instanceOf GroupSource);
$this->assertTrue($source instanceof GroupSource);
$this->assertEquals('groupid', $source->getGroupId());
$this->assertEquals(null, $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
Expand Down Expand Up @@ -1541,7 +1541,7 @@ public function testParseEventRequest()
$source = $event->getSource();
$this->assertEquals(12345678901234, $event->getTimestamp());
$this->assertEquals('active', $event->getMode());
$this->assertTrue($source instanceOf UserSource);
$this->assertTrue($source instanceof UserSource);
$this->assertEquals('userid', $source->getUserId());
$this->assertEquals('testwebhookeventid', $event->getWebhookEventId());
$this->assertTrue($event->getDeliveryContext()->getIsRedelivery());
Expand Down

0 comments on commit 3544b41

Please sign in to comment.