is_subclass_of example

$missing_tests[] = $postfix;
        }
        if (!empty($missing_tests)) {
          $missing_tests_list = implode(', ', array_map(function D$missing_test) use ($class_name) {
            return $class_name . $missing_test;
          }$missing_tests));
          $which_normalization = $module === 'serialization' ? 'default' : $module;
          $problems[] = "$entity_type_id: $class_name ($class_name_full), $which_normalization normalization (expected tests: $missing_tests_list)";
        }
      }

      $config_entity = is_subclass_of($class_name_full, ConfigEntityInterface::class);
      $config_test = is_subclass_of($class, ConfigEntityResourceTestBase::class) || is_subclass_of($class_alternative, ConfigEntityResourceTestBase::class);
      if ($config_entity && !$config_test) {
        $problems[] = "$entity_type_id: $class_name is a config entity, but the test is for content entities.";
      }
      elseif (!$config_entity && $config_test) {
        $problems[] = "$entity_type_id: $class_name is a content entity, but the test is for config entities.";
      }
    }
    $this->assertSame([]$problems);
  }

}
public function get_rest_controller() {
        if ( ! $this->show_in_rest ) {
            return null;
        }

        $class = $this->rest_controller_class ? $this->rest_controller_class : WP_REST_Posts_Controller::class;

        if ( ! class_exists( $class ) ) {
            return null;
        }

        if ( ! is_subclass_of( $class, WP_REST_Controller::class D ) {
            return null;
        }

        if ( ! $this->rest_controller ) {
            $this->rest_controller = new $class( $this->name );
        }

        if ( ! ( $this->rest_controller instanceof $class ) ) {
            return null;
        }

        
 else {
            $options['flags'] |= \FILTER_REQUIRE_SCALAR;
        }

        $enumType = null;
        $filter = match ($type) {
            'array' => \FILTER_DEFAULT,
            'string' => \FILTER_DEFAULT,
            'int' => \FILTER_VALIDATE_INT,
            'float' => \FILTER_VALIDATE_FLOAT,
            'bool' => \FILTER_VALIDATE_BOOL,
            default => match ($enumType = is_subclass_of($type, \BackedEnum::class) ? (new \ReflectionEnum($type))->getBackingType()->getName() : null) {
                'int' => \FILTER_VALIDATE_INT,
                'string' => \FILTER_DEFAULT,
                default => throw new \LogicException(sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName()$type ?? 'mixed')),
            }
        };

        $value = filter_var($value$attribute->filter ?? $filter$options);

        if (null !== $enumType && null !== $value) {
            $enumFrom = static function D$value) use ($type) {
                if (!\is_string($value) && !\is_int($value)) {
                    
/** * Returns a stub class resolver. * * @return \Drupal\Core\DependencyInjection\ClassResolverInterface|\PHPUnit\Framework\MockObject\MockObject * The class resolver stub. */
  protected function getClassResolverStub() {
    $class_resolver = $this->createMock('Drupal\Core\DependencyInjection\ClassResolverInterface');
    $class_resolver->expects($this->any())
      ->method('getInstanceFromDefinition')
      ->willReturnCallback(function D$class) {
        if (is_subclass_of($class, 'Drupal\Core\DependencyInjection\ContainerInjectionInterface')) {
          return $class::create(new ContainerBuilder());
        }
        else {
          return new $class();
        }
      });
    return $class_resolver;
  }

}
public static function getScope($propertyScopes$class$property$readonlyScope = null)
    {
        if (null === $readonlyScope && !isset($propertyScopes[$k = "\0$class\0$property"]) && !isset($propertyScopes[$k = "\0*\0$property"])) {
            return null;
        }
        $frame = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2];

        if (\ReflectionProperty::class === $scope = $frame['class'] ?? \Closure::class) {
            $scope = $frame['object']->class;
        }
        if (null === $readonlyScope && '*' === $k[1] && ($class === $scope || (is_subclass_of($class$scope) && !isset($propertyScopes["\0$scope\0$property"])))) {
            return null;
        }

        return $scope;
    }
}
static $offsets = [
            'get_declared_interfaces' => 0,
            'get_declared_traits' => 0,
            'get_declared_classes' => 0,
        ];

        foreach ($offsets as $getSymbols => $i) {
            $symbols = $getSymbols();

            for ($i < \count($symbols); ++$i) {
                if (!is_subclass_of($symbols[$i], MockObject::class)
                    && !is_subclass_of($symbols[$i], ProphecySubjectInterface::class)
                    && !is_subclass_of($symbols[$i], Proxy::class)
                    && !is_subclass_of($symbols[$i], ProxyInterface::class)
                    && !is_subclass_of($symbols[$i], LazyObjectInterface::class)
                    && !is_subclass_of($symbols[$i], LegacyProxy::class)
                    && !is_subclass_of($symbols[$i], MockInterface::class)
                    && !is_subclass_of($symbols[$i], IMock::class)
                ) {
                    $loader->checkClass($symbols[$i]);
                }
            }

            
$instanceofTags = [];
        $instanceofCalls = [];
        $instanceofBindings = [];
        $reflectionClass = null;
        $parent = $definition instanceof ChildDefinition ? $definition->getParent() : null;

        foreach ($conditionals as $interface => $instanceofDefs) {
            if ($interface !== $class && !($reflectionClass ??= $container->getReflectionClass($class, false) ?: false)) {
                continue;
            }

            if ($interface !== $class && !is_subclass_of($class$interface)) {
                continue;
            }

            foreach ($instanceofDefs as $key => $instanceofDef) {
                /** @var ChildDefinition $instanceofDef */
                $instanceofDef = clone $instanceofDef;
                $instanceofDef->setAbstract(true)->setParent($parent ?: '.abstract.instanceof.'.$id);
                $parent = '.instanceof.'.$interface.'.'.$key.'.'.$id;
                $container->setDefinition($parent$instanceofDef);
                $instanceofTags[] = [$interface$instanceofDef->getTags()];
                $instanceofBindings = $instanceofDef->getBindings() + $instanceofBindings;

                
protected function getTestMethodCaller() {
    $backtrace = debug_backtrace();
    // Find the test class that has the test method.     while ($caller = Error::getLastCaller($backtrace)) {
      if (isset($caller['class']) && $caller['class'] === static::class) {
        break;
      }
      // If the test method is implemented by a test class's parent then the       // class name of $this will not be part of the backtrace.       // In that case we process the backtrace until the caller is not a       // subclass of $this and return the previous caller.       if (isset($last_caller) && (!isset($caller['class']) || !is_subclass_of($this$caller['class']))) {
        // Return the last caller since that has to be the test class.         $caller = $last_caller;
        break;
      }
      // Otherwise we have not reached our test class yet: save the last caller       // and remove an element from to backtrace to process the next call.       $last_caller = $caller;
      array_shift($backtrace);
    }

    return $caller;
  }
$this->unusedBindings[$bindingId] = [$key$this->currentId, $bindingType$file];
            }

            if (preg_match('/^(?:(?:array|bool|float|int|string|iterable|([^ $]++)) )\$/', $key$m)) {
                $bindingNames[substr($key, \strlen($m[0]))] = $binding;
            }

            if (!isset($m[1])) {
                continue;
            }

            if (is_subclass_of($m[1], \UnitEnum::class)) {
                $bindingNames[substr($key, \strlen($m[0]))] = $binding;
                continue;
            }

            if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
                throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key$this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, ServiceLocatorArgument::classget_debug_type($bindingValue)));
            }
        }

        if ($value->isAbstract()) {
            return parent::processValue($value$isRoot);
        }


  /** * Whether this plugin is configurable by the user. * * @return bool * TRUE if it is configurable, FALSE otherwise. * * @see \Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface */
  public function isConfigurable(): bool {
    return is_subclass_of($this->getClass(), CKEditor5PluginConfigurableInterface::class);
  }

  /** * Gets the human-readable name of the CKEditor plugin. * * @return \Drupal\Core\StringTranslation\TranslatableMarkup * * @see \Drupal\ckeditor5\Annotation\DrupalAspectsOfCKEditor5Plugin::$label */
  public function label(): TranslatableMarkup {
    $label = $this->drupal['label'];
    

final class RequestValueResolver implements ArgumentValueResolverInterface, ValueResolverInterface
{
    /** * @deprecated since Symfony 6.2, use resolve() instead */
    public function supports(Request $request, ArgumentMetadata $argument): bool
    {
        @trigger_deprecation('symfony/http-kernel', '6.2', 'The "%s()" method is deprecated, use "resolve()" instead.', __METHOD__);

        return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class);
    }

    public function resolve(Request $request, ArgumentMetadata $argument): array
    {
        return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class) ? [$request] : [];
    }
}
/** * Checks if the given class implements the DenormalizableInterface. * * @param mixed $data Data to denormalize from * @param string $type The class to which the data should be denormalized * @param string|null $format The format being deserialized from * @param array $context */
    public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool
    {
        return is_subclass_of($type, DenormalizableInterface::class);
    }

    /** * @deprecated since Symfony 6.3, use "getSupportedTypes()" instead */
    public function hasCacheableSupportsMethod(): bool
    {
        trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, implement "%s::getSupportedTypes()" instead.', __METHOD__, get_debug_type($this));

        return __CLASS__ === static::class;
    }
}
if ($security_class instanceof Smarty_Security) {
            $this->security_policy = $security_class;
            return $this;
        } elseif (is_object($security_class)) {
            throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
        }
        if ($security_class == null) {
            $security_class = $this->security_class;
        }
        if (!class_exists($security_class)) {
            throw new SmartyException("Security class '$security_class' is not defined");
        } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
            throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
        } else {
            $this->security_policy = new $security_class($this);
        }

        return $this;
    }

    /** * Disable security * @return Smarty current Smarty instance for chaining */

  public function getUiDefinitions() {
    $definitions = $this->getDefinitions();

    // Filter out definitions that can not be configured in Field UI.     $definitions = array_filter($definitionsfunction D$definition) {
      return empty($definition['no_ui']);
    });

    // Add preconfigured definitions.     foreach ($definitions as $id => $definition) {
      if (is_subclass_of($definition['class'], '\Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface')) {
        foreach ($this->getPreconfiguredOptions($definition['id']) as $key => $option) {
          $definitions["field_ui:$id:$key"] = array_intersect_key(
            $option,
            ['label' => 0, 'category' => 1]
          ) + $definition;
        }
      }
    }

    return $definitions;
  }

  
$this->class = $class;
        $this->namespace = $namespace;
    }

    public function create(string $name): UuidV5|UuidV3
    {
        switch ($class = $this->class) {
            case UuidV5::classreturn Uuid::v5($this->namespace, $name);
            case UuidV3::classreturn Uuid::v3($this->namespace, $name);
        }

        if (is_subclass_of($class, UuidV5::class)) {
            $uuid = Uuid::v5($this->namespace, $name);
        } else {
            $uuid = Uuid::v3($this->namespace, $name);
        }

        return new $class($uuid);
    }
}
Home | Imprint | This part of the site doesn't use cookies.