Skip to content

Commit 8af2f70

Browse files
committed
Less_Parser: Fix SetImportDirs() type hint to accept callable without key
The way this is used in practice, in MediaWiki, in ParserTest::testSetImportDirs, and in the parameter documentation on this very method, is without a (meaningless) string key. During a downstream PR at https://github.com/flarum/framework/pull/4225/files, I found PHPStan failing on: ``` $parser->SetImportDirs([ $function ]); // PHPStan: // Parameter #1 $dirs of method Less_Parser::SetImportDirs() // expects // array<string, (callable(): mixed)|string>, // array{callable(): mixed} // given. ``` Note that PHPStan 1.11.0 understands `phan-param` as alias for `param`, so it will parse it the same way, which is good, this isn't an issue with Phan vs PHPStan. Our documented typehint is actually incomplete. Ref phpstan/phpstan#10996 Change-Id: Id5953eaa3e3a62f6b29ec533a5393ef32dbb1098
1 parent fd255ab commit 8af2f70

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/Less/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public function SetCacheDir( $dir ) {
599599
* files may be imported. The value is an optional public URL or URL base path that corresponds to
600600
* the same directory (use empty string otherwise). The value may also be a closure, in
601601
* which case the key is ignored.
602-
* @phan-param array<string,string|callable> $dirs
602+
* @phan-param array<string,string|callable>|callable[] $dirs
603603
*/
604604
public function SetImportDirs( $dirs ) {
605605
self::$options['import_dirs'] = [];

0 commit comments

Comments
 (0)