getTypeObjectFromTypehint() public static méthode

public static getTypeObjectFromTypehint ( string $typehintString, boolean $isNullable, string $selfClass = null ) : PHPStan\Type\Type
$typehintString string
$isNullable boolean
$selfClass string
Résultat PHPStan\Type\Type
 public function getReturnType() : Type
 {
     if ($this->returnType === null) {
         $phpTypeReflection = $this->reflection->getReturnType();
         if ($phpTypeReflection === null) {
             $this->returnType = new MixedType(true);
         } else {
             $this->returnType = TypehintHelper::getTypeObjectFromTypehint((string) $phpTypeReflection, $phpTypeReflection->allowsNull());
         }
     }
     return $this->returnType;
 }
Exemple #2
0
 private function getTypeFromTypeString(string $typeString, string $className = null) : Type
 {
     $typeParts = explode('|', $typeString);
     $typePartsWithoutNull = array_values(array_filter($typeParts, function ($part) {
         return strtolower($part) !== 'null';
     }));
     if (count($typePartsWithoutNull) === 0) {
         return new NullType();
     }
     if (count($typePartsWithoutNull) !== 1) {
         return new MixedType(false);
     }
     $isNullable = count($typeParts) !== count($typePartsWithoutNull);
     return TypehintHelper::getTypeObjectFromTypehint($typePartsWithoutNull[0], $isNullable, $className);
 }