Skip to content

Commit 14524a2

Browse files
committed
fix: update linter script
1 parent f24fee0 commit 14524a2

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ before_script: composer install --ignore-platform-reqs
1212

1313
script:
1414
- vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt
15-
- vendor/bin/phpcs -p
15+
- vendor/bin/psalm --show-info=true

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"license": "MIT",
77

88
"scripts": {
9-
"test": "vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt",
10-
"lint": "vendor/bin/phpcs",
11-
"format": "vendor/bin/phpcbf"
9+
"test": ".vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt",
10+
"lint": "./vendor/bin/pint --test",
11+
"format": "./vendor/bin/pint"
1212
},
1313
"autoload": {
1414
"psr-4": {"Utopia\\CLI\\": "src/CLI"}

src/CLI/CLI.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function getResource(string $name, bool $fresh = false): mixed
165165
{
166166
if (! \array_key_exists($name, $this->resources) || $fresh || self::$resourcesCallbacks[$name]['reset']) {
167167
if (! \array_key_exists($name, self::$resourcesCallbacks)) {
168-
throw new Exception('Failed to find resource: "' . $name . '"');
168+
throw new Exception('Failed to find resource: "'.$name.'"');
169169
}
170170

171171
$this->resources[$name] = \call_user_func_array(
@@ -382,11 +382,11 @@ protected function validate(string $key, array $param, $value): void
382382
}
383383

384384
if (! $validator->isValid($value)) {
385-
throw new Exception('Invalid ' . $key . ': ' . $validator->getDescription(), 400);
385+
throw new Exception('Invalid '.$key.': '.$validator->getDescription(), 400);
386386
}
387387
} else {
388388
if (! $param['optional']) {
389-
throw new Exception('Param "' . $key . '" is not optional.', 400);
389+
throw new Exception('Param "'.$key.'" is not optional.', 400);
390390
}
391391
}
392392
}

src/CLI/Console.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function title(string $title): bool
2727
*/
2828
public static function log(string $message): int|false
2929
{
30-
return \fwrite(STDOUT, $message . "\n");
30+
return \fwrite(STDOUT, $message."\n");
3131
}
3232

3333
/**
@@ -40,7 +40,7 @@ public static function log(string $message): int|false
4040
*/
4141
public static function success(string $message): int|false
4242
{
43-
return \fwrite(STDOUT, "\033[32m" . $message . "\033[0m\n");
43+
return \fwrite(STDOUT, "\033[32m".$message."\033[0m\n");
4444
}
4545

4646
/**
@@ -53,7 +53,7 @@ public static function success(string $message): int|false
5353
*/
5454
public static function error(string $message): int|false
5555
{
56-
return \fwrite(STDERR, "\033[31m" . $message . "\033[0m\n");
56+
return \fwrite(STDERR, "\033[31m".$message."\033[0m\n");
5757
}
5858

5959
/**
@@ -66,7 +66,7 @@ public static function error(string $message): int|false
6666
*/
6767
public static function info(string $message): int|false
6868
{
69-
return \fwrite(STDOUT, "\033[34m" . $message . "\033[0m\n");
69+
return \fwrite(STDOUT, "\033[34m".$message."\033[0m\n");
7070
}
7171

7272
/**
@@ -79,7 +79,7 @@ public static function info(string $message): int|false
7979
*/
8080
public static function warning(string $message): int|false
8181
{
82-
return \fwrite(STDERR, "\033[1;33m" . $message . "\033[0m\n");
82+
return \fwrite(STDERR, "\033[1;33m".$message."\033[0m\n");
8383
}
8484

8585
/**
@@ -133,7 +133,7 @@ public static function exit(int $status = 0): void
133133
*/
134134
public static function execute(string $cmd, string $stdin, string &$stdout, string &$stderr, int $timeout = -1): int
135135
{
136-
$cmd = '( ' . $cmd . ' ) 3>/dev/null ; echo $? >&3';
136+
$cmd = '( '.$cmd.' ) 3>/dev/null ; echo $? >&3';
137137

138138
$pipes = [];
139139
$process = \proc_open(

tests/CLI/CLITest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testResources()
2424
return rand();
2525
});
2626
CLI::setResource('first', function ($second) {
27-
return 'first-' . $second;
27+
return 'first-'.$second;
2828
}, ['second']);
2929
CLI::setResource('second', function () {
3030
return 'second';
@@ -93,7 +93,7 @@ public function testAppArray()
9393
->param('email', null, new Text(0), 'Valid email address')
9494
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
9595
->action(function ($email, $list) {
96-
echo $email . '-' . implode('-', $list);
96+
echo $email.'-'.implode('-', $list);
9797
});
9898

9999
$cli->run();
@@ -112,15 +112,15 @@ public function testGetTasks()
112112
->param('email', null, new Text(0), 'Valid email address')
113113
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
114114
->action(function ($email, $list) {
115-
echo $email . '-' . implode('-', $list);
115+
echo $email.'-'.implode('-', $list);
116116
});
117117

118118
$cli
119119
->task('build2')
120120
->param('email', null, new Text(0), 'Valid email address')
121121
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
122122
->action(function ($email, $list) {
123-
echo $email . '-' . implode('-', $list);
123+
echo $email.'-'.implode('-', $list);
124124
});
125125

126126
$this->assertCount(2, $cli->getTasks());
@@ -135,15 +135,15 @@ public function testGetArgs()
135135
->param('email', null, new Text(0), 'Valid email address')
136136
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
137137
->action(function ($email, $list) {
138-
echo $email . '-' . implode('-', $list);
138+
echo $email.'-'.implode('-', $list);
139139
});
140140

141141
$cli
142142
->task('build2')
143143
->param('email', null, new Text(0), 'Valid email address')
144144
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
145145
->action(function ($email, $list) {
146-
echo $email . '-' . implode('-', $list);
146+
echo $email.'-'.implode('-', $list);
147147
});
148148

149149
$this->assertCount(2, $cli->getArgs());
@@ -173,7 +173,7 @@ public function testHook()
173173
->param('email', null, new Text(0), 'Valid email address')
174174
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
175175
->action(function ($email, $list) {
176-
echo $email . '-' . implode('-', $list);
176+
echo $email.'-'.implode('-', $list);
177177
});
178178

179179
\ob_start();
@@ -195,7 +195,7 @@ public function testInjection()
195195
->inject('test')
196196
->param('email', null, new Text(15), 'valid email address')
197197
->action(function ($test, $email) {
198-
echo $test . '-' . $email;
198+
echo $test.'-'.$email;
199199
});
200200

201201
$cli->run();
@@ -214,15 +214,15 @@ public function testMatch()
214214
->param('email', null, new Text(0), 'Valid email address')
215215
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
216216
->action(function ($email, $list) {
217-
echo $email . '-' . implode('-', $list);
217+
echo $email.'-'.implode('-', $list);
218218
});
219219

220220
$cli
221221
->task('build2')
222222
->param('email', null, new Text(0), 'Valid email address')
223223
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
224224
->action(function ($email, $list) {
225-
echo $email . '-' . implode('-', $list);
225+
echo $email.'-'.implode('-', $list);
226226
});
227227

228228
$this->assertEquals('build2', $cli->match()->getName());
@@ -234,15 +234,15 @@ public function testMatch()
234234
->param('email', null, new Text(0), 'Valid email address')
235235
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
236236
->action(function ($email, $list) {
237-
echo $email . '-' . implode('-', $list);
237+
echo $email.'-'.implode('-', $list);
238238
});
239239

240240
$cli
241241
->task('build2')
242242
->param('email', null, new Text(0), 'Valid email address')
243243
->param('list', null, new ArrayList(new Text(256)), 'List of strings')
244244
->action(function ($email, $list) {
245-
echo $email . '-' . implode('-', $list);
245+
echo $email.'-'.implode('-', $list);
246246
});
247247

248248
$this->assertEquals(null, $cli->match());

tests/CLI/ConsoleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ public function testExecuteTimeout()
106106

107107
public function testLoop()
108108
{
109-
$file = __DIR__ . '/../resources/loop.php';
109+
$file = __DIR__.'/../resources/loop.php';
110110
$stdin = '';
111111
$stdout = '';
112112
$stderr = '';
113-
$code = Console::execute('php ' . $file, $stdin, $stdout, $stderr, 30);
113+
$code = Console::execute('php '.$file, $stdin, $stdout, $stderr, 30);
114114

115115
$this->assertEquals('', $stderr);
116116
$this->assertGreaterThan(30, count(explode("\n", $stdout)));

tests/resources/loop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Utopia\CLI\Console;
44

5-
include __DIR__ . '/../../vendor/autoload.php';
5+
include __DIR__.'/../../vendor/autoload.php';
66

77
Console::loop(function () {
88
echo "Hello\n";

0 commit comments

Comments
 (0)