Skip to content

Commit

Permalink
Merge pull request #9752 from kkmuffme/improve-glob-stubs
Browse files Browse the repository at this point in the history
improve glob stubs
  • Loading branch information
orklah authored May 6, 2023
2 parents 0ea2a6a + ad7be63 commit 5712401
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dictionaries/CallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3329,7 +3329,7 @@
'gettimeofday' => ['array<string, int>'],
'gettimeofday\'1' => ['float', 'as_float='=>'true'],
'gettype' => ['string', 'value'=>'mixed'],
'glob' => ['list<string>|false', 'pattern'=>'string', 'flags='=>'int'],
'glob' => ['list<non-empty-string>|false', 'pattern'=>'non-empty-string', 'flags='=>'int<1, max>'],
'GlobIterator::__construct' => ['void', 'pattern'=>'string', 'flags='=>'int'],
'GlobIterator::count' => ['int'],
'GlobIterator::current' => ['FilesystemIterator|SplFileInfo|string'],
Expand Down
2 changes: 1 addition & 1 deletion dictionaries/CallMap_historical.php
Original file line number Diff line number Diff line change
Expand Up @@ -10727,7 +10727,7 @@
'gettimeofday' => ['array<string, int>'],
'gettimeofday\'1' => ['float', 'as_float='=>'true'],
'gettype' => ['string', 'value'=>'mixed'],
'glob' => ['list<string>|false', 'pattern'=>'string', 'flags='=>'int'],
'glob' => ['list<non-empty-string>|false', 'pattern'=>'non-empty-string', 'flags='=>'int<1, max>'],
'gmdate' => ['string', 'format'=>'string', 'timestamp='=>'int'],
'gmmktime' => ['int|false', 'hour='=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
'gmp_abs' => ['GMP', 'num'=>'GMP|string|int'],
Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Config/FileFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public static function loadFromArray(
$declare_strict_types = (bool) ($directory['useStrictTypes'] ?? false);

if ($directory_path[0] === '/' && DIRECTORY_SEPARATOR === '/') {
/** @var non-empty-string */
$prospective_directory_path = $directory_path;
} else {
$prospective_directory_path = $base_dir . DIRECTORY_SEPARATOR . $directory_path;
Expand Down Expand Up @@ -238,6 +239,7 @@ public static function loadFromArray(
$file_path = (string) ($file['name'] ?? '');

if ($file_path[0] === '/' && DIRECTORY_SEPARATOR === '/') {
/** @var non-empty-string */
$prospective_file_path = $file_path;
} else {
$prospective_file_path = $base_dir . DIRECTORY_SEPARATOR . $file_path;
Expand Down
5 changes: 4 additions & 1 deletion tests/CallableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,10 @@ function f(callable $p): void {}',
],
'fileExistsCallable' => [
'code' => '<?php
/** @return string[] */
/**
* @param non-empty-string $prospective_file_path
* @return non-empty-string[]
*/
function foo(string $prospective_file_path) : array {
return array_filter(
glob($prospective_file_path),
Expand Down

0 comments on commit 5712401

Please sign in to comment.