MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
StringInput.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
namespace
Symfony\Component\Console\Input
;
4
5
/*
6
* This file is part of the Symfony framework.
7
*
8
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
9
*
10
* This source file is subject to the MIT license that is bundled
11
* with this source code in the file LICENSE.
12
*/
13
23
class
StringInput
extends
ArgvInput
24
{
25
const
REGEX_STRING
=
'([^ ]+?)(?: |(?<!\\\\)"|(?<!\\\\)\'|$)'
;
26
const
REGEX_QUOTED_STRING
=
'(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')'
;
27
34
public
function
__construct
($input,
InputDefinition
$definition
=
null
)
35
{
36
parent::__construct(array(),
$definition
);
37
38
$this->tokens = $this->
tokenize
($input);
39
}
40
44
protected
function
tokenize
($input)
45
{
46
$input = preg_replace(
'/(\r\n|\r|\n|\t)/'
,
' '
, $input);
47
48
$tokens
= array();
49
$length = strlen($input);
50
$cursor = 0;
51
while
($cursor < $length) {
52
if
(preg_match(
'/\s+/A'
, $input, $match,
null
, $cursor)) {
53
} elseif (preg_match(
'/([^="\' ]+?)(=?)('
.self::REGEX_QUOTED_STRING.
'+)/A'
, $input, $match,
null
, $cursor)) {
54
$tokens
[] = $match[1].$match[2].stripcslashes(str_replace(array(
'"\''
,
'\'
"', '\'\'', '"
"'), '', substr($match[3], 1, strlen($match[3]) - 2)));
55
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
56
$tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2));
57
} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
58
$tokens[] = stripcslashes($match[1]);
59
} else {
60
// should never happen
61
// @codeCoverageIgnoreStart
62
throw new \InvalidArgumentException(sprintf('Unable to parse input near "
... %s ...
"', substr($input, $cursor, 10)));
63
// @codeCoverageIgnoreEnd
64
}
65
66
$cursor += strlen($match[0]);
67
}
68
69
return $tokens;
70
}
71
}
Symfony\Component\Console\Input\ArgvInput
Definição
ArgvInput.php:40
Symfony\Component\Console\Input\ArgvInput\$tokens
$tokens
Definição
ArgvInput.php:41
Symfony\Component\Console\Input\InputDefinition
Definição
InputDefinition.php:27
Symfony\Component\Console\Input\Input\$definition
$definition
Definição
Input.php:27
Symfony\Component\Console\Input\StringInput
Definição
StringInput.php:24
Symfony\Component\Console\Input\StringInput\__construct
__construct($input, InputDefinition $definition=null)
Definição
StringInput.php:34
Symfony\Component\Console\Input\StringInput\tokenize
tokenize($input)
Definição
StringInput.php:44
Symfony\Component\Console\Input\StringInput\REGEX_QUOTED_STRING
const REGEX_QUOTED_STRING
Definição
StringInput.php:26
Symfony\Component\Console\Input\StringInput\REGEX_STRING
const REGEX_STRING
Definição
StringInput.php:25
Symfony\Component\Console\Input
Definição
ArgvInput.php:3
classes
extensions
doctrine-dbal
Doctrine
Symfony
Component
Console
Input
StringInput.php
Gerado por
1.10.0