BetterReflection\Reflection\ReflectionParameter::isDefaultValueAvailable PHP Méthode

isDefaultValueAvailable() public méthode

Note this is distinct from "isOptional" because you can have a default value, but the parameter not be optional. In the example, the $foo parameter isOptional() == false, but isDefaultValueAvailable == true
public isDefaultValueAvailable ( ) : boolean
Résultat boolean
    public function isDefaultValueAvailable()
    {
        return null !== $this->node->default;
    }

Usage Example

Exemple #1
0
 /**
  * Factory depuis une reflection
  *
  * @param ReflectionParameter $reflection
  * @return static
  */
 public static function fromReflection(ReflectionParameter $reflection)
 {
     // VALUE
     $value = $reflection->isDefaultValueAvailable() ? $reflection->getDefaultValue() : Maker::NO_VALUE;
     // TYPE
     $type = $reflection->getTypeHint();
     // analyse du type
     if (!is_null($type)) {
         if ($type instanceof Object_) {
             $type = strval($type->getFqsen());
         } elseif ($type instanceof Array_) {
             $type = 'array';
         } else {
             exc('Impossible de determiner le type du paramètre : ' . $reflection->getName());
         }
     }
     // construction
     $parameter = new static($reflection->getName(), $value, $type);
     return $parameter;
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionParameter::isDefaultValueAvailable