-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28179f2
commit 9f12f0f
Showing
8 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Bug6053; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param ?mixed $items | ||
* | ||
* @return ?array<mixed> | ||
*/ | ||
public function processItems($items): ?array | ||
{ | ||
if ($items === null || !is_array($items)) { | ||
return null; | ||
} | ||
|
||
if ($items === []) { | ||
return []; | ||
} | ||
|
||
$result = []; | ||
foreach ($items as $item) { | ||
$result[] = 'something'; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Bug6055; | ||
|
||
class HelloWorld | ||
{ | ||
public function sayHello(): void | ||
{ | ||
$this->check(null); | ||
|
||
$this->check(array_merge( | ||
['key1' => true], | ||
['key2' => 'value'] | ||
)); | ||
} | ||
|
||
/** | ||
* @param ?array<mixed> $items | ||
*/ | ||
private function check(?array $items): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Bug6081; | ||
|
||
class HelloWorld | ||
{ | ||
/** @param mixed[]|string $thing */ | ||
public function something($thing) : void{} | ||
|
||
/** @param int[] $array */ | ||
public function sayHello(array $array): void | ||
{ | ||
$this->something($array); | ||
if(count($array) !== 0){ | ||
$this->something($array); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Bug6118; | ||
|
||
|
||
/** | ||
* @template-covariant T of mixed | ||
*/ | ||
class Element { | ||
/** @var T */ | ||
public mixed $value; | ||
|
||
/** | ||
* @param Element<mixed> $element | ||
*/ | ||
function getValue(Element $element) : void { | ||
} | ||
|
||
/** | ||
* @param Element<int> $element | ||
*/ | ||
function takesValue(Element $element) : void { | ||
$this->getValue($element); | ||
} | ||
|
||
|
||
/** | ||
* @param Element<int|null> $element | ||
*/ | ||
function getValue2(Element $element) : void { | ||
} | ||
|
||
/** | ||
* @param Element<int> $element | ||
*/ | ||
function takesValue2(Element $element) : void { | ||
getValue2($element); | ||
} | ||
} | ||
|
||
/** | ||
* @template-covariant T of string|int|array<mixed> | ||
*/ | ||
interface Example { | ||
/** | ||
* @return T|null | ||
*/ | ||
public function normalize(): string|int|array|null; | ||
} | ||
|
||
/** | ||
* @implements Example<string|int|array<mixed>> | ||
*/ | ||
class Foo implements Example { | ||
public function normalize(): int | ||
{ | ||
return 0; | ||
} | ||
/** | ||
* @param Example<int|string|array<mixed>> $example | ||
*/ | ||
function foo(Example $example): void { | ||
} | ||
|
||
function bar(): void { | ||
$this->foo(new Foo()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Bug6236; | ||
|
||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param \Traversable<mixed, \DateTime> $t | ||
*/ | ||
public static function sayHello(\Traversable $t): void | ||
{ | ||
} | ||
|
||
/** | ||
* @param \SplObjectStorage<\DateTime, \DateTime> $foo | ||
*/ | ||
public function doFoo($foo) | ||
{ | ||
$this->sayHello(new \ArrayIterator([new \DateTime()])); | ||
|
||
$this->sayHello(new \ArrayIterator(['a' => new \DateTime()])); | ||
|
||
$this->sayHello($foo); | ||
} | ||
} | ||
|