Skip to content

Commit 2247446

Browse files
committed
increased php version requirement to 8.0
1 parent 1bad5f9 commit 2247446

File tree

6 files changed

+38
-89
lines changed

6 files changed

+38
-89
lines changed

.scrutinizer.yml

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

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
![Downloads](https://img.shields.io/packagist/dt/akaunting/laravel-menu)
44
![Tests](https://img.shields.io/github/workflow/status/akaunting/laravel-menu/Tests?label=tests)
55
[![StyleCI](https://github.styleci.io/repos/180763610/shield?style=flat&branch=master)](https://styleci.io/repos/180763610)
6-
[![Quality](https://img.shields.io/scrutinizer/quality/g/akaunting/laravel-menu?label=quality)](https://scrutinizer-ci.com/g/akaunting/laravel-menu)
76
[![License](https://img.shields.io/github/license/akaunting/laravel-menu)](LICENSE.md)
87

98
This package intends to create and manage menus and sidebars for your Laravel app. It ships with ready-to-go presenters and you can create your own ones.
@@ -51,6 +50,10 @@ Please see [Releases](../../releases) for more information what has changed rece
5150

5251
Pull requests are more than welcome. You must follow the PSR coding standards.
5352

53+
## Security
54+
55+
Please review [our security policy](https://github.com/akaunting/laravel-menu/security/policy) on how to report security vulnerabilities.
56+
5457
## Credits
5558

5659
- [Denis Duliçi](https://github.com/denisdulici)

SECURITY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Security Policy
2+
3+
**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).**
4+
5+
## Reporting a Vulnerability
6+
7+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=7.3",
22-
"illuminate/config": ">=5.5",
23-
"illuminate/support": ">=5.5",
24-
"illuminate/view": ">=5.5",
25-
"laravelcollective/html": ">=5.5"
21+
"php": "^8.0",
22+
"illuminate/config": "^9.0",
23+
"illuminate/support": "^9.0",
24+
"illuminate/view": "^9.0",
25+
"laravelcollective/html": "^6.3"
2626
},
2727
"require-dev": {
28-
"friendsofphp/php-cs-fixer": ">=3.4",
29-
"mockery/mockery": ">=1.4",
30-
"orchestra/testbench": ">=6.0",
31-
"phpunit/phpunit": ">=9.0"
28+
"friendsofphp/php-cs-fixer": "^3.12",
29+
"mockery/mockery": "^1.5",
30+
"orchestra/testbench": "^7.11",
31+
"phpunit/phpunit": "^9.5"
3232
},
3333
"autoload": {
3434
"psr-4": {

src/Menu.php

Lines changed: 16 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,20 @@
22

33
namespace Akaunting\Menu;
44

5+
use Akaunting\Menu\MenuBuilder;
56
use Closure;
67
use Countable;
78
use Illuminate\Contracts\Config\Repository;
89
use Illuminate\View\Factory;
910

1011
class Menu implements Countable
1112
{
12-
/**
13-
* The menu collections.
14-
*
15-
* @var array
16-
*/
17-
protected $menu = [];
18-
/**
19-
* @var Repository
20-
*/
21-
private $config;
22-
/**
23-
* @var Factory
24-
*/
25-
private $views;
13+
protected array $menu = [];
14+
15+
protected Repository $config;
16+
17+
protected Factory $views;
2618

27-
/**
28-
* The constructor.
29-
*
30-
* @param Factory $views
31-
* @param Repository $config
32-
*/
3319
public function __construct(Factory $views, Repository $config)
3420
{
3521
$this->views = $views;
@@ -38,26 +24,16 @@ public function __construct(Factory $views, Repository $config)
3824

3925
/**
4026
* Make new menu.
41-
*
42-
* @param string $name
43-
* @param Closure $callback
44-
*
45-
* @return \Akaunting\Menu\MenuBuilder
4627
*/
47-
public function make($name, \Closure $callback)
28+
public function make(string $name, Closure $callback): mixed
4829
{
4930
return $this->create($name, $callback);
5031
}
5132

5233
/**
5334
* Create new menu.
54-
*
55-
* @param string $name
56-
* @param Callable $resolver
57-
*
58-
* @return \Akaunting\Menu\MenuBuilder
5935
*/
60-
public function create($name, Closure $resolver)
36+
public function create(string $name, Closure $resolver): mixed
6137
{
6238
$builder = new MenuBuilder($name, $this->config);
6339

@@ -70,36 +46,24 @@ public function create($name, Closure $resolver)
7046

7147
/**
7248
* Check if the menu exists.
73-
*
74-
* @param string $name
75-
*
76-
* @return bool
7749
*/
78-
public function has($name)
50+
public function has(string $name): bool
7951
{
8052
return array_key_exists($name, $this->menu);
8153
}
8254

8355
/**
8456
* Get instance of the given menu if exists.
85-
*
86-
* @param string $name
87-
*
88-
* @return string|null
8957
*/
90-
public function instance($name)
58+
public function instance(string $name): ?MenuBuilder
9159
{
9260
return $this->has($name) ? $this->menu[$name] : null;
9361
}
9462

9563
/**
9664
* Modify a specific menu.
97-
*
98-
* @param string $name
99-
* @param Closure $callback
100-
* @return void
10165
*/
102-
public function modify($name, Closure $callback)
66+
public function modify(string $name, Closure $callback): void
10367
{
10468
$menu = collect($this->menu)->filter(function ($menu) use ($name) {
10569
return $menu->getName() == $name;
@@ -110,55 +74,39 @@ public function modify($name, Closure $callback)
11074

11175
/**
11276
* Render the menu tag by given name.
113-
*
114-
* @param string $name
115-
* @param string $presenter
116-
*
117-
* @return string|null
11877
*/
119-
public function get($name, $presenter = null, $bindings = [])
78+
public function get(string $name, ?string $presenter = null, array $bindings = []): ?string
12079
{
12180
return $this->has($name) ?
12281
$this->menu[$name]->setBindings($bindings)->render($presenter) : null;
12382
}
12483

12584
/**
12685
* Render the menu tag by given name.
127-
*
128-
* @param $name
129-
* @param null $presenter
130-
*
131-
* @return string
13286
*/
133-
public function render($name, $presenter = null, $bindings = [])
87+
public function render(string $name, ?string $presenter = null, array $bindings = []): ?string
13488
{
13589
return $this->get($name, $presenter, $bindings);
13690
}
13791

13892
/**
13993
* Get a stylesheet for enable multilevel menu.
140-
*
141-
* @return mixed
14294
*/
143-
public function style()
95+
public function style(): mixed
14496
{
14597
return $this->views->make('menu::bootstrap3.style')->render();
14698
}
14799

148100
/**
149101
* Get all menus.
150-
*
151-
* @return array
152102
*/
153-
public function all()
103+
public function all(): array
154104
{
155105
return $this->menu;
156106
}
157107

158108
/**
159109
* Count menus.
160-
*
161-
* @return int
162110
*/
163111
public function count(): int
164112
{
@@ -168,7 +116,7 @@ public function count(): int
168116
/**
169117
* Empty the current menus.
170118
*/
171-
public function destroy()
119+
public function destroy(): void
172120
{
173121
$this->menu = [];
174122
}

src/MenuItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ protected function hasRoute()
576576
protected function getActiveStateFromRoute()
577577
{
578578
$url = str_replace(url('/') . '/', '', $this->getUrl());
579-
$url = str_replace('#' . $this->fragment, '', $url);
579+
$url = str_replace('#' . (string) $this->fragment, '', $url);
580580

581581
return $this->checkActiveState($url);
582582
}
@@ -588,7 +588,7 @@ protected function getActiveStateFromRoute()
588588
*/
589589
protected function getActiveStateFromUrl()
590590
{
591-
$url = str_replace('#' . $this->fragment, '', $this->url);
591+
$url = str_replace('#' . (string) $this->fragment, '', (string) $this->url);
592592

593593
return $this->checkActiveState($url);
594594
}

0 commit comments

Comments
 (0)