get_class_vars example

foreach ($options as $name => $value) {
            $this->$name = $value;
        }
    }

    protected function normalizeOptions(mixed $options): array
    {
        $normalizedOptions = [];
        $defaultOption = $this->getDefaultOption();
        $invalidOptions = [];
        $missingOptions = array_flip((array) $this->getRequiredOptions());
        $knownOptions = get_class_vars(static::class);

        if (\is_array($options) && isset($options['value']) && !property_exists($this, 'value')) {
            if (null === $defaultOption) {
                throw new ConstraintDefinitionException(sprintf('No default option is configured for constraint "%s".', static::class));
            }

            $options[$defaultOption] = $options['value'];
            unset($options['value']);
        }

        if (\is_array($options)) {
            
private static array $defaultProperties = [];

    /** * @internal */
    public function __sleep(): array
    {
        $properties = [];

        if (!isset(self::$defaultProperties[$c = static::class])) {
            self::$defaultProperties[$c] = get_class_vars($c);

            foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
                unset(self::$defaultProperties[$c][$k]);
            }
        }

        foreach (self::$defaultProperties[$c] as $k => $v) {
            if ($this->$k !== $v) {
                $properties[] = $k;
            }
        }

        
private static array $defaultProperties = [];

    /** * @internal */
    public function __sleep(): array
    {
        $properties = [];

        if (!isset(self::$defaultProperties[$c = static::class])) {
            self::$defaultProperties[$c] = get_class_vars($c);

            foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
                unset(self::$defaultProperties[$c][$k]);
            }
        }

        foreach (self::$defaultProperties[$c] as $k => $v) {
            if ($this->$k !== $v) {
                $properties[] = $k;
            }
        }

        
$this->assertEquals($expected_derived_plugin_definitions$actual_definitions);
  }

  /** * Data provider. * * @return \Generator * Test scenarios. */
  public function providerTestDerivedPluginDefinitions(): \Generator {
    // Defaults inherited from CKEditor5AspectsOfCKEditor5Plugin.     $ckeditor5_aspects_defaults = get_class_vars(CKEditor5AspectsOfCKEditor5Plugin::class);
    // Defaults inherited from DrupalAspectsOfCKEditor5Plugin.     $drupal_aspects_defaults = get_class_vars(DrupalAspectsOfCKEditor5Plugin::class);

    $simple_deriver_additional_files = [
      'src' => [
        'Plugin' => [
          'CKEditor5Plugin' => [
            'SimpleDeriver.php' => <<<'PHP' <?php namespace Drupal\ckeditor5_derived_plugin\Plugin\CKEditor5Plugin; use Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition; use Drupal\Component\Plugin\Derivative\DeriverBase; class SimpleDeriver extends DeriverBase { public function getDerivativeDefinitions($base_plugin_definition) { assert($base_plugin_definition instanceof CKEditor5PluginDefinition); foreach (['bar', 'baz'] as $id) { $definition = $base_plugin_definition->toArray(); $definition['id'] = $id; $definition['drupal']['label'] = sprintf("Foo %s", $id); $this->derivatives[$id] = new CKEditor5PluginDefinition($definition); } return $this->derivatives; } }
foreach ($options as $name => $value) {
            $this->$name = $value;
        }
    }

    protected function normalizeOptions(mixed $options): array
    {
        $normalizedOptions = [];
        $defaultOption = $this->getDefaultOption();
        $invalidOptions = [];
        $missingOptions = array_flip((array) $this->getRequiredOptions());
        $knownOptions = get_class_vars(static::class);

        if (\is_array($options) && isset($options['value']) && !property_exists($this, 'value')) {
            if (null === $defaultOption) {
                throw new ConstraintDefinitionException(sprintf('No default option is configured for constraint "%s".', static::class));
            }

            $options[$defaultOption] = $options['value'];
            unset($options['value']);
        }

        if (\is_array($options)) {
            
/** * Outputs the object data as array. * Used to convert a form structure to * a uniform array structure which can be used * from the Shopware\Components\Form\Persister and * Shopware\Components\Form\Hydrator * * @return array */
    public function toArray()
    {
        $properties = get_class_vars(\get_class($this));

        $data = [
            'type' => \get_class($this),
        ];

        foreach ($properties as $property => $value) {
            $method = 'get' . ucfirst($property);

            if (!method_exists($this$method)) {
                continue;
            }

            

    public function initialize($config)
    {
        $this->clear();

        if ($config instanceof \Config\Email) {
            $config = get_object_vars($config);
        }

        foreach (array_keys(get_class_vars(static::class)) as $key) {
            if (property_exists($this$key) && isset($config[$key])) {
                $method = 'set' . ucfirst($key);

                if (method_exists($this$method)) {
                    $this->{$method}($config[$key]);
                } else {
                    $this->{$key} = $config[$key];
                }
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.