Skip to content

Commit

Permalink
Remove code that is no longer needed because E_WARNING is ignored by …
Browse files Browse the repository at this point in the history
…the error handler when the error suppression operator is used
  • Loading branch information
sebastianbergmann committed Aug 27, 2022
1 parent 758cdcc commit 1234057
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 120 deletions.
Expand Up @@ -9,9 +9,9 @@
*/
namespace PHPUnit\Framework\Constraint;

use function preg_match;
use function sprintf;
use Exception;
use PHPUnit\Util\RegularExpression as RegularExpressionUtil;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -41,7 +41,7 @@ public function toString(): string
*/
protected function matches(mixed $other): bool
{
$match = RegularExpressionUtil::safeMatch($this->regularExpression, (string) $other);
$match = @preg_match($this->regularExpression, (string) $other);

if ($match === false) {
throw new \PHPUnit\Framework\Exception(
Expand Down
3 changes: 1 addition & 2 deletions src/Runner/Filter/NameFilterIterator.php
Expand Up @@ -19,7 +19,6 @@
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Util\RegularExpression;
use RecursiveFilterIterator;
use RecursiveIterator;

Expand Down Expand Up @@ -73,7 +72,7 @@ public function accept(): bool
*/
private function setFilter(string $filter): void
{
if (RegularExpression::safeMatch($filter, '') === false) {
if (@preg_match($filter, '') === false) {
// Handles:
// * testAssertEqualsSucceeds#4
// * testAssertEqualsSucceeds#4-8
Expand Down
20 changes: 0 additions & 20 deletions src/Util/ErrorHandler.php
Expand Up @@ -31,7 +31,6 @@ final class ErrorHandler
{
private static ?self $instance = null;
private bool $enabled = false;
private bool $ignoreWarnings = false;

public static function instance(): self
{
Expand Down Expand Up @@ -73,10 +72,6 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil
break;

case E_WARNING:
if ($this->ignoreWarnings) {
return true;
}

Event\Facade::emitter()->testTriggeredPhpWarning(
$this->testValueObjectForEvents(),
$errorString,
Expand Down Expand Up @@ -166,21 +161,6 @@ public function disable(): void
$this->enabled = false;
}

public function isDisabled(): bool
{
return !$this->enabled;
}

public function ignoreWarnings(): void
{
$this->ignoreWarnings = true;
}

public function doNotIgnoreWarnings(): void
{
$this->ignoreWarnings = false;
}

/**
* @throws Exception
*/
Expand Down
42 changes: 0 additions & 42 deletions src/Util/RegularExpression.php

This file was deleted.

54 changes: 0 additions & 54 deletions tests/unit/Util/RegularExpressionTest.php

This file was deleted.

0 comments on commit 1234057

Please sign in to comment.