Skip to content

Commit 0c1837a

Browse files
committed
lint
1 parent 83ec37d commit 0c1837a

File tree

15 files changed

+162
-88
lines changed

15 files changed

+162
-88
lines changed

.github/workflows/code-style.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: code-style
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
code-style:
11+
runs-on: ubuntu-22.04
12+
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [ 8.2 ]
17+
node-version: [ "20.x" ]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
27+
- name: Cache Composer packages
28+
id: composer-cache
29+
uses: actions/cache@v2
30+
with:
31+
path: vendor
32+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-php-
35+
36+
- name: Install dependencies
37+
if: steps.composer-cache.outputs.cache-hit != 'true'
38+
run: composer install --prefer-dist --no-progress --no-suggest
39+
40+
- name: Run pint
41+
run: ./vendor/bin/pint --test

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"psy/psysh": "*"
1919
},
2020
"minimum-stability": "stable",
21-
"prefer-stable": true
21+
"prefer-stable": true,
22+
"require-dev": {
23+
"laravel/pint": "^1.19"
24+
}
2225
}

composer.lock

Lines changed: 69 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
use TweakPHP\Client\Loader;
44

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

77
$arguments = $argv;
88

99
if (count($arguments) < 3) {
10-
echo 'Invalid arguments' . PHP_EOL;
10+
echo 'Invalid arguments'.PHP_EOL;
1111
exit(1);
1212
}
1313

@@ -23,7 +23,7 @@ function dd(...$args)
2323
$loader = Loader::load($arguments[1]);
2424

2525
if ($loader === null) {
26-
echo 'Invalid path' . PHP_EOL;
26+
echo 'Invalid path'.PHP_EOL;
2727
exit(1);
2828
}
2929

@@ -34,8 +34,8 @@ function dd(...$args)
3434
'execute',
3535
];
3636

37-
if (!in_array($arguments[2], $supportedCommands)) {
38-
echo 'Invalid command' . PHP_EOL;
37+
if (! in_array($arguments[2], $supportedCommands)) {
38+
echo 'Invalid command'.PHP_EOL;
3939
exit(1);
4040
}
4141

@@ -46,13 +46,13 @@ function dd(...$args)
4646
'version' => $loader->version(),
4747
'php_version' => phpversion(),
4848
]);
49-
echo $info . PHP_EOL;
49+
echo $info.PHP_EOL;
5050
break;
5151
case 'execute':
5252
if (count($arguments) < 4) {
53-
echo 'Invalid arguments' . PHP_EOL;
53+
echo 'Invalid arguments'.PHP_EOL;
5454
exit(1);
5555
}
56-
echo $loader->execute(base64_decode($arguments[3])) . PHP_EOL;
56+
echo $loader->execute(base64_decode($arguments[3])).PHP_EOL;
5757
break;
58-
}
58+
}

src/Loader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
class Loader
1313
{
1414
/**
15-
* @param string $path
1615
* @return null|LoaderInterface
1716
*/
1817
public static function load(string $path)

src/Loaders/BaseLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function init()
4343
]);
4444
}
4545

46-
$this->tinker = new Tinker(new CustomOutputModifier(), $config);
46+
$this->tinker = new Tinker(new CustomOutputModifier, $config);
4747
}
4848

4949
public function execute(string $code)
@@ -52,4 +52,4 @@ public function execute(string $code)
5252

5353
echo trim($output);
5454
}
55-
}
55+
}

src/Loaders/ComposerLoader.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,23 @@
44

55
class ComposerLoader extends BaseLoader
66
{
7-
/**
8-
* @param string $path
9-
* @return bool
10-
*/
117
public static function supports(string $path): bool
128
{
13-
return file_exists($path . '/vendor/autoload.php');
9+
return file_exists($path.'/vendor/autoload.php');
1410
}
1511

16-
/**
17-
* @param string $path
18-
*/
1912
public function __construct(string $path)
2013
{
21-
require $path . '/vendor/autoload.php';
14+
require $path.'/vendor/autoload.php';
2215
}
2316

2417
public function name(): string
2518
{
2619
return 'Composer Project';
2720
}
2821

29-
/**
30-
* @return string
31-
*/
3222
public function version(): string
3323
{
34-
return "";
24+
return '';
3525
}
3626
}

src/Loaders/LaravelLoader.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,27 @@
22

33
namespace TweakPHP\Client\Loaders;
44

5-
use Throwable;
6-
75
class LaravelLoader extends ComposerLoader
86
{
97
private $app;
108

11-
/**
12-
* @param string $path
13-
* @return bool
14-
*/
159
public static function supports(string $path): bool
1610
{
17-
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/bootstrap/app.php');
11+
return file_exists($path.'/vendor/autoload.php') && file_exists($path.'/bootstrap/app.php');
1812
}
1913

20-
/**
21-
* @param string $path
22-
*/
2314
public function __construct(string $path)
2415
{
2516
parent::__construct($path);
26-
$this->app = require_once $path . '/bootstrap/app.php';
17+
$this->app = require_once $path.'/bootstrap/app.php';
2718
$this->app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
2819
}
2920

30-
/**
31-
* @return string
32-
*/
3321
public function name(): string
3422
{
3523
return 'Laravel';
3624
}
3725

38-
/**
39-
* @return string
40-
*/
4126
public function version(): string
4227
{
4328
return $this->app->version();

src/Loaders/LoaderInterface.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@
44

55
interface LoaderInterface
66
{
7-
/**
8-
* @param string $path
9-
* @return bool
10-
*/
117
public static function supports(string $path): bool;
128

13-
/**
14-
* @return string
15-
*/
169
public function name(): string;
1710

18-
/**
19-
* @return string
20-
*/
2111
public function version(): string;
2212

2313
/**
@@ -26,7 +16,6 @@ public function version(): string;
2616
public function init();
2717

2818
/**
29-
* @param string $code
3019
* @return string
3120
*/
3221
public function execute(string $code);

src/Loaders/PimcoreLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PimcoreLoader extends BaseLoader
88
{
99
public function __construct(string $path)
1010
{
11-
require_once $path . '/vendor/autoload.php';
11+
require_once $path.'/vendor/autoload.php';
1212

1313
if (class_exists('\Pimcore\Bootstrap')) {
1414
\Pimcore\Bootstrap::setProjectRoot();
@@ -29,6 +29,6 @@ public function version(): string
2929

3030
public static function supports(string $path): bool
3131
{
32-
return file_exists($path . '/vendor/autoload.php') && file_exists($path . '/vendor/pimcore/pimcore');
32+
return file_exists($path.'/vendor/autoload.php') && file_exists($path.'/vendor/pimcore/pimcore');
3333
}
3434
}

0 commit comments

Comments
 (0)