33namespace TwigCS ;
44
55use \Exception ;
6- use \Traversable ;
76use Twig \Environment ;
87use Twig \Error \Error ;
98use Twig \Source ;
@@ -42,19 +41,15 @@ public function __construct(Environment $env, Tokenizer $tokenizer)
4241 /**
4342 * Run the linter on the given $files against the given $ruleset.
4443 *
45- * @param array|string $files List of files to process.
46- * @param Ruleset $ruleset Set of rules to check.
44+ * @param array $files List of files to process.
45+ * @param Ruleset $ruleset Set of rules to check.
4746 *
4847 * @return Report an object with all violations and stats.
4948 *
5049 * @throws Exception
5150 */
52- public function run ($ files , Ruleset $ ruleset )
51+ public function run (array $ files , Ruleset $ ruleset )
5352 {
54- if (!is_array ($ files ) && !$ files instanceof Traversable) {
55- $ files = [$ files ];
56- }
57-
5853 if (empty ($ files )) {
5954 throw new Exception ('No files to process, provide at least one file to be linted ' );
6055 }
@@ -91,7 +86,7 @@ public function run($files, Ruleset $ruleset)
9186 *
9287 * @return bool
9388 */
94- public function processTemplate ($ file , $ ruleset , $ report )
89+ public function processTemplate (string $ file , Ruleset $ ruleset , Report $ report )
9590 {
9691 $ twigSource = new Source (file_get_contents ($ file ), $ file , $ file );
9792
@@ -118,7 +113,7 @@ public function processTemplate($file, $ruleset, $report)
118113 $ sniffViolation = new SniffViolation (
119114 SniffInterface::MESSAGE_TYPE_ERROR ,
120115 sprintf ('Unable to tokenize file ' ),
121- ( string ) $ file
116+ $ file
122117 );
123118
124119 $ report ->addMessage ($ sniffViolation );
@@ -141,7 +136,7 @@ public function processTemplate($file, $ruleset, $report)
141136 * @param Report $report
142137 * @param string|null $file
143138 */
144- protected function setErrorHandler (Report $ report , $ file = null )
139+ protected function setErrorHandler (Report $ report , string $ file = null )
145140 {
146141 set_error_handler (function ($ type , $ message ) use ($ report , $ file ) {
147142 if (E_USER_DEPRECATED === $ type ) {
0 commit comments