Skip to content

Commit 8ae5b11

Browse files
committed
Level 2
1 parent 49635f4 commit 8ae5b11

8 files changed

Lines changed: 29 additions & 29 deletions

File tree

lib/cli/Arguments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function getInvalidArguments() {
287287
public function getFlag($flag) {
288288
if ($flag instanceOf Argument) {
289289
$obj = $flag;
290-
$flag = $flag->value;
290+
$flag = $flag->value();
291291
}
292292

293293
if (isset($this->_flags[$flag])) {
@@ -350,7 +350,7 @@ public function isStackable($flag) {
350350
public function getOption($option) {
351351
if ($option instanceOf Argument) {
352352
$obj = $option;
353-
$option = $option->value;
353+
$option = $option->value();
354354
}
355355

356356
if (isset($this->_options[$option])) {
@@ -412,7 +412,7 @@ public function parse() {
412412
continue;
413413
}
414414

415-
array_push($this->_invalid, $argument->raw);
415+
array_push($this->_invalid, $argument->raw());
416416
}
417417

418418
if ($this->_strict && !empty($this->_invalid)) {

lib/cli/Streams.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ static public function isTty() {
2727
* then each key in the array will be the placeholder name. Placeholders are of the
2828
* format {:key}.
2929
*
30-
* @param string $msg The message to render.
31-
* @param mixed ... Either scalar arguments or a single array argument.
30+
* @param string $msg The message to render.
31+
* @param mixed ...$args Either scalar arguments or a single array argument.
3232
* @return string The rendered string.
3333
*/
34-
public static function render( $msg ) {
34+
public static function render( $msg, ...$args ) {
3535
$args = func_get_args();
3636

3737
// No string replacement is needed
@@ -66,23 +66,23 @@ public static function render( $msg ) {
6666
* through `sprintf` before output.
6767
*
6868
* @param string $msg The message to output in `printf` format.
69-
* @param mixed ... Either scalar arguments or a single array argument.
69+
* @param mixed ...$args Either scalar arguments or a single array argument.
7070
* @return void
7171
* @see \cli\render()
7272
*/
73-
public static function out( $msg ) {
73+
public static function out( $msg, ...$args ) {
7474
fwrite( static::$out, self::_call( 'render', func_get_args() ) );
7575
}
7676

7777
/**
7878
* Pads `$msg` to the width of the shell before passing to `cli\out`.
7979
*
8080
* @param string $msg The message to pad and pass on.
81-
* @param mixed ... Either scalar arguments or a single array argument.
81+
* @param mixed ...$args Either scalar arguments or a single array argument.
8282
* @return void
8383
* @see cli\out()
8484
*/
85-
public static function out_padded( $msg ) {
85+
public static function out_padded( $msg, ...$args ) {
8686
$msg = self::_call( 'render', func_get_args() );
8787
self::out( str_pad( $msg, \cli\Shell::columns() ) );
8888
}
@@ -107,10 +107,10 @@ public static function line( $msg = '' ) {
107107
*
108108
* @param string $msg The message to output in `printf` format. With no string,
109109
* a newline is printed.
110-
* @param mixed ... Either scalar arguments or a single array argument.
110+
* @param mixed ...$args Either scalar arguments or a single array argument.
111111
* @return void
112112
*/
113-
public static function err( $msg = '' ) {
113+
public static function err( $msg = '', ...$args ) {
114114
// func_get_args is empty if no args are passed even with the default above.
115115
$args = array_merge( func_get_args(), array( '' ) );
116116
$args[0] .= "\n";

lib/cli/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function countRows() {
311311
/**
312312
* Set whether items in an Ascii table are pre-colorized.
313313
*
314-
* @param bool|array $precolorized A boolean to set all columns in the table as pre-colorized, or an array of booleans keyed by column index (number) to set individual columns as pre-colorized.
314+
* @param bool|array $pre_colorized A boolean to set all columns in the table as pre-colorized, or an array of booleans keyed by column index (number) to set individual columns as pre-colorized.
315315
* @see cli\Ascii::setPreColorized()
316316
*/
317317
public function setAsciiPreColorized( $pre_colorized ) {

lib/cli/arguments/Argument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Argument extends Memoize {
2525
/**
2626
* The canonical name of this argument, used for aliasing.
2727
*
28-
* @param string
28+
* @var string
2929
*/
3030
public $key;
3131

lib/cli/arguments/Lexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(array $items) {
3232
/**
3333
* The current token.
3434
*
35-
* @return string
35+
* @return Argument
3636
*/
3737
#[\ReturnTypeWillChange]
3838
public function current() {

lib/cli/cli.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
* then each key in the array will be the placeholder name. Placeholders are of the
2020
* format {:key}.
2121
*
22-
* @param string $msg The message to render.
23-
* @param mixed ... Either scalar arguments or a single array argument.
22+
* @param string $msg The message to render.
23+
* @param mixed ...$args Either scalar arguments or a single array argument.
2424
* @return string The rendered string.
2525
*/
26-
function render( $msg ) {
26+
function render( $msg, ...$args ) {
2727
return Streams::_call( 'render', func_get_args() );
2828
}
2929

@@ -32,23 +32,23 @@ function render( $msg ) {
3232
* through `sprintf` before output.
3333
*
3434
* @param string $msg The message to output in `printf` format.
35-
* @param mixed ... Either scalar arguments or a single array argument.
35+
* @param mixed ...$args Either scalar arguments or a single array argument.
3636
* @return void
3737
* @see \cli\render()
3838
*/
39-
function out( $msg ) {
39+
function out( $msg, ...$args ) {
4040
Streams::_call( 'out', func_get_args() );
4141
}
4242

4343
/**
4444
* Pads `$msg` to the width of the shell before passing to `cli\out`.
4545
*
4646
* @param string $msg The message to pad and pass on.
47-
* @param mixed ... Either scalar arguments or a single array argument.
47+
* @param mixed ...$args Either scalar arguments or a single array argument.
4848
* @return void
4949
* @see cli\out()
5050
*/
51-
function out_padded( $msg ) {
51+
function out_padded( $msg, ...$args ) {
5252
Streams::_call( 'out_padded', func_get_args() );
5353
}
5454

@@ -68,10 +68,10 @@ function line( $msg = '' ) {
6868
*
6969
* @param string $msg The message to output in `printf` format. With no string,
7070
* a newline is printed.
71-
* @param mixed ... Either scalar arguments or a single array argument.
71+
* @param mixed ...$args Either scalar arguments or a single array argument.
7272
* @return void
7373
*/
74-
function err( $msg = '' ) {
74+
function err( $msg = '', ...$args ) {
7575
Streams::_call( 'err', func_get_args() );
7676
}
7777

@@ -162,7 +162,7 @@ function menu( $items, $default = null, $title = 'Choose an item' ) {
162162
*/
163163
function safe_strlen( $str, $encoding = false ) {
164164
// Allow for selective testings - "1" bit set tests grapheme_strlen(), "2" preg_match_all( '/\X/u' ), "4" mb_strlen(), "other" strlen().
165-
$test_safe_strlen = getenv( 'PHP_CLI_TOOLS_TEST_SAFE_STRLEN' );
165+
$test_safe_strlen = (int) getenv( 'PHP_CLI_TOOLS_TEST_SAFE_STRLEN' );
166166

167167
// Assume UTF-8 if no encoding given - `grapheme_strlen()` will return null if given non-UTF-8 string.
168168
if ( ( ! $encoding || 'UTF-8' === $encoding ) && can_use_icu() && null !== ( $length = grapheme_strlen( $str ) ) ) {
@@ -225,7 +225,7 @@ function safe_substr( $str, $start, $length = false, $is_width = false, $encodin
225225
}
226226

227227
// Allow for selective testings - "1" bit set tests grapheme_substr(), "2" preg_split( '/\X/' ), "4" mb_substr(), "8" substr().
228-
$test_safe_substr = getenv( 'PHP_CLI_TOOLS_TEST_SAFE_SUBSTR' );
228+
$test_safe_substr = (int) getenv( 'PHP_CLI_TOOLS_TEST_SAFE_SUBSTR' );
229229

230230
// Assume UTF-8 if no encoding given - `grapheme_substr()` will return false (not null like `grapheme_strlen()`) if given non-UTF-8 string.
231231
if ( ( ! $encoding || 'UTF-8' === $encoding ) && can_use_icu() && false !== ( $try = grapheme_substr( $str, $start, $length ) ) ) {
@@ -325,7 +325,7 @@ function strwidth( $string, $encoding = false ) {
325325
list( $eaw_regex, $m_regex ) = get_unicode_regexs();
326326

327327
// Allow for selective testings - "1" bit set tests grapheme_strlen(), "2" preg_match_all( '/\X/u' ), "4" mb_strwidth(), "other" safe_strlen().
328-
$test_strwidth = getenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' );
328+
$test_strwidth = (int) getenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' );
329329

330330
// Assume UTF-8 if no encoding given - `grapheme_strlen()` will return null if given non-UTF-8 string.
331331
if ( ( ! $encoding || 'UTF-8' === $encoding ) && can_use_icu() && null !== ( $width = grapheme_strlen( $string ) ) ) {

lib/cli/table/Ascii.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function padColumn($content, $column) {
246246
/**
247247
* Set whether items are pre-colorized.
248248
*
249-
* @param bool|array $colorized A boolean to set all columns in the table as pre-colorized, or an array of booleans keyed by column index (number) to set individual columns as pre-colorized.
249+
* @param bool|array $pre_colorized A boolean to set all columns in the table as pre-colorized, or an array of booleans keyed by column index (number) to set individual columns as pre-colorized.
250250
*/
251251
public function setPreColorized( $pre_colorized ) {
252252
$this->_pre_colorized = $pre_colorized;

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 1
2+
level: 2
33
paths:
44
- lib
55
scanDirectories:

0 commit comments

Comments
 (0)