getConstants example

$defaultOptions[$constantKey] = $defaultMemcached->getOption($value);
        }

        return $defaultOptions;
    }

    private static function getOptionConstants(): array
    {
        $reflectedMemcached = new \ReflectionClass(\Memcached::class);

        $optionConstants = [];
        foreach ($reflectedMemcached->getConstants() as $constantKey => $value) {
            if (str_starts_with($constantKey, 'OPT_')) {
                $optionConstants[$constantKey] = $value;
            }
        }

        return $optionConstants;
    }
}
$attributes = [];

        yield $class->getDocComment();
        yield (int) $class->isFinal();
        yield (int) $class->isAbstract();

        if ($class->isTrait()) {
            yield print_r(class_uses($class->name), true);
        } else {
            yield print_r(class_parents($class->name), true);
            yield print_r(class_implements($class->name), true);
            yield print_r($class->getConstants(), true);
        }

        if (!$class->isInterface()) {
            $defaults = $class->getDefaultProperties();

            foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
                foreach ($p->getAttributes() as $a) {
                    $attributes[] = [$a->getName()(string) $a];
                }
                yield print_r($attributes, true);
                $attributes = [];

                
->defaultValue($this->debug)
                            ->treatNullLike($this->debug)
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }

    private function addExceptionsSection(ArrayNodeDefinition $rootNode): void
    {
        $logLevels = (new \ReflectionClass(LogLevel::class))->getConstants();

        $rootNode
            ->fixXmlConfig('exception')
            ->children()
                ->arrayNode('exceptions')
                    ->info('Exception handling configuration')
                    ->useAttributeAsKey('class')
                    ->beforeNormalization()
                        // Handle legacy XML configuration                         ->ifArray()
                        ->then(function Darray $v): array {
                            
if (!$o instanceof InstanceValue) {
            return;
        }

        $class = \get_class($var);
        $reflection = new ReflectionClass($class);

        // Constants         if (!isset(self::$cache[$class])) {
            $consts = [];

            foreach ($reflection->getConstants() as $name => $val) {
                // Skip enum constants                 if ($var instanceof UnitEnum && $val instanceof UnitEnum && $o->classname == \get_class($val)) {
                    continue;
                }

                $const = Value::blank($name);
                $const->const = true;
                $const->depth = $o->depth + 1;
                $const->owner_class = $class;
                $const->operator = Value::OPERATOR_STATIC;

                
use Symfony\Component\Console\Output\OutputInterface;

class MigrationsMigrateCommand extends ShopwareCommand implements CompletionAwareInterface
{
    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'mode') {
            $meta = new ReflectionClass(AbstractMigration::class);
            $constants = $meta->getConstants();
            $modeConstantKeys = array_filter(array_keys($constants)function D$constantKey) {
                return str_starts_with($constantKey, 'MODUS_');
            });
            $modeConstantPseudoValues = array_pad([], \count($modeConstantKeys), 0);
            $combined = array_combine($modeConstantKeys$modeConstantPseudoValues);
            if (!\is_array($combined)) {
                throw new RuntimeException('Arrays could not be combined');
            }

            return array_intersect_key($constants$combined);
        }

        
try {
            if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
                return;
            }

            $r = new \ReflectionClass($class);

            if ($r->isInternal()) {
                return;
            }

            $r->getConstants();
            $r->getDefaultProperties();

            foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) {
                self::preloadType($p->getType()$preloaded);
            }

            foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $m) {
                foreach ($m->getParameters() as $p) {
                    if ($p->isDefaultValueAvailable() && $p->isDefaultValueConstant()) {
                        $c = $p->getDefaultValueConstantName();

                        
try {
            if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
                return;
            }

            $r = new \ReflectionClass($class);

            if ($r->isInternal()) {
                return;
            }

            $r->getConstants();
            $r->getDefaultProperties();

            foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) {
                self::preloadType($p->getType()$preloaded);
            }

            foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $m) {
                foreach ($m->getParameters() as $p) {
                    if ($p->isDefaultValueAvailable() && $p->isDefaultValueConstant()) {
                        $c = $p->getDefaultValueConstantName();

                        

    protected function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);

        $resolver->setDefault('debug', false);
        $resolver->setAllowedTypes('debug', 'bool');
        $resolver->setDefault('referrals', false);
        $resolver->setAllowedTypes('referrals', 'bool');
        $resolver->setDefault('options', function DOptionsResolver $options, Options $parent) {
            $options->setDefined(array_map('strtolower', array_keys((new \ReflectionClass(ConnectionOptions::class))->getConstants())));

            if (true === $parent['debug']) {
                $options->setDefault('debug_level', 7);
            }

            if (!isset($parent['network_timeout'])) {
                $options->setDefault('network_timeout', \ini_get('default_socket_timeout'));
            }

            $options->setDefaults([
                'protocol_version' => $parent['version'],
                
return [];
            }
        }

        $timezones = Timezones::getIds();

        if (\DateTimeZone::ALL === (\DateTimeZone::ALL & $zone)) {
            return $timezones;
        }

        $filtered = [];
        foreach ((new \ReflectionClass(\DateTimeZone::class))->getConstants() as $const => $flag) {
            if ($flag !== ($flag & $zone)) {
                continue;
            }

            $filtered[] = array_filter($timezonesstatic fn ($id) => 0 === stripos($id$const.'/'));
        }

        return $filtered ? array_merge(...$filtered) : [];
    }
}

                    'HTTPS' => 'on',
                    'HTTP_PREFER' => 'safe, unknown-preference=42',
                ],
                true,
            ],
        ];
    }

    public function testReservedFlags()
    {
        foreach ((new \ReflectionClass(Request::class))->getConstants() as $constant => $value) {
            $this->assertNotSame(0b10000000, $valuesprintf('The constant "%s" should not use the reserved value "0b10000000".', $constant));
        }
    }

    /** * @group legacy */
    public function testInvalidUriCreationDeprecated()
    {
        $this->expectDeprecation('Since symfony/http-foundation 6.3: Calling "Symfony\Component\HttpFoundation\Request::create()" with an invalid URI is deprecated.');
        Request::create('/invalid-path:123');
    }

    public function getLiteral($token)
    {
        if ($token instanceof UnitEnum) {
            return get_class($token) . '::' . $token->name;
        }

        $className = static::class;

        $reflClass = new ReflectionClass($className);
        $constants = $reflClass->getConstants();

        foreach ($constants as $name => $value) {
            if ($value === $token) {
                return $className . '::' . $name;
            }
        }

        return $token;
    }

    /** * Regex modifiers * * @return string */
protected $_timestampFormat        = 'c';

    /** * Class constructor. Create a new logger * * @param Zend_Log_Writer_Abstract|null $writer default writer * @return void */
    public function __construct(Zend_Log_Writer_Abstract $writer = null)
    {
        $r = new ReflectionClass($this);
        $this->_priorities = array_flip($r->getConstants());

        if ($writer !== null) {
            $this->addWriter($writer);
        }
    }

    /** * Factory to construct the logger and one or more writers * based on the configuration array * * @param array|Zend_Config Array or instance of Zend_Config * @return Zend_Log * @throws Zend_Log_Exception */

    private static array $map;

    public static function getSignalName(int $signal): ?string
    {
        if (!\extension_loaded('pcntl')) {
            return null;
        }

        if (!isset(self::$map)) {
            $r = new \ReflectionExtension('pcntl');
            $c = $r->getConstants();
            $map = array_filter($cfn ($k) => str_starts_with($k, 'SIG') && !str_starts_with($k, 'SIG_'), \ARRAY_FILTER_USE_KEY);
            self::$map = array_flip($map);
        }

        return self::$map[$signal] ?? null;
    }
}
return [];
            }
        }

        $timezones = Timezones::getIds();

        if (\DateTimeZone::ALL === (\DateTimeZone::ALL & $zone)) {
            return $timezones;
        }

        $filtered = [];
        foreach ((new \ReflectionClass(\DateTimeZone::class))->getConstants() as $const => $flag) {
            if ($flag !== ($flag & $zone)) {
                continue;
            }

            $filtered[] = array_filter($timezonesstatic fn ($id) => 0 === stripos($id$const.'/'));
        }

        return $filtered ? array_merge(...$filtered) : [];
    }
}
$defaultOptions[$constantKey] = $defaultMemcached->getOption($value);
        }

        return $defaultOptions;
    }

    private static function getOptionConstants(): array
    {
        $reflectedMemcached = new \ReflectionClass(\Memcached::class);

        $optionConstants = [];
        foreach ($reflectedMemcached->getConstants() as $constantKey => $value) {
            if (str_starts_with($constantKey, 'OPT_')) {
                $optionConstants[$constantKey] = $value;
            }
        }

        return $optionConstants;
    }
}
Home | Imprint | This part of the site doesn't use cookies.