Added proper PHP CS fixer rules (#527)

* Added proper PHP CS fixer rules

* Adding Symfony cs rules

* Updated CS on tests
This commit is contained in:
Tobias Nyholm 2019-01-07 06:12:53 +01:00 committed by GitHub
parent 6aecbd5be4
commit 519fd7a674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 36 deletions

37
.php_cs
View File

@ -1,13 +1,32 @@
<?php <?php
/* $header = <<<TXT
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally Copyright (C) 2013 Mailgun
* with composer.
*
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
use SLLH\StyleCIBridge\ConfigBridge; This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
TXT;
return ConfigBridge::create(); $finder = PhpCsFixer\Finder::create()
->in('src')
->in('tests');
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => false, // true
'no_empty_phpdoc' => true,
'no_superfluous_phpdoc_tags' => false, // true
'header_comment' => [
'commentType' => 'comment',
'header' => $header,
'location' => 'after_declare_strict',
'separate' => 'both',
],
])
->setFinder($finder)
;

View File

@ -56,7 +56,7 @@ class Domain extends HttpApi
/** /**
* Returns a single domain. * Returns a single domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* *
* @return ShowResponse|array|ResponseInterface * @return ShowResponse|array|ResponseInterface
*/ */
@ -76,10 +76,10 @@ class Domain extends HttpApi
* *
* @see https://documentation.mailgun.com/en/latest/api-domains.html#domains * @see https://documentation.mailgun.com/en/latest/api-domains.html#domains
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param string $smtpPass Password for SMTP authentication. * @param string $smtpPass password for SMTP authentication
* @param string $spamAction `disable` or `tag` - inbound spam filtering. * @param string $spamAction `disable` or `tag` - inbound spam filtering
* @param bool $wildcard Domain will accept email for subdomains. * @param bool $wildcard domain will accept email for subdomains
* *
* @return CreateResponse|array|ResponseInterface * @return CreateResponse|array|ResponseInterface
*/ */
@ -108,7 +108,7 @@ class Domain extends HttpApi
* Removes a domain from the account. * Removes a domain from the account.
* WARNING: This action is irreversible! Be cautious! * WARNING: This action is irreversible! Be cautious!
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* *
* @return DeleteResponse|array|ResponseInterface * @return DeleteResponse|array|ResponseInterface
*/ */
@ -124,7 +124,7 @@ class Domain extends HttpApi
/** /**
* Returns a list of SMTP credentials for the specified domain. * Returns a list of SMTP credentials for the specified domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param int $limit Number of credentials to return * @param int $limit Number of credentials to return
* @param int $skip Number of credentials to omit from the list * @param int $skip Number of credentials to omit from the list
* *
@ -149,8 +149,8 @@ class Domain extends HttpApi
/** /**
* Create a new SMTP credential pair for the specified domain. * Create a new SMTP credential pair for the specified domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param string $login SMTP Username. * @param string $login SMTP Username
* @param string $password SMTP Password. Length min 5, max 32. * @param string $password SMTP Password. Length min 5, max 32.
* *
* @return CreateCredentialResponse|array|ResponseInterface * @return CreateCredentialResponse|array|ResponseInterface
@ -175,8 +175,8 @@ class Domain extends HttpApi
/** /**
* Update a set of SMTP credentials for the specified domain. * Update a set of SMTP credentials for the specified domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param string $login SMTP Username. * @param string $login SMTP Username
* @param string $pass New SMTP Password. Length min 5, max 32. * @param string $pass New SMTP Password. Length min 5, max 32.
* *
* @return UpdateCredentialResponse|array|ResponseInterface * @return UpdateCredentialResponse|array|ResponseInterface
@ -200,8 +200,8 @@ class Domain extends HttpApi
/** /**
* Remove a set of SMTP credentials from the specified domain. * Remove a set of SMTP credentials from the specified domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param string $login SMTP Username. * @param string $login SMTP Username
* *
* @return DeleteCredentialResponse|array|ResponseInterface * @return DeleteCredentialResponse|array|ResponseInterface
*/ */
@ -224,7 +224,7 @@ class Domain extends HttpApi
/** /**
* Returns delivery connection settings for the specified domain. * Returns delivery connection settings for the specified domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* *
* @return ConnectionResponse|ResponseInterface * @return ConnectionResponse|ResponseInterface
*/ */
@ -241,9 +241,9 @@ class Domain extends HttpApi
* Updates the specified delivery connection settings for the specified domain. * Updates the specified delivery connection settings for the specified domain.
* If a parameter is passed in as null, it will not be updated. * If a parameter is passed in as null, it will not be updated.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* @param bool|null $requireTLS Enforces that messages are sent only over a TLS connection. * @param bool|null $requireTLS enforces that messages are sent only over a TLS connection
* @param bool|null $noVerify Disables TLS certificate and hostname verification. * @param bool|null $noVerify disables TLS certificate and hostname verification
* *
* @return UpdateConnectionResponse|array|ResponseInterface * @return UpdateConnectionResponse|array|ResponseInterface
*/ */
@ -271,7 +271,7 @@ class Domain extends HttpApi
/** /**
* Returns a single domain. * Returns a single domain.
* *
* @param string $domain Name of the domain. * @param string $domain name of the domain
* *
* @return VerifyResponse|array|ResponseInterface * @return VerifyResponse|array|ResponseInterface
*/ */

View File

@ -122,7 +122,8 @@ class Member extends HttpApi
// workaround for webmozart/asserts <= 1.2 // workaround for webmozart/asserts <= 1.2
if (count($members) > 1000) { if (count($members) > 1000) {
throw new InvalidArgumentException(sprintf('Expected an Array to contain at most %2$d elements. Got: %d', throw new InvalidArgumentException(sprintf(
'Expected an Array to contain at most %2$d elements. Got: %d',
1000, 1000,
count($members) count($members)
)); ));

View File

@ -78,7 +78,7 @@ class BatchMessage extends MessageBuilder
protected function addRecipient($headerName, $address, array $variables) protected function addRecipient($headerName, $address, array $variables)
{ {
if (array_key_exists($headerName, $this->counters['recipients'])) { if (array_key_exists($headerName, $this->counters['recipients'])) {
if ($this->counters['recipients'][$headerName] === self::RECIPIENT_COUNT_LIMIT) { if (self::RECIPIENT_COUNT_LIMIT === $this->counters['recipients'][$headerName]) {
if (false === $this->autoSend) { if (false === $this->autoSend) {
throw TooManyRecipients::whenAutoSendDisabled(); throw TooManyRecipients::whenAutoSendDisabled();
} }

View File

@ -135,7 +135,7 @@ class MessageBuilder
$this->message[$headerName] = [$compiledAddress]; $this->message[$headerName] = [$compiledAddress];
} }
if (array_key_exists($headerName, $this->counters['recipients'])) { if (array_key_exists($headerName, $this->counters['recipients'])) {
$this->counters['recipients'][$headerName] += 1; ++$this->counters['recipients'][$headerName];
} }
return $this; return $this;
@ -383,7 +383,7 @@ class MessageBuilder
} else { } else {
$this->message['o:campaign'] = [(string) $campaignId]; $this->message['o:campaign'] = [(string) $campaignId];
} }
$this->counters['attributes']['campaign_id'] += 1; ++$this->counters['attributes']['campaign_id'];
return $this; return $this;
} }
@ -406,7 +406,7 @@ class MessageBuilder
} else { } else {
$this->message['o:tag'] = [$tag]; $this->message['o:tag'] = [$tag];
} }
$this->counters['attributes']['tag'] += 1; ++$this->counters['attributes']['tag'];
return $this; return $this;
} }

View File

@ -64,7 +64,7 @@ final class DnsRecord
} }
/** /**
* @param string|null $name Name of the record, as used in CNAME, etc. * @param string|null $name name of the record, as used in CNAME, etc
* @param string $type DNS record type * @param string $type DNS record type
* @param string $value DNS record value * @param string $value DNS record value
* @param string|null $priority Record priority, used for MX * @param string|null $priority Record priority, used for MX

View File

@ -243,7 +243,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
/** /**
* @param mixed|callable $property Example $this->requestMethod * @param mixed|callable $property Example $this->requestMethod
* @param mixed $value The actual value from the user. * @param mixed $value the actual value from the user
* *
* @return bool * @return bool
*/ */

View File

@ -9,7 +9,6 @@
namespace Mailgun\Tests\Model\Domain; namespace Mailgun\Tests\Model\Domain;
use Mailgun\Model\Domain\Domain;
use Mailgun\Model\Domain\UpdateConnectionResponse; use Mailgun\Model\Domain\UpdateConnectionResponse;
use Mailgun\Tests\Model\BaseModelTest; use Mailgun\Tests\Model\BaseModelTest;

View File

@ -9,7 +9,6 @@
namespace Mailgun\Tests\Model\Domain; namespace Mailgun\Tests\Model\Domain;
use Mailgun\Model\Domain\Domain;
use Mailgun\Model\Domain\VerifyResponse; use Mailgun\Model\Domain\VerifyResponse;
use Mailgun\Tests\Model\BaseModelTest; use Mailgun\Tests\Model\BaseModelTest;