Skip to content

Commit 16ec5d1

Browse files
committed
minor #19096 Use str_starts_with() in OptionsResolver examples (BenMorel)
This PR was merged into the 6.3 branch. Discussion ---------- Use str_starts_with() in OptionsResolver examples Not targeting `5.4` as these examples are for PHP 8. Commits ------- 93ab432 Use str_starts_with() in OptionsResolver examples
2 parents c7493e0 + 93ab432 commit 16ec5d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

components/options_resolver.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ option. You can configure a normalizer by calling
413413
// ...
414414

415415
$resolver->setNormalizer('host', function (Options $options, string $value): string {
416-
if ('http://' !== substr($value, 0, 7)) {
416+
if (!str_starts_with($value, 'http://')) {
417417
$value = 'http://'.$value;
418418
}
419419

@@ -434,7 +434,7 @@ if you need to use other options during normalization::
434434
{
435435
// ...
436436
$resolver->setNormalizer('host', function (Options $options, string $value): string {
437-
if ('http://' !== substr($value, 0, 7) && 'https://' !== substr($value, 0, 8)) {
437+
if (!str_starts_with($value, 'http://') && !str_starts_with($value, 'https://')) {
438438
if ('ssl' === $options['encryption']) {
439439
$value = 'https://'.$value;
440440
} else {

0 commit comments

Comments
 (0)