1 | <?php |
||
17 | class PublicKey implements VerificationInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $rawKey; |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | public $commonName; |
||
27 | /** |
||
28 | * @var \DateTime |
||
29 | */ |
||
30 | public $validFrom; |
||
31 | /** |
||
32 | * @var \DateTime |
||
33 | */ |
||
34 | public $validTo; |
||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | public $emailAddress; |
||
39 | /** |
||
40 | * @var string Cryptographic Service Provider |
||
41 | */ |
||
42 | public $cspName; |
||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | public $serialNumber; |
||
47 | |||
48 | /** |
||
49 | * PublicKey constructor. |
||
50 | * @param string $publicKey |
||
51 | */ |
||
52 | 19 | public function __construct($publicKey) |
|
57 | |||
58 | /** |
||
59 | * Load class with certificate content |
||
60 | * @param string $content |
||
61 | * @return \NFePHP\Common\Certificate\PublicKey |
||
62 | */ |
||
63 | 5 | public static function createFromContent($content) |
|
75 | |||
76 | /** |
||
77 | * Parse an X509 certificate and define the information in object |
||
78 | * @link http://php.net/manual/en/function.openssl-x509-read.php |
||
79 | * @link http://php.net/manual/en/function.openssl-x509-parse.php |
||
80 | * @return void |
||
81 | * @throws CertificateException Unable to open certificate |
||
82 | */ |
||
83 | 19 | protected function read() |
|
102 | |||
103 | /** |
||
104 | * Verify signature |
||
105 | * @link http://php.net/manual/en/function.openssl-verify.php |
||
106 | * @param string $data |
||
107 | * @param string $signature |
||
108 | * @param int $algorithm [optional] For more information see the list of Signature Algorithms. |
||
109 | * @return bool Returns true if the signature is correct, false if it is incorrect |
||
110 | * @throws CertificateException An error has occurred when verify signature |
||
111 | */ |
||
112 | 6 | public function verify($data, $signature, $algorithm = OPENSSL_ALGO_SHA1) |
|
120 | |||
121 | /** |
||
122 | * Check if is in valid date interval. |
||
123 | * @return bool Returns true |
||
124 | */ |
||
125 | 4 | public function isExpired() |
|
129 | |||
130 | /** |
||
131 | * Returns raw public key without markers and LF's |
||
132 | * @return string |
||
133 | */ |
||
134 | 5 | public function unFormated() |
|
139 | |||
140 | /** |
||
141 | * Returns raw public key |
||
142 | * @return string |
||
143 | */ |
||
144 | 1 | public function __toString() |
|
148 | |||
149 | /** |
||
150 | * Extract CNPJ number by OID |
||
151 | * @return string |
||
152 | */ |
||
153 | 1 | public function cnpj() |
|
157 | |||
158 | /** |
||
159 | * Extract CPF number by OID |
||
160 | * @return string |
||
161 | */ |
||
162 | 2 | public function cpf() |
|
166 | } |
||
167 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.