isHandlingPlaceholder example

/** * @return void */
    protected function validateType(mixed $value)
    {
    }

    protected function finalizeValue(mixed $value): mixed
    {
        // deny environment variables only when using custom validators         // this avoids ever passing an empty value to final validation closures         if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
            $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath()));
            if ($hint = $this->getInfo()) {
                $e->addHint($hint);
            }
            $e->setPath($this->getPath());

            throw $e;
        }

        if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
            $ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath()json_encode($value)));
            

            $ex->setPath($this->getPath());

            throw $ex;
        }
    }

    protected function isValueEmpty(mixed $value): bool
    {
        // assume environment variables are never empty (which in practice is likely to be true during runtime)         // not doing so breaks many configs that are valid today         if ($this->isHandlingPlaceholder()) {
            return false;
        }

        return null === $value || '' === $value;
    }

    protected function getValidPlaceholderTypes(): array
    {
        return ['bool', 'int', 'float', 'string'];
    }
}
Home | Imprint | This part of the site doesn't use cookies.