@@ -53,7 +53,7 @@ |
||
53 | 53 | * Read PFX and return this class |
54 | 54 | * @param string $content |
55 | 55 | * @param string $password |
56 | - * @return \static |
|
56 | + * @return Certificate |
|
57 | 57 | * @throws CertificateException |
58 | 58 | */ |
59 | 59 | public static function readPfx($content, $password) |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Add new certificate to certification chain |
43 | - * @param string $contente Certificate in DER, CER or PEM format |
|
43 | + * @param string $content Certificate in DER, CER or PEM format |
|
44 | 44 | * @return array |
45 | 45 | */ |
46 | 46 | public function add($content) |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Load class with certificate content |
65 | 65 | * @param string $content |
66 | - * @return \static |
|
66 | + * @return PublicKey |
|
67 | 67 | */ |
68 | 68 | public static function createFromContent($content) |
69 | 69 | { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param string $data |
109 | 109 | * @param string $signature |
110 | 110 | * @param int $algorithm [optional] For more information see the list of Signature Algorithms. |
111 | - * @return int Returns true if the signature is correct, false if it is incorrect |
|
111 | + * @return boolean Returns true if the signature is correct, false if it is incorrect |
|
112 | 112 | * @throws CertificateException An error has occurred when verify signature |
113 | 113 | */ |
114 | 114 | public function verify($data, $signature, $algorithm = OPENSSL_ALGO_SHA1) |
@@ -93,8 +93,7 @@ |
||
93 | 93 | $detail = openssl_x509_parse($resource, false); |
94 | 94 | $this->commonName = $detail['subject']['commonName']; |
95 | 95 | $this->emailAddress = !empty($detail['subject']['emailAddress']) ? |
96 | - $detail['subject']['emailAddress'] : |
|
97 | - ''; |
|
96 | + $detail['subject']['emailAddress'] : ''; |
|
98 | 97 | $this->cspName = $detail['issuer']['organizationalUnitName']; |
99 | 98 | $this->serialNumber = $detail['serialNumber']; |
100 | 99 | $this->validFrom = \DateTime::createFromFormat('ymdHis\Z', $detail['validFrom']); |
@@ -55,7 +55,7 @@ |
||
55 | 55 | /** |
56 | 56 | * Load xml from path |
57 | 57 | * @param string $filename |
58 | - * @return bool |
|
58 | + * @return false|null |
|
59 | 59 | */ |
60 | 60 | public function loadXMLFile($filename) |
61 | 61 | { |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | public function getChave($nodeName = 'infNFe') |
126 | 126 | { |
127 | 127 | $node = $this->getElementsByTagName($nodeName)->item(0); |
128 | - if (! empty($node)) { |
|
128 | + if (!empty($node)) { |
|
129 | 129 | $chaveId = $node->getAttribute("Id"); |
130 | - $chave = preg_replace('/[^0-9]/', '', $chaveId); |
|
130 | + $chave = preg_replace('/[^0-9]/', '', $chaveId); |
|
131 | 131 | return $chave; |
132 | 132 | } |
133 | 133 | return ''; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return void |
148 | 148 | */ |
149 | 149 | public function addChild( |
150 | - DOMElement &$parent, |
|
150 | + DOMElement & $parent, |
|
151 | 151 | $name, |
152 | 152 | $content = '', |
153 | 153 | $obrigatorio = false, |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param string $msg |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - public function appChild(DOMElement &$parent, DOMElement $child = null, $msg = '') |
|
177 | + public function appChild(DOMElement & $parent, DOMElement $child = null, $msg = '') |
|
178 | 178 | { |
179 | 179 | if (empty($child)) { |
180 | 180 | $this->erros[] = $msg; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param DOMElement $parent |
189 | 189 | * @param DOMElement $child |
190 | 190 | */ |
191 | - public function appExternalChild(DOMElement &$parent, DOMElement $child) |
|
191 | + public function appExternalChild(DOMElement & $parent, DOMElement $child) |
|
192 | 192 | { |
193 | 193 | $node = $this->importNode($child, true); |
194 | 194 | $parent->appendChild($node); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return void |
204 | 204 | */ |
205 | 205 | public function appExternalChildBefore( |
206 | - DOMElement &$parent, |
|
206 | + DOMElement & $parent, |
|
207 | 207 | DOMElement $child, |
208 | 208 | $before |
209 | 209 | ) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $msg |
226 | 226 | * @return void |
227 | 227 | */ |
228 | - public function appChildBefore(DOMElement &$parent, DOMElement $child = null, $before = '', $msg = '') |
|
228 | + public function appChildBefore(DOMElement & $parent, DOMElement $child = null, $before = '', $msg = '') |
|
229 | 229 | { |
230 | 230 | if (empty($child) || |
231 | 231 | empty($before) || |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | * @param array $arr |
245 | 245 | * @return int |
246 | 246 | */ |
247 | - public function addArrayChild(DOMElement &$parent, $arr) |
|
247 | + public function addArrayChild(DOMElement & $parent, $arr) |
|
248 | 248 | { |
249 | 249 | $num = 0; |
250 | - if (! empty($arr) && ! empty($parent)) { |
|
250 | + if (!empty($arr) && !empty($parent)) { |
|
251 | 251 | foreach ($arr as $node) { |
252 | 252 | $this->appChild($parent, $node, ''); |
253 | 253 | $num++; |
@@ -32,7 +32,6 @@ |
||
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Add exceptions to the collection |
35 | - * @param ExceptionCollection|\Exception $e Exception to add |
|
36 | 35 | * @return ExceptionCollection; |
37 | 36 | */ |
38 | 37 | public function add(\Exception $exception) |
@@ -71,7 +71,7 @@ |
||
71 | 71 | |
72 | 72 | public function __toString() |
73 | 73 | { |
74 | - $messages = array_map(function (\Exception $exception) { |
|
74 | + $messages = array_map(function(\Exception $exception) { |
|
75 | 75 | return $exception->getMessage(); |
76 | 76 | }, $this->exceptions); |
77 | 77 | return implode(PHP_EOL, $messages); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * Make Signature tag |
38 | 38 | * @param string $content |
39 | 39 | * @param string $tagname |
40 | - * @param string $marker for URI |
|
40 | + * @param string $mark for URI |
|
41 | 41 | * @param string $algorithm |
42 | 42 | * @param array $canonical parameters to format node for signature |
43 | 43 | * @param string $rootname name of tag to insert signature block |
@@ -102,7 +102,6 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Verify if xml signature is valid |
105 | - * @param string $content xml content |
|
106 | 105 | * @param string $tagname tag for sign |
107 | 106 | * @return boolean |
108 | 107 | */ |
@@ -237,8 +236,6 @@ discard block |
||
237 | 236 | /** |
238 | 237 | * digestCheck |
239 | 238 | * Verify digest value |
240 | - * @param string $content |
|
241 | - * @param string $tagid |
|
242 | 239 | * @return boolean |
243 | 240 | * @throws \NFePHP\Common\Exception\SignerException |
244 | 241 | */ |
@@ -24,7 +24,6 @@ |
||
24 | 24 | |
25 | 25 | use NFePHP\Common\Certificate; |
26 | 26 | use NFePHP\Common\Certificate\PublicKey; |
27 | -use NFePHP\Common\Strings; |
|
28 | 27 | use RuntimeException; |
29 | 28 | use DOMDocument; |
30 | 29 | use DOMElement; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Signer |
33 | 33 | { |
34 | - private static $canonical = [false,false,null,null]; |
|
34 | + private static $canonical = [false, false, null, null]; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Make Signature tag |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $tagname = '', |
51 | 51 | $mark = 'Id', |
52 | 52 | $algorithm = OPENSSL_ALGO_SHA1, |
53 | - $canonical = [false,false,null,null], |
|
53 | + $canonical = [false, false, null, null], |
|
54 | 54 | $rootname = '' |
55 | 55 | ) { |
56 | 56 | if (!empty($canonical)) { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'Tag not found ' . $tagname . ' ' . $rootname |
71 | 71 | ); |
72 | 72 | } |
73 | - if (! self::existsSignature($dom)) { |
|
73 | + if (!self::existsSignature($dom)) { |
|
74 | 74 | $dom = self::createSignature( |
75 | 75 | $certificate, |
76 | 76 | $dom, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | DOMElement $node, |
137 | 137 | $mark, |
138 | 138 | $algorithm = OPENSSL_ALGO_SHA1, |
139 | - $canonical = [false,false,null,null] |
|
139 | + $canonical = [false, false, null, null] |
|
140 | 140 | ) { |
141 | 141 | $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#'; |
142 | 142 | $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
149 | 149 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
150 | 150 | } |
151 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
151 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
152 | 152 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
153 | 153 | $idSigned = trim($node->getAttribute($mark)); |
154 | 154 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | $root = $dom->documentElement; |
251 | 251 | $node = $dom->getElementsByTagName($tagname)->item(0); |
252 | 252 | if (empty($node)) { |
253 | - throw new \RuntimeException('Tag not found ' .$tagname); |
|
253 | + throw new \RuntimeException('Tag not found ' . $tagname); |
|
254 | 254 | } |
255 | 255 | $signature = $dom->getElementsByTagName('Signature')->item(0); |
256 | - if (! empty($signature)) { |
|
256 | + if (!empty($signature)) { |
|
257 | 257 | $clone = $signature->cloneNode(true); |
258 | 258 | } else { |
259 | 259 | $signature = $dom->getElementsByTagName('Signature')->item(0); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param array $canonical |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false,false,null,null]) |
|
291 | + private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false, false, null, null]) |
|
292 | 292 | { |
293 | 293 | $dados = $node->C14N(true, false, null, null); |
294 | 294 | //calcular o hash dos dados |
@@ -17,7 +17,6 @@ |
||
17 | 17 | |
18 | 18 | use NFePHP\Common\Certificate; |
19 | 19 | use NFePHP\Common\Soap\SoapInterface; |
20 | -use NFePHP\Common\Exception\SoapException; |
|
21 | 20 | use NFePHP\Common\Exception\RuntimeException; |
22 | 21 | use NFePHP\Common\Strings; |
23 | 22 | use League\Flysystem\Filesystem; |
@@ -250,9 +250,9 @@ |
||
250 | 250 | ); |
251 | 251 | } |
252 | 252 | $this->certsdir = $this->certificate->getCnpj() . '/certs/'; |
253 | - $this->prifile = $this->certsdir. Strings::randomString(10).'.pem'; |
|
254 | - $this->pubfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
255 | - $this->certfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
253 | + $this->prifile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
254 | + $this->pubfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
255 | + $this->certfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
256 | 256 | $ret = true; |
257 | 257 | $ret &= $this->filesystem->put( |
258 | 258 | $this->prifile, |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | /** |
198 | 198 | * Set security protocol |
199 | 199 | * @param int $protocol |
200 | - * @return type Description |
|
200 | + * @return integer Description |
|
201 | 201 | */ |
202 | 202 | public function protocol($protocol = self::SSL_DEFAULT) |
203 | 203 | { |
@@ -248,6 +248,7 @@ discard block |
||
248 | 248 | * @param string $operation |
249 | 249 | * @param array $namespaces |
250 | 250 | * @param \SOAPHeader $header |
251 | + * @param integer $soapver |
|
251 | 252 | * @return string |
252 | 253 | */ |
253 | 254 | protected function makeEnvelopeSoap( |
@@ -316,6 +317,7 @@ discard block |
||
316 | 317 | |
317 | 318 | /** |
318 | 319 | * Delete all files in folder |
320 | + * @param string $folder |
|
319 | 321 | */ |
320 | 322 | public function removeTemporarilyFiles($folder) |
321 | 323 | { |
@@ -16,7 +16,6 @@ |
||
16 | 16 | */ |
17 | 17 | use NFePHP\Common\Soap\SoapBase; |
18 | 18 | use NFePHP\Common\Soap\SoapInterface; |
19 | -use NFePHP\Common\Exception\SoapException; |
|
20 | 19 | use NFePHP\Common\Certificate; |
21 | 20 | use Psr\Log\LoggerInterface; |
22 | 21 |
@@ -39,10 +39,10 @@ |
||
39 | 39 | $dom->formatOutput = false; |
40 | 40 | $dom->loadXML($xml, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG); |
41 | 41 | libxml_clear_errors(); |
42 | - if (! $dom->schemaValidate($xsd)) { |
|
42 | + if (!$dom->schemaValidate($xsd)) { |
|
43 | 43 | $msg = ''; |
44 | 44 | foreach (libxml_get_errors() as $error) { |
45 | - $msg .= $error->message."\n"; |
|
45 | + $msg .= $error->message . "\n"; |
|
46 | 46 | } |
47 | 47 | throw new RuntimeException($msg); |
48 | 48 | } |