Skip to content

Commit

Permalink
Conditional return type for microtime/gettimeofday
Browse files Browse the repository at this point in the history
#WI-58098 Fixed
  • Loading branch information
wbars committed Jan 20, 2021
1 parent 3cbb0fb commit 85deee7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions meta/attributes/internal/ReturnTypeContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace JetBrains\PhpStorm\Internal;

use Attribute;

/**
* For PhpStorm internal use only
* @since 8.0
* @internal
*/
#[Attribute(Attribute::TARGET_PARAMETER)]
class ReturnTypeContract
{
public function __construct(
string $true,
string $false
) {}
}
5 changes: 3 additions & 2 deletions standard/standard_3.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use JetBrains\PhpStorm\Deprecated;
use JetBrains\PhpStorm\Internal\LanguageLevelTypeAware;
use JetBrains\PhpStorm\Pure;
use JetBrains\PhpStorm\Internal\ReturnTypeContract as TypeContract;

/**
* Gets time of last page modification
Expand Down Expand Up @@ -875,7 +876,7 @@ function sys_getloadavg (): array|false
* @return string|float
*/
#[Pure]
function microtime (bool $as_float): string|float
function microtime (#[TypeContract(true: "float", false: "string")] bool $as_float): string|float
{}

/**
Expand All @@ -895,7 +896,7 @@ function microtime (bool $as_float): string|float
* "dsttime" - type of dst correction
*/
#[Pure]
function gettimeofday (bool $as_float): array|float
function gettimeofday (#[TypeContract(true: "float", false: "int[]")] bool $as_float): array|float
{}

/**
Expand Down

0 comments on commit 85deee7

Please sign in to comment.