Skip to content

Commit 952d8f6

Browse files
author
Gitea
committed
Update language level to 7.2
1 parent 0dd876b commit 952d8f6

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Code Climate](https://codeclimate.com/github/JBlond/php-cli/badges/gpa.svg)](https://codeclimate.com/github/JBlond/php-cli) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/438eaa51c0464a689229709cfeb583bb)](https://www.codacy.com/app/leet31337/php-cli?utm_source=github.com&utm_medium=referral&utm_content=JBlond/php-cli&utm_campaign=Badge_Grade)
44

55

6-
## php command line / cli scritping classes
6+
## php command line / cli scripting classes
77

88
### Example
99

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=5.6"
17+
"php": ">=7.2"
1818
},
1919
"autoload": {
2020
"psr-4": {

src/jblond/cli/Cli.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ class Cli {
1414
* @param string $default
1515
* @return string
1616
*/
17-
public function input($prompt, $validInputs, $default = ''){
17+
public function input(string $prompt, $validInputs, string $default = ''): string
18+
{
1819
echo $prompt;
19-
$input = trim(fgets(fopen('php://stdin', 'r')));
20+
$input = trim(fgets(fopen('php://stdin', 'rb')));
2021
while(
2122
!isset($input) ||
2223
(
2324
is_array($validInputs) &&
24-
!in_array($input, $validInputs)
25+
!in_array($input, $validInputs, true)
2526
) ||
2627
(
27-
$validInputs == 'is_file' &&
28+
$validInputs === 'is_file' &&
2829
!is_file($input)
2930
)
3031
){
3132
echo $prompt;
32-
$input = trim(fgets(fopen('php://stdin', 'r')));
33+
$input = trim(fgets(fopen('php://stdin', 'rb')));
3334
if(empty($input) && !empty($default)) {
3435
$input = $default;
3536
}
@@ -40,17 +41,19 @@ public function input($prompt, $validInputs, $default = ''){
4041
/**
4142
* @param string $output
4243
*/
43-
public function output($output){
44-
$out = fopen('php://output', 'w');
45-
fputs($out, $output);
44+
public function output(string $output): void
45+
{
46+
$out = fopen('php://output', 'wb');
47+
fwrite($out, $output);
4648
fclose($out);
4749
}
4850

4951
/**
5052
* @param string $string
5153
*/
52-
public function error($string){
53-
$stdError = fopen('php://stderr', 'w');
54+
public function error(string $string): void
55+
{
56+
$stdError = fopen('php://stderr', 'wb');
5457
fwrite($stdError, $string);
5558
fclose($stdError);
5659
}

src/jblond/cli/CliColors.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class CliColors {
5858
public function getColoredString($string, $foregroundColor = null, $backgroundColor = null){
5959
$coloredString = '';
6060

61-
if(!isset($this->foregroundColors["$foregroundColor"])){
61+
if(!isset($this->foregroundColors[(string) $foregroundColor])){
6262
throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s).', $foregroundColor, implode(', ', array_keys($this->foregroundColors))));
6363
}
6464

6565
$coloredString .= "\033[" . $this->foregroundColors[$foregroundColor] . "m";
66-
if(isset($this->backgroundColors["$backgroundColor"])) {
66+
if(isset($this->backgroundColors[(string) $backgroundColor])) {
6767
$coloredString .= "\033[" . $this->backgroundColors[$backgroundColor] . "m";
6868
}
6969
$coloredString .= $string . "\033[0m";
@@ -75,7 +75,8 @@ public function getColoredString($string, $foregroundColor = null, $backgroundCo
7575
*
7676
* @return array
7777
*/
78-
public function getForegroundColors() {
78+
public function getForegroundColors(): array
79+
{
7980
return array_keys($this->foregroundColors);
8081
}
8182

@@ -84,7 +85,8 @@ public function getForegroundColors() {
8485
*
8586
* @return array
8687
*/
87-
public function getBackgroundColors() {
88+
public function getBackgroundColors(): array
89+
{
8890
return array_keys($this->backgroundColors);
8991
}
9092
}

0 commit comments

Comments
 (0)