Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Generator.php

class Generator

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Framework/MockObject/Generator/Generator.php \PHPUnit\Framework\MockObject\Generator\Generator
  2. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/Generator.php \PHPUnit\TextUI\XmlConfiguration\Generator
  3. 11.1.x vendor/squizlabs/php_codesniffer/src/Generators/Generator.php \PHP_CodeSniffer\Generators\Generator

@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

@internal This class is not covered by the backward compatibility promise for PHPUnit

Hierarchy

  • class \PHPUnit\Runner\Baseline\Generator

Expanded class hierarchy of Generator

1 file declares its use of Generator
Application.php in vendor/phpunit/phpunit/src/TextUI/Application.php
4 string references to 'Generator'
BareHtmlPageRenderer::systemPageAttachments in core/lib/Drupal/Core/Render/BareHtmlPageRenderer.php
Helper for system_page_attachments.
Config::printPHPCSUsage in vendor/squizlabs/php_codesniffer/src/Config.php
Prints out the usage information for PHPCS.
MethodProphecy::__construct in vendor/phpspec/prophecy/src/Prophecy/Prophecy/MethodProphecy.php
@internal
ReturnValueGenerator::generate in vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/ReturnValueGenerator.php
@psalm-param class-string $className @psalm-param non-empty-string $methodName @psalm-param class-string $stubClassName

File

vendor/phpunit/phpunit/src/Runner/Baseline/Generator.php, line 30

Namespace

PHPUnit\Runner\Baseline
View source
final class Generator {
    private Baseline $baseline;
    private readonly Source $source;
    
    /**
     * @throws EventFacadeIsSealedException
     * @throws UnknownSubscriberTypeException
     */
    public function __construct(Facade $facade, Source $source) {
        $facade->registerSubscribers(new TestTriggeredDeprecationSubscriber($this), new TestTriggeredNoticeSubscriber($this), new TestTriggeredPhpDeprecationSubscriber($this), new TestTriggeredPhpNoticeSubscriber($this), new TestTriggeredPhpWarningSubscriber($this), new TestTriggeredWarningSubscriber($this));
        $this->baseline = new Baseline();
        $this->source = $source;
    }
    public function baseline() : Baseline {
        return $this->baseline;
    }
    
    /**
     * @throws FileDoesNotExistException
     * @throws FileDoesNotHaveLineException
     */
    public function testTriggeredIssue(DeprecationTriggered|NoticeTriggered|PhpDeprecationTriggered|PhpNoticeTriggered|PhpWarningTriggered|WarningTriggered $event) : void {
        if ($event->wasSuppressed() && !$this->isSuppressionIgnored($event)) {
            return;
        }
        if ($this->restrict($event) && !(new SourceFilter())->includes($this->source, $event->file())) {
            return;
        }
        $this->baseline
            ->add(Issue::from($event->file(), $event->line(), null, $event->message()));
    }
    private function restrict(DeprecationTriggered|NoticeTriggered|PhpDeprecationTriggered|PhpNoticeTriggered|PhpWarningTriggered|WarningTriggered $event) : bool {
        if ($event instanceof WarningTriggered || $event instanceof PhpWarningTriggered) {
            return $this->source
                ->restrictWarnings();
        }
        if ($event instanceof NoticeTriggered || $event instanceof PhpNoticeTriggered) {
            return $this->source
                ->restrictNotices();
        }
        return $this->source
            ->restrictDeprecations();
    }
    private function isSuppressionIgnored(DeprecationTriggered|NoticeTriggered|PhpDeprecationTriggered|PhpNoticeTriggered|PhpWarningTriggered|WarningTriggered $event) : bool {
        if ($event instanceof WarningTriggered) {
            return $this->source
                ->ignoreSuppressionOfWarnings();
        }
        if ($event instanceof PhpWarningTriggered) {
            return $this->source
                ->ignoreSuppressionOfPhpWarnings();
        }
        if ($event instanceof PhpNoticeTriggered) {
            return $this->source
                ->ignoreSuppressionOfPhpNotices();
        }
        if ($event instanceof NoticeTriggered) {
            return $this->source
                ->ignoreSuppressionOfNotices();
        }
        if ($event instanceof PhpDeprecationTriggered) {
            return $this->source
                ->ignoreSuppressionOfPhpDeprecations();
        }
        return $this->source
            ->ignoreSuppressionOfDeprecations();
    }

}

Members

Title Sort descending Modifiers Object type Summary
Generator::$baseline private property
Generator::$source private property
Generator::baseline public function
Generator::isSuppressionIgnored private function
Generator::restrict private function
Generator::testTriggeredIssue public function
Generator::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal