|
| 1 | +<?php // lint >= 8.0 |
| 2 | + |
| 3 | +declare(strict_types = 1); |
| 4 | + |
| 5 | +namespace Bug6777; |
| 6 | + |
| 7 | +class HelloWorld |
| 8 | +{ |
| 9 | + /** @param \ArrayObject<int, string> $array */ |
| 10 | + public function __construct(private \ArrayObject $array){} |
| 11 | + |
| 12 | + public function send(string $s) : void{ |
| 13 | + $this->array[] = $s; |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +class WithThreaded |
| 18 | +{ |
| 19 | + private \Threaded $collection; |
| 20 | + |
| 21 | + public function __construct() |
| 22 | + { |
| 23 | + $this->collection = new \Threaded(); |
| 24 | + } |
| 25 | + |
| 26 | + public function add(string $s): void |
| 27 | + { |
| 28 | + $this->collection[] = $s; |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +class WithUnionObjectArray |
| 33 | +{ |
| 34 | + /** @var \ArrayObject<int, string>|array<int, string> */ |
| 35 | + private \ArrayObject|array $collection; |
| 36 | + |
| 37 | + /** @param \ArrayObject<int, string>|array<int, string> $collection */ |
| 38 | + public function __construct(\ArrayObject|array $collection) |
| 39 | + { |
| 40 | + $this->collection = $collection; |
| 41 | + } |
| 42 | + |
| 43 | + public function add(string $s): void |
| 44 | + { |
| 45 | + $this->collection[] = $s; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +class WithAssignByReference |
| 50 | +{ |
| 51 | + /** @param \ArrayObject<int, string> $array */ |
| 52 | + public function __construct(private \ArrayObject $array){} |
| 53 | + |
| 54 | + public function send(string &$s) : void{ |
| 55 | + $this->array[] =& $s; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +class WithUnionObjectString |
| 60 | +{ |
| 61 | + /** @var \ArrayObject<int, string>|string */ |
| 62 | + private \ArrayObject|string $collection; |
| 63 | + |
| 64 | + /** @param \ArrayObject<int, string>|string $collection */ |
| 65 | + public function __construct(\ArrayObject|string $collection) |
| 66 | + { |
| 67 | + $this->collection = $collection; |
| 68 | + } |
| 69 | + |
| 70 | + public function add(string $s): void |
| 71 | + { |
| 72 | + $this->collection[] = $s; |
| 73 | + } |
| 74 | +} |
0 commit comments