/** * @param Type $type * @return int|float|bool|string|array|object|null */ private function getValueForType(Type $type) { if ($type instanceof IntegerType) { return 0; } else { if ($type instanceof FloatType) { return 0.0; } else { if ($type instanceof BooleanType) { return false; } else { if ($type instanceof StringType) { return ''; } else { if ($type instanceof ArrayType) { return array(); } else { if ($type instanceof MultiType) { return $this->getValueForType($type->getTypes()[0]); } else { if ($type instanceof ClassType) { return (new Mockster($type->getClass(), $this->factory))->mock(); } else { return null; } } } } } } } }
private function toString(Type $type) { if ($type instanceof ClassType) { return (new \ReflectionClass($type->getClass()))->getShortName(); } else { return (string) $type; } }
private function objectOfRightClass(Type $type, $object) { return $type instanceof ClassType && is_object($object) && $type->getClass() == get_class($object); }