-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
array_map - understand call with multiple arrays
- 2.1.0
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.12.14
- 1.12.13
- 1.12.12
- 1.12.11
- 1.12.10
- 1.12.9
- 1.12.8
- 1.12.7
- 1.12.6
- 1.12.5
- 1.12.4
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.11
- 1.11.10
- 1.11.9
- 1.11.8
- 1.11.7
- 1.11.6
- 1.11.5
- 1.11.4
- 1.11.3
- 1.11.2
- 1.11.1
- 1.11.0
- 1.10.67
- 1.10.66
- 1.10.65
- 1.10.64
- 1.10.63
- 1.10.62
- 1.10.61
- 1.10.60
- 1.10.59
- 1.10.58
- 1.10.57
- 1.10.56
- 1.10.55
- 1.10.54
- 1.10.53
- 1.10.52
- 1.10.51
- 1.10.50
- 1.10.49
- 1.10.48
- 1.10.47
- 1.10.46
- 1.10.45
- 1.10.44
- 1.10.43
- 1.10.42
- 1.10.41
- 1.10.40
- 1.10.39
- 1.10.38
- 1.10.37
- 1.10.36
- 1.10.35
- 1.10.34
- 1.10.33
- 1.10.32
- 1.10.31
- 1.10.30
- 1.10.29
- 1.10.28
- 1.10.27
- 1.10.26
- 1.10.25
- 1.10.24
- 1.10.23
- 1.10.22
- 1.10.21
- 1.10.20
- 1.10.19
- 1.10.18
- 1.10.17
- 1.10.16
- 1.10.15
- 1.10.14
- 1.10.13
- 1.10.12
- 1.10.11
- 1.10.10
- 1.10.9
- 1.10.8
- 1.10.7
- 1.10.6
- 1.10.5
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.18
- 1.9.17
- 1.9.16
- 1.9.15
- 1.9.14
- 1.9.13
- 1.9.12
- 1.9.11
- 1.9.10
- 1.9.9
- 1.9.8
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.11
- 1.8.10
- 1.8.9
- 1.8.8
- 1.8.7
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.15
- 1.7.14
- 1.7.13
- 1.7.12
- 1.7.11
- 1.7.10
- 1.7.9
- 1.7.8
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- 0.12.100
- 0.12.99
1 parent
9c3b765
commit 3e0ecec
Showing
8 changed files
with
162 additions
and
21 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
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,21 @@ | ||
<?php | ||
|
||
namespace ArrayMapMultiple; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(int $i, string $s): void | ||
{ | ||
$result = array_map(function ($a, $b) { | ||
assertType('int', $a); | ||
assertType('string', $b); | ||
|
||
return rand(0, 1) ? $a : $b; | ||
}, ['foo' => $i], ['bar' => $s]); | ||
assertType('array<int, int|string>&nonEmpty', $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
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,63 @@ | ||
<?php | ||
|
||
namespace ArrayMapMultipleCallTest; | ||
|
||
/** | ||
* @template TKey as array-key | ||
* @template TValue | ||
*/ | ||
class Collection | ||
{ | ||
/** | ||
* @var array<TKey, TValue> | ||
*/ | ||
protected $items = []; | ||
|
||
/** | ||
* @param array<TKey, TValue> $items | ||
* @return void | ||
*/ | ||
public function __construct($items) | ||
{ | ||
$this->items = $items; | ||
} | ||
|
||
/** | ||
* @template TMapValue | ||
* | ||
* @param callable(TValue, TKey): TMapValue $callback | ||
* @return self<TKey, TMapValue> | ||
*/ | ||
public function map(callable $callback) | ||
{ | ||
$keys = array_keys($this->items); | ||
|
||
$items = array_map($callback, $this->items, $keys); | ||
|
||
return new self(array_combine($keys, $items)); | ||
} | ||
|
||
/** | ||
* @return array<TKey, TValue> | ||
*/ | ||
public function all() | ||
{ | ||
return $this->items; | ||
} | ||
} | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(): void | ||
{ | ||
array_map(function (int $a, string $b) { | ||
|
||
}, [1, 2], ['foo', 'bar']); | ||
|
||
array_map(function (int $a, int $b) { | ||
|
||
}, [1, 2], ['foo', 'bar']); | ||
} | ||
|
||
} |