aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Request/FauxResponse.php
diff options
context:
space:
mode:
authorMatěj Suchánek <matejsuchanek97@gmail.com>2023-05-20 14:16:32 +0200
committerMatěj Suchánek <matejsuchanek97@gmail.com>2023-05-20 15:40:21 +0200
commit676fcf43792a1199619f95ecf836a8d84b58d26a (patch)
tree7ba674b17beae9aef8c11f27d6800c40b151ab3a /includes/Request/FauxResponse.php
parent9c134e2283a50fd4e9cc7b08e26ec1274e2da4a4 (diff)
downloadmediawikicore-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 'includes/Request/FauxResponse.php')
-rw-r--r--includes/Request/FauxResponse.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/includes/Request/FauxResponse.php b/includes/Request/FauxResponse.php
index 6154efef73d1..4aee59d89dd4 100644
--- a/includes/Request/FauxResponse.php
+++ b/includes/Request/FauxResponse.php
@@ -45,7 +45,7 @@ class FauxResponse extends WebResponse {
* @param null|int $http_response_code Forces the HTTP response code to the specified value.
*/
public function header( $string, $replace = true, $http_response_code = null ) {
- if ( substr( $string, 0, 5 ) == 'HTTP/' ) {
+ if ( str_starts_with( $string, 'HTTP/' ) ) {
$parts = explode( ' ', $string, 3 );
$this->code = intval( $parts[1] );
} else {