Skip to content

Commit 943391e

Browse files
umherirrenderjenkins-bot
authored andcommitted
Use php8 functions str_contains and str_starts_with
For readability of the conditions Change-Id: I5e872525185e8b32aa1d8db3872fed2a250e3670
1 parent e0fb30f commit 943391e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Objects/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function __toString() {
420420
$unit = '%';
421421
} elseif ( $this->type === self::T_DIMENSION ) {
422422
$unit = self::escapeIdent( $this->unit );
423-
if ( strpos( $number, 'e' ) === false && strpos( $number, 'E' ) === false &&
423+
if ( !str_contains( $number, 'e' ) && !str_contains( $number, 'E' ) &&
424424
preg_match( '/^[eE][+-]?\d/', $unit )
425425
) {
426426
// Unit would look like exponential notation, so escape the leading "e"

src/Parser/Encoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class Encoder {
265265
*/
266266
public static function convert( $text, $encodings = [] ) {
267267
// First, check for a BOM and honor that if it's present.
268-
if ( strpos( $text, "\xef\xbb\xbf" ) === 0 ) {
268+
if ( str_starts_with( $text, "\xef\xbb\xbf" ) ) {
269269
// UTF-8 with BOM (convert it anyway in case the BOM is a lie)
270270
return self::doConvert( 'UTF-8', substr( $text, 3 ) );
271271
}

tests/Grammar/TestMatcherFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function urlstring( $type ) {
3131
$key = __METHOD__ . ':' . $type;
3232
if ( !isset( $this->cache[$key] ) ) {
3333
$this->cache[$key] = new TokenMatcher( Token::T_STRING, static function ( $url ) use ( $type ) {
34-
return strpos( $url, $type ) !== false;
34+
return str_contains( $url, $type );
3535
} );
3636
}
3737
return $this->cache[$key];
@@ -42,7 +42,7 @@ public function url( $type ) {
4242
$key = __METHOD__ . ':' . $type;
4343
if ( !isset( $this->cache[$key] ) ) {
4444
$this->cache[$key] = new UrlMatcher( static function ( $url, $modifiers ) use ( $type ) {
45-
return strpos( $url, $type ) !== false;
45+
return str_contains( $url, $type );
4646
}, [
4747
'modifierMatcher' => new Alternative( [
4848
new KeywordMatcher( [ 'x', 'y' ] ),

0 commit comments

Comments
 (0)