Skip to content

Commit a73f691

Browse files
committed
Leverage PHP 8.0 string functions
1 parent d2f3766 commit a73f691

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ function create_field_path_type_map(array $typeMap, string $fieldPath): array
497497
/* Special case if we want to convert an array, in which case we need to
498498
* ensure that the field containing the array is exposed as an array,
499499
* instead of the type given in the type map's array key. */
500-
if (substr($fieldPath, -2, 2) === '.$') {
500+
if (str_ends_with($fieldPath, '.$')) {
501501
$typeMap['fieldPaths'][substr($fieldPath, 0, -2)] = 'array';
502502
}
503503

tests/UnifiedSpecTests/Constraint/Matches.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private static function getOperatorName(BSONDocument $document): string
373373
{
374374
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
375375
foreach ($document as $key => $_) {
376-
if (strpos((string) $key, '$$') === 0) {
376+
if (str_starts_with((string) $key, '$$')) {
377377
return $key;
378378
}
379379
}
@@ -394,7 +394,7 @@ private static function isOperator(BSONDocument $document): bool
394394

395395
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
396396
foreach ($document as $key => $_) {
397-
return strpos((string) $key, '$$') === 0;
397+
return str_starts_with((string) $key, '$$');
398398
}
399399

400400
throw new LogicException('should not reach this point');

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private function createContext(): Context
528528
// We assume the internal client URI has multiple mongos hosts
529529
$multiMongosUri = $this->internalClientUri;
530530

531-
if (strpos($multiMongosUri, 'mongodb+srv://') === 0) {
531+
if (str_starts_with($multiMongosUri, 'mongodb+srv://')) {
532532
/* TODO: If an SRV URI is provided, we can consider connecting and
533533
* checking the topology for multiple mongoses and then selecting a
534534
* single mongos to reconstruct a single mongos URI; however, that

0 commit comments

Comments
 (0)