Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5974996
CommandCompletionTester.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
CommandCompletionTester.php
View Options
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\Console\Tester
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Completion\CompletionInput
;
use
Symfony\Component\Console\Completion\CompletionSuggestions
;
/**
* Eases the testing of command completion.
*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
class
CommandCompletionTester
{
public
function
__construct
(
private
Command
$command
,
)
{
}
/**
* Create completion suggestions from input tokens.
*/
public
function
complete
(
array
$input
):
array
{
$currentIndex
=
\count
(
$input
);
if
(
''
===
end
(
$input
))
{
array_pop
(
$input
);
}
array_unshift
(
$input
,
$this
->
command
->
getName
());
$completionInput
=
CompletionInput
::
fromTokens
(
$input
,
$currentIndex
);
$completionInput
->
bind
(
$this
->
command
->
getDefinition
());
$suggestions
=
new
CompletionSuggestions
();
$this
->
command
->
complete
(
$completionInput
,
$suggestions
);
$options
=
[];
foreach
(
$suggestions
->
getOptionSuggestions
()
as
$option
)
{
$options
[]
=
'--'
.
$option
->
getName
();
}
return
array_map
(
'strval'
,
array_merge
(
$options
,
$suggestions
->
getValueSuggestions
()));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 17:53 (9 h, 19 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
28/cd/a9d6b65a671419094710590eac92
Default Alt Text
CommandCompletionTester.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment