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

Breadcrumb

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

class Exception

Same name in this branch
  1. 11.1.x vendor/masterminds/html5/src/HTML5/Exception.php \Masterminds\HTML5\Exception
  2. 11.1.x vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Stub/Exception.php \PHPUnit\Framework\MockObject\Stub\Exception
  3. 11.1.x vendor/phpunit/phpunit/src/Framework/Exception/Exception.php \PHPUnit\Framework\Exception
  4. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/Exception.php \PHPUnit\TextUI\XmlConfiguration\Exception
  5. 11.1.x vendor/phpunit/phpunit/src/TextUI/Configuration/Cli/Exception.php \PHPUnit\TextUI\CliArguments\Exception
  6. 11.1.x vendor/lullabot/php-webdriver/lib/WebDriver/Exception.php \WebDriver\Exception
  7. 11.1.x vendor/theseer/tokenizer/src/Exception.php \TheSeer\Tokenizer\Exception
  8. 11.1.x vendor/behat/mink/src/Exception/Exception.php \Behat\Mink\Exception\Exception
  9. 11.1.x vendor/mck89/peast/lib/Peast/Selector/Exception.php \Peast\Selector\Exception
  10. 11.1.x vendor/mck89/peast/lib/Peast/Syntax/Exception.php \Peast\Syntax\Exception

@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\Framework\Constraint\Constraint implements \Countable, \PHPUnit\Framework\SelfDescribing
    • class \PHPUnit\Framework\Constraint\Exception extends \PHPUnit\Framework\Constraint\Constraint

Expanded class hierarchy of Exception

1 file declares its use of Exception
TestCase.php in vendor/phpunit/phpunit/src/Framework/TestCase.php
25 string references to 'Exception'
ErrorListener::onControllerArguments in vendor/symfony/http-kernel/EventListener/ErrorListener.php
ExceptionDataCollector::getName in vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php
Returns the name of the collector.
Exporter::prepare in vendor/symfony/var-exporter/Internal/Exporter.php
Prepares an array of values for VarExporter.
Formatter::format in vendor/open-telemetry/api/Behavior/Internal/LogWriter/Formatter.php
FullyQualifiedExceptionsSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/FullyQualifiedExceptionsSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

... See full list

File

vendor/phpunit/phpunit/src/Framework/Constraint/Exception/Exception.php, line 21

Namespace

PHPUnit\Framework\Constraint
View source
final class Exception extends Constraint {
    private readonly string $className;
    public function __construct(string $className) {
        $this->className = $className;
    }
    
    /**
     * Returns a string representation of the constraint.
     */
    public function toString() : string {
        return sprintf('exception of type "%s"', $this->className);
    }
    
    /**
     * Evaluates the constraint for parameter $other. Returns true if the
     * constraint is met, false otherwise.
     */
    protected function matches(mixed $other) : bool {
        return $other instanceof $this->className;
    }
    
    /**
     * Returns the description of the failure.
     *
     * The beginning of failure messages is "Failed asserting that" in most
     * cases. This method should return the second part of that sentence.
     *
     * @throws \PHPUnit\Framework\Exception
     */
    protected function failureDescription(mixed $other) : string {
        if ($other === null) {
            return sprintf('exception of type "%s" is thrown', $this->className);
        }
        $message = '';
        if ($other instanceof Throwable) {
            $message = '. Message was: "' . $other->getMessage() . '" at' . "\n" . Filter::getFilteredStacktrace($other);
        }
        return sprintf('exception of type "%s" matches expected exception "%s"%s', $other::class, $this->className, $message);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Constraint::additionalFailureDescription protected function Return additional failure description where needed. 7
Constraint::count public function Counts the number of constraint elements. 3
Constraint::evaluate public function Evaluates the constraint for parameter $other. 7
Constraint::exporter protected function
Constraint::fail protected function Throws an exception for the given compared value and test description. 1
Constraint::failureDescriptionInContext protected function Returns the description of the failure when this constraint appears in
context of an $operator expression.
Constraint::reduce protected function Reduces the sub-expression starting at $this by skipping degenerate
sub-expression and returns first descendant constraint that starts
a non-reducible sub-expression.
2
Constraint::toStringInContext protected function Returns a custom string representation of the constraint object when it
appears in context of an $operator expression.
Constraint::valueToTypeStringFragment protected function @psalm-return non-empty-string
Exception::$className private property
Exception::failureDescription protected function Returns the description of the failure. Overrides Constraint::failureDescription
Exception::matches protected function Evaluates the constraint for parameter $other. Returns true if the
constraint is met, false otherwise.
Overrides Constraint::matches
Exception::toString public function Returns a string representation of the constraint. Overrides SelfDescribing::toString
Exception::__construct public function
RSS feed
Powered by Drupal