1<?php 2 3/* 4 * This file is part of the Prophecy. 5 * (c) Konstantin Kudryashov <ever.zet@gmail.com> 6 * Marcello Duarte <marcello.duarte@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Prophecy\Doubler\Generator\Node; 13 14/** 15 * Argument node. 16 * 17 * @author Konstantin Kudryashov <ever.zet@gmail.com> 18 */ 19class ArgumentNode 20{ 21 private $name; 22 private $typeHint; 23 private $default; 24 private $optional = false; 25 private $byReference = false; 26 private $isVariadic = false; 27 private $isNullable = false; 28 29 /** 30 * @param string $name 31 */ 32 public function __construct($name) 33 { 34 $this->name = $name; 35 } 36 37 public function getName() 38 { 39 return $this->name; 40 } 41 42 public function getTypeHint() 43 { 44 return $this->typeHint; 45 } 46 47 public function setTypeHint($typeHint = null) 48 { 49 $this->typeHint = $typeHint; 50 } 51 52 public function hasDefault() 53 { 54 return $this->isOptional() && !$this->isVariadic(); 55 } 56 57 public function getDefault() 58 { 59 return $this->default; 60 } 61 62 public function setDefault($default = null) 63 { 64 $this->optional = true; 65 $this->default = $default; 66 } 67 68 public function isOptional() 69 { 70 return $this->optional; 71 } 72 73 public function setAsPassedByReference($byReference = true) 74 { 75 $this->byReference = $byReference; 76 } 77 78 public function isPassedByReference() 79 { 80 return $this->byReference; 81 } 82 83 public function setAsVariadic($isVariadic = true) 84 { 85 $this->isVariadic = $isVariadic; 86 } 87 88 public function isVariadic() 89 { 90 return $this->isVariadic; 91 } 92 93 public function isNullable() 94 { 95 return $this->isNullable; 96 } 97 98 public function setAsNullable($isNullable = true) 99 { 100 $this->isNullable = $isNullable; 101 } 102} 103