Skip to content

Commit 234d63f

Browse files
Merge branch '4.0'
* 4.0: [Translation] Process multiple segments within a single unit. Document the container.autowiring.strict_mode option fix custom radios/inputs for checkbox/radio type Another PR template tweak [FrameworkBundle] Add missing XML config for circular_reference_handler. Add tests. fix CS [PropertyInfo] ReflectionExtractor: give a chance to other extractors if no properties Clean calls to http_build_query() [WebProfilerBundle] limit ajax request to 100 and remove the last one Add support for URL-like DSNs for the PdoSessionHandler removed version in @Final @internal for version < 4.0 [HttpFoundation] Fix missing "throw" in JsonResponse Improve the documentation of Suppress warning from sapi_windows_vt100_support on stream other than STDIO removed extra-verbose comments Fixes #26136: Avoid emitting warning in hasParameterOption() Added a README entry to the PR template [HttpFoundation] Add x-zip-compressed to MimeTypeExtensionGuesser. [DI] Add null check for removeChild
2 parents c2f04ad + e0feb60 commit 234d63f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Input/ArgvInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function hasParameterOption($values, $onlyParams = false)
281281
// For long options, test for '--option=' at beginning
282282
// For short options, test for '-o' at beginning
283283
$leading = 0 === strpos($value, '--') ? $value.'=' : $value;
284-
if ($token === $value || 0 === strpos($token, $leading)) {
284+
if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
285285
return true;
286286
}
287287
}
@@ -312,7 +312,7 @@ public function getParameterOption($values, $default = false, $onlyParams = fals
312312
// For long options, test for '--option=' at beginning
313313
// For short options, test for '-o' at beginning
314314
$leading = 0 === strpos($value, '--') ? $value.'=' : $value;
315-
if (0 === strpos($token, $leading)) {
315+
if ('' !== $leading && 0 === strpos($token, $leading)) {
316316
return substr($token, strlen($leading));
317317
}
318318
}

Output/StreamOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function hasColorSupport()
9292
{
9393
if (DIRECTORY_SEPARATOR === '\\') {
9494
return
95-
function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support($this->stream)
95+
function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($this->stream)
9696
|| '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
9797
|| false !== getenv('ANSICON')
9898
|| 'ON' === getenv('ConEmuANSI')

Tests/Input/ArgvInputTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,19 @@ public function testHasParameterOptionEdgeCasesAndLimitations()
370370
$this->assertFalse($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
371371
}
372372

373+
public function testNoWarningOnInvalidParameterOption()
374+
{
375+
$input = new ArgvInput(array('cli.php', '-edev'));
376+
377+
$this->assertTrue($input->hasParameterOption(array('-e', '')));
378+
// No warning thrown
379+
$this->assertFalse($input->hasParameterOption(array('-m', '')));
380+
381+
$this->assertEquals('dev', $input->getParameterOption(array('-e', '')));
382+
// No warning thrown
383+
$this->assertFalse($input->getParameterOption(array('-m', '')));
384+
}
385+
373386
public function testToString()
374387
{
375388
$input = new ArgvInput(array('cli.php', '-f', 'foo'));

0 commit comments

Comments
 (0)