Skip to content
Snippets Groups Projects
Unverified Commit 902e7a8c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3517614 by alexpott, longwave, cmlara, catch, quietone, mstrelan:...

Issue #3517614 by alexpott, longwave, cmlara, catch, quietone, mstrelan: Possible Non GPLv2 compatible code in ExpectDeprecationTrait

(cherry picked from commit 405ac9da)
parent 6155dc89
No related branches found
No related tags found
No related merge requests found
Pipeline #485568 passed with warnings
Pipeline: drupal

#485594

    Pipeline: drupal

    #485588

      Pipeline: drupal

      #485581

        +2
        ......@@ -63,10 +63,7 @@ public function tearDownErrorHandler(): void {
        // restored during ::tearDown().
        $handler = Error::currentErrorHandler();
        if (!$handler instanceof TestErrorHandler) {
        throw new \RuntimeException(sprintf('%s registered its own error handler (%s) without restoring the previous one before or during tear down. This can cause unpredictable test results. Ensure the test cleans up after itself.',
        $this->name(),
        self::getCallableName($handler),
        ));
        throw new \RuntimeException(sprintf('%s registered its own error handler without restoring the previous one before or during tear down. This can cause unpredictable test results. Ensure the test cleans up after itself.', $this->name()));
        }
        restore_error_handler();
        ......@@ -97,41 +94,4 @@ public function expectDeprecation(string $message): void {
        DeprecationHandler::expectDeprecation($message);
        }
        /**
        * Returns a callable as a string suitable for inclusion in a message.
        *
        * @param callable $callable
        * The callable.
        *
        * @return string
        * The string suitable for inclusion in a message.
        *
        * @see https://stackoverflow.com/questions/34324576/print-name-or-definition-of-callable-in-php
        */
        private static function getCallableName(callable $callable): string {
        switch (TRUE) {
        case is_string($callable) && strpos($callable, '::'):
        return '[static] ' . $callable;
        case is_string($callable):
        return '[function] ' . $callable;
        case is_array($callable) && is_object($callable[0]):
        return '[method] ' . get_class($callable[0]) . '->' . $callable[1];
        case is_array($callable):
        return '[static] ' . $callable[0] . '::' . $callable[1];
        case $callable instanceof \Closure:
        return '[closure]';
        case is_object($callable):
        return '[invokable] ' . get_class($callable);
        default:
        return '[unknown]';
        }
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment