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 ( 3a317d...2b814d )
by Akpé Aurelle Emmanuel Moïse
13s queued 10s
created
src/beforeStrip.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
 namespace EZAMA{
4 4
 class beforeStrip
5 5
 {
6
-    protected $multi = false;
7
-    protected $is_html = false;
8
-    protected $is_php = false;
9
-    protected $html = [];
10
-    protected $php = [];
11
-    protected $content = '';
6
+    protected $multi=false;
7
+    protected $is_html=false;
8
+    protected $is_php=false;
9
+    protected $html=[];
10
+    protected $php=[];
11
+    protected $content='';
12 12
     protected $doctype;
13 13
     protected $body;
14 14
     protected $head;
@@ -19,58 +19,58 @@  discard block
 block discarded – undo
19 19
         if (!is_string($html)) {
20 20
             throw new \InvalidArgumentException(sprintf('Waiting string, %s given', gettype($html)));
21 21
         }
22
-        $html = is_file($html) ? file_get_contents($html) : $html;
22
+        $html=is_file($html) ? file_get_contents($html) : $html;
23 23
         $this->setMainTags($html);
24 24
 
25
-        $html = '<div>' . str_replace(
25
+        $html='<div>'.str_replace(
26 26
             [$this->doctype, $this->html_tag, '</html>', $this->head, '</head>', $this->body, '</body>'],
27
-            ['<doctypetag' . substr($this->doctype, 9), '<htmltag ' . substr($this->html_tag, 5), '</htmltag>', '<headtag ' . substr($this->head, 5), '</headtag>', '<bodytag ' . substr($this->body, 5), '</bodytag>'],
27
+            ['<doctypetag'.substr($this->doctype, 9), '<htmltag '.substr($this->html_tag, 5), '</htmltag>', '<headtag '.substr($this->head, 5), '</headtag>', '<bodytag '.substr($this->body, 5), '</bodytag>'],
28 28
             $html
29
-                                ) . '</doctypetag></div>';
30
-        $preprocessed = token_get_all($html);
29
+                                ).'</doctypetag></div>';
30
+        $preprocessed=token_get_all($html);
31 31
 
32
-        $HTML = array_filter($preprocessed, function ($v) {
33
-            return is_array($v) && $v[0] === T_INLINE_HTML;
32
+        $HTML=array_filter($preprocessed, function($v) {
33
+            return is_array($v)&&$v[0]===T_INLINE_HTML;
34 34
         });
35
-        $PHP = array_diff_key($preprocessed, $HTML);
35
+        $PHP=array_diff_key($preprocessed, $HTML);
36 36
         $this->init($HTML, $PHP, $html);
37 37
     }
38 38
 
39 39
     protected function setMainTags(&$html)
40 40
     {
41
-        $doctypeOffset = stripos($html, '<!doctype');
42
-        $headOffset = stripos($html, '<head');
43
-        $htmlTagOffset = stripos($html, '<html');
44
-        $bodyOffset = stripos($html, '<body');
45
-        if (false !== $doctypeOffset) {
46
-            $endDoctypeOffset = strpos($html, '>', $doctypeOffset);
47
-            $this->doctype = substr($html, $doctypeOffset, $endDoctypeOffset - $doctypeOffset + 1);
41
+        $doctypeOffset=stripos($html, '<!doctype');
42
+        $headOffset=stripos($html, '<head');
43
+        $htmlTagOffset=stripos($html, '<html');
44
+        $bodyOffset=stripos($html, '<body');
45
+        if (false!==$doctypeOffset) {
46
+            $endDoctypeOffset=strpos($html, '>', $doctypeOffset);
47
+            $this->doctype=substr($html, $doctypeOffset, $endDoctypeOffset-$doctypeOffset+1);
48 48
         }
49
-        if (false !== $headOffset) {
50
-            $endHeadOffset = strpos($html, '>', $headOffset);
51
-            $this->head = substr($html, $headOffset, $endHeadOffset - $headOffset + 1);
49
+        if (false!==$headOffset) {
50
+            $endHeadOffset=strpos($html, '>', $headOffset);
51
+            $this->head=substr($html, $headOffset, $endHeadOffset-$headOffset+1);
52 52
         }
53
-        if (false !== $bodyOffset) {
54
-            $endBodyOffset = strpos($html, '>', $bodyOffset);
55
-            $this->body = substr($html, $bodyOffset, $endBodyOffset - $bodyOffset + 1);
53
+        if (false!==$bodyOffset) {
54
+            $endBodyOffset=strpos($html, '>', $bodyOffset);
55
+            $this->body=substr($html, $bodyOffset, $endBodyOffset-$bodyOffset+1);
56 56
         }
57
-        if (false !== $htmlTagOffset) {
58
-            $endHtmlTagOffset = strpos($html, '>', $htmlTagOffset);
59
-            $this->html_tag = substr($html, $htmlTagOffset, $endHtmlTagOffset - $htmlTagOffset + 1);
57
+        if (false!==$htmlTagOffset) {
58
+            $endHtmlTagOffset=strpos($html, '>', $htmlTagOffset);
59
+            $this->html_tag=substr($html, $htmlTagOffset, $endHtmlTagOffset-$htmlTagOffset+1);
60 60
         }
61 61
     }
62 62
 
63 63
     protected function init(&$HTML, &$PHP, &$html)
64 64
     {
65
-        $is_h = (bool)$HTML;
66
-        $is_p = (bool)$PHP;
67
-
68
-        $this->is_html = $is_h;
69
-        $this->is_php = $is_p;
70
-        $this->multi = $is_h && $is_p;
71
-        $this->content = $html;
72
-        $this->html = $is_p ? $HTML : [];
73
-        $this->php = $is_p ? $PHP : [];
65
+        $is_h=(bool)$HTML;
66
+        $is_p=(bool)$PHP;
67
+
68
+        $this->is_html=$is_h;
69
+        $this->is_php=$is_p;
70
+        $this->multi=$is_h&&$is_p;
71
+        $this->content=$html;
72
+        $this->html=$is_p ? $HTML : [];
73
+        $this->php=$is_p ? $PHP : [];
74 74
     }
75 75
 
76 76
     public function mustLoadMulti()
Please login to merge, or discard this patch.
src/htmlStrip.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@  discard block
 block discarded – undo
5 5
 {
6 6
     protected $type;
7 7
 
8
-    public function __construct($html, $type = 'replace', $notAllowedTags = ['', false], $notAllowedAttributes = ['', false])
8
+    public function __construct($html, $type='replace', $notAllowedTags=['', false], $notAllowedAttributes=['', false])
9 9
     {
10
-        $callback = function ($v) {
10
+        $callback=function($v) {
11 11
             return trim(strtolower($v));
12 12
         };
13
-        if (!$this->handleTags($notAllowedTags, $callback, function ($v) {
13
+        if (!$this->handleTags($notAllowedTags, $callback, function($v) {
14 14
             return isset(self::$tags[$v]);
15 15
         })) {
16
-            $this->allowedTags = self::$tags;
16
+            $this->allowedTags=self::$tags;
17 17
         }
18
-        if (!$this->handleAttributes($notAllowedAttributes, $callback, function ($v) {
18
+        if (!$this->handleAttributes($notAllowedAttributes, $callback, function($v) {
19 19
             return isset(self::$attributes[$v]);
20 20
         })) {
21
-            $this->allowedAttributes = self::$attributes;
21
+            $this->allowedAttributes=self::$attributes;
22 22
         }
23
-        $this->type = !is_string($type) || !in_array($tmp = strtolower(trim($type)), ['remove', 'replace']) ? 'remove' : $tmp;
23
+        $this->type=!is_string($type)||!in_array($tmp=strtolower(trim($type)), ['remove', 'replace']) ? 'remove' : $tmp;
24 24
 
25
-        $bs = new BeforeStrip($html);
26
-        $this->is_html = $bs->isHtml();
27
-        $this->is_php = $bs->isPHP();
28
-        $bs = new prepareStrip($bs);
25
+        $bs=new BeforeStrip($html);
26
+        $this->is_html=$bs->isHtml();
27
+        $this->is_php=$bs->isPHP();
28
+        $bs=new prepareStrip($bs);
29 29
         $this->loadHTML($bs->getPrepared());
30 30
     }
31 31
 
32
-    public function go($type = self::TAGS)
32
+    public function go($type=self::TAGS)
33 33
     {
34 34
         switch ($type) {
35 35
             case self::TAGS_AND_ATTRIBUTES:
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 
53 53
     protected static function strip($domDoc, $type, $allowed_tags, $allowed_attrs, $is_php)
54 54
     {
55
-        $firstDiv = 0;
56
-        if (count(self::$tags) > count($allowed_tags) || count(self::$attributes) > count($allowed_attrs)) {
55
+        $firstDiv=0;
56
+        if (count(self::$tags)>count($allowed_tags)||count(self::$attributes)>count($allowed_attrs)) {
57 57
             foreach (new DOMNodeRecursiveIterator($domDoc->getElementsByTagName('*'))as $tag) {
58
-                if (!isset($allowed_tags['<' . $tag->tagName . '>'])) {
58
+                if (!isset($allowed_tags['<'.$tag->tagName.'>'])) {
59 59
                     if (self::skipUsefull($tag, $firstDiv)) {
60 60
                         continue;
61 61
                     }
@@ -73,25 +73,25 @@  discard block
 block discarded – undo
73 73
 
74 74
     protected static function skipUsefull($tag, &$firstDiv)
75 75
     {
76
-        if ($tag->tagName === 'div' && !$firstDiv) {
76
+        if ($tag->tagName==='div'&&!$firstDiv) {
77 77
             $firstDiv++;
78 78
 
79 79
             return true;
80 80
         }
81
-        if ($tag->tagName === 'doctypetag') {
81
+        if ($tag->tagName==='doctypetag') {
82 82
             return true;
83 83
         }
84 84
     }
85 85
 
86 86
     private static function replaceOrRemove($tag, $type)
87 87
     {
88
-        if ($type === 'remove') {
88
+        if ($type==='remove') {
89 89
             $tag->parentNode->removeChild($tag);
90 90
         } else {
91 91
             if (!in_array(strtolower($tag->tagName), ['php', 'style', 'script'])) {
92
-                $elem = $tag->parentNode;
93
-                $childNodes = $tag->childNodes;
94
-                while ($childNodes->length > 0) {
92
+                $elem=$tag->parentNode;
93
+                $childNodes=$tag->childNodes;
94
+                while ($childNodes->length>0) {
95 95
                     $elem->insertBefore($childNodes->item(0), $tag);
96 96
                 }
97 97
                 $elem->removeChild($tag);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     protected static function stripTagsWithAttributes($domDoc, &$allowed_tags, &$allowed_attrs, $is_php)
105 105
     {
106
-        if (count(self::$attributes) > count($allowed_attrs)) {
106
+        if (count(self::$attributes)>count($allowed_attrs)) {
107 107
             foreach (new DOMNodeRecursiveIterator($domDoc->getElementsByTagName('*'))as $tag) {
108 108
                 self::stripAttributes($tag, $allowed_attrs, 2);
109 109
             }
Please login to merge, or discard this patch.
src/prepareStrip.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
     public function __construct(beforeStrip $prepocessed)
10 10
     {
11 11
         if ($prepocessed->mustLoadMulti()) {
12
-            $this->state = 'multi';
12
+            $this->state='multi';
13 13
         } else {
14
-            $this->state = 'single';
14
+            $this->state='single';
15 15
         }
16
-        $this->prepocessed = $prepocessed;
16
+        $this->prepocessed=$prepocessed;
17 17
     }
18 18
 
19 19
     public function getPrepared()
20 20
     {
21
-        if ($this->state === 'single') {
21
+        if ($this->state==='single') {
22 22
             return $this->prepocessed->getContent();
23 23
         }
24
-        $prepared = $this->preparePhp() + $this->prepareHtml();
24
+        $prepared=$this->preparePhp()+$this->prepareHtml();
25 25
         ksort($prepared);
26 26
 
27 27
         return join('', $prepared);
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function prepareHtml()
31 31
     {
32
-        return  array_map(function ($v) {
32
+        return  array_map(function($v) {
33 33
             return is_array($v) ? $v[1] : $v;
34 34
         }, $this->prepocessed->getHTML());
35 35
     }
36 36
 
37 37
     public function preparePhp()
38 38
     {
39
-        return array_map(function ($v) {
40
-            return is_array($v) && ($v[0] === T_OPEN_TAG || $v[0] === T_CLOSE_TAG) ? ($v[0] === T_OPEN_TAG ? '<php>' : '</php>') : (is_array($v) ? $v[1] : $v);
39
+        return array_map(function($v) {
40
+            return is_array($v)&&($v[0]===T_OPEN_TAG||$v[0]===T_CLOSE_TAG) ? ($v[0]===T_OPEN_TAG ? '<php>' : '</php>') : (is_array($v) ? $v[1] : $v);
41 41
         }, $this->prepocessed->getPHP());
42 42
     }
43 43
 }
Please login to merge, or discard this patch.
src/DOMNodeRecursiveIterator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@
 block discarded – undo
5 5
 {
6 6
     public function __construct(\DOMNodeList $node_list)
7 7
     {
8
-        $nodes = [];
8
+        $nodes=[];
9 9
         foreach ($node_list as $node) {
10
-            $nodes[] = $node;
10
+            $nodes[]=$node;
11 11
         }
12 12
 
13 13
         parent::__construct($nodes);
Please login to merge, or discard this patch.
src/htmlStripHelper.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -3,21 +3,21 @@  discard block
 block discarded – undo
3 3
 namespace EZAMA{
4 4
 abstract class htmlStripHelper
5 5
 {
6
-    const TAGS = 3;
7
-    const ATTRIBUTES = 4;
8
-    const TAGS_AND_ATTRIBUTES = 1;
9
-    const TAGS_WITH_ATTRIBUTES = 2;
6
+    const TAGS=3;
7
+    const ATTRIBUTES=4;
8
+    const TAGS_AND_ATTRIBUTES=1;
9
+    const TAGS_WITH_ATTRIBUTES=2;
10 10
 
11
-    protected $is_php = false;
12
-    protected $is_html = false;
13
-    protected $allowedTags = [];
14
-    protected $allowedAttributes = [];
15
-    protected $html = '';
11
+    protected $is_php=false;
12
+    protected $is_html=false;
13
+    protected $allowedTags=[];
14
+    protected $allowedAttributes=[];
15
+    protected $html='';
16 16
     protected $doctype;
17 17
     protected $body;
18 18
     protected $head;
19 19
     protected $html_tag;
20
-    protected static $events_attributes = [
20
+    protected static $events_attributes=[
21 21
     'onabort' => 1,
22 22
     'onafterprint' => 1,
23 23
     'onbeforeprint' => 1,
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     'onwheel' => 1,
88 88
     ];
89 89
 
90
-    protected static $attributes = [
90
+    protected static $attributes=[
91 91
     'accept' => 1,
92 92
     'accesskey' => 1,
93 93
     'action' => 1,
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
     'width' => 1,
249 249
     'wrap' => 1,
250 250
 ];
251
-    protected static $special_tags = ['<doctypetag>' => '<!doctype>', '<htmltag>' => '<html>', '<headtag>' => '<head>', '<htmltag>' => '<html>', '<bodytag>' => '<body>'];
252
-    protected static $tags = [
251
+    protected static $special_tags=['<doctypetag>' => '<!doctype>', '<htmltag>' => '<html>', '<headtag>' => '<head>', '<htmltag>' => '<html>', '<bodytag>' => '<body>'];
252
+    protected static $tags=[
253 253
     '<php>' => 1,
254 254
     '<!-- -->' => 1,
255 255
     '<doctypetag>' => 1,
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
         if (!strlen($html)) {
383 383
             throw new \InvalidArgumentException('Empty string given');
384 384
         }
385
-        $xml = new \DOMDocument();
385
+        $xml=new \DOMDocument();
386 386
         //Suppress warnings: proper error handling is beyond scope of example
387 387
         libxml_use_internal_errors(true);
388 388
 
389
-        $true = $xml->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
389
+        $true=$xml->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
390 390
         if ($true) {
391
-            $this->html = $xml;
391
+            $this->html=$xml;
392 392
         }
393 393
     }
394 394
 
@@ -397,19 +397,19 @@  discard block
 block discarded – undo
397 397
         if (!is_array($notAllowedTags)) {
398 398
             return false;
399 399
         }
400
-        if (count($notAllowedTags) !== 2) {
400
+        if (count($notAllowedTags)!==2) {
401 401
             return false;
402 402
         }
403
-        $notAllowedTags = array_values($notAllowedTags);
404
-        $keep = (bool)$notAllowedTags[1];
405
-        $notAllowedTags = $notAllowedTags[0];
403
+        $notAllowedTags=array_values($notAllowedTags);
404
+        $keep=(bool)$notAllowedTags[1];
405
+        $notAllowedTags=$notAllowedTags[0];
406 406
         if (is_string($notAllowedTags)) {
407
-            $notAllowedTags = explode(',', $notAllowedTags);
407
+            $notAllowedTags=explode(',', $notAllowedTags);
408 408
         }
409 409
         if (is_array($notAllowedTags)) {
410 410
             self::checkSpecialTags($notAllowedTags);
411
-            $notAllowedTags = array_filter(array_map($callback, $notAllowedTags), $callback1);
412
-            $this->allowedTags = !$keep ? array_fill_keys($notAllowedTags, 1) : array_diff_key(self::$tags, array_flip($notAllowedTags));
411
+            $notAllowedTags=array_filter(array_map($callback, $notAllowedTags), $callback1);
412
+            $this->allowedTags=!$keep ? array_fill_keys($notAllowedTags, 1) : array_diff_key(self::$tags, array_flip($notAllowedTags));
413 413
         } else {
414 414
             return false;
415 415
         }
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
     protected static function checkSpecialTags(&$notAllowedTags)
421 421
     {
422 422
         foreach (self::$special_tags as $fakeTag => $trueTag) {
423
-            if (false !== $key = array_search($trueTag, $notAllowedTags, true)) {
424
-                $notAllowedTags[$key] = $fakeTag;
423
+            if (false!==$key=array_search($trueTag, $notAllowedTags, true)) {
424
+                $notAllowedTags[$key]=$fakeTag;
425 425
             }
426 426
         }
427 427
     }
@@ -431,17 +431,17 @@  discard block
 block discarded – undo
431 431
         if (!is_array($notAllowedAttributes)) {
432 432
             return false;
433 433
         }
434
-        if (count($notAllowedAttributes) !== 2) {
434
+        if (count($notAllowedAttributes)!==2) {
435 435
             return false;
436 436
         }
437
-        $keep = (bool)$notAllowedAttributes[1];
438
-        $notAllowedAttributes = $notAllowedAttributes[0];
437
+        $keep=(bool)$notAllowedAttributes[1];
438
+        $notAllowedAttributes=$notAllowedAttributes[0];
439 439
         if (is_string($notAllowedAttributes)) {
440
-            $notAllowedAttributes = explode(',', $notAllowedAttributes);
440
+            $notAllowedAttributes=explode(',', $notAllowedAttributes);
441 441
         }
442 442
         if (is_array($notAllowedAttributes)) {
443
-            $notAllowedAttributes = array_filter(array_map($callback, $notAllowedAttributes), $callback2);
444
-            $this->allowedAttributes = !$keep ? array_fill_keys($notAllowedAttributes, 1) : array_diff_key(self::$attributes, array_flip($notAllowedAttributes));
443
+            $notAllowedAttributes=array_filter(array_map($callback, $notAllowedAttributes), $callback2);
444
+            $this->allowedAttributes=!$keep ? array_fill_keys($notAllowedAttributes, 1) : array_diff_key(self::$attributes, array_flip($notAllowedAttributes));
445 445
         } else {
446 446
             return false;
447 447
         }
@@ -451,41 +451,41 @@  discard block
 block discarded – undo
451 451
 
452 452
     protected static function handlePhp($is_php, $domDoc, &$allowed_tags)
453 453
     {
454
-        $result = $domDoc->saveHTML();
454
+        $result=$domDoc->saveHTML();
455 455
         self::handleMainHtmlTags($result, $allowed_tags);
456 456
 
457
-        return substr(($is_php && isset($allowed_tags['<php>'])) ?
458
-        str_replace(['<php>', '</php>'], ['<?php ', '?>'], $result) : $result, stripos($result, '<div>') + 5, -7);
457
+        return substr(($is_php&&isset($allowed_tags['<php>'])) ?
458
+        str_replace(['<php>', '</php>'], ['<?php ', '?>'], $result) : $result, stripos($result, '<div>')+5, -7);
459 459
     }
460 460
 
461 461
     protected static function handleMainHtmlTags(&$result, &$allowed_tags)
462 462
     {
463
-        $result = str_replace(
463
+        $result=str_replace(
464 464
             ['<doctypetag', '</doctypetag>', '<headtag', '</headtag', '<htmltag', '</htmltag', '<bodytag', '</bodytag'],
465 465
             ['<!doctype', '', '<head', '</head', '<html', '</html', '<body', '</body'],
466 466
             $result
467 467
                         );
468 468
         if (!isset($allowed_tags['<doctypetag>'])) {
469
-            $doctypeOffset = stripos($result, '<!doctype');
470
-            $result = str_replace(substr($result, $doctypeOffset, strpos($result, '>', $doctypeOffset) + 1 - $doctypeOffset), '', $result);
469
+            $doctypeOffset=stripos($result, '<!doctype');
470
+            $result=str_replace(substr($result, $doctypeOffset, strpos($result, '>', $doctypeOffset)+1-$doctypeOffset), '', $result);
471 471
         }
472 472
     }
473 473
 
474 474
     protected static function handleComments($domDoc, &$allowed_tags)
475 475
     {
476 476
         if (!isset($allowed_tags['<!-- -->'])) {
477
-            $xpath = new \DOMXPath($domDoc);
478
-            $DomComments = $xpath->query('//comment()');
477
+            $xpath=new \DOMXPath($domDoc);
478
+            $DomComments=$xpath->query('//comment()');
479 479
             foreach ($DomComments as $DomComment) {
480 480
                 $DomComment->parentNode->removeChild($DomComment);
481 481
             }
482 482
         }
483 483
     }
484 484
 
485
-    protected static function stripAttributes($tag, &$allowed_attrs, $type = 1)
485
+    protected static function stripAttributes($tag, &$allowed_attrs, $type=1)
486 486
     {
487 487
         if ($tag instanceof \DOMElement) {
488
-            if ($type === 2) {
488
+            if ($type===2) {
489 489
                 self:: stripAttributesTypeTwo($tag, $allowed_attrs);
490 490
             } else {
491 491
                 self::stripAttributesTypeOne($tag, $allowed_attrs);
Please login to merge, or discard this patch.