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

Breadcrumb

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

class Issue

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Runner/TestResult/Issue.php \PHPUnit\TestRunner\TestResult\Issues\Issue

@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\Issue

Expanded class hierarchy of Issue

1 file declares its use of Issue
ErrorHandler.php in vendor/phpunit/phpunit/src/Runner/ErrorHandler.php
3 string references to 'Issue'
Gitlab::generateFileReport in vendor/micheh/phpcs-gitlab/src/Report/Gitlab.php
@psalm-suppress ImplementedParamTypeMismatch PHP_CodeSniffer has a wrong docblock
Reader::read in vendor/phpunit/phpunit/src/Runner/Baseline/Reader.php
@psalm-param non-empty-string $baselineFile
Writer::write in vendor/phpunit/phpunit/src/Runner/Baseline/Writer.php
@psalm-param non-empty-string $baselineFile

File

vendor/phpunit/phpunit/src/Runner/Baseline/Issue.php, line 24

Namespace

PHPUnit\Runner\Baseline
View source
final class Issue {
    
    /**
     * @psalm-var non-empty-string
     */
    private readonly string $file;
    
    /**
     * @psalm-var positive-int
     */
    private readonly int $line;
    
    /**
     * @psalm-var non-empty-string
     */
    private readonly string $hash;
    
    /**
     * @psalm-var non-empty-string
     */
    private readonly string $description;
    
    /**
     * @psalm-param non-empty-string $file
     * @psalm-param positive-int $line
     * @psalm-param ?non-empty-string $hash
     * @psalm-param non-empty-string $description
     *
     * @throws FileDoesNotExistException
     * @throws FileDoesNotHaveLineException
     */
    public static function from(string $file, int $line, ?string $hash, string $description) : self {
        if ($hash === null) {
            $hash = self::calculateHash($file, $line);
        }
        return new self($file, $line, $hash, $description);
    }
    
    /**
     * @psalm-param non-empty-string $file
     * @psalm-param positive-int $line
     * @psalm-param non-empty-string $hash
     * @psalm-param non-empty-string $description
     */
    private function __construct(string $file, int $line, string $hash, string $description) {
        $this->file = $file;
        $this->line = $line;
        $this->hash = $hash;
        $this->description = $description;
    }
    
    /**
     * @psalm-return non-empty-string
     */
    public function file() : string {
        return $this->file;
    }
    
    /**
     * @psalm-return positive-int
     */
    public function line() : int {
        return $this->line;
    }
    
    /**
     * @psalm-return non-empty-string
     */
    public function hash() : string {
        return $this->hash;
    }
    
    /**
     * @psalm-return non-empty-string
     */
    public function description() : string {
        return $this->description;
    }
    public function equals(self $other) : bool {
        return $this->file() === $other->file() && $this->line() === $other->line() && $this->hash() === $other->hash() && $this->description() === $other->description();
    }
    
    /**
     * @psalm-param non-empty-string $file
     * @psalm-param positive-int $line
     *
     * @psalm-return non-empty-string
     *
     * @throws FileDoesNotExistException
     * @throws FileDoesNotHaveLineException
     */
    private static function calculateHash(string $file, int $line) : string {
        $lines = @file($file, FILE_IGNORE_NEW_LINES);
        if ($lines === false && !is_file($file)) {
            throw new FileDoesNotExistException($file);
        }
        $key = $line - 1;
        if (!isset($lines[$key])) {
            throw new FileDoesNotHaveLineException($file, $line);
        }
        $hash = sha1($lines[$key]);
        assert($hash !== '');
        return $hash;
    }

}

Members

Title Sort descending Modifiers Object type Summary
Issue::$description private property @psalm-var non-empty-string
Issue::$file private property @psalm-var non-empty-string
Issue::$hash private property @psalm-var non-empty-string
Issue::$line private property @psalm-var positive-int
Issue::calculateHash private static function @psalm-param non-empty-string $file
@psalm-param positive-int $line
Issue::description public function @psalm-return non-empty-string
Issue::equals public function
Issue::file public function @psalm-return non-empty-string
Issue::from public static function @psalm-param non-empty-string $file
@psalm-param positive-int $line
@psalm-param ?non-empty-string $hash
@psalm-param non-empty-string $description
Issue::hash public function @psalm-return non-empty-string
Issue::line public function @psalm-return positive-int
Issue::__construct private function @psalm-param non-empty-string $file
@psalm-param positive-int $line
@psalm-param non-empty-string $hash
@psalm-param non-empty-string $description
RSS feed
Powered by Drupal