Skip to content

Commit

Permalink
fix inconsistency with @SInCE annotation in phpstub and allow @SInCE
Browse files Browse the repository at this point in the history
…stubbed to override callmap
  • Loading branch information
kkmuffme committed Mar 2, 2024
1 parent 0dc4886 commit 3d356a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal
&& $function_id
&& $storage instanceof FunctionStorage
) {
if (($this->codebase->register_stub_files && !InternalCallMapHandler::hasDelta($function_id))
if (($this->codebase->register_stub_files
&& (!InternalCallMapHandler::hasDelta($function_id)
// if the stub is for a specific PHP version, which is equal or lower than the analyzed version
// as otherwise we would have returned already above
// we also want to use the stub, since it contains the correct types for the current version
|| !empty($docblock_info->since_php_major_version)))
// if the function is autoloaded we want to register it even if it has a delta, since there's a polyfill
|| ($this->codebase->register_autoload_files
&& !$this->codebase->functions->hasStubbedFunction($function_id))
Expand Down Expand Up @@ -940,10 +945,12 @@ private function createStorageForFunctionLike(
&& ($this->codebase->register_stub_files
|| !$this->codebase->functions->hasStubbedFunction($function_id))
) {
$this->codebase->functions->addGlobalFunction(
$function_id,
$this->file_storage->functions[$function_id],
);
if (!$this->codebase->register_stub_files || !InternalCallMapHandler::hasDelta($function_id)) {
$this->codebase->functions->addGlobalFunction(
$function_id,
$this->file_storage->functions[$function_id],
);
}

$storage = $this->storage = $this->file_storage->functions[$function_id];

Expand Down
2 changes: 2 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ function join($separator, array $array = []): string
}

/**
* @since 4.0
*
* @psalm-pure
*
* @param non-empty-string $separator
Expand Down
4 changes: 2 additions & 2 deletions stubs/Reflection.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ class ReflectionParameter implements Reflector {
public function getAttributes(?string $name = null, int $flags = 0): array {}

/**
* @since 8.0
*/
* @since 8.0
*/
public function isPromoted(): bool {}

/**
Expand Down

0 comments on commit 3d356a1

Please sign in to comment.