Skip to content

Commit 81db54b

Browse files
committed
fix php 8.2 deprecation error, bump min php version to php7.4
1 parent 8b05872 commit 81db54b

File tree

11 files changed

+35
-47
lines changed

11 files changed

+35
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
composer.phar
33
composer.lock
44
.DS_Store
5+
.phpunit.result.cache
56
/.idea

.travis.yml

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

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
Run ```composer require arrilot/laravel-widgets```
1313

14-
Laravel >=5.5 uses Package Auto-Discovery, so you don't need to manually add the ServiceProvider and Facades
15-
1614
## Usage
1715

1816
Let's consider that we want to make a list of recent news and reuse it in several views.
@@ -43,7 +41,7 @@ class RecentNews extends AbstractWidget
4341
*
4442
* @var array
4543
*/
46-
protected $config = [];
44+
protected array $config = [];
4745

4846
/**
4947
* Treat this method as a controller action.
@@ -92,7 +90,7 @@ This can be easily achieved by:
9290
class RecentNews extends AbstractWidget
9391
{
9492
...
95-
protected $config = [
93+
protected array $config = [
9694
'count' => 5
9795
];
9896
...
@@ -112,7 +110,7 @@ Config array is available in every widget method so you can use it to configure
112110
class RecentNews extends AbstractWidget
113111
{
114112
...
115-
protected $config = [
113+
protected array $config = [
116114
'count' => 5,
117115
'foo' => 'bar'
118116
];
@@ -129,7 +127,7 @@ In this case do the following:
129127

130128
1) Do not add `protected $config = [...]` line to a child.
131129

132-
2) Instead add defaults like this:
130+
2) Instead, add defaults like this:
133131

134132
```php
135133
public function __construct(array $config = [])
@@ -157,7 +155,7 @@ public function run($sortBy, $sortOrder) { }
157155

158156
## Namespaces
159157

160-
By default the package tries to find your widget in the ```App\Widgets``` namespace.
158+
By default, the package tries to find your widget in the ```App\Widgets``` namespace.
161159

162160
You can override this by publishing package config (```php artisan vendor:publish --provider="Arrilot\Widgets\ServiceProvider"```) and setting `default_namespace` property.
163161

@@ -183,7 +181,7 @@ No problem, there are several ways to call those widgets:
183181

184182
## Asynchronous widgets
185183

186-
In some situations it can be very beneficial to load widget content with AJAX.
184+
Sometimes it can be very beneficial to load widget content with AJAX.
187185

188186
Fortunately, this can be achieved very easily!
189187
All you need to do is to change facade or blade directive - `Widget::` => `AsyncWidget::`, `@widget` => `@asyncWidget`
@@ -195,12 +193,12 @@ For example, if you pass something like user_id through widget params and turn e
195193

196194
> Note: You can set `use_jquery_for_ajax_calls` to `true` in the config file to use it for ajax calls if you want to, but you need to manually add jquery to your page in this case.
197195
198-
By default nothing is shown until ajax call is finished.
196+
By default, nothing is shown until ajax call is finished.
199197

200198
This can be customized by adding a `placeholder()` method to the widget class.
201199

202200
```php
203-
public function placeholder()
201+
public function placeholder(): string
204202
{
205203
return 'Loading...';
206204
}
@@ -243,7 +241,7 @@ This container is defined by `AbstractWidget::container()` method and can be cus
243241
*
244242
* @return array
245243
*/
246-
public function container()
244+
public function container(): array
247245
{
248246
return [
249247
'element' => 'div',
@@ -292,7 +290,7 @@ class RecentNews extends AbstractWidget
292290
*
293291
* @var array
294292
*/
295-
public $cacheTags = ['news', 'frontend'];
293+
public array $cacheTags = ['news', 'frontend'];
296294
}
297295
```
298296

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
],
1212
"homepage": "https://github.com/arrilot/laravel-widgets",
1313
"require": {
14-
"php": ">=7.0",
15-
"illuminate/support": ">=5.5",
16-
"illuminate/contracts": ">=5.5",
17-
"illuminate/view": ">=5.5",
18-
"illuminate/container": ">=5.5",
19-
"illuminate/console": ">=5.5",
20-
"illuminate/cache": ">=5.5"
14+
"php": ">=7.4",
15+
"illuminate/support": ">=8",
16+
"illuminate/contracts": ">=8",
17+
"illuminate/view": ">=8",
18+
"illuminate/container": ">=8",
19+
"illuminate/console": ">=8",
20+
"illuminate/cache": ">=8"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "~6.0"
23+
"phpunit/phpunit": "~8.0"
2424
},
2525
"autoload": {
2626
"psr-4": {

phpunit.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
34
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
55
colors="true"
6+
verbose="true"
67
convertErrorsToExceptions="true"
78
convertNoticesToExceptions="true"
89
convertWarningsToExceptions="true"
910
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
>
11+
stopOnFailure="false">
1312
<testsuites>
1413
<testsuite name="Package Test Suite">
1514
<directory>tests</directory>

src/WidgetGroupCollection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
class WidgetGroupCollection
88
{
9+
/**
10+
* The application wrapper.
11+
*
12+
* @var ApplicationWrapperContract
13+
*/
14+
protected ApplicationWrapperContract $app;
15+
916
/**
1017
* The array of widget groups.
1118
*

tests/AsyncWidgetFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AsyncWidgetFactoryTest extends TestCase
1313
*/
1414
protected $factory;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
$this->factory = new AsyncWidgetFactory(new TestApplicationWrapper());
1919
}

tests/Support/TestCase.php

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

88
class TestCase extends BaseTestCase
99
{
10-
public function tearDown()
10+
public function tearDown(): void
1111
{
1212
WidgetId::reset();
1313
}

tests/WidgetFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WidgetFactoryTest extends TestCase
1414
*/
1515
protected $factory;
1616

17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
$this->factory = new WidgetFactory(new TestApplicationWrapper());
2020
}

tests/WidgetGroupCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class WidgetGroupCollectionTest extends TestCase
1414
*/
1515
protected $collection;
1616

17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
$this->collection = new WidgetGroupCollection(new TestApplicationWrapper());
2020
}

0 commit comments

Comments
 (0)