22
33namespace SlevomatCodingStandard \Sniffs \TypeHints ;
44
5+ use SlevomatCodingStandard \Helpers \SniffSettingsHelper ;
56use SlevomatCodingStandard \Helpers \TokenHelper ;
67
78class DeclareStrictTypesSniff implements \PHP_CodeSniffer_Sniff
@@ -98,7 +99,8 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $openTagPointer)
9899 }
99100
100101 $ strictTypesContent = TokenHelper::getContent ($ phpcsFile , $ strictTypesPointer , $ numberPointer );
101- $ format = sprintf ('strict_types%1$s=%1$s1 ' , str_repeat (' ' , $ this ->spacesCountAroundEqualsSign ));
102+ $ spacesCountAroundEqualsSign = SniffSettingsHelper::normalizeInteger ($ this ->spacesCountAroundEqualsSign );
103+ $ format = sprintf ('strict_types%1$s=%1$s1 ' , str_repeat (' ' , $ spacesCountAroundEqualsSign ));
102104 if ($ strictTypesContent !== $ format ) {
103105 $ fix = $ phpcsFile ->addFixableError (
104106 sprintf (
@@ -120,7 +122,7 @@ public function process(\PHP_CodeSniffer_File $phpcsFile, $openTagPointer)
120122 }
121123
122124 $ openingWhitespace = substr ($ tokens [$ openTagPointer ]['content ' ], strlen ('<?php ' ));
123- $ newlinesCountBetweenOpenTagAndDeclare = ( int ) trim (( string ) $ this ->newlinesCountBetweenOpenTagAndDeclare );
125+ $ newlinesCountBetweenOpenTagAndDeclare = SniffSettingsHelper:: normalizeInteger ( $ this ->newlinesCountBetweenOpenTagAndDeclare );
124126 if ($ newlinesCountBetweenOpenTagAndDeclare === 0 ) {
125127 if ($ openingWhitespace !== ' ' ) {
126128 $ fix = $ phpcsFile ->addFixableError (
0 commit comments