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

Deps/update #26

Merged
merged 9 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Dependencies updated and Rector+ECS fixes
  • Loading branch information
Spomky committed Dec 10, 2022
commit e2f4730282432e141a2dd6c43d4b31b84eae10e2
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.5.5",
"rector/rector": "^0.14",
"rector/rector": "^0.15",
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^6.1",
"symfony/var-dumper": "^6.1",
Expand Down
6 changes: 1 addition & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
Expand All @@ -16,7 +15,7 @@
return static function (RectorConfig $config): void {
$config->import(SetList::DEAD_CODE);
$config->import(LevelSetList::UP_TO_PHP_81);
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_60);
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_61);
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
$config->import(SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES);
$config->import(SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION);
Expand All @@ -35,7 +34,4 @@
$config->parallel();
$config->importNames();
$config->importShortClasses();

$services = $config->services();
$services->set(TypedPropertyRector::class);
};
2 changes: 1 addition & 1 deletion src/ASN1/Type/Primitive/GeneralizedTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected static function decodeFromDER(Identifier $identifier, string $data, in
if (isset($match[7])) {
$frac = $match[7];
// DER restricts trailing zeroes in fractional seconds component
if ($frac[mb_strlen((string) $frac, '8bit') - 1] === '0') {
if ($frac[mb_strlen($frac, '8bit') - 1] === '0') {
throw new DecodeException('Fractional seconds must omit trailing zeroes.');
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/ASN1/Type/Primitive/RelativeOID.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ final class RelativeOID extends Element
/**
* @param string $oid OID in dotted format
*/
private function __construct(private readonly string $oid)
{
private function __construct(
private readonly string $oid
) {
parent::__construct(self::TYPE_RELATIVE_OID);
$this->subids = self::explodeDottedOID($oid);
}
Expand Down
5 changes: 3 additions & 2 deletions src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ abstract class AlgorithmIdentifier implements AlgorithmIdentifierType

final public const OID_SHA512 = '2.16.840.1.101.3.4.2.3';

protected function __construct(protected readonly string $oid)
{
protected function __construct(
protected readonly string $oid
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ final class ECPublicKeyAlgorithmIdentifier extends SpecificAlgorithmIdentifier i
/**
* @param string $namedCurve Curve identifier
*/
private function __construct(private readonly string $namedCurve)
{
private function __construct(
private readonly string $namedCurve
) {
parent::__construct(self::OID_EC_PUBLIC_KEY);
}

Expand Down
5 changes: 3 additions & 2 deletions src/CryptoTypes/Asymmetric/RFC8410/RFC8410PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ abstract class RFC8410PublicKey extends PublicKey
/**
* @param string $publicKey Public key data
*/
protected function __construct(private readonly string $publicKey)
{
protected function __construct(
private readonly string $publicKey
) {
}

public function toDER(): string
Expand Down
5 changes: 3 additions & 2 deletions src/X501/ASN1/AttributeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ final class AttributeType
/**
* @param string $_oid OID in dotted format
*/
private function __construct(protected string $_oid)
{
private function __construct(
protected string $_oid
) {
}

public static function create(string $oid): self
Expand Down
5 changes: 3 additions & 2 deletions src/X501/ASN1/AttributeValue/AttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ abstract class AttributeValue implements Stringable
/**
* @param string $oid OID of the attribute type.
*/
protected function __construct(protected string $oid)
{
protected function __construct(
protected string $oid
) {
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/X501/DN/DNParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ final class DNParser
/**
* @param string $_dn Distinguised name
*/
private function __construct(private readonly string $_dn)
{
private function __construct(
private readonly string $_dn
) {
$this->_len = mb_strlen($_dn, '8bit');
}

Expand Down Expand Up @@ -340,7 +341,7 @@ private function _regexMatch(string $pattern, int &$offset): ?string
if (preg_match($pattern, mb_substr($this->_dn, $idx, null, '8bit'), $match) !== 1) {
return null;
}
$idx += mb_strlen((string) $match[0], '8bit');
$idx += mb_strlen($match[0], '8bit');
$offset = $idx;
return end($match);
}
Expand Down
5 changes: 3 additions & 2 deletions src/X501/StringPrep/MapStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ final class MapStep implements PrepareStep
/**
* @param bool $fold Whether to apply case folding
*/
private function __construct(protected bool $fold)
{
private function __construct(
protected bool $fold
) {
}

public static function create(bool $fold = false): self
Expand Down
5 changes: 3 additions & 2 deletions src/X501/StringPrep/TranscodeStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ final class TranscodeStep implements PrepareStep
/**
* @param int $_type ASN.1 type tag of the string
*/
private function __construct(private readonly int $_type)
{
private function __construct(
private readonly int $_type
) {
}

public static function create(int $_type): self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ abstract class PolicyQualifierInfo
*/
public const OID_UNOTICE = '1.3.6.1.5.5.7.2.2';

protected function __construct(protected string $oid)
{
protected function __construct(
protected string $oid
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ abstract class DistributionPointName

public const TAG_RDN = 1;

protected function __construct(protected int $tag)
{
protected function __construct(
protected int $tag
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/X509/Certificate/Extension/Target/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ abstract class Target

public const TYPE_CERT = 2;

protected function __construct(protected int $type)
{
protected function __construct(
protected int $type
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ final class CertificationPathBuilder
/**
* @param CertificateBundle $trustList List of trust anchors
*/
private function __construct(private readonly CertificateBundle $trustList)
{
private function __construct(
private readonly CertificateBundle $trustList
) {
}

public static function create(CertificateBundle $trustList): self
Expand Down
5 changes: 2 additions & 3 deletions src/X509/CertificationPath/PathValidation/ValidatorState.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use LogicException;
use SpomkyLabs\Pki\ASN1\Element;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Feature\AlgorithmIdentifierType;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Feature\SignatureAlgorithmIdentifier;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PublicKeyInfo;
use SpomkyLabs\Pki\X501\ASN1\Name;
use SpomkyLabs\Pki\X509\Certificate\Certificate;
Expand Down Expand Up @@ -81,10 +82,8 @@ final class ValidatorState
* Working public key algorithm (working_public_key_algorithm).
*
* The digital signature algorithm used to verify the signature of a certificate.
*
* @var AlgorithmIdentifierType
*/
private $_workingPublicKeyAlgorithm;
private SignatureAlgorithmIdentifier|AlgorithmIdentifierType|null $_workingPublicKeyAlgorithm = null;

/**
* Working public key (working_public_key).
Expand Down
5 changes: 3 additions & 2 deletions src/X509/CertificationPath/Policy/PolicyTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ final class PolicyTree
/**
* @param PolicyNode $root Initial root node
*/
private function __construct(private ?PolicyNode $root)
{
private function __construct(
private ?PolicyNode $root
) {
}

public static function create(?PolicyNode $root): self
Expand Down
5 changes: 3 additions & 2 deletions src/X509/GeneralName/DNSName.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ final class DNSName extends GeneralName
/**
* @param string $name Domain name
*/
private function __construct(private readonly string $name)
{
private function __construct(
private readonly string $name
) {
parent::__construct(self::TAG_DNS_NAME);
}

Expand Down
5 changes: 3 additions & 2 deletions src/X509/GeneralName/EDIPartyName.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/
final class EDIPartyName extends GeneralName
{
private function __construct(protected Sequence $element)
{
private function __construct(
protected Sequence $element
) {
parent::__construct(self::TAG_EDI_PARTY_NAME);
}

Expand Down
5 changes: 3 additions & 2 deletions src/X509/GeneralName/GeneralName.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ abstract class GeneralName implements Stringable

public const TAG_REGISTERED_ID = 8;

protected function __construct(protected int $tag)
{
protected function __construct(
protected int $tag
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/X509/GeneralName/RegisteredID.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ final class RegisteredID extends GeneralName
/**
* @param string $oid OID in dotted format
*/
private function __construct(private readonly string $oid)
{
private function __construct(
private readonly string $oid
) {
parent::__construct(self::TAG_REGISTERED_ID);
}

Expand Down
5 changes: 3 additions & 2 deletions src/X509/GeneralName/X400Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/
final class X400Address extends GeneralName
{
protected function __construct(private readonly Sequence $element)
{
protected function __construct(
private readonly Sequence $element
) {
parent::__construct(self::TAG_X400_ADDRESS);
}

Expand Down
11 changes: 3 additions & 8 deletions tests/CryptoBridge/Unit/Crypto/OpenSSLCryptoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Signature\SHA384WithRSAEncryptionAlgorithmIdentifier;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Signature\SHA512WithRSAEncryptionAlgorithmIdentifier;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\SpecificAlgorithmIdentifier;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\OneAsymmetricKey;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PrivateKeyInfo;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSAPrivateKey;
use SpomkyLabs\Pki\CryptoTypes\Signature\RSASignature;
Expand All @@ -51,15 +52,9 @@ final class OpenSSLCryptoTest extends TestCase

private static ?OpenSSLCrypto $_crypto;

/**
* @var PrivateKeyInfo
*/
private static $_rsaPrivKeyInfo;
private static ?OneAsymmetricKey $_rsaPrivKeyInfo = null;

/**
* @var PrivateKeyInfo
*/
private static $_ecPrivKeyInfo;
private static ?OneAsymmetricKey $_ecPrivKeyInfo = null;

public static function setUpBeforeClass(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CryptoTypes/Unit/AlgoId/AlgorithmIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
final class AlgorithmIdentifierTest extends TestCase
{
private static $_unknownASN1;
private static ?Sequence $_unknownASN1 = null;

public static function setUpBeforeClass(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/X501/Unit/StringPrep/TranscodeStepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function bMP()
{
static $str = 'κόσμε';
$step = TranscodeStep::create(Element::TYPE_BMP_STRING);
static::assertEquals($str, $step->apply(mb_convert_encoding($str, 'UCS-2BE', 'UTF-8')));
static::assertEquals($str, $step->apply(mb_convert_encoding((string) $str, 'UCS-2BE', 'UTF-8')));
}

/**
Expand All @@ -51,7 +51,7 @@ public function universal()
{
static $str = 'κόσμε';
$step = TranscodeStep::create(Element::TYPE_UNIVERSAL_STRING);
static::assertEquals($str, $step->apply(mb_convert_encoding($str, 'UCS-4BE', 'UTF-8')));
static::assertEquals($str, $step->apply(mb_convert_encoding((string) $str, 'UCS-4BE', 'UTF-8')));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/X509/Integration/Ac/HolderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
final class HolderTest extends TestCase
{
private static $_pkc;
private static ?Certificate $_pkc = null;

public static function setUpBeforeClass(): void
{
Expand Down
5 changes: 3 additions & 2 deletions tests/X509/Integration/Ac/IssuerSerialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPUnit\Framework\TestCase;
use SpomkyLabs\Pki\CryptoEncoding\PEM;
use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Signature\SHA256WithRSAEncryptionAlgorithmIdentifier;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\OneAsymmetricKey;
use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PrivateKeyInfo;
use SpomkyLabs\Pki\X501\ASN1\Name;
use SpomkyLabs\Pki\X509\AttributeCertificate\IssuerSerial;
Expand All @@ -22,9 +23,9 @@
*/
final class IssuerSerialTest extends TestCase
{
private static $_cert;
private static ?Certificate $_cert = null;

private static $_privKey;
private static ?OneAsymmetricKey $_privKey = null;

public static function setUpBeforeClass(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/X509/Integration/Ac/IssuerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
final class IssuerTest extends TestCase
{
private static $_pkc;
private static ?Certificate $_pkc = null;

public static function setUpBeforeClass(): void
{
Expand Down
Loading