diff --git a/config/v3-to-v4.php b/config/v3-to-v4.php index 8b88c1f..36d55f9 100644 --- a/config/v3-to-v4.php +++ b/config/v3-to-v4.php @@ -1,12 +1,16 @@ registerDecoratingNodeVisitor(X509NodeVisitor::class) ->withRules([ + Namespace_::class, + CryptRandom::class, + SFTPChmod::class, X509::class, ]) ->withPreparedSets( diff --git a/src/Rector/V3toV4/CryptRandom.php b/src/Rector/V3toV4/CryptRandom.php new file mode 100644 index 0000000..d1d9fec --- /dev/null +++ b/src/Rector/V3toV4/CryptRandom.php @@ -0,0 +1,63 @@ +uses = array_values(array_filter( + $node->uses, + fn(UseItem $item) => !$this->isName($item->name, 'phpseclib3\Crypt\Random') + )); + + // Remove the Use_ statement entirely if it now has no items + return count($node->uses) > 0 ? $node : NodeTraverser::REMOVE_NODE; + } + + if (!$node instanceof StaticCall) { + return null; + } + + if (!$this->isNames($node->class, ['Random', 'phpseclib3\Crypt\Random'])) { + return null; + } + + if (!$this->isName($node->name, 'string')) { + return null; + } + + return new FuncCall(new Name('random_bytes'), $node->args); + } +} diff --git a/src/Rector/V3toV4/Namespace_.php b/src/Rector/V3toV4/Namespace_.php new file mode 100644 index 0000000..b7e2045 --- /dev/null +++ b/src/Rector/V3toV4/Namespace_.php @@ -0,0 +1,69 @@ +name->toString(); + if (!str_starts_with($name, 'phpseclib3\\')) { + return null; + } + if (in_array($name, self::SKIP, true)) { + return null; + } + $node->name = new Name('phpseclib4\\' . substr($name, strlen('phpseclib3\\'))); + return $node; + } + + // FullyQualified — only rename if written explicitly in source (not resolved from a short name). + // Resolved short names occupy file-character span of the alias only (e.g. 4 chars for "SFTP"), + // while explicit FQNs span the full string including the leading backslash. + $name = $node->toString(); + if (!str_starts_with($name, 'phpseclib3\\')) { + return null; + } + if (in_array($name, self::SKIP, true)) { + return null; + } + $expectedSpan = strlen('\\' . $name); + $actualSpan = $node->getEndFilePos() - $node->getStartFilePos() + 1; + if ($actualSpan !== $expectedSpan) { + // Span doesn't match the full FQN — this was resolved from a short name via a use import. + return null; + } + + return new FullyQualified('phpseclib4\\' . substr($name, strlen('phpseclib3\\'))); + } +} diff --git a/src/Rector/V3toV4/README.md b/src/Rector/V3toV4/README.md index cf702e9..8564969 100644 --- a/src/Rector/V3toV4/README.md +++ b/src/Rector/V3toV4/README.md @@ -29,8 +29,9 @@ The rule performs the following transformations: - Converts instance method calls into the corresponding static calls on the appropriate phpseclib4 class. - Migrates calls such as: - `loadX509()` → `X509::load()` - - `loadCSR()` → `CSR::loadCSR()` - - `loadCRL()` → `CRL::loadCRL()` + - `loadCSR()` → `CSR::load()` + - `loadCRL()` → `CRL::load()` + - `loadSPKAC()` → `SPKAC::load()` - Rewrites API changes: - `getDN()` → `getSubjectDN(X509::DN_ARRAY)` - `setDNProp()` → `addDNProp()` @@ -112,7 +113,7 @@ $csr = $x509->loadCSR(file_get_contents('csr.csr')); ``` will be refactored to ```php -$csr = \phpseclib4\File\CSR::loadCSR(file_get_contents('csr.csr')); +$csr = \phpseclib4\File\CSR::load(file_get_contents('csr.csr')); ``` #### Set DN Prop @@ -159,7 +160,7 @@ $crl = $x509->loadCRL(file_get_contents('crl.bin')); ``` will be refactored to ```php -$crl = \phpseclib4\File\CRL::loadCRL(file_get_contents('crl.bin')); +$crl = \phpseclib4\File\CRL::load(file_get_contents('crl.bin')); ``` ### SPKAC @@ -172,10 +173,10 @@ $spkac = $x509->loadSPKAC(file_get_contents('spkac.txt')); ``` will be refactored to ```php -$spkac = \phpseclib4\File\CRL::loadCRL(file_get_contents('spkac.txt')); +$spkac = \phpseclib4\File\SPKAC::load(file_get_contents('spkac.txt')); ``` -#### Read cert +#### Create SPKAC ```php $x509 = new X509(); @@ -185,7 +186,7 @@ $spkac = $x509->signSPKAC(); ``` will be refactored to ```php -$spkac = \phpseclib4\File\CRL::loadCRL($privKey->getPublicKey()); +$spkac = new \phpseclib4\File\SPKAC($privKey->getPublicKey()); $spkac->setChallenge('123456789'); $privKey->sign($spkac); ``` diff --git a/src/Rector/V3toV4/SFTPChmod.php b/src/Rector/V3toV4/SFTPChmod.php new file mode 100644 index 0000000..ae88293 --- /dev/null +++ b/src/Rector/V3toV4/SFTPChmod.php @@ -0,0 +1,53 @@ +chmod(0777, 'file.txt') + * phpseclib 4: $sftp->chmod('file.txt', 0777) + * + * Detection heuristic: any ->chmod() call whose first argument is an integer + * literal. PHP's built-in chmod() is a function (not a method), so there is + * no false-positive risk there; and no other common class exposes chmod(int, string). + */ +final class SFTPChmod extends AbstractRector +{ + public function getNodeTypes(): array + { + return [MethodCall::class]; + } + + public function refactor(Node $node): ?Node + { + if (!$node instanceof MethodCall) { + return null; + } + + if (!$this->isName($node->name, 'chmod')) { + return null; + } + + // Only act when the v3 signature is present: first arg is an int literal (octal mode) + if (!isset($node->args[0], $node->args[1])) { + return null; + } + + if (!$node->args[0]->value instanceof Int_) { + return null; + } + + // Swap path and mode — args[2] (recursive flag) stays in place + [$node->args[0], $node->args[1]] = [$node->args[1], $node->args[0]]; + + return $node; + } +} diff --git a/src/Rector/V3toV4/X509.php b/src/Rector/V3toV4/X509.php index 61179d6..ed9dba9 100644 --- a/src/Rector/V3toV4/X509.php +++ b/src/Rector/V3toV4/X509.php @@ -4,6 +4,7 @@ namespace phpseclib\rectorRules\Rector\V3toV4; +use PhpParser\NodeFinder; use PhpParser\NodeTraverser; use PhpParser\Node; use PhpParser\Node\Arg; @@ -38,12 +39,20 @@ final class X509 extends AbstractRector // targetClass, targetMethod private const METHOD_TO_CLASS = [ - 'loadX509' => ['phpseclib4\File\X509', 'load'], - 'loadCSR' => ['phpseclib4\File\CSR', 'loadCSR'], - 'loadCRL' => ['phpseclib4\File\CRL', 'loadCRL'], - 'loadSPKAC'=> ['phpseclib4\File\CRL', 'loadCRL'], - 'setPrivateKey'=> ['phpseclib4\File\CRL', 'loadCRL'], // Set to CRL per default - // 'setPrivateKey'=> ['phpseclib4\File\CSR', 'new CSR($privKey->getPublicKey())'], + 'loadX509' => ['phpseclib4\File\X509', 'load'], + 'loadCSR' => ['phpseclib4\File\CSR', 'load'], + 'loadCRL' => ['phpseclib4\File\CRL', 'load'], + 'loadSPKAC' => ['phpseclib4\File\SPKAC', 'load'], + 'setPrivateKey'=> ['phpseclib4\File\SPKAC', 'load'], + ]; + + // Methods that identify which phpseclib4 class to import (visitor analysis) + private const IMPORT_METHOD_MAP = [ + 'loadX509' => 'phpseclib4\File\X509', + 'getDN' => 'phpseclib4\File\X509', + 'loadCSR' => 'phpseclib4\File\CSR', + 'loadCRL' => 'phpseclib4\File\CRL', + 'loadSPKAC' => 'phpseclib4\File\SPKAC', ]; public function getNodeTypes(): array @@ -56,6 +65,112 @@ public function getNodeTypes(): array ]; } + /** + * Performs the pre-analysis that X509NodeVisitor used to provide as a decorator. + * Sets attributes on Class_ nodes and populates $this->usedImports. + * Must run before any Class_/MethodCall refactoring takes place. + */ + private function analyzeFile(FileNode $node): void + { + $this->usedImports = []; + $finder = new NodeFinder(); + + /** @var Class_[] $classes */ + $classes = $finder->findInstanceOf($node->stmts, Class_::class); + foreach ($classes as $class) { + $hasCsrMethodCall = false; + $hasX509MethodCall = false; + $hasSetPrivateKey = false; + $hasSetPublicKey = false; + $privKeyObj = null; + $pubKeyObj = null; + $issuerVar = null; + $subjectVar = null; + + /** @var MethodCall[] $methodCalls */ + $methodCalls = $finder->findInstanceOf($class->stmts, MethodCall::class); + foreach ($methodCalls as $methodCall) { + if (!$methodCall->name instanceof Identifier) { + continue; + } + $methodName = $methodCall->name->toString(); + $varName = ($methodCall->var instanceof Variable && is_string($methodCall->var->name)) + ? $methodCall->var->name + : null; + + if ($methodName === 'setPrivateKey') { + $hasSetPrivateKey = true; + $arg = $methodCall->args[0]->value ?? null; + if ($arg instanceof Variable && is_string($arg->name)) { + $privKeyObj = $arg->name; + } + $issuerVar = $varName; + } + + if ($methodName === 'setPublicKey') { + $hasSetPublicKey = true; + $arg = $methodCall->args[0]->value ?? null; + if ($arg instanceof Variable && is_string($arg->name)) { + $pubKeyObj = $arg->name; + } + $subjectVar = $varName; + } + + if (in_array($methodName, ['loadCSR', 'signCSR', 'saveCSR'], true)) { + $hasCsrMethodCall = true; + } + if (in_array($methodName, ['setPublicKey', 'saveX509', 'setDN'], true)) { + $hasX509MethodCall = true; + } + + if (isset(self::IMPORT_METHOD_MAP[$methodName])) { + $this->usedImports[self::IMPORT_METHOD_MAP[$methodName]] = true; + } + } + + if ($hasCsrMethodCall) { + $class->setAttribute(X509NodeVisitor::IS_CSR, true); + } + + if ($hasX509MethodCall) { + $class->setAttribute(X509NodeVisitor::IS_X509, true); + + $x509Assignments = $finder->find($class->stmts, function (Node $n): bool { + return $n instanceof Assign + && $n->expr instanceof New_ + && $n->expr->class instanceof Name + && in_array($n->expr->class->toString(), ['X509', 'phpseclib3\File\X509'], true); + }); + + if (count($x509Assignments) === 3) { + $x509Assignments[0]->setAttribute(X509NodeVisitor::IS_FIRST_X509_ASSIGNMENT, true); + } + } + + if ($subjectVar !== null) { + $class->setAttribute(X509NodeVisitor::SUBJECT_VAR, $subjectVar); + } + if ($issuerVar !== null) { + $class->setAttribute(X509NodeVisitor::ISSUER_VAR, $issuerVar); + } + + if ($hasSetPrivateKey) { + $class->setAttribute(X509NodeVisitor::PRIV_KEY_OBJ, $privKeyObj); + + if ($class->getAttribute(X509NodeVisitor::IS_CSR, false)) { + $this->usedImports['phpseclib4\File\CSR'] = true; + } elseif ($class->getAttribute(X509NodeVisitor::IS_X509, false)) { + $this->usedImports['phpseclib4\File\X509'] = true; + } else { + $this->usedImports['phpseclib4\File\SPKAC'] = true; + } + } + if ($hasSetPublicKey) { + $class->setAttribute(X509NodeVisitor::PUB_KEY_OBJ, $pubKeyObj); + } + } + } + private function stmtsWithoutLegacyImport($stmts) { return array_values(array_filter($stmts, function ($stmt) { if (!$stmt instanceof Use_) { @@ -101,7 +216,11 @@ private function reset() { public function refactor(Node $node): int|null|Node { if($node instanceof FileNode) { - $this->usedImports = $node->getAttribute('usedImports', []); + // Perform the pre-analysis (previously done by X509NodeVisitor) to avoid + // depending on the decorator mechanism, which has singleton-lifetime issues + // in combined PHPUnit runs. + $this->analyzeFile($node); + // Remove old import $node->stmts = $this->stmtsWithoutLegacyImport($node->stmts); @@ -260,7 +379,7 @@ public function refactor(Node $node): int|null|Node return new Assign( new Variable('spkac'), - new StaticCall(new Name($shortClass), $targetMethod, $args) + new New_(new Name($shortClass), $args) ); } diff --git a/src/Rector/V3toV4/X509NodeVisitor.php b/src/Rector/V3toV4/X509NodeVisitor.php index 4c610a8..177d835 100644 --- a/src/Rector/V3toV4/X509NodeVisitor.php +++ b/src/Rector/V3toV4/X509NodeVisitor.php @@ -35,11 +35,11 @@ final class X509NodeVisitor extends NodeVisitorAbstract implements DecoratingNod public const ISSUER_VAR = 'issuer_var'; private const METHOD_TO_CLASS = [ - 'loadX509' => 'phpseclib4\File\X509', - 'getDN' => 'phpseclib4\File\X509', - 'loadCSR' => 'phpseclib4\File\CSR', - 'loadCRL' => 'phpseclib4\File\CRL', - 'loadSPKAC'=> 'phpseclib4\File\CRL', + 'loadX509' => 'phpseclib4\File\X509', + 'getDN' => 'phpseclib4\File\X509', + 'loadCSR' => 'phpseclib4\File\CSR', + 'loadCRL' => 'phpseclib4\File\CRL', + 'loadSPKAC' => 'phpseclib4\File\SPKAC', ]; public function __construct( @@ -150,7 +150,7 @@ public function enterNode(Node $node): ?Node } elseif ($class->getAttribute(self::IS_X509, false)) { $usedImports['phpseclib4\File\X509'] = true; } else { - $usedImports['phpseclib4\File\CRL'] = true; + $usedImports['phpseclib4\File\SPKAC'] = true; } } if ($hasSetPublicKey) { diff --git a/tests/V3toV4/CryptRandom/CryptRandomTest.php b/tests/V3toV4/CryptRandom/CryptRandomTest.php new file mode 100644 index 0000000..f99b8e2 --- /dev/null +++ b/tests/V3toV4/CryptRandom/CryptRandomTest.php @@ -0,0 +1,27 @@ +doTestFile($filePath); + } + + public static function provideData(): \Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/rule.php'; + } +} diff --git a/tests/V3toV4/CryptRandom/Fixture/crypt_random_fqn.php.inc b/tests/V3toV4/CryptRandom/Fixture/crypt_random_fqn.php.inc new file mode 100644 index 0000000..98fc81a --- /dev/null +++ b/tests/V3toV4/CryptRandom/Fixture/crypt_random_fqn.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/V3toV4/CryptRandom/Fixture/crypt_random_use.php.inc b/tests/V3toV4/CryptRandom/Fixture/crypt_random_use.php.inc new file mode 100644 index 0000000..3bf5354 --- /dev/null +++ b/tests/V3toV4/CryptRandom/Fixture/crypt_random_use.php.inc @@ -0,0 +1,25 @@ + +----- + diff --git a/tests/V3toV4/CryptRandom/config/rule.php b/tests/V3toV4/CryptRandom/config/rule.php new file mode 100644 index 0000000..ab46a2f --- /dev/null +++ b/tests/V3toV4/CryptRandom/config/rule.php @@ -0,0 +1,9 @@ +withRules([CryptRandom::class]); diff --git a/tests/V3toV4/Namespace_/Fixture/namespace_fqn.php.inc b/tests/V3toV4/Namespace_/Fixture/namespace_fqn.php.inc new file mode 100644 index 0000000..00723a0 --- /dev/null +++ b/tests/V3toV4/Namespace_/Fixture/namespace_fqn.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/tests/V3toV4/Namespace_/Fixture/namespace_skip_x509.php.inc b/tests/V3toV4/Namespace_/Fixture/namespace_skip_x509.php.inc new file mode 100644 index 0000000..b5bc58c --- /dev/null +++ b/tests/V3toV4/Namespace_/Fixture/namespace_skip_x509.php.inc @@ -0,0 +1,31 @@ + +----- + diff --git a/tests/V3toV4/Namespace_/Fixture/namespace_use.php.inc b/tests/V3toV4/Namespace_/Fixture/namespace_use.php.inc new file mode 100644 index 0000000..0cca908 --- /dev/null +++ b/tests/V3toV4/Namespace_/Fixture/namespace_use.php.inc @@ -0,0 +1,39 @@ + +----- + diff --git a/tests/V3toV4/Namespace_/Namespace_Test.php b/tests/V3toV4/Namespace_/Namespace_Test.php new file mode 100644 index 0000000..3d7d138 --- /dev/null +++ b/tests/V3toV4/Namespace_/Namespace_Test.php @@ -0,0 +1,27 @@ +doTestFile($filePath); + } + + public static function provideData(): \Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/rule.php'; + } +} diff --git a/tests/V3toV4/Namespace_/config/rule.php b/tests/V3toV4/Namespace_/config/rule.php new file mode 100644 index 0000000..ad0f9cf --- /dev/null +++ b/tests/V3toV4/Namespace_/config/rule.php @@ -0,0 +1,9 @@ +withRules([Namespace_::class]); diff --git a/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod.php.inc b/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod.php.inc new file mode 100644 index 0000000..16ef268 --- /dev/null +++ b/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod.php.inc @@ -0,0 +1,29 @@ +chmod(0777, 'filename.remote'); + $sftp->chmod(0755, 'dirname', true); + } +} + +?> +----- +chmod('filename.remote', 0777); + $sftp->chmod('dirname', 0755, true); + } +} + +?> diff --git a/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod_skip.php.inc b/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod_skip.php.inc new file mode 100644 index 0000000..5338149 --- /dev/null +++ b/tests/V3toV4/SFTPChmod/Fixture/sftp_chmod_skip.php.inc @@ -0,0 +1,29 @@ +chmod('filename.remote', 0777); + } +} + +?> +----- +chmod('filename.remote', 0777); + } +} + +?> diff --git a/tests/V3toV4/SFTPChmod/SFTPChmodTest.php b/tests/V3toV4/SFTPChmod/SFTPChmodTest.php new file mode 100644 index 0000000..393d33b --- /dev/null +++ b/tests/V3toV4/SFTPChmod/SFTPChmodTest.php @@ -0,0 +1,27 @@ +doTestFile($filePath); + } + + public static function provideData(): \Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/rule.php'; + } +} diff --git a/tests/V3toV4/SFTPChmod/config/rule.php b/tests/V3toV4/SFTPChmod/config/rule.php new file mode 100644 index 0000000..c6b7928 --- /dev/null +++ b/tests/V3toV4/SFTPChmod/config/rule.php @@ -0,0 +1,9 @@ +withRules([SFTPChmod::class]); diff --git a/tests/V3toV4/X509/Fixture/CRL_load_CRL-fullyqualified.php.inc b/tests/V3toV4/X509/Fixture/CRL_load_CRL-fullyqualified.php.inc index 4017adb..d78e051 100644 --- a/tests/V3toV4/X509/Fixture/CRL_load_CRL-fullyqualified.php.inc +++ b/tests/V3toV4/X509/Fixture/CRL_load_CRL-fullyqualified.php.inc @@ -18,6 +18,6 @@ final class SomeClass { function foo() { - $crl = CRL::loadCRL(file_get_contents('crl.bin')); + $crl = CRL::load(file_get_contents('crl.bin')); } } diff --git a/tests/V3toV4/X509/Fixture/CRL_load_CRL.php.inc b/tests/V3toV4/X509/Fixture/CRL_load_CRL.php.inc index 9d5cabb..8839161 100644 --- a/tests/V3toV4/X509/Fixture/CRL_load_CRL.php.inc +++ b/tests/V3toV4/X509/Fixture/CRL_load_CRL.php.inc @@ -21,7 +21,7 @@ final class SomeClass { function foo() { - $crl = CRL::loadCRL(file_get_contents('crl.bin')); + $crl = CRL::load(file_get_contents('crl.bin')); } } diff --git a/tests/V3toV4/X509/Fixture/CSR_load.php.inc b/tests/V3toV4/X509/Fixture/CSR_load.php.inc index cec3268..fa1c30e 100644 --- a/tests/V3toV4/X509/Fixture/CSR_load.php.inc +++ b/tests/V3toV4/X509/Fixture/CSR_load.php.inc @@ -21,7 +21,7 @@ final class SomeClass { public function foo() { - $csr = CSR::loadCSR(file_get_contents('csr.csr')); + $csr = CSR::load(file_get_contents('csr.csr')); } } diff --git a/tests/V3toV4/X509/Fixture/CSR_load_fullyqualified.php.inc b/tests/V3toV4/X509/Fixture/CSR_load_fullyqualified.php.inc index 2bd4c7b..67c8e67 100644 --- a/tests/V3toV4/X509/Fixture/CSR_load_fullyqualified.php.inc +++ b/tests/V3toV4/X509/Fixture/CSR_load_fullyqualified.php.inc @@ -18,6 +18,6 @@ final class SomeClass { function foo() { - $csr = CSR::loadCSR(file_get_contents('csr.csr')); + $csr = CSR::load(file_get_contents('csr.csr')); } } diff --git a/tests/V3toV4/X509/Fixture/CSR_setDnProp.php.inc b/tests/V3toV4/X509/Fixture/CSR_setDnProp.php.inc index b82764d..b31be85 100644 --- a/tests/V3toV4/X509/Fixture/CSR_setDnProp.php.inc +++ b/tests/V3toV4/X509/Fixture/CSR_setDnProp.php.inc @@ -18,7 +18,7 @@ use phpseclib4\File\CSR; class SetDNPropClass { public static function SetDNProp() { - $csr = CSR::loadCSR(file_get_contents('csr.csr')); + $csr = CSR::load(file_get_contents('csr.csr')); $csr->addDNProp('id-at-organizationName', 'phpseclib CA cert'); } } diff --git a/tests/V3toV4/X509/Fixture/SPKAC_create-fullyqualified.php.inc b/tests/V3toV4/X509/Fixture/SPKAC_create-fullyqualified.php.inc index 08b82f8..6f51ee8 100644 --- a/tests/V3toV4/X509/Fixture/SPKAC_create-fullyqualified.php.inc +++ b/tests/V3toV4/X509/Fixture/SPKAC_create-fullyqualified.php.inc @@ -15,12 +15,12 @@ final class SomeClass ----- getPublicKey()); + $spkac = new SPKAC($privKey->getPublicKey()); $spkac->setChallenge('123456789'); $privKey->sign($spkac); } diff --git a/tests/V3toV4/X509/Fixture/SPKAC_create.php.inc b/tests/V3toV4/X509/Fixture/SPKAC_create.php.inc index ac6b45f..ed0ed72 100644 --- a/tests/V3toV4/X509/Fixture/SPKAC_create.php.inc +++ b/tests/V3toV4/X509/Fixture/SPKAC_create.php.inc @@ -17,13 +17,13 @@ final class SomeClass ----- getPublicKey()); + $spkac = new SPKAC($privKey->getPublicKey()); $spkac->setChallenge('123456789'); $privKey->sign($spkac); } diff --git a/tests/V3toV4/X509/Fixture/SPKAC_load_SPKAC-fullyqualified.php.inc b/tests/V3toV4/X509/Fixture/SPKAC_load_SPKAC-fullyqualified.php.inc index b888582..6671681 100644 --- a/tests/V3toV4/X509/Fixture/SPKAC_load_SPKAC-fullyqualified.php.inc +++ b/tests/V3toV4/X509/Fixture/SPKAC_load_SPKAC-fullyqualified.php.inc @@ -13,11 +13,11 @@ final class SomeClass ----- ----- getPublicKey()); + $spkac = new SPKAC($privKey->getPublicKey()); $spkac->setChallenge('123456789'); } } diff --git a/tests/V3toV4/X509/Fixture/SPKAC_sign.php.inc b/tests/V3toV4/X509/Fixture/SPKAC_sign.php.inc index ef4b882..003ded2 100644 --- a/tests/V3toV4/X509/Fixture/SPKAC_sign.php.inc +++ b/tests/V3toV4/X509/Fixture/SPKAC_sign.php.inc @@ -16,13 +16,13 @@ final class SPKACSignClass ----- getPublicKey()); + $spkac = new SPKAC($privKey->getPublicKey()); $privKey->sign($spkac); } } diff --git a/tests/V3toV4/X509/config/rule.php b/tests/V3toV4/X509/config/rule.php index 1d277f3..26a84c7 100644 --- a/tests/V3toV4/X509/config/rule.php +++ b/tests/V3toV4/X509/config/rule.php @@ -4,9 +4,7 @@ use Rector\Config\RectorConfig; -use phpseclib\rectorRules\Rector\V3toV4\X509NodeVisitor; use phpseclib\rectorRules\Rector\V3toV4\X509; return RectorConfig::configure() - ->registerDecoratingNodeVisitor(X509NodeVisitor::class) ->withRules([X509::class]);