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/Constraint/Exception/Exception.php \PHPUnit\Framework\Constraint\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

Base class for all PHPUnit Framework exceptions.

Ensures that exceptions thrown during a test run do not leave stray references behind.

Every Exception contains a stack trace. Each stack frame contains the 'args' of the called function. The function arguments can contain references to instantiated objects. The references prevent the objects from being destructed (until test results are eventually printed), so memory cannot be freed up.

With enabled process isolation, test results are serialized in the child process and unserialized in the parent process. The stack trace of Exceptions may contain objects that cannot be serialized or unserialized (e.g., PDO connections). Unserializing user-space objects from the child process into the parent would break the intended encapsulation of process isolation.

@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\Exception extends \RuntimeException implements \PHPUnit\Exception

Expanded class hierarchy of Exception

See also

http://fabien.potencier.org/article/9/php-serialization-stack-traces-an…

10 files declare their use of Exception
AbstractPhpProcess.php in vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php
Count.php in vendor/phpunit/phpunit/src/Framework/Constraint/Cardinality/Count.php
DefaultPhpProcess.php in vendor/phpunit/phpunit/src/Util/PHP/DefaultPhpProcess.php
Filter.php in vendor/phpunit/phpunit/src/Util/Filter.php
MockBuilder.php in vendor/phpunit/phpunit/src/Framework/MockObject/MockBuilder.php

... See full list

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/Exception/Exception.php, line 43

Namespace

PHPUnit\Framework
View source
class Exception extends RuntimeException implements \PHPUnit\Exception {
    protected array $serializableTrace;
    public function __construct(string $message = '', int|string $code = 0, ?Throwable $previous = null) {
        
        /**
         * @see https://github.com/sebastianbergmann/phpunit/issues/5965
         */
        if (!is_int($code)) {
            $message .= sprintf(' (exception code: %s)', $code);
            $code = 0;
        }
        parent::__construct($message, $code, $previous);
        $this->serializableTrace = $this->getTrace();
        foreach (array_keys($this->serializableTrace) as $key) {
            unset($this->serializableTrace[$key]['args']);
        }
    }
    public function __sleep() : array {
        return array_keys(get_object_vars($this));
    }
    
    /**
     * Returns the serializable trace (without 'args').
     */
    public function getSerializableTrace() : array {
        return $this->serializableTrace;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
Exception::$serializableTrace protected property
Exception::getSerializableTrace public function Returns the serializable trace (without 'args').
Exception::__construct public function 30
Exception::__sleep public function

API Navigation

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