From 3fc2f8e227c38b7e0618f2f05de9491b2547056d Mon Sep 17 00:00:00 2001 From: Martin San Juan Date: Mon, 30 Mar 2020 19:18:19 -0300 Subject: [PATCH] build: fix style and phpstan --- .php_cs | 1 + src/Api/Domain.php | 1 - src/Api/HttpApi.php | 6 +++--- src/Api/Ip.php | 6 ------ src/Api/MailingList/Member.php | 6 +----- src/Api/Message.php | 2 +- src/Api/Suppression.php | 2 +- src/Api/Tag.php | 3 --- src/Api/Webhook.php | 4 ++-- src/Mailgun.php | 4 ++-- src/Model/Domain/AbstractDomainResponse.php | 2 +- src/Model/Event/EventResponse.php | 4 ++-- src/Model/MailingList/Member/IndexResponse.php | 4 ++-- src/Model/MailingList/PagesResponse.php | 4 ++-- src/Model/Suppression/BaseResponse.php | 2 +- src/Model/Webhook/BaseResponse.php | 2 +- tests/Api/TagTest.php | 1 - tests/Api/WebhookTest.php | 4 ++-- 18 files changed, 22 insertions(+), 36 deletions(-) diff --git a/.php_cs b/.php_cs index 4bc5c37..c46d688 100644 --- a/.php_cs +++ b/.php_cs @@ -21,6 +21,7 @@ return PhpCsFixer\Config::create() 'declare_strict_types' => true, 'no_empty_phpdoc' => true, 'no_superfluous_phpdoc_tags' => true, + 'no_unneeded_final_method' => false, # prevent phpstan divergence 'header_comment' => [ 'commentType' => 'comment', 'header' => $header, diff --git a/src/Api/Domain.php b/src/Api/Domain.php index e05a251..d676abb 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -35,7 +35,6 @@ class Domain extends HttpApi /** * Returns a list of domains on the account. * - * * @return IndexResponse */ public function index(int $limit = 100, int $skip = 0) diff --git a/src/Api/HttpApi.php b/src/Api/HttpApi.php index 4c3c469..f3281fe 100644 --- a/src/Api/HttpApi.php +++ b/src/Api/HttpApi.php @@ -11,12 +11,12 @@ declare(strict_types=1); namespace Mailgun\Api; -use Mailgun\Exception\UnknownErrorException; -use Mailgun\Hydrator\Hydrator; -use Mailgun\Hydrator\NoopHydrator; use Mailgun\Exception\HttpClientException; use Mailgun\Exception\HttpServerException; +use Mailgun\Exception\UnknownErrorException; use Mailgun\HttpClient\RequestBuilder; +use Mailgun\Hydrator\Hydrator; +use Mailgun\Hydrator\NoopHydrator; use Psr\Http\Client as Psr18; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\ResponseInterface; diff --git a/src/Api/Ip.php b/src/Api/Ip.php index 96034f5..f16757f 100644 --- a/src/Api/Ip.php +++ b/src/Api/Ip.php @@ -27,7 +27,6 @@ class Ip extends HttpApi /** * Returns a list of IPs. * - * * @return IndexResponse|ResponseInterface */ public function index(bool $dedicated = false) @@ -46,7 +45,6 @@ class Ip extends HttpApi /** * Returns a list of IPs assigned to a domain. * - * * @return IndexResponse|ResponseInterface */ public function domainIndex(string $domain) @@ -61,7 +59,6 @@ class Ip extends HttpApi /** * Returns a single ip. * - * * @return ShowResponse|ResponseInterface */ public function show(string $ip) @@ -76,7 +73,6 @@ class Ip extends HttpApi /** * Assign a dedicated IP to the domain specified. * - * * @return UpdateResponse|ResponseInterface */ public function assign(string $domain, string $ip) @@ -95,8 +91,6 @@ class Ip extends HttpApi /** * Unassign an IP from the domain specified. - * - * * @return UpdateResponse|ResponseInterface */ diff --git a/src/Api/MailingList/Member.php b/src/Api/MailingList/Member.php index 5968c9e..5796dba 100644 --- a/src/Api/MailingList/Member.php +++ b/src/Api/MailingList/Member.php @@ -128,11 +128,7 @@ class Member extends HttpApi // workaround for webmozart/asserts <= 1.2 if (count($members) > 1000) { - throw new InvalidArgumentException(sprintf( - 'Expected an Array to contain at most %2$d elements. Got: %d', - 1000, - count($members) - )); + throw new InvalidArgumentException(sprintf('Expected an Array to contain at most %2$d elements. Got: %d', 1000, count($members))); } foreach ($members as $data) { diff --git a/src/Api/Message.php b/src/Api/Message.php index 77e3b9f..f804a49 100644 --- a/src/Api/Message.php +++ b/src/Api/Message.php @@ -71,7 +71,7 @@ class Message extends HttpApi * * @return SendResponse|ResponseInterface */ - public function sendMime(string $domain, array $recipients, string $message, array $params) + public function sendMime(string $domain, array $recipients, string $message, array $params) { Assert::string($domain); Assert::notEmpty($domain); diff --git a/src/Api/Suppression.php b/src/Api/Suppression.php index a8ff9c0..4147fdb 100644 --- a/src/Api/Suppression.php +++ b/src/Api/Suppression.php @@ -14,9 +14,9 @@ namespace Mailgun\Api; use Mailgun\Api\Suppression\Bounce; use Mailgun\Api\Suppression\Complaint; use Mailgun\Api\Suppression\Unsubscribe; +use Mailgun\HttpClient\RequestBuilder; use Mailgun\Hydrator\Hydrator; use Psr\Http\Client\ClientInterface; -use Mailgun\HttpClient\RequestBuilder; /** * @see https://documentation.mailgun.com/api-suppressions.html diff --git a/src/Api/Tag.php b/src/Api/Tag.php index be5f123..a94a6e6 100644 --- a/src/Api/Tag.php +++ b/src/Api/Tag.php @@ -67,7 +67,6 @@ class Tag extends HttpApi /** * Update a tag. * - * * @return UpdateResponse|ResponseInterface */ public function update(string $domain, string $tag, string $description) @@ -87,7 +86,6 @@ class Tag extends HttpApi /** * Returns statistics for a single tag. * - * * @return StatisticsResponse|ResponseInterface */ public function stats(string $domain, string $tag, array $params) @@ -103,7 +101,6 @@ class Tag extends HttpApi /** * Removes a tag from the account. * - * * @return DeleteResponse|ResponseInterface */ public function delete(string $domain, string $tag) diff --git a/src/Api/Webhook.php b/src/Api/Webhook.php index 7ad1d03..229e2f6 100644 --- a/src/Api/Webhook.php +++ b/src/Api/Webhook.php @@ -12,15 +12,15 @@ declare(strict_types=1); namespace Mailgun\Api; use Mailgun\Assert; +use Mailgun\HttpClient\RequestBuilder; use Mailgun\Hydrator\Hydrator; use Mailgun\Model\Webhook\CreateResponse; use Mailgun\Model\Webhook\DeleteResponse; use Mailgun\Model\Webhook\IndexResponse; use Mailgun\Model\Webhook\ShowResponse; use Mailgun\Model\Webhook\UpdateResponse; -use Mailgun\HttpClient\RequestBuilder; -use Psr\Http\Message\ResponseInterface; use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\ResponseInterface; /** * @see https://documentation.mailgun.com/en/latest/api-webhooks.html diff --git a/src/Mailgun.php b/src/Mailgun.php index 45fee9e..0ce768f 100644 --- a/src/Mailgun.php +++ b/src/Mailgun.php @@ -15,10 +15,10 @@ use Http\Client\Common\PluginClient; use Mailgun\HttpClient\HttpClientConfigurator; use Mailgun\HttpClient\Plugin\History; use Mailgun\HttpClient\RequestBuilder; -use Mailgun\Hydrator\ModelHydrator; use Mailgun\Hydrator\Hydrator; -use Psr\Http\Message\ResponseInterface; +use Mailgun\Hydrator\ModelHydrator; use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\ResponseInterface; /** * This class is the base class for the Mailgun SDK. diff --git a/src/Model/Domain/AbstractDomainResponse.php b/src/Model/Domain/AbstractDomainResponse.php index c3fcba3..6a16494 100644 --- a/src/Model/Domain/AbstractDomainResponse.php +++ b/src/Model/Domain/AbstractDomainResponse.php @@ -54,7 +54,7 @@ abstract class AbstractDomainResponse implements ApiResponse return $model; } - private function __construct() + final private function __construct() { } diff --git a/src/Model/Event/EventResponse.php b/src/Model/Event/EventResponse.php index de02a3a..66ddab3 100644 --- a/src/Model/Event/EventResponse.php +++ b/src/Model/Event/EventResponse.php @@ -11,9 +11,9 @@ declare(strict_types=1); namespace Mailgun\Model\Event; -use Mailgun\Model\PagingProvider; -use Mailgun\Model\PaginationResponse; use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; /** * @author Tobias Nyholm diff --git a/src/Model/MailingList/Member/IndexResponse.php b/src/Model/MailingList/Member/IndexResponse.php index b3c9842..0eb72e2 100644 --- a/src/Model/MailingList/Member/IndexResponse.php +++ b/src/Model/MailingList/Member/IndexResponse.php @@ -11,9 +11,9 @@ declare(strict_types=1); namespace Mailgun\Model\MailingList\Member; -use Mailgun\Model\PagingProvider; -use Mailgun\Model\PaginationResponse; use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; final class IndexResponse implements ApiResponse, PagingProvider { diff --git a/src/Model/MailingList/PagesResponse.php b/src/Model/MailingList/PagesResponse.php index 78745c9..8cee9d6 100644 --- a/src/Model/MailingList/PagesResponse.php +++ b/src/Model/MailingList/PagesResponse.php @@ -11,9 +11,9 @@ declare(strict_types=1); namespace Mailgun\Model\MailingList; -use Mailgun\Model\PagingProvider; -use Mailgun\Model\PaginationResponse; use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; final class PagesResponse implements ApiResponse, PagingProvider { diff --git a/src/Model/Suppression/BaseResponse.php b/src/Model/Suppression/BaseResponse.php index e97d2fb..9306437 100644 --- a/src/Model/Suppression/BaseResponse.php +++ b/src/Model/Suppression/BaseResponse.php @@ -23,7 +23,7 @@ abstract class BaseResponse implements ApiResponse private $address; private $message; - private function __construct() + final private function __construct() { } diff --git a/src/Model/Webhook/BaseResponse.php b/src/Model/Webhook/BaseResponse.php index 9a00ca3..3190445 100644 --- a/src/Model/Webhook/BaseResponse.php +++ b/src/Model/Webhook/BaseResponse.php @@ -23,7 +23,7 @@ abstract class BaseResponse implements ApiResponse private $webhook = []; private $message; - private function __construct() + final private function __construct() { } diff --git a/tests/Api/TagTest.php b/tests/Api/TagTest.php index b7d0898..e9f3582 100644 --- a/tests/Api/TagTest.php +++ b/tests/Api/TagTest.php @@ -13,7 +13,6 @@ namespace Mailgun\Tests\Api; use GuzzleHttp\Psr7\Response; use Mailgun\Api\Tag; -use Mailgun\Mailgun; /** * @author Tobias Nyholm diff --git a/tests/Api/WebhookTest.php b/tests/Api/WebhookTest.php index 1387843..7753cf3 100644 --- a/tests/Api/WebhookTest.php +++ b/tests/Api/WebhookTest.php @@ -12,10 +12,10 @@ declare(strict_types=1); namespace Mailgun\Tests\Api; use Mailgun\Api\Webhook; -use Mailgun\Model\Webhook\IndexResponse; -use Mailgun\Model\Webhook\ShowResponse; use Mailgun\Model\Webhook\CreateResponse; use Mailgun\Model\Webhook\DeleteResponse; +use Mailgun\Model\Webhook\IndexResponse; +use Mailgun\Model\Webhook\ShowResponse; use Mailgun\Model\Webhook\UpdateResponse; class WebhookTest extends TestCase