GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8abb02...91afec )
by Joni
07:17
created

examples/create-csr.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Create certification request.
4
 *
5
 * php create-csr.php
6
 */
7
8
use Sop\CryptoEncoding\PEM;
9
use Sop\CryptoTypes\AlgorithmIdentifier\Hash\SHA256AlgorithmIdentifier;
10
use Sop\CryptoTypes\AlgorithmIdentifier\Signature\SignatureAlgorithmIdentifierFactory;
11
use Sop\CryptoTypes\Asymmetric\PrivateKeyInfo;
12
use X501\ASN1\Name;
13
use X509\CertificationRequest\CertificationRequestInfo;
14
15
require dirname(__DIR__) . "/vendor/autoload.php";
16
17
// load EC private key from PEM
18
$private_key_info = PrivateKeyInfo::fromPEM(
19
    PEM::fromFile(dirname(__DIR__) . "/test/assets/ec/private_key.pem"));
20
// extract public key from private key
21
$public_key_info = $private_key_info->publicKeyInfo();
22
// DN of the subject
23
$subject = Name::fromString("cn=example.com, O=Example\, Inc., C=US");
24
// create certification request info
25
$cri = new CertificationRequestInfo($subject, $public_key_info);
26
// sign certificate request with private key
27
$algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto(
28
    $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier());
0 ignored issues
show
$private_key_info->algorithmIdentifier() of type object<Sop\CryptoTypes\A...lgorithmIdentifierType> is not a sub-type of object<Sop\CryptoTypes\A...ptoAlgorithmIdentifier>. It seems like you assume a child interface of the interface Sop\CryptoTypes\Algorith...AlgorithmIdentifierType to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
29
$csr = $cri->sign($algo, $private_key_info);
30
echo $csr;
31