Skip to content

fix: add updated signature for getenv #4009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/functionMap_php80delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'forward_static_call_array' => ['mixed', 'function'=>'callable', 'parameters'=>'array<int|string,mixed>'],
'get_debug_type' => ['string', 'var'=>'mixed'],
'get_resource_id' => ['int', 'res'=>'resource'],
'getenv' => ['string|array<string,string>|false', 'name='=>'string|null', 'local_only='=>'bool'],
'gmdate' => ['string', 'format'=>'string', 'timestamp='=>'int'],
'gmmktime' => ['int|false', 'hour'=>'int', 'minute='=>'int', 'second='=>'int', 'month='=>'int', 'day='=>'int', 'year='=>'int'],
'hash' => ['non-falsy-string', 'algo'=>'string', 'data'=>'string', 'raw_output='=>'bool'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
<?php // lint < 8.0

namespace Bug4538;

use function PHPStan\Testing\assertType;

class Foo
class FooPhp7
{
/**
* @param string $index
Expand Down
18 changes: 18 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-4538-php8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php // lint >= 8.0

namespace Bug4538;

use function PHPStan\Testing\assertType;

class FooPhp8
{
/**
* @param string $index
*/
public function bar(string $index): void
{
assertType('string|array<string,string>|false', getenv($index));
assertType('array<string, string>', getenv());
assertType('array<string, string>', getenv(null));
}
}
Loading