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/phpunit/phpunit/src/Runner/Baseline/Generator.php \PHPUnit\Runner\Baseline\Generator

Hierarchy

  • class \PHP_CodeSniffer\Generators\Generator

Expanded class hierarchy of Generator

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/squizlabs/php_codesniffer/src/Generators/Generator.php, line 22

Namespace

PHP_CodeSniffer\Generators
View source
abstract class Generator {
    
    /**
     * The ruleset used for the run.
     *
     * @var \PHP_CodeSniffer\Ruleset
     */
    public $ruleset = null;
    
    /**
     * XML documentation files used to produce the final output.
     *
     * @var string[]
     */
    public $docFiles = [];
    
    /**
     * Constructs a doc generator.
     *
     * @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run.
     *
     * @see generate()
     */
    public function __construct(Ruleset $ruleset) {
        $this->ruleset = $ruleset;
        $find = [
            DIRECTORY_SEPARATOR . 'Sniffs' . DIRECTORY_SEPARATOR,
            'Sniff.php',
        ];
        $replace = [
            DIRECTORY_SEPARATOR . 'Docs' . DIRECTORY_SEPARATOR,
            'Standard.xml',
        ];
        foreach ($ruleset->sniffs as $className => $sniffClass) {
            $file = Autoload::getLoadedFileName($className);
            $docFile = str_replace($find, $replace, $file);
            if (is_file($docFile) === true) {
                $this->docFiles[] = $docFile;
            }
        }
        // Always present the docs in a consistent alphabetical order.
        sort($this->docFiles, SORT_NATURAL | SORT_FLAG_CASE);
    }
    
    //end __construct()
    
    /**
     * Retrieves the title of the sniff from the DOMNode supplied.
     *
     * @param \DOMNode $doc The DOMNode object for the sniff.
     *                      It represents the "documentation" tag in the XML
     *                      standard file.
     *
     * @return string
     */
    protected function getTitle(DOMNode $doc) {
        return $doc->getAttribute('title');
    }
    
    //end getTitle()
    
    /**
     * Generates the documentation for a standard.
     *
     * It's probably wise for doc generators to override this method so they
     * have control over how the docs are produced. Otherwise, the processSniff
     * method should be overridden to output content for each sniff.
     *
     * @return void
     * @see    processSniff()
     */
    public function generate() {
        foreach ($this->docFiles as $file) {
            $doc = new DOMDocument();
            $doc->load($file);
            $documentation = $doc->getElementsByTagName('documentation')
                ->item(0);
            $this->processSniff($documentation);
        }
    }
    
    //end generate()
    
    /**
     * Process the documentation for a single sniff.
     *
     * Doc generators must implement this function to produce output.
     *
     * @param \DOMNode $doc The DOMNode object for the sniff.
     *                      It represents the "documentation" tag in the XML
     *                      standard file.
     *
     * @return void
     * @see    generate()
     */
    protected abstract function processSniff(DOMNode $doc);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
Generator::$docFiles public property XML documentation files used to produce the final output.
Generator::$ruleset public property The ruleset used for the run.
Generator::generate public function Generates the documentation for a standard. 2
Generator::getTitle protected function Retrieves the title of the sniff from the DOMNode supplied.
Generator::processSniff abstract protected function Process the documentation for a single sniff. 3
Generator::__construct public function Constructs a doc generator.

API Navigation

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