MontealegreLuis /
phuml
| 1 | <?php declare(strict_types=1); |
||
| 2 | /** |
||
| 3 | * This source file is subject to the license that is bundled with this package in the file LICENSE. |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace PhUml\Code\Parameters; |
||
| 7 | |||
| 8 | use PhUml\Code\Name; |
||
| 9 | use PhUml\Code\Variables\HasType; |
||
| 10 | use PhUml\Code\Variables\Variable; |
||
| 11 | use PhUml\Code\Variables\WithVariable; |
||
| 12 | use Stringable; |
||
| 13 | |||
| 14 | final class Parameter implements HasType, Stringable |
||
| 15 | { |
||
| 16 | use WithVariable; |
||
| 17 | |||
| 18 | 41 | public function __construct( |
|
| 19 | Variable $variable, |
||
| 20 | private readonly bool $isVariadic = false, |
||
| 21 | private readonly bool $isByReference = false |
||
| 22 | ) { |
||
| 23 | 41 | $this->variable = $variable; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | /** @return Name[] */ |
||
| 27 | 14 | public function references(): array |
|
| 28 | { |
||
| 29 | 14 | return $this->variable->references(); |
|
| 30 | } |
||
| 31 | |||
| 32 | 16 | public function __toString(): string |
|
| 33 | { |
||
| 34 | 16 | return sprintf( |
|
| 35 | '%s%s%s', |
||
| 36 | 16 | $this->isVariadic ? '...' : '', |
|
| 37 | 16 | $this->isByReference ? '&' : '', |
|
| 38 | 16 | $this->variable |
|
| 39 | ); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |