Skip to content

Commit b2408c1

Browse files
Merge pull request #7 from hexadog/develop
Develop
2 parents adb1ae1 + 6e2ea14 commit b2408c1

File tree

11 files changed

+106
-79
lines changed

11 files changed

+106
-79
lines changed

.circleci/config.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/php-cs-fixer.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check and fix code styling with php-cs-fixer
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
style:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.head_ref }}
16+
17+
- name: Run php-cs-fixer
18+
uses: docker://oskarstark/php-cs-fixer-ga
19+
with:
20+
args: --config=.php_cs.dist --allow-risky=yes
21+
22+
- name: Commit changes
23+
uses: stefanzweifel/git-auto-commit-action@v4.10.0
24+
with:
25+
commit_message: Automatically applied php-cs-fixer changes

.php_cs.dist

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->notPath('vendor/*')
5+
->notPath('resources/*')
6+
->notPath('database/*')
7+
->notPath('storage/*')
8+
->notPath('node_modules/*')
9+
->in([
10+
__DIR__ . '/src',
11+
])
12+
->name('*.php')
13+
->notName('*.blade.php')
14+
->ignoreDotFiles(true)
15+
->ignoreVCS(true);
16+
17+
return PhpCsFixer\Config::create()
18+
->setRules([
19+
'@PSR2' => true,
20+
'array_syntax' => ['syntax' => 'short'],
21+
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
22+
'no_unused_imports' => true,
23+
'not_operator_with_successor_space' => true,
24+
'trailing_comma_in_multiline_array' => true,
25+
'phpdoc_scalar' => true,
26+
'unary_operator_spaces' => true,
27+
'binary_operator_spaces' => true,
28+
'blank_line_before_statement' => [
29+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
30+
],
31+
'phpdoc_single_line_var_spacing' => true,
32+
'phpdoc_var_without_name' => true,
33+
'class_attributes_separation' => [
34+
'elements' => [
35+
'method',
36+
],
37+
],
38+
'method_argument_space' => [
39+
'on_multiline' => 'ensure_fully_multiline',
40+
'keep_multiple_spaces_after_comma' => true,
41+
],
42+
'single_trait_insert_per_statement' => true,
43+
])
44+
->setFinder($finder);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"illuminate/view": "^7.0|^8.0"
2020
},
2121
"require-dev": {
22+
"friendsofphp/php-cs-fixer": "^2.18",
2223
"squizlabs/php_codesniffer": "3.*",
2324
"phpunit/phpunit": "^7.0|^8.0|^9.0",
2425
"orchestra/testbench": "~5.2"
@@ -45,6 +46,6 @@
4546
"test": "vendor/bin/phpunit",
4647
"test:windows": "vendor\\bin\\phpunit",
4748
"check-style": "vendor/bin/phpcs --extensions=php ./src",
48-
"fix-style": "vendor/bin/phpcbf --extensions=php ./src"
49+
"fix-style": "vendor/bin/php-cs-fixer fix"
4950
}
5051
}

src/Components/Menu.php

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

33
namespace Hexadog\MenusManager\Components;
44

5-
use Illuminate\View\Component;
6-
use Illuminate\Support\Collection;
75
use Hexadog\MenusManager\Facades\Menus;
6+
use Illuminate\Support\Collection;
7+
use Illuminate\View\Component;
88

99
class Menu extends Component
1010
{

src/Facades/MenusManager.php

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

33
namespace Hexadog\MenusManager\Facades;
44

5-
use Illuminate\Support\Facades\Facade;
65
use Hexadog\MenusManager\MenusManager as Manager;
6+
use Illuminate\Support\Facades\Facade;
77

88
class MenusManager extends Facade
99
{

src/Item.php

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

33
namespace Hexadog\MenusManager;
44

5-
use Illuminate\Support\Arr;
6-
use Illuminate\Support\Collection;
75
use Hexadog\MenusManager\Traits\HasItems;
86
use Illuminate\Contracts\Support\Arrayable;
7+
use Illuminate\Support\Arr;
8+
use Illuminate\Support\Collection;
99
use Illuminate\Support\Facades\Request;
1010
use Illuminate\Support\Facades\Route;
1111
use Illuminate\Support\Facades\URL;
@@ -28,13 +28,13 @@ class Item implements Arrayable
2828
* @var array
2929
*/
3030
protected $properties = [
31-
'attributes' => [],
32-
'icon' => null,
33-
'order' => 9000,
34-
'route' => null,
35-
'title' => '',
36-
'type' => 'link', // link | divider | header
37-
'url' => null,
31+
'attributes' => [],
32+
'icon' => null,
33+
'order' => 9000,
34+
'route' => null,
35+
'title' => '',
36+
'type' => 'link', // link | divider | header
37+
'url' => null,
3838
];
3939

4040
/**
@@ -101,7 +101,7 @@ public function __set($key, $value)
101101
public function asHeader(): Item
102102
{
103103
return $this->fill([
104-
'type' => 'header'
104+
'type' => 'header',
105105
]);
106106
}
107107

@@ -113,7 +113,7 @@ public function asHeader(): Item
113113
public function asDivider(): Item
114114
{
115115
return $this->fill([
116-
'type' => 'divider'
116+
'type' => 'divider',
117117
]);
118118
}
119119

@@ -194,11 +194,11 @@ public function hasChildren(): bool
194194
/**
195195
* Check if icon is set for the current item
196196
*
197-
* @return boolean
197+
* @return bool
198198
*/
199199
public function hasIcon(): bool
200200
{
201-
return !is_null($this->icon);
201+
return ! is_null($this->icon);
202202
}
203203

204204
/**
@@ -251,7 +251,7 @@ public function isHeader(): bool
251251
*/
252252
public function isHidden(): bool
253253
{
254-
return !$this->isVisible();
254+
return ! $this->isVisible();
255255
}
256256

257257
/**
@@ -289,7 +289,7 @@ public function icon(string $icon): Item
289289
*/
290290
public function if($callback): Item
291291
{
292-
if (!is_callable($callback)) {
292+
if (! is_callable($callback)) {
293293
$callback = function () use ($callback) {
294294
return $callback;
295295
};
@@ -303,7 +303,7 @@ public function if($callback): Item
303303
/**
304304
* Set the current item order
305305
*
306-
* @param integer $order
306+
* @param int $order
307307
*
308308
* @return Item
309309
*/
@@ -367,6 +367,7 @@ private function htmlAttributes($attributes)
367367
if (is_bool($attributes[$key])) {
368368
return $attributes[$key] ? $key : '';
369369
}
370+
370371
return $key . '="' . $attributes[$key] . '"';
371372
}, array_keys($attributes))));
372373
}
@@ -386,7 +387,7 @@ public function toArray()
386387
'order' => $this->order,
387388
'title' => $this->title,
388389
'type' => $this->type,
389-
'url' => $this->getUrl()
390+
'url' => $this->getUrl(),
390391
];
391392
}
392393
}

src/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function toArray()
5555
{
5656
return [
5757
'name' => $this->name,
58-
'items' => $this->items->toArray()
58+
'items' => $this->items->toArray(),
5959
];
6060
}
6161
}

src/MenusManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function all(): array
4141
*/
4242
public function register($name): Menu
4343
{
44-
if (!$menu = $this->get($name)) {
44+
if (! $menu = $this->get($name)) {
4545
$menu = new Menu($name);
4646

4747
$this->menus->put($name, $menu);
@@ -60,8 +60,8 @@ public function register($name): Menu
6060
*/
6161
public function __call($method_name, $args)
6262
{
63-
if (!method_exists($this, $method_name)) {
64-
return call_user_func_array(array($this->menus, $method_name), $args);
63+
if (! method_exists($this, $method_name)) {
64+
return call_user_func_array([$this->menus, $method_name], $args);
6565
}
6666
}
6767
}

src/Providers/PackageServiceProvider.php

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

33
namespace Hexadog\MenusManager\Providers;
44

5-
use ReflectionClass;
6-
use Illuminate\Support\Str;
7-
use Illuminate\Routing\Router;
85
use Hexadog\MenusManager\Components;
6+
use Hexadog\MenusManager\Facades\Menus as MenusFacade;
7+
use Hexadog\MenusManager\Facades\MenusManager as MenusManagerFacade;
98
use Hexadog\MenusManager\MenusManager;
109
use Illuminate\Foundation\AliasLoader;
10+
use Illuminate\Routing\Router;
1111
use Illuminate\Support\ServiceProvider;
12-
use Hexadog\MenusManager\Facades\Menus as MenusFacade;
13-
use Hexadog\MenusManager\Facades\MenusManager as MenusManagerFacade;
12+
use Illuminate\Support\Str;
13+
use ReflectionClass;
1414

1515
class PackageServiceProvider extends ServiceProvider
1616
{
@@ -69,7 +69,7 @@ public function boot(Router $router)
6969
Components\Header::class,
7070
Components\Icon::class,
7171
Components\Item::class,
72-
Components\Menu::class
72+
Components\Menu::class,
7373
]);
7474
}
7575

0 commit comments

Comments
 (0)