Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade lcobucci/coding-standard to v5.0 #361

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script:
- ./vendor/bin/infection --test-framework-options="--testsuite=unit" -s --threads=$(nproc) --min-msi=91.66 --min-covered-msi=92.77
- ./vendor/bin/infection --test-framework-options="--testsuite=unit" -s --threads=$(nproc) --min-msi=94 --min-covered-msi=94

- stage: Metrics and quality
env: STATIC_ANALYSIS
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require-dev": {
"infection/infection": "^0.16",
"lcobucci/coding-standard": "^4.0",
"lcobucci/coding-standard": "^5.0",
"mikey179/vfsstream": "^1.6",
"phpbench/phpbench": "dev-master@dev",
"phpstan/extension-installer": "^1.0",
Expand Down
4 changes: 1 addition & 3 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ final class Configuration
private Validator $validator;
private Closure $builderFactory;

/**
* @var Constraint[]
*/
/** @var Constraint[] */
private array $validationConstraints = [];

public static function forAsymmetricSigner(
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Ecdsa.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter;
use Lcobucci\JWT\Signer\Ecdsa\SignatureConverter;

use const OPENSSL_KEYTYPE_EC;

abstract class Ecdsa extends OpenSSL
Expand Down
14 changes: 10 additions & 4 deletions src/Signer/Ecdsa/MultibyteStringConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use InvalidArgumentException;

use function assert;
use function bin2hex;
use function dechex;
Expand All @@ -24,6 +25,7 @@
use function mb_strlen;
use function mb_substr;
use function str_pad;

use const STR_PAD_LEFT;

/**
Expand Down Expand Up @@ -80,8 +82,10 @@ private static function preparePositiveInteger(string $data): string
return self::ASN1_NEGATIVE_INTEGER . $data;
}

while (mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER
&& mb_substr($data, 2, self::BYTE_SIZE, '8bit') <= self::ASN1_BIG_INTEGER_LIMIT) {
while (
mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER
&& mb_substr($data, 2, self::BYTE_SIZE, '8bit') <= self::ASN1_BIG_INTEGER_LIMIT
) {
$data = mb_substr($data, 2, null, '8bit');
}

Expand Down Expand Up @@ -132,8 +136,10 @@ private static function readAsn1Integer(string $message, int &$position): string

private static function retrievePositiveInteger(string $data): string
{
while (mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER
&& mb_substr($data, 2, self::BYTE_SIZE, '8bit') > self::ASN1_BIG_INTEGER_LIMIT) {
while (
mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER
&& mb_substr($data, 2, self::BYTE_SIZE, '8bit') > self::ASN1_BIG_INTEGER_LIMIT
) {
$data = mb_substr($data, 2, null, '8bit');
}

Expand Down
1 change: 1 addition & 0 deletions src/Signer/Ecdsa/Sha256.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use Lcobucci\JWT\Signer\Ecdsa;

use const OPENSSL_ALGO_SHA256;

final class Sha256 extends Ecdsa
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Ecdsa/Sha384.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use Lcobucci\JWT\Signer\Ecdsa;

use const OPENSSL_ALGO_SHA384;

final class Sha384 extends Ecdsa
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Ecdsa/Sha512.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use Lcobucci\JWT\Signer\Ecdsa;

use const OPENSSL_ALGO_SHA512;

final class Sha512 extends Ecdsa
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Hmac.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer;

use Lcobucci\JWT\Signer;

use function hash_equals;
use function hash_hmac;

Expand Down
1 change: 1 addition & 0 deletions src/Signer/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use InvalidArgumentException;
use SplFileObject;
use Throwable;

use function assert;
use function is_string;
use function strpos;
Expand Down
1 change: 1 addition & 0 deletions src/Signer/OpenSSL.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use InvalidArgumentException;
use Lcobucci\JWT\Signer;

use function assert;
use function is_array;
use function is_resource;
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Rsa/Sha256.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Rsa;

use Lcobucci\JWT\Signer\Rsa;

use const OPENSSL_ALGO_SHA256;

final class Sha256 extends Rsa
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Rsa/Sha384.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Rsa;

use Lcobucci\JWT\Signer\Rsa;

use const OPENSSL_ALGO_SHA384;

final class Sha384 extends Rsa
Expand Down
1 change: 1 addition & 0 deletions src/Signer/Rsa/Sha512.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Rsa;

use Lcobucci\JWT\Signer\Rsa;

use const OPENSSL_ALGO_SHA512;

final class Sha512 extends Rsa
Expand Down
9 changes: 3 additions & 6 deletions src/Token/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Lcobucci\JWT\Builder as BuilderInterface;
use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Signer\Key;

use function array_diff;
use function array_intersect;
use function array_keys;
Expand All @@ -19,14 +20,10 @@

final class Builder implements BuilderInterface
{
/**
* @var array<string, mixed>
*/
/** @var array<string, mixed> */
private array $headers = ['typ' => 'JWT', 'alg' => null];

/**
* @var array<string, mixed>
*/
/** @var array<string, mixed> */
private array $claims = [];

private Parsing\Encoder $encoder;
Expand Down
4 changes: 1 addition & 3 deletions src/Token/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

final class DataSet
{
/**
* @var array<string, mixed>
*/
/** @var array<string, mixed> */
private array $data;
private string $encoded;

Expand Down
1 change: 1 addition & 0 deletions src/Token/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Lcobucci\Jose\Parsing;
use Lcobucci\JWT\Parser as ParserInterface;
use Lcobucci\JWT\Token as TokenInterface;

use function array_intersect;
use function array_keys;
use function count;
Expand Down
1 change: 1 addition & 0 deletions src/Token/Plain.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use DateTimeInterface;
use Lcobucci\JWT\Token as TokenInterface;

use function in_array;

final class Plain implements TokenInterface
Expand Down
4 changes: 1 addition & 3 deletions src/Validation/Constraint/IssuedBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

final class IssuedBy implements Constraint
{
/**
* @var string[]
*/
/** @var string[] */
private array $issuers;

public function __construct(string ...$issuers)
Expand Down
5 changes: 2 additions & 3 deletions src/Validation/InvalidToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
namespace Lcobucci\JWT\Validation;

use Lcobucci\JWT\Exception;

use function array_map;
use function implode;

final class InvalidToken extends Exception
{
/**
* @var ConstraintViolation[]
*/
/** @var ConstraintViolation[] */
private array $violations = [];

public static function fromViolations(ConstraintViolation ...$violations): self
Expand Down
8 changes: 2 additions & 6 deletions test/_keys/Keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@

trait Keys
{
/**
* @var array<string, Key>
*/
/** @var array<string, Key> */
protected static array $rsaKeys;

/**
* @var array<string, Key>
*/
/** @var array<string, Key> */
protected static array $ecdsaKeys;

/**
Expand Down
3 changes: 2 additions & 1 deletion test/functional/ES512TokenTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
declare (strict_types=1);
declare(strict_types=1);

namespace Lcobucci\JWT\FunctionalTests;

Expand All @@ -13,6 +13,7 @@
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\InvalidToken;
use PHPUnit\Framework\TestCase;

use function assert;

class ES512TokenTest extends TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/functional/EcdsaTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\InvalidToken;
use PHPUnit\Framework\TestCase;

use function assert;

use const PHP_EOL;

class EcdsaTokenTest extends TestCase
Expand Down
1 change: 1 addition & 0 deletions test/functional/HmacTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\InvalidToken;
use PHPUnit\Framework\TestCase;

use function assert;

class HmacTokenTest extends TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/functional/MaliciousTamperingPreventionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
use Lcobucci\JWT\Token\Plain;
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use PHPUnit\Framework\TestCase;

use function assert;
use function explode;
use function hash_hmac;
use function implode;

use const PHP_EOL;

final class MaliciousTamperingPreventionTest extends TestCase
Expand Down
2 changes: 2 additions & 0 deletions test/functional/RFC6978VectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
use Lcobucci\JWT\Signer\Ecdsa\Sha512;
use Lcobucci\JWT\Signer\Key;
use PHPUnit\Framework\TestCase;

use function assert;
use function hex2bin;
use function is_string;

use const PHP_EOL;

final class RFC6978VectorTest extends TestCase
Expand Down
1 change: 1 addition & 0 deletions test/functional/RsaTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Lcobucci\JWT\Validation\Constraint\SignedWith;
use Lcobucci\JWT\Validation\InvalidToken;
use PHPUnit\Framework\TestCase;

use function assert;

class RsaTokenTest extends TestCase
Expand Down
3 changes: 2 additions & 1 deletion test/functional/UnsignedTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Lcobucci\JWT\Validation\ConstraintViolation;
use Lcobucci\JWT\Validation\InvalidToken;
use PHPUnit\Framework\TestCase;

use function assert;

class UnsignedTokenTest extends TestCase
Expand Down Expand Up @@ -170,7 +171,7 @@ public function tokenAssertionShouldRaiseExceptionWhenOneOfTheConstraintsFails(T

private function validUserConstraint(): Constraint
{
return new class() implements Constraint
return new class () implements Constraint
{
public function assert(Token $token): void
{
Expand Down
24 changes: 6 additions & 18 deletions test/unit/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,22 @@

final class ConfigurationTest extends TestCase
{
/**
* @var Parser&MockObject
*/
/** @var Parser&MockObject */
private Parser $parser;

/**
* @var Signer&MockObject
*/
/** @var Signer&MockObject */
private Signer $signer;

/**
* @var Parsing\Encoder&MockObject
*/
/** @var Parsing\Encoder&MockObject */
private Parsing\Encoder $encoder;

/**
* @var Parsing\Decoder&MockObject
*/
/** @var Parsing\Decoder&MockObject */
private Parsing\Decoder $decoder;

/**
* @var Validator&MockObject
*/
/** @var Validator&MockObject */
private Validator $validator;

/**
* @var Constraint&MockObject
*/
/** @var Constraint&MockObject */
private Constraint $validationConstraints;

/**
Expand Down
1 change: 1 addition & 0 deletions test/unit/Signer/Ecdsa/MultibyteStringConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

use function assert;
use function bin2hex;
use function hex2bin;
Expand Down
1 change: 1 addition & 0 deletions test/unit/Signer/Ecdsa/Sha256Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use PHPUnit\Framework\TestCase;

use const OPENSSL_ALGO_SHA256;

final class Sha256Test extends TestCase
Expand Down
1 change: 1 addition & 0 deletions test/unit/Signer/Ecdsa/Sha384Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Lcobucci\JWT\Signer\Ecdsa;

use PHPUnit\Framework\TestCase;

use const OPENSSL_ALGO_SHA384;

final class Sha384Test extends TestCase
Expand Down
Loading