0 follower

Final Class Yiisoft\Proxy\ClassConfigFactory

InheritanceYiisoft\Proxy\ClassConfigFactory

Public Methods

Hide inherited methods

Method Description Defined By
getClassConfig() Gets single class config based for individual class. Yiisoft\Proxy\ClassConfigFactory

Method Details

Hide inherited methods

getClassConfig() public method

Gets single class config based for individual class.

public Yiisoft\Proxy\Config\ClassConfig getClassConfig ( string $className )
$className string

Full class or interface name (including namespace).

return Yiisoft\Proxy\Config\ClassConfig

Class config with all related configs (methods, parameters, types) linked.

throws InvalidArgumentException

In case class or interface does not exist.

                public function getClassConfig(string $className): ClassConfig
{
    try {
        $reflection = new ReflectionClass($className);
    } catch (ReflectionException) {
        throw new InvalidArgumentException("$className must exist.");
    }
    /**
     * @psalm-suppress MixedArgumentTypeCoercion Can be removed after release
     * https://github.com/vimeo/psalm/pull/8405
     */
    return new ClassConfig(
        isInterface: $reflection->isInterface(),
        namespace: $reflection->getNamespaceName(),
        modifiers: Reflection::getModifierNames($reflection->getModifiers()),
        name: $reflection->getName(),
        shortName: $reflection->getShortName(),
        parent: (string) $reflection->getParentClass(),
        interfaces: $reflection->getInterfaceNames(),
        methods: $this->getMethodConfigs($reflection),
    );
}