Skip to content

Commit f253872

Browse files
committed
up: upgrade support php8.4
1 parent db13026 commit f253872

File tree

12 files changed

+35
-28
lines changed

12 files changed

+35
-28
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717
matrix:
18-
php: [8.0, 8.1, 8.2] # 7.3, 7.4,
18+
php: [8.1, 8.2, 8.3, 8.4] # 7.3, 7.4,
1919
# os: [ubuntu-latest] # windows-latest,
2020
# include:
2121
# - os: 'ubuntu-latest'
@@ -61,4 +61,4 @@ jobs:
6161
- name: Test build PHAR
6262
run: |
6363
php -d phar.readonly=0 examples/app phar pack -o=myapp.phar
64-
php myapp.phar -h
64+
php myapp.phar -h

src/AbstractApplication.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ abstract class AbstractApplication implements ApplicationInterface
148148
* @param Input|null $input
149149
* @param Output|null $output
150150
*/
151-
public function __construct(array $config = [], Input $input = null, Output $output = null)
151+
public function __construct(array $config = [], ?Input $input = null, ?Output $output = null)
152152
{
153153
$this->runtimeCheck();
154154
$this->setConfig($config);
@@ -672,7 +672,7 @@ public function getLogoText(): ?string
672672
* @param string $logoTxt
673673
* @param string|null $style
674674
*/
675-
public function setLogo(string $logoTxt, string $style = null): void
675+
public function setLogo(string $logoTxt, ?string $style = null): void
676676
{
677677
$this->config['logoText'] = $logoTxt;
678678

@@ -848,6 +848,10 @@ public function isProfile(): bool
848848
$optKey = GlobalOption::PROFILE;
849849
$default = (bool)$this->getParam($optKey, false);
850850

851+
if (!$this->flags->hasOpt($optKey)) {
852+
return $default;
853+
}
854+
851855
// return $this->input->getBoolOpt($key, $def);
852856
return $this->flags->getOpt($optKey, $default);
853857
}

src/Application.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Application extends AbstractApplication
5252
* @param Input|null $input
5353
* @param Output|null $output
5454
*/
55-
public function __construct(array $config = [], Input $input = null, Output $output = null)
55+
public function __construct(array $config = [], ?Input $input = null, ?Output $output = null)
5656
{
5757
Console::setApp($this);
5858

@@ -294,7 +294,7 @@ protected function createController(array $info): Controller
294294
*
295295
* @return $this
296296
*/
297-
public function controller(string $name, ControllerInterface|string $class = null, array $config = []): static
297+
public function controller(string $name, ControllerInterface|string|null $class = null, array $config = []): static
298298
{
299299
$this->logf(Console::VERB_CRAZY, 'register group controller: %s', $name);
300300
$this->router->addGroup($name, $class, $config);
@@ -312,7 +312,7 @@ public function controller(string $name, ControllerInterface|string $class = nul
312312
* @return static
313313
* @see controller()
314314
*/
315-
public function addGroup(string $name, ControllerInterface|string $class = null, array $config = []): static
315+
public function addGroup(string $name, ControllerInterface|string|null $class = null, array $config = []): static
316316
{
317317
return $this->controller($name, $class, $config);
318318
}
@@ -325,7 +325,7 @@ public function addGroup(string $name, ControllerInterface|string $class = null,
325325
* @return $this
326326
* @see controller()
327327
*/
328-
public function addController(string $name, ControllerInterface|string $class = null, array $config = []): static
328+
public function addController(string $name, ControllerInterface|string|null $class = null, array $config = []): static
329329
{
330330
return $this->controller($name, $class, $config);
331331
}
@@ -353,7 +353,7 @@ public function addControllers(array $controllers): void
353353
*
354354
* @return Application
355355
*/
356-
public function command(string $name, string|Closure|CommandInterface $handler = null, array $config = []): static
356+
public function command(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): static
357357
{
358358
$this->logf(Console::VERB_CRAZY, 'register alone command: %s', $name);
359359
$this->router->addCommand($name, $handler, $config);
@@ -371,7 +371,7 @@ public function command(string $name, string|Closure|CommandInterface $handler =
371371
* @return Application
372372
* @see command()
373373
*/
374-
public function addCommand(string $name, string|Closure|CommandInterface $handler = null, array $config = []): static
374+
public function addCommand(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): static
375375
{
376376
return $this->command($name, $handler, $config);
377377
}

src/Component/Router.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Router implements RouterInterface
115115
* @return static
116116
* @throws InvalidArgumentException
117117
*/
118-
public function addGroup(string $name, ControllerInterface|string $class = null, array $config = []): static
118+
public function addGroup(string $name, ControllerInterface|string|null $class = null, array $config = []): static
119119
{
120120
/**
121121
* @var Controller $class name is an controller class
@@ -179,7 +179,7 @@ public function addGroup(string $name, ControllerInterface|string $class = null,
179179
*
180180
* @return static
181181
*/
182-
public function addCommand(string $name, string|Closure|CommandInterface $handler = null, array $config = []): static
182+
public function addCommand(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): static
183183
{
184184
if (!$handler && class_exists($name)) {
185185
$handler = $name;

src/Console.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public static function getOutput(): Output
117117
*/
118118
public static function newApp(
119119
array $config = [],
120-
Input $input = null,
121-
Output $output = null
120+
?Input $input = null,
121+
?Output $output = null
122122
): Application {
123123
return new Application($config, $input, $output);
124124
}

src/Contract/ApplicationInterface.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function stop(int $code = 0): void;
6565
* @return static
6666
* @throws InvalidArgumentException
6767
*/
68-
public function controller(string $name, ControllerInterface|string $class = null, array $config = []): static;
68+
public function controller(string $name, ControllerInterface|string|null $class = null, array $config = []): ApplicationInterface;
6969

7070
/**
7171
* Register a app independent console command
@@ -77,8 +77,11 @@ public function controller(string $name, ControllerInterface|string $class = nul
7777
* @return mixed
7878
* @throws InvalidArgumentException
7979
*/
80-
public function command(string $name, string|Closure|CommandInterface $handler = null, array $config = []): static;
80+
public function command(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): ApplicationInterface;
8181

82+
/**
83+
* @return void
84+
*/
8285
public function showCommandList();
8386

8487
/**

src/Contract/RouterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface RouterInterface
3535
*
3636
* @return static
3737
*/
38-
public function addGroup(string $name, ControllerInterface|string $class = null, array $config = []): static;
38+
public function addGroup(string $name, ControllerInterface|string|null $class = null, array $config = []): static;
3939

4040
/**
4141
* Register a app independent console command
@@ -46,7 +46,7 @@ public function addGroup(string $name, ControllerInterface|string $class = null,
4646
*
4747
* @return static
4848
*/
49-
public function addCommand(string $name, string|Closure|CommandInterface $handler = null, array $config = []): static;
49+
public function addCommand(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): static;
5050

5151
/**
5252
* ```php

src/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ protected function beforeRenderCommandHelp(array &$help): void
520520
*
521521
* @return ?Generator
522522
*/
523-
protected function getAllCommandMethods(ReflectionClass $ref = null, bool $onlyName = false): ?Generator
523+
protected function getAllCommandMethods(?ReflectionClass $ref = null, bool $onlyName = false): ?Generator
524524
{
525525
$ref = $ref ?: new ReflectionObject($this);
526526

src/Decorate/SubCommandsWareTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function createSubCommand(array $subInfo): Command
157157
* @param class-string|CommandInterface|null $handler
158158
* @param array $config
159159
*/
160-
public function addSub(string $name, string|CommandInterface $handler = null, array $config = []): void
160+
public function addSub(string $name, string|CommandInterface|null $handler = null, array $config = []): void
161161
{
162162
if (!$handler && class_exists($name)) {
163163
/** @var Command $name name is an command class */

src/Decorate/UserInteractAwareTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait UserInteractAwareTrait
4141
* @return string
4242
* @see Interact::choice()
4343
*/
44-
public function select(string $description, array|string $options, int|string $default = null, bool $allowExit = true): string
44+
public function select(string $description, array|string $options, int|string|null $default = null, bool $allowExit = true): string
4545
{
4646
return $this->choice($description, $options, $default, $allowExit);
4747
}
@@ -54,7 +54,7 @@ public function select(string $description, array|string $options, int|string $d
5454
*
5555
* @return string
5656
*/
57-
public function choice(string $description, array|string $options, int|string $default = null, bool $allowExit = true): string
57+
public function choice(string $description, array|string $options, int|string|null $default = null, bool $allowExit = true): string
5858
{
5959
return Interact::choice($description, $options, $default, $allowExit);
6060
}
@@ -88,7 +88,7 @@ public function unConfirm(string $question, bool $default = true): bool
8888
*
8989
* @return string|null
9090
*/
91-
public function ask(string $question, string $default = '', Closure $validator = null): ?string
91+
public function ask(string $question, string $default = '', ?Closure $validator = null): ?string
9292
{
9393
return $this->question($question, $default, $validator);
9494
}
@@ -100,7 +100,7 @@ public function ask(string $question, string $default = '', Closure $validator =
100100
*
101101
* @return string|null
102102
*/
103-
public function question(string $question, string $default = '', Closure $validator = null): ?string
103+
public function question(string $question, string $default = '', ?Closure $validator = null): ?string
104104
{
105105
return Interact::question($question, $default, $validator);
106106
}
@@ -114,7 +114,7 @@ public function question(string $question, string $default = '', Closure $valida
114114
* @return string|null
115115
* @see Interact::limitedAsk()
116116
*/
117-
public function limitedAsk(string $question, string $default = '', Closure $validator = null, int $times = 3): ?string
117+
public function limitedAsk(string $question, string $default = '', ?Closure $validator = null, int $times = 3): ?string
118118
{
119119
return Interact::limitedAsk($question, $default, $validator, $times);
120120
}
@@ -123,7 +123,7 @@ public function limitedAsk(string $question, string $default = '', Closure $vali
123123
* @param string $method
124124
* @param array $args
125125
*
126-
* @return int
126+
* @return mixed
127127
* @throws LogicException
128128
*/
129129
public function __call(string $method, array $args = [])

0 commit comments

Comments
 (0)