feat: add three new V3→V4 rules and fix X509 rule bugs#5
Merged
Conversation
Fix X509 rule: - All file-class load methods (loadCSR, loadCRL, loadSPKAC) now correctly map to ::load() instead of ::loadCSR() / ::loadCRL() / ::loadSPKAC() - SPKAC creation now generates `new SPKAC(...)` instead of a static call on the wrong CRL class - Remove DecoratingNodeVisitor dependency (singleton conflict when running V2toV3 and V3toV4 test suites together); inline visitor logic into the rule itself using PhpParser\NodeFinder Add three new rules: - Namespace_: renames phpseclib3\ to phpseclib4\ in use statements and explicit FQNs; skips phpseclib3\File\X509 (handled by X509 rule) and phpseclib3\Crypt\Random (handled by CryptRandom rule) - CryptRandom: replaces phpseclib3\Crypt\Random::string(n) with random_bytes(n) and removes the now-unused use import - SFTPChmod: swaps the argument order of SFTP::chmod() calls from (mode, path) to (path, mode) to match the phpseclib4 signature Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loadCSR,loadCRL,loadSPKAC) were mapped to wrong target method names; SPKAC creation used the wrong class (CRLinstead ofSPKAC) and wrong node type (static call instead ofnew). Also removes theDecoratingNodeVisitordependency that caused test failures when the V2→V3 and V3→V4 suites ran together (PHPStan'sNodeScopeResolveris a singleton whose internal traverser can only be built once).Namespace_rule: renamesphpseclib3\tophpseclib4\inusestatements and explicit inline FQNs. Short names (e.g.RSAafteruse phpseclib3\Crypt\RSA) are left alone — renaming theusestatement is sufficient. Skipsphpseclib3\File\X509(handled by the X509 rule) andphpseclib3\Crypt\Random(no phpseclib4 equivalent).CryptRandomrule: replacesphpseclib3\Crypt\Random::string($n)(both viauseimport and as a fully-qualified call) withrandom_bytes($n), and removes the now-deaduseimport.SFTPChmodrule: swaps the argument order ofSFTP::chmod()from(mode, path[, recursive])to(path, mode[, recursive])to match the phpseclib4 signature. Only applies when the first argument is an integer literal; calls that already have a string first argument are left unchanged.Test plan
php vendor/bin/phpunit tests/V3toV4— all 35 tests passphp vendor/bin/phpunit tests/— all 99 tests pass (V2→V3 + V3→V4 combined)🤖 Generated with Claude Code