class_exists example

/** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    $events = [];
    // If the autoloader is not fixed during module install when the modules     // module_install_class_loader_test1 and module_install_class_loader_test2     // are enabled in the same request the class_exists() will cause a crash.     // This is because \Composer\Autoload\ClassLoader maintains a negative     // cache.     if (class_exists('\Drupal\module_install_class_loader_test2\EventSubscriber')) {
      $events = [];
    }
    return $events;
  }

}

    protected function migrate($direction$migration): bool
    {
        include_once $migration->path;

        $class = $migration->class;
        $this->setName($migration->name);

        // Validate the migration file structure         if (class_exists($class, false)) {
            $message = sprintf(lang('Migrations.classNotFound')$class);

            if ($this->silent) {
                $this->cliMessages[] = "\t" . CLI::color($message, 'red');

                return false;
            }

            throw new RuntimeException($message);
        }

        
$this->elementInfo = $element_info;
    $this->csrfToken = $csrf_token;
    $this->themeManager = $theme_manager;
  }

  /** * {@inheritdoc} */
  public function getFormId($form_arg, FormStateInterface &$form_state) {
    // If the $form_arg is the name of a class, instantiate it. Don't allow     // arbitrary strings to be passed to the class resolver.     if (is_string($form_arg) && class_exists($form_arg)) {
      $form_arg = $this->classResolver->getInstanceFromDefinition($form_arg);
    }

    if (!is_object($form_arg)) {
      throw new \InvalidArgumentException(("The form class $form_arg could not be found or loaded."));
    }
    elseif (!($form_arg instanceof FormInterface)) {
      throw new \InvalidArgumentException('The form argument ' . $form_arg::class D ' must be an instance of \Drupal\Core\Form\FormInterface.');
    }

    // Add the $form_arg as the callback object and determine the form ID.
// If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode.         if ( ! $wpautop && $has_line_breaks ) {
            return true;
        }

        // If an HTML comment is present, assume legacy mode.         if ( str_contains( $instance['text'], '<!--' ) ) {
            return true;
        }

        // In the rare case that DOMDocument is not available we cannot reliably sniff content and so we assume legacy.         if ( ! class_exists( 'DOMDocument' ) ) {
            // @codeCoverageIgnoreStart             return true;
            // @codeCoverageIgnoreEnd         }

        $doc = new DOMDocument();

        // Suppress warnings generated by loadHTML.         $errors = libxml_use_internal_errors( true );
        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged         @$doc->loadHTML(
            
<?php
if (class_exists('ParagonIE_Sodium_Core32_Poly1305_State', false)) {
    return;
}

/** * Class ParagonIE_Sodium_Core32_Poly1305_State */
class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Util
{
    /** * @var array<int, int> */
    


    /** * @param string $provider * * @throws Exception */
    private function createDefaultProvider($provider)
    {
        $provider = $provider === 'apc' ? 'apcu' : $provider;

        if (!class_exists($provider, false)) {
            $provider = ucfirst($provider);
            $provider = "Doctrine\\Common\\Cache\\{$provider}Cache";
        }

        if (!class_exists($provider)) {
            throw new Exception(sprintf('Doctrine cache provider "%s" not found failure.', $provider));
        }

        return new $provider();
    }
}
extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === '0' ||
            ini_get('opcache.save_comments') === '0')
        ) {
            throw AnnotationException::optimizerPlusSaveComments();
        }

        if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') === 0) {
            throw AnnotationException::optimizerPlusSaveComments();
        }

        // Make sure that the IgnoreAnnotation annotation is loaded         class_exists(IgnoreAnnotation::class);

        $this->parser = $parser ?: new DocParser();

        $this->preParser = new DocParser();

        $this->preParser->setImports(self::$globalImports);
        $this->preParser->setIgnoreNotImportedAnnotations(true);
        $this->preParser->setIgnoredAnnotationNames(self::$globalIgnoredNames);

        $this->phpParser = new PhpParser();
    }

    

class HttpBrowser extends AbstractBrowser
{
    private HttpClientInterface $client;

    public function __construct(HttpClientInterface $client = null, History $history = null, CookieJar $cookieJar = null)
    {
        if (!$client && !class_exists(HttpClient::class)) {
            throw new LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__));
        }

        $this->client = $client ?? HttpClient::create();

        parent::__construct([]$history$cookieJar);
    }

    /** * @param Request $request */
    
/** * @internal experimental atm */
#[Package('core')] class Datadog implements ProfilerInterface
{
    private array $spans = [];

    public function start(string $title, string $category, array $tags): void
    {
        if (!class_exists(GlobalTracer::class)) {
            return;
        }

        if ($category !== 'shopware') {
            $category = 'shopware.' . $category;
        }

        /** @see \DDTrace\Tag::SERVICE_NAME */
        $tags = array_merge(['service.name' => $category]$tags);
        $span = GlobalTracer::get()->startActiveSpan($title[
            'tags' => $tags,
        ]);
<?php /** * HTTP API: WP_Http class * * @package WordPress * @subpackage HTTP * @since 2.7.0 */

if ( ! class_exists( 'WpOrg\Requests\Autoload' ) ) {
    require ABSPATH . WPINC . '/Requests/src/Autoload.php';

    WpOrg\Requests\Autoload::register();
    WpOrg\Requests\Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
}

/** * Core class used for managing HTTP transports and making HTTP requests. * * This class is used to consistently make outgoing HTTP requests easy for developers * while still being compatible with the many PHP configurations under which * WordPress runs. * * Debugging includes several actions, which pass different variables for debugging the HTTP API. * * @since 2.7.0 */

    public static function test( $args = array() ) {

        // First, test Imagick's extension and classes.         if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) {
            return false;
        }

        if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) {
            return false;
        }

        $required_methods = array(
            'clear',
            'destroy',
            'valid',
            
<?php
if (class_exists('ParagonIE_Sodium_Core_Curve25519_Ge_P2', false)) {
    return;
}

/** * Class ParagonIE_Sodium_Core_Curve25519_Ge_P2 */
class ParagonIE_Sodium_Core_Curve25519_Ge_P2
{
    /** * @var ParagonIE_Sodium_Core_Curve25519_Fe */
    
/** * Returns an AccessDeniedException. * * This will result in a 403 response code. Usage example: * * throw $this->createAccessDeniedException('Unable to access this page!'); * * @throws \LogicException If the Security component is not available */
    protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException
    {
        if (!class_exists(AccessDeniedException::class)) {
            throw new \LogicException('You cannot use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');
        }

        return new AccessDeniedException($message$previous);
    }

    /** * Creates and returns a Form instance from the type of the form. */
    protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
    {
        

final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
{
    public function createArgumentMetadata(string|object|array $controller, \ReflectionFunctionAbstract $reflector = null): array
    {
        $arguments = [];
        $reflector ??= new \ReflectionFunction($controller(...));

        foreach ($reflector->getParameters() as $param) {
            $attributes = [];
            foreach ($param->getAttributes() as $reflectionAttribute) {
                if (class_exists($reflectionAttribute->getName())) {
                    $attributes[] = $reflectionAttribute->newInstance();
                }
            }

            $arguments[] = new ArgumentMetadata($param->getName()$this->getType($param)$param->isVariadic()$param->isDefaultValueAvailable()$param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->allowsNull()$attributes);
        }

        return $arguments;
    }

    /** * Returns an associated type to the given parameter if available. */
/** * @return void */
    public function setLocale(string $locale)
    {
        $this->locale = $locale;
    }

    public function getLocale(): string
    {
        return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
    }

    public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
    {
        if (null === $id || '' === $id) {
            return '';
        }

        if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
            return strtr($id$parameters);
        }

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