1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

drop compatibility aliases

This commit is contained in:
orklah 2022-01-19 19:29:16 +01:00
parent d274d5241e
commit 52a7f0694e
11 changed files with 10 additions and 37 deletions

View File

@ -159,7 +159,7 @@ class PluginListTest extends TestCase
{ {
$plugin_list = new PluginList($this->config_file->reveal(), $this->composer_lock->reveal()); $plugin_list = new PluginList($this->config_file->reveal(), $this->composer_lock->reveal());
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/unknown plugin/i'); $this->expectExceptionMessageMatches('/unknown plugin/i');
$plugin_list->resolvePluginClass('vendor/package'); $plugin_list->resolvePluginClass('vendor/package');
} }

View File

@ -1156,7 +1156,7 @@ class PluginTest extends TestCase
$this->project_analyzer->trackTaintedInputs(); $this->project_analyzer->trackTaintedInputs();
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/TaintedHtml/'); $this->expectExceptionMessageMatches('/TaintedHtml/');
$this->analyzeFile($file_path, new Context()); $this->analyzeFile($file_path, new Context());
} }

View File

@ -237,7 +237,7 @@ class DocumentationTest extends TestCase
} }
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$codebase = $this->project_analyzer->getCodebase(); $codebase = $this->project_analyzer->getCodebase();
$codebase->config->visitPreloadedStubFiles($codebase); $codebase->config->visitPreloadedStubFiles($codebase);

View File

@ -90,7 +90,7 @@ class ErrorAfterUpdateTest extends TestCase
} }
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$codebase->reloadFiles($this->project_analyzer, array_keys($end_files)); $codebase->reloadFiles($this->project_analyzer, array_keys($end_files));

View File

@ -88,7 +88,7 @@ class IncludeTest extends TestCase
$config->skip_checks_on_unresolvable_includes = false; $config->skip_checks_on_unresolvable_includes = false;
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$codebase->scanFiles(); $codebase->scanFiles();

View File

@ -150,7 +150,7 @@ class PsalmPluginTest extends TestCase
$help_command = new CommandTester($this->app->find('help')); $help_command = new CommandTester($this->app->find('help'));
$help_command->execute(['command_name' => $command]); $help_command->execute(['command_name' => $command]);
$output = $help_command->getDisplay(); $output = $help_command->getDisplay();
$this->assertRegExp('/Usage:.*$\s+' . preg_quote($command, '/') . '\b/m', $output); $this->assertMatchesRegularExpression('/Usage:.*$\s+' . preg_quote($command, '/') . '\b/m', $output);
} }
/** /**

View File

@ -50,7 +50,7 @@ class TaintTest extends TestCase
} }
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$file_path = self::$src_dir_path . 'somefile.php'; $file_path = self::$src_dir_path . 'somefile.php';

View File

@ -24,7 +24,6 @@ use function defined;
use function getcwd; use function getcwd;
use function ini_set; use function ini_set;
use function is_string; use function is_string;
use function method_exists;
use const ARRAY_FILTER_USE_KEY; use const ARRAY_FILTER_USE_KEY;
use const DIRECTORY_SEPARATOR; use const DIRECTORY_SEPARATOR;
@ -153,28 +152,6 @@ class TestCase extends BaseTestCase
return $this->getName($withDataSet); return $this->getName($withDataSet);
} }
/**
* Compatibility alias
*/
public function expectExceptionMessageRegExp(string $regexp): void
{
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches($regexp);
} else {
/** @psalm-suppress UndefinedMethod */
parent::expectExceptionMessageRegExp($regexp);
}
}
public static function assertRegExp(string $pattern, string $string, string $message = ''): void
{
if (method_exists(self::class, 'assertMatchesRegularExpression')) {
self::assertMatchesRegularExpression($pattern, $string, $message);
} else {
parent::assertRegExp($pattern, $string, $message);
}
}
public static function assertArrayKeysAreStrings(array $array, string $message = ''): void public static function assertArrayKeysAreStrings(array $array, string $message = ''): void
{ {
$validKeys = array_filter($array, 'is_string', ARRAY_FILTER_USE_KEY); $validKeys = array_filter($array, 'is_string', ARRAY_FILTER_USE_KEY);

View File

@ -81,11 +81,7 @@ trait InvalidCodeAnalysisTestTrait
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
} else {
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
}
$codebase = $this->project_analyzer->getCodebase(); $codebase = $this->project_analyzer->getCodebase();
$codebase->config->visitPreloadedStubFiles($codebase); $codebase->config->visitPreloadedStubFiles($codebase);

View File

@ -90,7 +90,7 @@ class UnusedCodeTest extends TestCase
} }
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$file_path = self::$src_dir_path . 'somefile.php'; $file_path = self::$src_dir_path . 'somefile.php';

View File

@ -82,7 +82,7 @@ class UnusedVariableTest extends TestCase
} }
$this->expectException(CodeException::class); $this->expectException(CodeException::class);
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
$file_path = self::$src_dir_path . 'somefile.php'; $file_path = self::$src_dir_path . 'somefile.php';