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

Expand Psalm coverage #1757

Closed

Conversation

jack-worman
Copy link
Contributor

Psalm coverage to everywhere except phpseclib/Crypt/, phpseclib/Math/ and tests/

*/
public function withPassword($password = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change being made? Before, in PHPStorm, if you typed in $obj->withPassword you'd get a parameter hint that'd say withPassword(password). Now you get one that says withPassword(string)? In-so-far as parameter hints go this new one seems decidedly worse

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was because the arguments name in the interface is $string. I'll go ahead and update the interface to use $password instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.... good catch!

@@ -2382,6 +2382,9 @@ public function loadSPKAC($spkac)
$this->currentCert = false;
return false;
}
if (!is_array($spkac)) {
throw new \InvalidArgumentException('$spkac is not an array.');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right before this line there's this:

        if (!isset($spkac) || $spkac === false) {
            $this->currentCert = false;
            return false;
        }

We should (1) reset $this->currentCert to false and (2) we should either throw exceptions for every error or return false for every error. For be it from me to preach the need for consistency since phpseclib uses a mix of camelCase and snake_case but we ought to have it when we can.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3777,6 +3780,9 @@ private function formatSubjectPublicKey()

$decoded = ASN1::decodeBER($publicKey);
$mapped = ASN1::asn1map($decoded[0], Maps\SubjectPublicKeyInfo::MAP);
if (!is_array($mapped)) {
throw new \InvalidArgumentException('$mapped is not an array.');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return false for this one as well. X509.php is getting a massive rewrite for 4.0 and I may replace a lot of the return false's with exceptions but, for the time being, let's stick with return false!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

… and tests/

Revert "Removed remaining tabs"

This reverts commit 31c077d.

Revert "Whitespace php-cs-fixer.php rules added"

This reverts commit 25e3366.

Addressing comments
@terrafrost
Copy link
Member

I cherry-picked this from your branch into 3.0 and merged that into master:

b96fc26

Thanks!

@terrafrost terrafrost closed this Feb 14, 2022
@jack-worman jack-worman deleted the Expand_psalm_coverage branch February 15, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants