Test Setup Failed
Pull Request — master (#144)
by Sebastiao
02:26
created
src/DOMImproved.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      * @param DOMElement $child
190 190
      * @return void
191 191
      */
192
-    public function appExternalChild(DOMElement &$parent, DOMElement $child)
192
+    public function appExternalChild(DOMElement & $parent, DOMElement $child)
193 193
     {
194 194
         $node = $this->importNode($child, true);
195 195
         $parent->appendChild($node);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      * @return void
205 205
      */
206 206
     public function appExternalChildBefore(
207
-        DOMElement &$parent,
207
+        DOMElement & $parent,
208 208
         DOMElement $child,
209 209
         $before
210 210
     ) {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @param string $msg
227 227
      * @return void
228 228
      */
229
-    public function appChildBefore(DOMElement &$parent, DOMElement $child = null, $before = '', $msg = '')
229
+    public function appChildBefore(DOMElement & $parent, DOMElement $child = null, $before = '', $msg = '')
230 230
     {
231 231
         if (empty($child) ||
232 232
             empty($before) ||
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
      * @param array $arr
246 246
      * @return int
247 247
      */
248
-    public function addArrayChild(DOMElement &$parent, $arr)
248
+    public function addArrayChild(DOMElement & $parent, $arr)
249 249
     {
250 250
         $num = 0;
251
-        if (! empty($arr) && ! empty($parent)) {
251
+        if (!empty($arr) && !empty($parent)) {
252 252
             foreach ($arr as $node) {
253 253
                 $this->appChild($parent, $node, '');
254 254
                 $num++;
Please login to merge, or discard this patch.
src/Certificate/Oids.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
      */
52 52
     private static function loadOids()
53 53
     {
54
-        $json = file_get_contents(__DIR__ .'/oids.json');
54
+        $json = file_get_contents(__DIR__ . '/oids.json');
55 55
         self::$oidsTable = (array) json_decode($json, true);
56 56
     }
57 57
 }
Please login to merge, or discard this patch.
src/Soap/SoapClientExtended.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
     public function __doRequest($request, $location, $action, $version, $oneWay = 0)
32 32
     {
33
-        $search = [":ns1","ns1:","\n","\r"];
33
+        $search = [":ns1", "ns1:", "\n", "\r"];
34 34
         return parent::__doRequest(
35 35
             str_replace($search, '', $request),
36 36
             $location,
Please login to merge, or discard this patch.
src/Soap/SoapCode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 {
23 23
     public static function info($code)
24 24
     {
25
-        $codes = (array) json_decode(file_get_contents(__DIR__.'/httpcodes.json'), true);
25
+        $codes = (array) json_decode(file_get_contents(__DIR__ . '/httpcodes.json'), true);
26 26
         if (array_key_exists($code, $codes)) {
27 27
             return $codes[$code];
28 28
         }
Please login to merge, or discard this patch.
src/Certificate/PublicKey.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
src/Certificate/Asn1.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Exception/ExceptionCollection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     
45 45
     /**
46 46
      * Add exceptions to the collection
47
-     * @param Exception Exception to add
47
+     * @param Exception \Exception to add
48 48
      * @return ExceptionCollection;
49 49
      */
50 50
     public function add(\Exception $exception)
Please login to merge, or discard this patch.
src/Soap/SoapCurl.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 curl_setopt($oCurl, CURLOPT_KEYPASSWD, $this->temppass);
99 99
             }
100 100
             curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
101
-            if (! empty($envelope)) {
101
+            if (!empty($envelope)) {
102 102
                 curl_setopt($oCurl, CURLOPT_POST, 1);
103 103
                 curl_setopt($oCurl, CURLOPT_POSTFIELDS, $envelope);
104 104
                 curl_setopt($oCurl, CURLOPT_HTTPHEADER, $parameters);
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
         if ($this->proxyIP != '') {
141 141
             curl_setopt($oCurl, CURLOPT_HTTPPROXYTUNNEL, 1);
142 142
             curl_setopt($oCurl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
143
-            curl_setopt($oCurl, CURLOPT_PROXY, $this->proxyIP.':'.$this->proxyPort);
143
+            curl_setopt($oCurl, CURLOPT_PROXY, $this->proxyIP . ':' . $this->proxyPort);
144 144
             if ($this->proxyUser != '') {
145
-                curl_setopt($oCurl, CURLOPT_PROXYUSERPWD, $this->proxyUser.':'.$this->proxyPass);
145
+                curl_setopt($oCurl, CURLOPT_PROXYUSERPWD, $this->proxyUser . ':' . $this->proxyPass);
146 146
                 curl_setopt($oCurl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
147 147
             }
148 148
         }
Please login to merge, or discard this patch.
src/Signer.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -25,11 +25,9 @@
 block discarded – undo
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 NFePHP\Common\Validator;
30 29
 use DOMDocument;
31 30
 use DOMNode;
32
-use DOMElement;
33 31
 
34 32
 class Signer
35 33
 {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 class Signer
35 35
 {
36
-    private static $canonical = [true,false,null,null];
36
+    private static $canonical = [true, false, null, null];
37 37
     
38 38
     /**
39 39
      * Make Signature tag
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $tagname,
54 54
         $mark = 'Id',
55 55
         $algorithm = OPENSSL_ALGO_SHA1,
56
-        $canonical = [true,false,null,null],
56
+        $canonical = [true, false, null, null],
57 57
         $rootname = ''
58 58
     ) {
59 59
         if (!empty($canonical)) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         if (empty($content)) {
63 63
             throw SignerException::isNotXml();
64 64
         }
65
-        if (! Validator::isXML($content)) {
65
+        if (!Validator::isXML($content)) {
66 66
             throw SignerException::isNotXml();
67 67
         }
68 68
         $dom = new DOMDocument('1.0', 'UTF-8');
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         if (empty($node) || empty($root)) {
78 78
             throw SignerException::tagNotFound($tagname);
79 79
         }
80
-        if (! self::existsSignature($content)) {
80
+        if (!self::existsSignature($content)) {
81 81
             $dom = self::createSignature(
82 82
                 $certificate,
83 83
                 $dom,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         DOMNode $node,
111 111
         $mark,
112 112
         $algorithm = OPENSSL_ALGO_SHA1,
113
-        $canonical = [true,false,null,null]
113
+        $canonical = [true, false, null, null]
114 114
     ) {
115 115
         $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#';
116 116
         $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256';
123 123
             $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256';
124 124
         }
125
-        $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature';
125
+        $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature';
126 126
         $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
127 127
         $idSigned = trim($node->getAttribute($mark));
128 128
         $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public static function removeSignature($content)
179 179
     {
180
-        if (! self::existsSignature($content)) {
180
+        if (!self::existsSignature($content)) {
181 181
             return $content;
182 182
         }
183 183
         $dom = new \DOMDocument('1.0', 'utf-8');
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     public static function isSigned(
206 206
         $content,
207 207
         $tagname = '',
208
-        $canonical = [true,false,null,null]
208
+        $canonical = [true, false, null, null]
209 209
     ) {
210 210
         if (self::existsSignature($content)) {
211 211
             if (self::digestCheck($content, $tagname, $canonical)) {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public static function existsSignature($content)
226 226
     {
227
-        if (! Validator::isXML($content)) {
227
+        if (!Validator::isXML($content)) {
228 228
             throw SignerException::isNotXml();
229 229
         }
230 230
         $dom = new \DOMDocument('1.0', 'utf-8');
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     private static function signatureCheck(
248 248
         $xml,
249
-        $canonical = [true,false,null,null]
249
+        $canonical = [true, false, null, null]
250 250
     ) {
251 251
         $dom = new \DOMDocument('1.0', 'utf-8');
252 252
         $dom->formatOutput = false;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $decodedSignature = base64_decode(
273 273
             str_replace(array("\r", "\n"), '', $signatureValue)
274 274
         );
275
-        if (! $publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) {
275
+        if (!$publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) {
276 276
             throw SignerException::signatureComparisonFailed();
277 277
         }
278 278
         return true;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     private static function digestCheck(
289 289
         $xml,
290 290
         $tagname = '',
291
-        $canonical = [true,false,null,null]
291
+        $canonical = [true, false, null, null]
292 292
     ) {
293 293
         $dom = new \DOMDocument('1.0', 'utf-8');
294 294
         $dom->formatOutput = false;
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
     private static function makeDigest(
345 345
         DOMNode $node,
346 346
         $algorithm,
347
-        $canonical = [true,false,null,null]
347
+        $canonical = [true, false, null, null]
348 348
     ) {
349 349
         //calcular o hash dos dados
350 350
         $c14n = self::canonize($node, $canonical);
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
      */
361 361
     private static function canonize(
362 362
         DOMNode $node,
363
-        $canonical = [true,false,null,null]
363
+        $canonical = [true, false, null, null]
364 364
     ) {
365 365
         return $node->C14N(
366 366
             $canonical[0],
Please login to merge, or discard this patch.