Skip to content

Commit

Permalink
Added @return never
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Nov 28, 2024
1 parent b5f7b76 commit b448eeb
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/Reflection/Adapter/ReflectionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function getArguments(): array
return $this->betterReflectionAttribute->getArguments();
}

/** @return never */
public function newInstance(): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
Expand Down
29 changes: 24 additions & 5 deletions src/Reflection/Adapter/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,61 +449,76 @@ public function isInstance(object $object): bool
return $this->betterReflectionClass->isInstance($object);
}

/** @return never */
public function newInstance(mixed ...$args): self
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceWithoutConstructor(): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceArgs(array|null $args = null): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<self::SKIP_*> $options */
/**
* @param int-mask-of<self::SKIP_*> $options
*
* @return never
*/
public function newLazyGhost(callable $initializer, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<self::SKIP_*> $options */
/**
* @param int-mask-of<self::SKIP_*> $options
*
* @return never
*/
public function newLazyProxy(callable $factory, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function markLazyObjectAsInitialized(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function getLazyInitializer(object $object): callable|null
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function initializeLazyObject(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function isUninitializedLazyObject(object $object): bool
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<self::SKIP_*> $options */
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): void
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<self::SKIP_*> $options */
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): void
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}
Expand Down Expand Up @@ -624,7 +639,11 @@ public function implementsInterface(CoreReflectionClass|string $interface): bool
return $this->betterReflectionClass->implementsInterface($realInterfaceName);
}

/** @psalm-mutation-free */
/**
* @return never
*
* @psalm-mutation-free
*/
public function getExtension(): CoreReflectionExtension|null
{
throw new Exception\NotImplemented('Not implemented');
Expand Down
24 changes: 20 additions & 4 deletions src/Reflection/Adapter/ReflectionEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,61 +361,76 @@ public function isInstance(object $object): bool
return $this->betterReflectionEnum->isInstance($object);
}

/** @return never */
public function newInstance(mixed ...$args): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceWithoutConstructor(): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceArgs(array|null $args = null): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
/**
* @param int-mask-of<ReflectionClass::SKIP_*> $options
*
* @return never
*/
public function newLazyGhost(callable $initializer, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
/**
* @param int-mask-of<ReflectionClass::SKIP_*> $options
*
* @return never
*/
public function newLazyProxy(callable $factory, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function markLazyObjectAsInitialized(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function getLazyInitializer(object $object): callable|null
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function initializeLazyObject(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function isUninitializedLazyObject(object $object): bool
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): void
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): void
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}
Expand Down Expand Up @@ -493,6 +508,7 @@ public function implementsInterface(CoreReflectionClass|string $interface): bool
return $this->betterReflectionEnum->implementsInterface($realInterfaceName);
}

/** @return never */
public function getExtension(): CoreReflectionExtension|null
{
throw new Exception\NotImplemented('Not implemented');
Expand Down
1 change: 1 addition & 0 deletions src/Reflection/Adapter/ReflectionEnumBackedCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function getType(): null
return null;
}

/** @return never */
public function getValue(): UnitEnum
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
Expand Down
1 change: 1 addition & 0 deletions src/Reflection/Adapter/ReflectionEnumUnitCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function getType(): null
return null;
}

/** @return never */
public function getValue(): UnitEnum
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Adapter/ReflectionFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function getClosure(): Closure
return $this->betterReflectionFunction->getClosure();
}

/** @return mixed[] */
/** @return never */
public function getClosureUsedVariables(): array
{
throw new Exception\NotImplemented('Not implemented');
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Adapter/ReflectionMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function getTentativeReturnType(): CoreReflectionType|null
return ReflectionType::fromTypeOrNull($this->betterReflectionMethod->getTentativeReturnType());
}

/** @return mixed[] */
/** @return never */
public function getClosureUsedVariables(): array
{
throw new Exception\NotImplemented('Not implemented');
Expand Down
29 changes: 24 additions & 5 deletions src/Reflection/Adapter/ReflectionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,61 +381,76 @@ public function isInstance(object $object): bool
return $this->betterReflectionObject->isInstance($object);
}

/** @return never */
public function newInstance(mixed ...$args): ReflectionObject
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceWithoutConstructor(): ReflectionObject
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function newInstanceArgs(array|null $args = null): ReflectionObject
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
/**
* @param int-mask-of<ReflectionClass::SKIP_*> $options
*
* @return never
*/
public function newLazyGhost(callable $initializer, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
/**
* @param int-mask-of<ReflectionClass::SKIP_*> $options
*
* @return never
*/
public function newLazyProxy(callable $factory, int $options = 0): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function markLazyObjectAsInitialized(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function getLazyInitializer(object $object): callable|null
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function initializeLazyObject(object $object): object
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function isUninitializedLazyObject(object $object): bool
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): void
public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @param int-mask-of<ReflectionClass::SKIP_*> $options */
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): void
public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}
Expand Down Expand Up @@ -552,7 +567,11 @@ public function implementsInterface(CoreReflectionClass|string $interface): bool
return $this->betterReflectionObject->implementsInterface($realInterfaceName);
}

/** @psalm-mutation-free */
/**
* @return never
*
* @psalm-mutation-free
*/
public function getExtension(): CoreReflectionExtension|null
{
throw new Exception\NotImplemented('Not implemented');
Expand Down
6 changes: 4 additions & 2 deletions src/Reflection/Adapter/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ public function setValue(mixed $objectOrValue, mixed $value = null): void
}
}

public function setRawValueWithoutLazyInitialization(object $object, mixed $value): void
public function setRawValueWithoutLazyInitialization(object $object, mixed $value): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

/** @return never */
public function isLazy(object $object): bool
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}

public function skipLazyInitialization(object $object): void
public function skipLazyInitialization(object $object): never
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
}
Expand Down Expand Up @@ -325,6 +326,7 @@ public function getSettableType(): ReflectionUnionType|ReflectionNamedType|Refle
return $this->getType();
}

/** @return never */
public function getRawValue(object $object): mixed
{
throw Exception\NotImplementedBecauseItTriggersAutoloading::create();
Expand Down

0 comments on commit b448eeb

Please sign in to comment.