Skip to content

Commit c2b9d9e

Browse files
committed
up: fix some code syntax error on php 8.4
1 parent f253872 commit c2b9d9e

File tree

12 files changed

+21
-20
lines changed

12 files changed

+21
-20
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Run unit tests
5656
run: |
57-
phpunit -v --debug
57+
phpunit --debug
5858
php examples/alone -h
5959
php examples/app --help
6060

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PHP Console
22

33
[![License](https://img.shields.io/packagist/l/inhere/console.svg?style=flat-square)](LICENSE)
4-
[![Php Version](https://img.shields.io/badge/php-%3E=8.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/inhere/console)
4+
[![Php Version](https://img.shields.io/packagist/php-v/inhere/console?maxAge=2592000)](https://packagist.org/packages/inhere/console)
55
[![Latest Stable Version](http://img.shields.io/packagist/v/inhere/console.svg)](https://packagist.org/packages/inhere/console)
66
[![Github Actions Status](https://github.com/inhere/php-console/workflows/Unit-tests/badge.svg)](https://github.com/inhere/php-console/actions)
77
[![zh-CN readme](https://img.shields.io/badge/Readme-中文-brightgreen.svg?maxAge=2592000)](README.md)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PHP Console
22

33
[![License](https://img.shields.io/packagist/l/inhere/console.svg?style=flat-square)](LICENSE)
4-
[![Php Version](https://img.shields.io/badge/php-%3E=8.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/inhere/console)
4+
[![Php Version](https://img.shields.io/packagist/php-v/inhere/console?maxAge=2592000)](https://packagist.org/packages/inhere/console)
55
[![Latest Stable Version](http://img.shields.io/packagist/v/inhere/console.svg)](https://packagist.org/packages/inhere/console)
66
[![Github Actions Status](https://github.com/inhere/php-console/workflows/Unit-tests/badge.svg)](https://github.com/inhere/php-console/actions)
77
[![English](https://img.shields.io/badge/Readme-English-brightgreen.svg?maxAge=2592000)](README.en.md)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">8.0.1",
25+
"php": ">8.1",
2626
"toolkit/cli-utils": "~2.0",
2727
"toolkit/fsutil": "~2.0",
2828
"toolkit/pflag": "~2.0",

src/Component/ErrorHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function handle(Throwable $e): void
8888
$file = $e->getFile();
8989
$prev = $e->getPrevious();
9090

91+
// var_dump($e);
9192
$snippet = Highlighter::create()->snippet(file_get_contents($file), $line, 3, 3);
9293
$message = sprintf(
9394
$tpl, // $e->getCode(),

src/Component/Interact/LimitedAsk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class LimitedAsk extends InteractiveHandle
6363
public static function ask(
6464
string $question,
6565
string $default = '',
66-
Closure $validator = null,
66+
?Closure $validator = null,
6767
int $times = 3
6868
): string {
6969
if (!$question = trim($question)) {

src/Component/Interact/Question.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Question extends InteractiveHandle
6262
* echo "Your input: $answer";
6363
* ```
6464
*/
65-
public static function ask(string $question, string $default = '', Closure $validator = null): string
65+
public static function ask(string $question, string $default = '', ?Closure $validator = null): string
6666
{
6767
if (!$question = trim($question)) {
6868
Show::error('Please provide a question text!', 1);

src/Component/Symbol/ArtFont.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function showInternal(string $name, array $opts = []): int
109109
*
110110
* @return int
111111
*/
112-
public function showItalic(string $name, string $group = null, array $opts = []): int
112+
public function showItalic(string $name, ?string $group = null, array $opts = []): int
113113
{
114114
$opts['type'] = 'italic';
115115

@@ -129,7 +129,7 @@ public function showItalic(string $name, string $group = null, array $opts = [])
129129
*
130130
* @return int
131131
*/
132-
public function show(string $name, string $group = null, array $opts = []): int
132+
public function show(string $name, ?string $group = null, array $opts = []): int
133133
{
134134
$opts = array_merge([
135135
'type' => '',
@@ -175,7 +175,7 @@ public function show(string $name, string $group = null, array $opts = []): int
175175
*
176176
* @return string
177177
*/
178-
public function font(string $name, string $group = null): string
178+
public function font(string $name, ?string $group = null): string
179179
{
180180
return '';
181181
}
@@ -227,7 +227,7 @@ public function setGroup(string $group, string $path): self
227227
*
228228
* @return $this
229229
*/
230-
public function addFont(string $name, string $file, string $group = null): self
230+
public function addFont(string $name, string $file, ?string $group = null): self
231231
{
232232
$group = $group ?: self::DEFAULT_GROUP;
233233

src/Decorate/RuntimeProfileTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function profile($name, array $context = [], string $category = 'a
8181
*
8282
* @return bool|array
8383
*/
84-
public static function profileEnd(string $msg = null, array $context = []): bool|array
84+
public static function profileEnd(?string $msg = null, array $context = []): bool|array
8585
{
8686
if (!$latestKey = array_pop(self::$keyQueue)) {
8787
return false;
@@ -114,7 +114,7 @@ public static function profileEnd(string $msg = null, array $context = []): bool
114114
*
115115
* @return array
116116
*/
117-
public static function getProfileData(string $name = null, string $category = 'application'): array
117+
public static function getProfileData(?string $name = null, string $category = 'application'): array
118118
{
119119
if ($name) {
120120
return self::$profiles[$category][$name] ?? [];

src/Util/Interact.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static function unConfirm(string $question, bool $default = true): bool
180180
*
181181
* @return bool
182182
*/
183-
public static function answerIsYes(bool $default = null): bool
183+
public static function answerIsYes(?bool $default = null): bool
184184
{
185185
$mark = ' [yes|no]: ';
186186

@@ -216,7 +216,7 @@ public static function answerIsYes(bool $default = null): bool
216216
*
217217
* @return string|null
218218
*/
219-
public static function ask(string $question, string $default = '', Closure $validator = null): ?string
219+
public static function ask(string $question, string $default = '', ?Closure $validator = null): ?string
220220
{
221221
return self::question($question, $default, $validator);
222222
}
@@ -231,7 +231,7 @@ public static function ask(string $question, string $default = '', Closure $vali
231231
* @return string
232232
* @see Question::ask()
233233
*/
234-
public static function question(string $question, string $default = '', Closure $validator = null): string
234+
public static function question(string $question, string $default = '', ?Closure $validator = null): string
235235
{
236236
return Question::ask($question, $default, $validator);
237237
}
@@ -250,7 +250,7 @@ public static function question(string $question, string $default = '', Closure
250250
public static function limitedAsk(
251251
string $question,
252252
string $default = '',
253-
Closure $validator = null,
253+
?Closure $validator = null,
254254
int $times = 3
255255
): string {
256256
return LimitedAsk::ask($question, $default, $validator, $times);

0 commit comments

Comments
 (0)