diff options
author | Matěj Suchánek <matejsuchanek97@gmail.com> | 2023-05-20 14:16:32 +0200 |
---|---|---|
committer | Matěj Suchánek <matejsuchanek97@gmail.com> | 2023-05-20 15:40:21 +0200 |
commit | 676fcf43792a1199619f95ecf836a8d84b58d26a (patch) | |
tree | 7ba674b17beae9aef8c11f27d6800c40b151ab3a /tests/phpunit/includes/db/DatabaseTestHelper.php | |
parent | 9c134e2283a50fd4e9cc7b08e26ec1274e2da4a4 (diff) | |
download | mediawikicore-676fcf43792a1199619f95ecf836a8d84b58d26a.tar.gz mediawikicore-676fcf43792a1199619f95ecf836a8d84b58d26a.zip |
Replace substr with cleaner string methods
Use str_starts_with, str_ends_with or string offset where appropriate.
This fixes a bug in MimeAnalyzer where the "UTF-16LE" header could not
be identified because of wrong constant. This is the exact type of bug
that the new functions can avoid.
Change-Id: I9f30881e7e895f011db29cf5dcbe43bc4f341062
Diffstat (limited to 'tests/phpunit/includes/db/DatabaseTestHelper.php')
-rw-r--r-- | tests/phpunit/includes/db/DatabaseTestHelper.php | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/phpunit/includes/db/DatabaseTestHelper.php b/tests/phpunit/includes/db/DatabaseTestHelper.php index 4261a9851b23..15cb1f398c4f 100644 --- a/tests/phpunit/includes/db/DatabaseTestHelper.php +++ b/tests/phpunit/includes/db/DatabaseTestHelper.php @@ -141,7 +141,7 @@ class DatabaseTestHelper extends Database { $check = $m[1]; } - if ( substr( $check, 0, strlen( $this->testName ) ) !== $this->testName ) { + if ( !str_starts_with( $check, $this->testName ) ) { throw new MWException( 'function name does not start with test class. ' . $fname . ' vs. ' . $this->testName . '. ' . 'Please provide __METHOD__ to database methods.' ); |