Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function register()
50 50
     {
51
-        if (\defined('T_ANON_CLASS')) {
52
-            $this->indicators[\T_ANON_CLASS] = \T_ANON_CLASS;
51
+        if ( \defined( 'T_ANON_CLASS' ) ) {
52
+            $this->indicators[ \T_ANON_CLASS ] = \T_ANON_CLASS;
53 53
         }
54 54
 
55
-        return array(\T_NEW);
55
+        return array( \T_NEW );
56 56
     }
57 57
 
58 58
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70
-        if ($this->supportsBelow('5.6') === false) {
70
+        if ( $this->supportsBelow( '5.6' ) === false ) {
71 71
             return;
72 72
         }
73 73
 
74 74
         $tokens       = $phpcsFile->getTokens();
75
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
76
-        if ($nextNonEmpty === false || isset($this->indicators[$tokens[$nextNonEmpty]['code']]) === false) {
75
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
76
+        if ( $nextNonEmpty === false || isset( $this->indicators[ $tokens[ $nextNonEmpty ][ 'code' ] ] ) === false ) {
77 77
             return;
78 78
         }
79 79
 
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Classes/NewConstVisibilitySniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function register()
37 37
     {
38
-        return array(\T_CONST);
38
+        return array( \T_CONST );
39 39
     }
40 40
 
41 41
     /**
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return void
49 49
      */
50
-    public function process(File $phpcsFile, $stackPtr)
50
+    public function process( File $phpcsFile, $stackPtr )
51 51
     {
52
-        if ($this->supportsBelow('7.0') === false) {
52
+        if ( $this->supportsBelow( '7.0' ) === false ) {
53 53
             return;
54 54
         }
55 55
 
56 56
         $tokens    = $phpcsFile->getTokens();
57
-        $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true);
57
+        $prevToken = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
58 58
 
59 59
         // Is the previous token a visibility indicator ?
60
-        if ($prevToken === false || isset(Tokens::$scopeModifiers[$tokens[$prevToken]['code']]) === false) {
60
+        if ( $prevToken === false || isset( Tokens::$scopeModifiers[ $tokens[ $prevToken ][ 'code' ] ] ) === false ) {
61 61
             return;
62 62
         }
63 63
 
64 64
         // Is this a class constant ?
65
-        if ($this->isClassConstant($phpcsFile, $stackPtr) === false) {
65
+        if ( $this->isClassConstant( $phpcsFile, $stackPtr ) === false ) {
66 66
             // This may be a constant declaration in the global namespace with visibility,
67 67
             // but that would throw a parse error, i.e. not our concern.
68 68
             return;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"',
73 73
             $stackPtr,
74 74
             'Found',
75
-            array($tokens[$prevToken]['content'])
75
+            array( $tokens[ $prevToken ][ 'content' ] )
76 76
         );
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Classes/NewClassesSniff.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -581,11 +581,11 @@  discard block
 block discarded – undo
581 581
     public function register()
582 582
     {
583 583
         // Handle case-insensitivity of class names.
584
-        $this->newClasses    = $this->arrayKeysToLowercase($this->newClasses);
585
-        $this->newExceptions = $this->arrayKeysToLowercase($this->newExceptions);
584
+        $this->newClasses    = $this->arrayKeysToLowercase( $this->newClasses );
585
+        $this->newExceptions = $this->arrayKeysToLowercase( $this->newExceptions );
586 586
 
587 587
         // Add the Exception classes to the Classes list.
588
-        $this->newClasses = array_merge($this->newClasses, $this->newExceptions);
588
+        $this->newClasses = array_merge( $this->newClasses, $this->newExceptions );
589 589
 
590 590
         $targets = array(
591 591
             \T_NEW,
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
             \T_CATCH,
597 597
         );
598 598
 
599
-        if (\defined('T_ANON_CLASS')) {
600
-            $targets[] = \T_ANON_CLASS;
599
+        if ( \defined( 'T_ANON_CLASS' ) ) {
600
+            $targets[ ] = \T_ANON_CLASS;
601 601
         }
602 602
 
603
-        if (\defined('T_RETURN_TYPE')) {
604
-            $targets[] = \T_RETURN_TYPE;
603
+        if ( \defined( 'T_RETURN_TYPE' ) ) {
604
+            $targets[ ] = \T_RETURN_TYPE;
605 605
         }
606 606
 
607 607
         return $targets;
@@ -617,33 +617,33 @@  discard block
 block discarded – undo
617 617
      *
618 618
      * @return void
619 619
      */
620
-    public function process(File $phpcsFile, $stackPtr)
620
+    public function process( File $phpcsFile, $stackPtr )
621 621
     {
622 622
         $tokens = $phpcsFile->getTokens();
623 623
 
624
-        switch ($tokens[$stackPtr]['type']) {
624
+        switch ( $tokens[ $stackPtr ][ 'type' ] ) {
625 625
             case 'T_FUNCTION':
626 626
             case 'T_CLOSURE':
627
-                $this->processFunctionToken($phpcsFile, $stackPtr);
627
+                $this->processFunctionToken( $phpcsFile, $stackPtr );
628 628
 
629 629
                 // Deal with older PHPCS version which don't recognize return type hints
630 630
                 // as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
631
-                $returnTypeHint = $this->getReturnTypeHintToken($phpcsFile, $stackPtr);
632
-                if ($returnTypeHint !== false) {
633
-                    $this->processReturnTypeToken($phpcsFile, $returnTypeHint);
631
+                $returnTypeHint = $this->getReturnTypeHintToken( $phpcsFile, $stackPtr );
632
+                if ( $returnTypeHint !== false ) {
633
+                    $this->processReturnTypeToken( $phpcsFile, $returnTypeHint );
634 634
                 }
635 635
                 break;
636 636
 
637 637
             case 'T_CATCH':
638
-                $this->processCatchToken($phpcsFile, $stackPtr);
638
+                $this->processCatchToken( $phpcsFile, $stackPtr );
639 639
                 break;
640 640
 
641 641
             case 'T_RETURN_TYPE':
642
-                $this->processReturnTypeToken($phpcsFile, $stackPtr);
642
+                $this->processReturnTypeToken( $phpcsFile, $stackPtr );
643 643
                 break;
644 644
 
645 645
             default:
646
-                $this->processSingularToken($phpcsFile, $stackPtr);
646
+                $this->processSingularToken( $phpcsFile, $stackPtr );
647 647
                 break;
648 648
         }
649 649
     }
@@ -658,29 +658,29 @@  discard block
 block discarded – undo
658 658
      *
659 659
      * @return void
660 660
      */
661
-    private function processSingularToken(File $phpcsFile, $stackPtr)
661
+    private function processSingularToken( File $phpcsFile, $stackPtr )
662 662
     {
663 663
         $tokens      = $phpcsFile->getTokens();
664 664
         $FQClassName = '';
665 665
 
666
-        if ($tokens[$stackPtr]['type'] === 'T_NEW') {
667
-            $FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr);
666
+        if ( $tokens[ $stackPtr ][ 'type' ] === 'T_NEW' ) {
667
+            $FQClassName = $this->getFQClassNameFromNewToken( $phpcsFile, $stackPtr );
668 668
 
669
-        } elseif ($tokens[$stackPtr]['type'] === 'T_CLASS' || $tokens[$stackPtr]['type'] === 'T_ANON_CLASS') {
670
-            $FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr);
669
+        } elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_CLASS' || $tokens[ $stackPtr ][ 'type' ] === 'T_ANON_CLASS' ) {
670
+            $FQClassName = $this->getFQExtendedClassName( $phpcsFile, $stackPtr );
671 671
 
672
-        } elseif ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') {
673
-            $FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr);
672
+        } elseif ( $tokens[ $stackPtr ][ 'type' ] === 'T_DOUBLE_COLON' ) {
673
+            $FQClassName = $this->getFQClassNameFromDoubleColonToken( $phpcsFile, $stackPtr );
674 674
         }
675 675
 
676
-        if ($FQClassName === '') {
676
+        if ( $FQClassName === '' ) {
677 677
             return;
678 678
         }
679 679
 
680
-        $className   = substr($FQClassName, 1); // Remove global namespace indicator.
681
-        $classNameLc = strtolower($className);
680
+        $className   = substr( $FQClassName, 1 ); // Remove global namespace indicator.
681
+        $classNameLc = strtolower( $className );
682 682
 
683
-        if (isset($this->newClasses[$classNameLc]) === false) {
683
+        if ( isset( $this->newClasses[ $classNameLc ] ) === false ) {
684 684
             return;
685 685
         }
686 686
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
             'name'   => $className,
689 689
             'nameLc' => $classNameLc,
690 690
         );
691
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
691
+        $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
692 692
     }
693 693
 
694 694
 
@@ -703,24 +703,24 @@  discard block
 block discarded – undo
703 703
      *
704 704
      * @return void
705 705
      */
706
-    private function processFunctionToken(File $phpcsFile, $stackPtr)
706
+    private function processFunctionToken( File $phpcsFile, $stackPtr )
707 707
     {
708 708
         // Retrieve typehints stripped of global NS indicator and/or nullable indicator.
709
-        $typeHints = $this->getTypeHintsFromFunctionDeclaration($phpcsFile, $stackPtr);
710
-        if (empty($typeHints) || \is_array($typeHints) === false) {
709
+        $typeHints = $this->getTypeHintsFromFunctionDeclaration( $phpcsFile, $stackPtr );
710
+        if ( empty( $typeHints ) || \is_array( $typeHints ) === false ) {
711 711
             return;
712 712
         }
713 713
 
714
-        foreach ($typeHints as $hint) {
714
+        foreach ( $typeHints as $hint ) {
715 715
 
716
-            $typeHintLc = strtolower($hint);
716
+            $typeHintLc = strtolower( $hint );
717 717
 
718
-            if (isset($this->newClasses[$typeHintLc]) === true) {
718
+            if ( isset( $this->newClasses[ $typeHintLc ] ) === true ) {
719 719
                 $itemInfo = array(
720 720
                     'name'   => $hint,
721 721
                     'nameLc' => $typeHintLc,
722 722
                 );
723
-                $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
723
+                $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
724 724
             }
725 725
         }
726 726
     }
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
      *
738 738
      * @return void
739 739
      */
740
-    private function processCatchToken(File $phpcsFile, $stackPtr)
740
+    private function processCatchToken( File $phpcsFile, $stackPtr )
741 741
     {
742 742
         $tokens = $phpcsFile->getTokens();
743 743
 
744 744
         // Bow out during live coding.
745
-        if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === false) {
745
+        if ( isset( $tokens[ $stackPtr ][ 'parenthesis_opener' ], $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === false ) {
746 746
             return;
747 747
         }
748 748
 
749
-        $opener = $tokens[$stackPtr]['parenthesis_opener'];
750
-        $closer = ($tokens[$stackPtr]['parenthesis_closer'] + 1);
749
+        $opener = $tokens[ $stackPtr ][ 'parenthesis_opener' ];
750
+        $closer = ( $tokens[ $stackPtr ][ 'parenthesis_closer' ] + 1 );
751 751
         $name   = '';
752 752
         $listen = array(
753 753
             // Parts of a (namespaced) class name.
@@ -759,30 +759,30 @@  discard block
 block discarded – undo
759 759
             \T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this.
760 760
         );
761 761
 
762
-        for ($i = ($opener + 1); $i < $closer; $i++) {
763
-            if (isset($listen[$tokens[$i]['code']]) === false) {
762
+        for ( $i = ( $opener + 1 ); $i < $closer; $i++ ) {
763
+            if ( isset( $listen[ $tokens[ $i ][ 'code' ] ] ) === false ) {
764 764
                 continue;
765 765
             }
766 766
 
767
-            if ($listen[$tokens[$i]['code']] === true) {
768
-                $name .= $tokens[$i]['content'];
767
+            if ( $listen[ $tokens[ $i ][ 'code' ] ] === true ) {
768
+                $name .= $tokens[ $i ][ 'content' ];
769 769
                 continue;
770 770
             } else {
771
-                if (empty($name) === true) {
771
+                if ( empty( $name ) === true ) {
772 772
                     // Weird, we should have a name by the time we encounter a variable or |.
773 773
                     // So this may be the closer.
774 774
                     continue;
775 775
                 }
776 776
 
777
-                $name   = ltrim($name, '\\');
778
-                $nameLC = strtolower($name);
777
+                $name   = ltrim( $name, '\\' );
778
+                $nameLC = strtolower( $name );
779 779
 
780
-                if (isset($this->newExceptions[$nameLC]) === true) {
780
+                if ( isset( $this->newExceptions[ $nameLC ] ) === true ) {
781 781
                     $itemInfo = array(
782 782
                         'name'   => $name,
783 783
                         'nameLc' => $nameLC,
784 784
                     );
785
-                    $this->handleFeature($phpcsFile, $i, $itemInfo);
785
+                    $this->handleFeature( $phpcsFile, $i, $itemInfo );
786 786
                 }
787 787
 
788 788
                 // Reset for a potential multi-catch.
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
      *
804 804
      * @return void
805 805
      */
806
-    private function processReturnTypeToken(File $phpcsFile, $stackPtr)
806
+    private function processReturnTypeToken( File $phpcsFile, $stackPtr )
807 807
     {
808
-        $returnTypeHint   = $this->getReturnTypeHintName($phpcsFile, $stackPtr);
809
-        $returnTypeHint   = ltrim($returnTypeHint, '\\');
810
-        $returnTypeHintLc = strtolower($returnTypeHint);
808
+        $returnTypeHint   = $this->getReturnTypeHintName( $phpcsFile, $stackPtr );
809
+        $returnTypeHint   = ltrim( $returnTypeHint, '\\' );
810
+        $returnTypeHintLc = strtolower( $returnTypeHint );
811 811
 
812
-        if (isset($this->newClasses[$returnTypeHintLc]) === false) {
812
+        if ( isset( $this->newClasses[ $returnTypeHintLc ] ) === false ) {
813 813
             return;
814 814
         }
815 815
 
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
             'name'   => $returnTypeHint,
819 819
             'nameLc' => $returnTypeHintLc,
820 820
         );
821
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
821
+        $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
822 822
     }
823 823
 
824 824
 
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
      *
830 830
      * @return array Version and other information about the item.
831 831
      */
832
-    public function getItemArray(array $itemInfo)
832
+    public function getItemArray( array $itemInfo )
833 833
     {
834
-        return $this->newClasses[$itemInfo['nameLc']];
834
+        return $this->newClasses[ $itemInfo[ 'nameLc' ] ];
835 835
     }
836 836
 
837 837
 
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Classes/NewTypedPropertiesSniff.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function register()
49 49
     {
50
-        return array(\T_VARIABLE);
50
+        return array( \T_VARIABLE );
51 51
     }
52 52
 
53 53
     /**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      * @return int|void Integer stack pointer to skip forward or void to continue
61 61
      *                  normal file processing.
62 62
      */
63
-    public function process(File $phpcsFile, $stackPtr)
63
+    public function process( File $phpcsFile, $stackPtr )
64 64
     {
65
-        if ($this->isClassProperty($phpcsFile, $stackPtr) === false) {
65
+        if ( $this->isClassProperty( $phpcsFile, $stackPtr ) === false ) {
66 66
             return;
67 67
         }
68 68
 
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
         );
74 74
 
75 75
         $tokens   = $phpcsFile->getTokens();
76
-        $modifier = $phpcsFile->findPrevious($find, ($stackPtr - 1));
77
-        if ($modifier === false
78
-            || $tokens[$modifier]['code'] === \T_SEMICOLON
79
-            || $tokens[$modifier]['code'] === \T_OPEN_CURLY_BRACKET
76
+        $modifier = $phpcsFile->findPrevious( $find, ( $stackPtr - 1 ) );
77
+        if ( $modifier === false
78
+            || $tokens[ $modifier ][ 'code' ] === \T_SEMICOLON
79
+            || $tokens[ $modifier ][ 'code' ] === \T_OPEN_CURLY_BRACKET
80 80
         ) {
81 81
             // Parse error. Ignore.
82 82
             return;
83 83
         }
84 84
 
85
-        $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($modifier + 1), null, true);
86
-        if ($tokens[$type]['code'] === \T_VARIABLE) {
85
+        $type = $phpcsFile->findNext( Tokens::$emptyTokens, ( $modifier + 1 ), null, true );
86
+        if ( $tokens[ $type ][ 'code' ] === \T_VARIABLE ) {
87 87
             return;
88 88
         }
89 89
 
90 90
         // Still here ? In that case, this will be a typed property.
91
-        if ($this->supportsBelow('7.3') === true) {
91
+        if ( $this->supportsBelow( '7.3' ) === true ) {
92 92
             $phpcsFile->addError(
93 93
                 'Typed properties are not supported in PHP 7.3 or earlier',
94 94
                 $type,
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
             );
97 97
         }
98 98
 
99
-        if ($this->supportsAbove('7.4') === true) {
99
+        if ( $this->supportsAbove( '7.4' ) === true ) {
100 100
             // Examine the type to verify it's valid.
101
-            if ($tokens[$type]['type'] === 'T_NULLABLE'
101
+            if ( $tokens[ $type ][ 'type' ] === 'T_NULLABLE'
102 102
                 // Needed to support PHPCS < 3.5.0 which doesn't correct to the nullable token type yet.
103
-                || $tokens[$type]['code'] === \T_INLINE_THEN
103
+                || $tokens[ $type ][ 'code' ] === \T_INLINE_THEN
104 104
             ) {
105
-                $type = $phpcsFile->findNext(Tokens::$emptyTokens, ($type + 1), null, true);
105
+                $type = $phpcsFile->findNext( Tokens::$emptyTokens, ( $type + 1 ), null, true );
106 106
             }
107 107
 
108
-            $content = $tokens[$type]['content'];
109
-            if ($content === 'void' || $content === 'callable') {
108
+            $content = $tokens[ $type ][ 'content' ];
109
+            if ( $content === 'void' || $content === 'callable' ) {
110 110
                 $phpcsFile->addError(
111 111
                     '%s is not supported as a type declaration for properties',
112 112
                     $type,
113 113
                     'InvalidType',
114
-                    array($content)
114
+                    array( $content )
115 115
                 );
116 116
             }
117 117
         }
118 118
 
119
-        $endOfStatement = $phpcsFile->findNext(\T_SEMICOLON, ($stackPtr + 1));
120
-        if ($endOfStatement !== false) {
119
+        $endOfStatement = $phpcsFile->findNext( \T_SEMICOLON, ( $stackPtr + 1 ) );
120
+        if ( $endOfStatement !== false ) {
121 121
             // Don't throw the same error multiple times for multi-property declarations.
122
-            return ($endOfStatement + 1);
122
+            return ( $endOfStatement + 1 );
123 123
         }
124 124
     }
125 125
 }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Classes/ForbiddenAbstractPrivateMethodsSniff.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function register()
53 53
     {
54
-        return array(\T_FUNCTION);
54
+        return array( \T_FUNCTION );
55 55
     }
56 56
 
57 57
     /**
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70
-        if ($this->supportsAbove('5.1') === false) {
70
+        if ( $this->supportsAbove( '5.1' ) === false ) {
71 71
             return;
72 72
         }
73 73
 
74
-        if ($this->validDirectScope($phpcsFile, $stackPtr, $this->ooScopeTokens) === false) {
74
+        if ( $this->validDirectScope( $phpcsFile, $stackPtr, $this->ooScopeTokens ) === false ) {
75 75
             // Function, not method.
76 76
             return;
77 77
         }
78 78
 
79
-        $properties = $phpcsFile->getMethodProperties($stackPtr);
80
-        if ($properties['scope'] !== 'private' || $properties['is_abstract'] !== true) {
79
+        $properties = $phpcsFile->getMethodProperties( $stackPtr );
80
+        if ( $properties[ 'scope' ] !== 'private' || $properties[ 'is_abstract' ] !== true ) {
81 81
             return;
82 82
         }
83 83
 
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Classes/NewLateStaticBindingSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function register()
35 35
     {
36
-        return array(\T_STATIC);
36
+        return array( \T_STATIC );
37 37
     }
38 38
 
39 39
 
@@ -46,21 +46,21 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @return void
48 48
      */
49
-    public function process(File $phpcsFile, $stackPtr)
49
+    public function process( File $phpcsFile, $stackPtr )
50 50
     {
51
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
52
-        if ($nextNonEmpty === false) {
51
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
52
+        if ( $nextNonEmpty === false ) {
53 53
             return;
54 54
         }
55 55
 
56 56
         $tokens = $phpcsFile->getTokens();
57
-        if ($tokens[$nextNonEmpty]['code'] !== \T_DOUBLE_COLON) {
57
+        if ( $tokens[ $nextNonEmpty ][ 'code' ] !== \T_DOUBLE_COLON ) {
58 58
             return;
59 59
         }
60 60
 
61
-        $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
61
+        $inClass = $this->inClassScope( $phpcsFile, $stackPtr, false );
62 62
 
63
-        if ($inClass === true && $this->supportsBelow('5.2') === true) {
63
+        if ( $inClass === true && $this->supportsBelow( '5.2' ) === true ) {
64 64
             $phpcsFile->addError(
65 65
                 'Late static binding is not supported in PHP 5.2 or earlier.',
66 66
                 $stackPtr,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             );
69 69
         }
70 70
 
71
-        if ($inClass === false) {
71
+        if ( $inClass === false ) {
72 72
             $phpcsFile->addError(
73 73
                 'Late static binding is not supported outside of class scope.',
74 74
                 $stackPtr,
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/Lists/ForbiddenEmptyListAssignmentSniff.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
         // Set up a list of tokens to disregard when determining whether the list() is empty.
47 47
         // Only needs to be set up once.
48 48
         $this->ignoreTokens                       = Tokens::$emptyTokens;
49
-        $this->ignoreTokens[\T_COMMA]             = \T_COMMA;
50
-        $this->ignoreTokens[\T_OPEN_PARENTHESIS]  = \T_OPEN_PARENTHESIS;
51
-        $this->ignoreTokens[\T_CLOSE_PARENTHESIS] = \T_CLOSE_PARENTHESIS;
49
+        $this->ignoreTokens[ \T_COMMA ]             = \T_COMMA;
50
+        $this->ignoreTokens[ \T_OPEN_PARENTHESIS ]  = \T_OPEN_PARENTHESIS;
51
+        $this->ignoreTokens[ \T_CLOSE_PARENTHESIS ] = \T_CLOSE_PARENTHESIS;
52 52
 
53 53
         return array(
54 54
             \T_LIST,
@@ -65,42 +65,42 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return void
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70
-        if ($this->supportsAbove('7.0') === false) {
70
+        if ( $this->supportsAbove( '7.0' ) === false ) {
71 71
             return;
72 72
         }
73 73
 
74 74
         $tokens = $phpcsFile->getTokens();
75 75
 
76
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY) {
77
-            if ($this->isShortList($phpcsFile, $stackPtr) === false) {
76
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY ) {
77
+            if ( $this->isShortList( $phpcsFile, $stackPtr ) === false ) {
78 78
                 return;
79 79
             }
80 80
 
81 81
             $open  = $stackPtr;
82
-            $close = $tokens[$stackPtr]['bracket_closer'];
82
+            $close = $tokens[ $stackPtr ][ 'bracket_closer' ];
83 83
         } else {
84 84
             // T_LIST.
85
-            $open = $phpcsFile->findNext(\T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true);
86
-            if ($open === false || isset($tokens[$open]['parenthesis_closer']) === false) {
85
+            $open = $phpcsFile->findNext( \T_OPEN_PARENTHESIS, $stackPtr, null, false, null, true );
86
+            if ( $open === false || isset( $tokens[ $open ][ 'parenthesis_closer' ] ) === false ) {
87 87
                 return;
88 88
             }
89 89
 
90
-            $close = $tokens[$open]['parenthesis_closer'];
90
+            $close = $tokens[ $open ][ 'parenthesis_closer' ];
91 91
         }
92 92
 
93 93
         $error = true;
94
-        if (($close - $open) > 1) {
95
-            for ($cnt = $open + 1; $cnt < $close; $cnt++) {
96
-                if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) {
94
+        if ( ( $close - $open ) > 1 ) {
95
+            for ( $cnt = $open + 1; $cnt < $close; $cnt++ ) {
96
+                if ( isset( $this->ignoreTokens[ $tokens[ $cnt ][ 'code' ] ] ) === false ) {
97 97
                     $error = false;
98 98
                     break;
99 99
                 }
100 100
             }
101 101
         }
102 102
 
103
-        if ($error === true) {
103
+        if ( $error === true ) {
104 104
             $phpcsFile->addError(
105 105
                 'Empty list() assignments are not allowed since PHP 7.0',
106 106
                 $stackPtr,
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Lists/NewKeyedListSniff.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      *
34 34
      * @var array
35 35
      */
36
-    protected $sniffTargets =  array(
36
+    protected $sniffTargets = array(
37 37
         \T_LIST             => \T_LIST,
38 38
         \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
39 39
     );
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function bowOutEarly()
89 89
     {
90
-        return ($this->supportsBelow('7.0') === false);
90
+        return ( $this->supportsBelow( '7.0' ) === false );
91 91
     }
92 92
 
93 93
     /**
@@ -99,47 +99,47 @@  discard block
 block discarded – undo
99 99
      *
100 100
      * @return void
101 101
      */
102
-    public function process(File $phpcsFile, $stackPtr)
102
+    public function process( File $phpcsFile, $stackPtr )
103 103
     {
104
-        if ($this->bowOutEarly() === true) {
104
+        if ( $this->bowOutEarly() === true ) {
105 105
             return;
106 106
         }
107 107
 
108 108
         $tokens = $phpcsFile->getTokens();
109 109
 
110
-        if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
111
-            && $this->isShortList($phpcsFile, $stackPtr) === false
110
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_OPEN_SHORT_ARRAY
111
+            && $this->isShortList( $phpcsFile, $stackPtr ) === false
112 112
         ) {
113 113
             // Short array, not short list.
114 114
             return;
115 115
         }
116 116
 
117
-        if ($tokens[$stackPtr]['code'] === \T_LIST) {
118
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
119
-            if ($nextNonEmpty === false
120
-                || $tokens[$nextNonEmpty]['code'] !== \T_OPEN_PARENTHESIS
121
-                || isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false
117
+        if ( $tokens[ $stackPtr ][ 'code' ] === \T_LIST ) {
118
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
119
+            if ( $nextNonEmpty === false
120
+                || $tokens[ $nextNonEmpty ][ 'code' ] !== \T_OPEN_PARENTHESIS
121
+                || isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === false
122 122
             ) {
123 123
                 // Parse error or live coding.
124 124
                 return;
125 125
             }
126 126
 
127 127
             $opener = $nextNonEmpty;
128
-            $closer = $tokens[$nextNonEmpty]['parenthesis_closer'];
128
+            $closer = $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ];
129 129
         } else {
130 130
             // Short list syntax.
131 131
             $opener = $stackPtr;
132 132
 
133
-            if (isset($tokens[$stackPtr]['bracket_closer'])) {
134
-                $closer = $tokens[$stackPtr]['bracket_closer'];
133
+            if ( isset( $tokens[ $stackPtr ][ 'bracket_closer' ] ) ) {
134
+                $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
135 135
             }
136 136
         }
137 137
 
138
-        if (isset($opener, $closer) === false) {
138
+        if ( isset( $opener, $closer ) === false ) {
139 139
             return;
140 140
         }
141 141
 
142
-        $this->examineList($phpcsFile, $opener, $closer);
142
+        $this->examineList( $phpcsFile, $opener, $closer );
143 143
     }
144 144
 
145 145
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return void
154 154
      */
155
-    protected function examineList(File $phpcsFile, $opener, $closer)
155
+    protected function examineList( File $phpcsFile, $opener, $closer )
156 156
     {
157 157
         $start = $opener;
158
-        while (($start = $this->hasTargetInList($phpcsFile, $start, $closer)) !== false) {
158
+        while ( ( $start = $this->hasTargetInList( $phpcsFile, $start, $closer ) ) !== false ) {
159 159
             $phpcsFile->addError(
160 160
                 'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.',
161 161
                 $start,
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
      *
178 178
      * @return int|bool Stack pointer to the target token if encountered. False otherwise.
179 179
      */
180
-    protected function hasTargetInList(File $phpcsFile, $start, $closer)
180
+    protected function hasTargetInList( File $phpcsFile, $start, $closer )
181 181
     {
182 182
         $tokens = $phpcsFile->getTokens();
183 183
 
184
-        for ($i = ($start + 1); $i < $closer; $i++) {
185
-            if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
184
+        for ( $i = ( $start + 1 ); $i < $closer; $i++ ) {
185
+            if ( isset( $this->allTargets[ $tokens[ $i ][ 'code' ] ] ) === false ) {
186 186
                 continue;
187 187
             }
188 188
 
189
-            if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
189
+            if ( isset( $this->targetsInList[ $tokens[ $i ][ 'code' ] ] ) === true ) {
190 190
                 return $i;
191 191
             }
192 192
 
193 193
             // Skip past nested list constructs.
194
-            if ($tokens[$i]['code'] === \T_LIST) {
195
-                $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
196
-                if ($nextNonEmpty !== false
197
-                    && $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
198
-                    && isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
194
+            if ( $tokens[ $i ][ 'code' ] === \T_LIST ) {
195
+                $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
196
+                if ( $nextNonEmpty !== false
197
+                    && $tokens[ $nextNonEmpty ][ 'code' ] === \T_OPEN_PARENTHESIS
198
+                    && isset( $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ] ) === true
199 199
                 ) {
200
-                    $i = $tokens[$nextNonEmpty]['parenthesis_closer'];
200
+                    $i = $tokens[ $nextNonEmpty ][ 'parenthesis_closer' ];
201 201
                 }
202
-            } elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
203
-                && isset($tokens[$i]['bracket_closer'])
202
+            } elseif ( $tokens[ $i ][ 'code' ] === \T_OPEN_SHORT_ARRAY
203
+                && isset( $tokens[ $i ][ 'bracket_closer' ] )
204 204
             ) {
205
-                $i = $tokens[$i]['bracket_closer'];
205
+                $i = $tokens[ $i ][ 'bracket_closer' ];
206 206
             }
207 207
         }
208 208
 
Please login to merge, or discard this patch.
php-compatibility/PHPCompatibility/Sniffs/Lists/NewShortListSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function register()
39 39
     {
40
-        return array(\T_OPEN_SHORT_ARRAY);
40
+        return array( \T_OPEN_SHORT_ARRAY );
41 41
     }
42 42
 
43 43
     /**
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
      * @return int|void Integer stack pointer to skip forward or void to continue
51 51
      *                  normal file processing.
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55
-        if ($this->supportsBelow('7.0') === false) {
55
+        if ( $this->supportsBelow( '7.0' ) === false ) {
56 56
             return;
57 57
         }
58 58
 
59
-        if ($this->isShortList($phpcsFile, $stackPtr) === false) {
59
+        if ( $this->isShortList( $phpcsFile, $stackPtr ) === false ) {
60 60
             return;
61 61
         }
62 62
 
63 63
         $tokens = $phpcsFile->getTokens();
64
-        $closer = $tokens[$stackPtr]['bracket_closer'];
64
+        $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
65 65
 
66
-        $hasVariable = $phpcsFile->findNext(\T_VARIABLE, ($stackPtr + 1), $closer);
67
-        if ($hasVariable === false) {
66
+        $hasVariable = $phpcsFile->findNext( \T_VARIABLE, ( $stackPtr + 1 ), $closer );
67
+        if ( $hasVariable === false ) {
68 68
             // List syntax is only valid if there are variables in it.
69 69
             return;
70 70
         }
@@ -75,6 +75,6 @@  discard block
 block discarded – undo
75 75
             'Found'
76 76
         );
77 77
 
78
-        return ($closer + 1);
78
+        return ( $closer + 1 );
79 79
     }
80 80
 }
Please login to merge, or discard this patch.