@@ -63,7 +63,7 @@ |
||
| 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 | { |
@@ -25,7 +25,6 @@ |
||
| 25 | 25 | use NFePHP\Common\Certificate; |
| 26 | 26 | use NFePHP\Common\Certificate\PublicKey; |
| 27 | 27 | use NFePHP\Common\Exception\SignerException; |
| 28 | -use NFePHP\Common\Strings; |
|
| 29 | 28 | use DOMDocument; |
| 30 | 29 | use DOMNode; |
| 31 | 30 | use DOMElement; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class Signer |
| 34 | 34 | { |
| 35 | - private static $canonical = [false,false,null,null]; |
|
| 35 | + private static $canonical = [false, false, null, null]; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Make Signature tag |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $tagname = '', |
| 52 | 52 | $mark = 'Id', |
| 53 | 53 | $algorithm = OPENSSL_ALGO_SHA1, |
| 54 | - $canonical = [false,false,null,null], |
|
| 54 | + $canonical = [false, false, null, null], |
|
| 55 | 55 | $rootname = '' |
| 56 | 56 | ) { |
| 57 | 57 | if (!empty($canonical)) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if (empty($node) || empty($root)) { |
| 70 | 70 | throw SignerException::tagNotFound($tagname); |
| 71 | 71 | } |
| 72 | - if (! self::existsSignature($dom)) { |
|
| 72 | + if (!self::existsSignature($dom)) { |
|
| 73 | 73 | $dom = self::createSignature( |
| 74 | 74 | $certificate, |
| 75 | 75 | $dom, |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | DOMNode $node, |
| 136 | 136 | $mark, |
| 137 | 137 | $algorithm = OPENSSL_ALGO_SHA1, |
| 138 | - $canonical = [false,false,null,null] |
|
| 138 | + $canonical = [false, false, null, null] |
|
| 139 | 139 | ) { |
| 140 | 140 | $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#'; |
| 141 | 141 | $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
| 148 | 148 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
| 149 | 149 | } |
| 150 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 150 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 151 | 151 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
| 152 | 152 | $idSigned = trim($node->getAttribute($mark)); |
| 153 | 153 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $node = $dom->getElementsByTagName($tagname)->item(0); |
| 250 | 250 | if (empty($node)) { |
| 251 | - throw new \RuntimeException('Tag not found ' .$tagname); |
|
| 251 | + throw new \RuntimeException('Tag not found ' . $tagname); |
|
| 252 | 252 | } |
| 253 | 253 | $signature = $dom->getElementsByTagName('Signature')->item(0); |
| 254 | 254 | if (empty($signature)) { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param array $canonical |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false,false,null,null]) |
|
| 288 | + private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false, false, null, null]) |
|
| 289 | 289 | { |
| 290 | 290 | //calcular o hash dos dados |
| 291 | 291 | $c14n = $node->C14N( |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | //get length of OID data |
| 78 | 78 | $len = self::getLength((string) $data); |
| 79 | 79 | //get only a string with bytes belongs to OID |
| 80 | - $oidData = substr($data, 2 + $bytes, $len-($bytes)); |
|
| 80 | + $oidData = substr($data, 2 + $bytes, $len - ($bytes)); |
|
| 81 | 81 | //parse OID data many possibel formats and structures |
| 82 | 82 | $head = strlen($oidData) - strlen($xcv) - 2; |
| 83 | 83 | $ret = substr($oidData, -$head); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | if ($num == 0) { |
| 122 | 122 | $bun = 40 * $partes[$num]; |
| 123 | 123 | } elseif ($num == 1) { |
| 124 | - $bun += $partes[$num]; |
|
| 124 | + $bun += $partes[$num]; |
|
| 125 | 125 | $abBinary[] = $bun; |
| 126 | 126 | } else { |
| 127 | 127 | $abBinary = self::xBase128((array) $abBinary, (integer) $partes[$num], true); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $abc = $abIn; |
| 147 | 147 | if ($qIn > 127) { |
| 148 | - $abc = self::xBase128($abc, floor($qIn/128), false); |
|
| 148 | + $abc = self::xBase128($abc, floor($qIn / 128), false); |
|
| 149 | 149 | } |
| 150 | 150 | $qIn2 = $qIn % 128; |
| 151 | 151 | if ($flag) { |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | */ |
| 88 | 88 | public function __toString() |
| 89 | 89 | { |
| 90 | - $messages = array_map(function (\Exception $exception) { |
|
| 90 | + $messages = array_map(function(\Exception $exception) { |
|
| 91 | 91 | return $exception->getMessage(); |
| 92 | 92 | }, $this->exceptions); |
| 93 | 93 | return implode(PHP_EOL, $messages); |