1- <?php
1+ <?php declare (strict_types= 1 );
22
33/*
44 * This file is part of Polymorphine/Dev package.
@@ -21,15 +21,12 @@ final class AlignedMethodChainFixer implements FixerInterface
2121{
2222 use FixerMethods;
2323
24- /** @var Tokens */
25- private $ tokens ;
26-
27- public function getName ()
24+ public function getName (): string
2825 {
2926 return 'Polymorphine/aligned_method_chain ' ;
3027 }
3128
32- public function isCandidate (Tokens $ tokens )
29+ public function isCandidate (Tokens $ tokens ): bool
3330 {
3431 if (!$ arrows = $ tokens ->findGivenKind (T_OBJECT_OPERATOR )) {
3532 return false ;
@@ -68,10 +65,10 @@ public function fix(SplFileInfo $file, Tokens $tokens)
6865 }
6966 }
7067
71- private function findNextChain ($ search )
68+ private function findNextChain (int $ search ): ? int
7269 {
7370 $ idx = $ this ->tokens ->getNextTokenOfKind ($ search , [[T_OBJECT_OPERATOR ]]);
74- if (!$ idx ) { return false ; }
71+ if (!$ idx ) { return null ; }
7572
7673 if ($ this ->tokens [$ idx - 1 ]->isWhitespace () || !$ this ->isStartOfMultilineChain ($ idx )) {
7774 return $ this ->findNextChain ($ idx );
@@ -80,7 +77,7 @@ private function findNextChain($search)
8077 return $ idx ;
8178 }
8279
83- private function isStartOfMultilineChain ($ idx )
80+ private function isStartOfMultilineChain (int $ idx ): bool
8481 {
8582 $ next = ($ this ->tokens [$ idx + 2 ]->getContent () === '( ' ) ? $ this ->findClosing ($ idx + 2 ) + 1 : $ idx + 2 ;
8683 if ($ this ->tokens [$ next ]->isWhitespace () && $ this ->tokens [$ next + 1 ]->isGivenKind (T_OBJECT_OPERATOR )) {
@@ -90,14 +87,14 @@ private function isStartOfMultilineChain($idx)
9087 return $ this ->tokens [$ next ]->isGivenKind (T_OBJECT_OPERATOR ) ? $ this ->isStartOfMultilineChain ($ next ) : false ;
9188 }
9289
93- private function indentationLength ($ idx ): int
90+ private function indentationLength (int $ idx ): int
9491 {
9592 $ lineBreak = $ this ->prevLineBreak ($ idx );
9693 $ code = $ this ->tokens ->generatePartialCode ($ lineBreak , $ idx - 1 );
9794 return $ this ->codeLength ($ code );
9895 }
9996
100- private function alignChain ($ idx , $ indent ): void
97+ private function alignChain (int $ idx , int $ indent ): void
10198 {
10299 $ next = $ this ->nextIndentation ($ idx + 2 , $ indent );
103100 if (!$ next ) { return ; }
@@ -117,7 +114,7 @@ private function alignChain($idx, $indent): void
117114 if ($ idx ) { $ this ->alignChain ($ idx , $ indent ); }
118115 }
119116
120- private function nextIndentation ($ idx , $ indent )
117+ private function nextIndentation (int $ idx , int $ indent ): ? int
121118 {
122119 if ($ this ->tokens [$ idx ]->getContent () !== '( ' ) {
123120 return $ this ->tokens [$ idx ]->isWhitespace () ? $ idx : null ;
@@ -133,7 +130,7 @@ private function nextIndentation($idx, $indent)
133130 return $ next ;
134131 }
135132
136- private function findClosing ($ idx )
133+ private function findClosing (int $ idx ): ? int
137134 {
138135 $ parenthesis = $ this ->tokens ->getNextTokenOfKind ($ idx , ['( ' , ') ' ]);
139136
@@ -145,7 +142,7 @@ private function findClosing($idx)
145142 return $ parenthesis ;
146143 }
147144
148- private function indentMultilineParam ($ idx , $ end , $ indent )
145+ private function indentMultilineParam (int $ idx , int $ end , int $ indent ): void
149146 {
150147 $ minLevel = $ this ->codeLength ($ this ->tokens [$ idx ]->getContent ());
151148
0 commit comments