Application::hasDefaultCommands()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
1
<?php
2
3
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webmozart\Console\Api\Application;
13
14
use Webmozart\Console\Api\Args\Format\ArgsFormat;
15
use Webmozart\Console\Api\Args\RawArgs;
16
use Webmozart\Console\Api\Command\Command;
17
use Webmozart\Console\Api\Command\CommandCollection;
18
use Webmozart\Console\Api\Command\NoSuchCommandException;
19
use Webmozart\Console\Api\Config\ApplicationConfig;
20
use Webmozart\Console\Api\IO\InputStream;
21
use Webmozart\Console\Api\IO\OutputStream;
22
use Webmozart\Console\Api\Resolver\CannotResolveCommandException;
23
use Webmozart\Console\Api\Resolver\ResolvedCommand;
24
25
/**
26
 * A console application.
27
 *
28
 * @since  1.0
29
 *
30
 * @author Bernhard Schussek <[email protected]>
31
 */
32
interface Application
33
{
34
    /**
35
     * Returns the application configuration.
36
     *
37
     * @return ApplicationConfig The application configuration.
38
     */
39
    public function getConfig();
40
41
    /**
42
     * Returns the global arguments format of the application.
43
     *
44
     * @return ArgsFormat The global arguments format.
45
     */
46
    public function getGlobalArgsFormat();
47
48
    /**
49
     * Returns the command for a given name.
50
     *
51
     * @param string $name The name of the command.
52
     *
53
     * @return Command The command.
54
     *
55
     * @throws NoSuchCommandException If the command is not found.
56
     *
57
     * @see addCommand(), getCommands()
58
     */
59
    public function getCommand($name);
60
61
    /**
62
     * Returns all registered commands.
63
     *
64
     * @return CommandCollection The commands.
65
     *
66
     * @see addCommand(), getCommand()
67
     */
68
    public function getCommands();
69
70
    /**
71
     * Returns whether the application has a command with a given name.
72
     *
73
     * @param string $name The name of the command.
74
     *
75
     * @return bool Returns `true` if the command with the given name exists and
76
     *              `false` otherwise.
77
     *
78
     * @see hasCommands(), getCommand()
79
     */
80
    public function hasCommand($name);
81
82
    /**
83
     * Returns whether the application has any registered commands.
84
     *
85
     * @return bool Returns `true` if the application has any commands and
86
     *              `false` otherwise.
87
     *
88
     * @see hasCommand(), getCommands()
89
     */
90
    public function hasCommands();
91
92
    /**
93
     * Returns the commands that are not anonymous.
94
     *
95
     * @return CommandCollection The named commands.
96
     */
97
    public function getNamedCommands();
98
99
    /**
100
     * Returns whether the application has any commands that are not anonymous.
101
     *
102
     * @return bool Returns `true` if the application has named commands and
103
     *              `false` otherwise.
104
     *
105
     * @see getNamedCommands()
106
     */
107
    public function hasNamedCommands();
108
109
    /**
110
     * Returns the commands that should be executed if no explicit command is
111
     * passed.
112
     *
113
     * @return CommandCollection The default commands.
114
     */
115
    public function getDefaultCommands();
116
117
    /**
118
     * Returns whether the application has any default commands.
119
     *
120
     * @return bool Returns `true` if the application has default commands and
121
     *              `false` otherwise.
122
     *
123
     * @see getDefaultCommands()
124
     */
125
    public function hasDefaultCommands();
126
127
    /**
128
     * Returns the command to execute for the given console arguments.
129
     *
130
     * @param RawArgs $args The console arguments.
131
     *
132
     * @return ResolvedCommand The command to execute.
133
     *
134
     * @throws CannotResolveCommandException If the command cannot be resolved.
135
     */
136
    public function resolveCommand(RawArgs $args);
137
138
    /**
139
     * Executes the command.
140
     *
141
     * @param RawArgs      $args         The console arguments. If not given,
0 ignored issues
show
Documentation introduced by
Should the type for parameter $args not be null|RawArgs?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
142
     *                                   the arguments passed to the PHP process
143
     *                                   are used.
144
     * @param InputStream  $inputStream  The standard input. If not given, the
0 ignored issues
show
Documentation introduced by
Should the type for parameter $inputStream not be null|InputStream?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
145
     *                                   application reads from the standard
146
     *                                   input of the PHP process.
147
     * @param OutputStream $outputStream The standard output. If not given, the
0 ignored issues
show
Documentation introduced by
Should the type for parameter $outputStream not be null|OutputStream?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
148
     *                                   application prints to the standard
149
     *                                   output of the PHP process.
150
     * @param OutputStream $errorStream  The error output. If not given, the
0 ignored issues
show
Documentation introduced by
Should the type for parameter $errorStream not be null|OutputStream?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
151
     *                                   application prints to the error output
152
     *                                   of the PHP process.
153
     *
154
     * @return int The exit status.
155
     */
156
    public function run(RawArgs $args = null, InputStream $inputStream = null, OutputStream $outputStream = null, OutputStream $errorStream = null);
157
}
158