Skip to content

Commit 8a0bcfb

Browse files
committed
Use strpos in place of substr
1 parent 9864d95 commit 8a0bcfb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,8 @@ public function ask(OutputInterface $output, $question, $default = null, array $
162162
$ofs = 0;
163163

164164
foreach ($autocomplete as $value) {
165-
// Get a substring of the current autocomplete item based on number of chars typed (e.g. AcmeDemoBundle = Acme)
166-
$matchTest = substr($value, 0, $i);
167-
168-
if ($ret === $matchTest && $i !== strlen($value)) {
165+
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
166+
if (0 === strpos($value, $ret) && $i !== strlen($value)) {
169167
$matches[$numMatches++] = $value;
170168
}
171169
}

0 commit comments

Comments
 (0)