Skip to content

Commit 9260fb5

Browse files
author
Zain Mehdi
authored
Merge pull request #33 from Weebly/php-8-support
PHP 8.x Support
2 parents 0f3f7ea + aab32b1 commit 9260fb5

18 files changed

+81
-60
lines changed

.github/workflows/test.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
strategy:
2424
matrix:
25-
php: [7.2, 7.3, 7.4, 8.0]
25+
php: [7.2, 7.3, 7.4, 8.0, 8.1]
2626
laravel: [6.*, 7.*, 8.*]
2727
include:
2828
- laravel: 6.*
@@ -37,6 +37,12 @@ jobs:
3737
php: 7.1
3838
- laravel: 8.*
3939
php: 7.2
40+
# Laravel 6 only support PHP <=8.0
41+
- laravel: 6.*
42+
php: 8.1
43+
# Laravel 7 only support PHP <=8.0
44+
- laravel: 7.*
45+
php: 8.1
4046

4147

4248
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
@@ -65,3 +71,6 @@ jobs:
6571
run: vendor/bin/phpunit --testsuite Integration
6672
env:
6773
DB_PORT: ${{ job.services.mysql.ports[3306] }}
74+
75+
- name: Run PHPStan
76+
run: vendor/bin/phpstan analyze

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
"license": "BSD-2-Clause",
66
"keywords": ["laravel", "eloquent", "uuid", "encrypt", "database"],
77
"require": {
8-
"php": ">=7.2",
8+
"php": ">=7.2 || ^8.0",
99
"ramsey/uuid": "~3.0 || ~4.0",
10-
"illuminate/database": "^6.0 || ^7.0 || ^8.0",
11-
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
12-
"illuminate/encryption": "^6.0 || ^7.0 || ^8.0"
10+
"laravel/framework": "^6.0 || ^7.0 || ^8.0"
1311
},
1412
"require-dev": {
1513
"mockery/mockery": "^1.0",
1614
"phpunit/phpunit": "^8.0",
1715
"laravel/framework": "8.*",
18-
"orchestra/testbench": "^6.0"
16+
"orchestra/testbench": "^6.0",
17+
"phpstan/phpstan": "^1.8"
1918
},
2019
"autoload": {
2120
"psr-4": {

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- src
5+
- config

src/Database/Eloquent/Relations/BelongsToMany.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function buildDictionary(Collection $results)
9494
/**
9595
* Create a new pivot attachment record.
9696
*
97-
* @param int $id
97+
* @param int $id
9898
* @param bool $timed
9999
* @return array
100100
*/
@@ -198,7 +198,7 @@ protected function parseIds($value)
198198
* Sync the intermediate tables with a list of IDs or collection of models.
199199
*
200200
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids
201-
* @param bool $detaching
201+
* @param bool $detaching
202202
* @return array
203203
*/
204204
public function sync($ids, $detaching = true)

src/Database/EloquentBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Weebly\Mutate\Database;
44

55
use Closure;
6+
use Illuminate\Contracts\Support\Arrayable;
67
use Illuminate\Database\Eloquent\Builder as BaseEloquentBuilder;
78
use Illuminate\Database\Query\Builder as QueryBuilder;
89
use Illuminate\Database\Query\Expression;
@@ -195,7 +196,7 @@ public function pluck($column, $key = null)
195196
/**
196197
* Get the column name without any table prefix.
197198
*
198-
* @param string $column
199+
* @param string $column
199200
* @return string
200201
*/
201202
protected function getUnqualifiedColumnName($column)

src/Database/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Model extends Eloquent
1111
use HasMutators;
1212

1313
/**
14-
* @param string $key
14+
* @param string $key
1515
* @return \Illuminate\Foundation\Application|mixed
1616
*/
1717
public function getAttribute($key)

src/Database/Traits/HasMutators.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ trait HasMutators
1717
protected $mutatedCache = [];
1818

1919
/**
20-
* @param string $attribute
21-
* @param mixed $value
20+
* @param string $attribute
21+
* @param mixed $value
2222
* @return \Illuminate\Foundation\Application|mixed
2323
*/
2424
public function serializeAttribute($attribute, $value)
@@ -39,9 +39,9 @@ public function serializeAttribute($attribute, $value)
3939
}
4040

4141
/**
42-
* @param string $attribute
43-
* @param mixed $value
44-
* @param bool $force
42+
* @param string $attribute
43+
* @param mixed $value
44+
* @param bool $force
4545
* @return mixed
4646
*/
4747
public function unserializeAttribute($attribute, $value, $force = false)
@@ -73,7 +73,7 @@ public function getMutators()
7373
}
7474

7575
/**
76-
* @param string $attribute
76+
* @param string $attribute
7777
* @return mixed|null
7878
*/
7979
public function getMutator($attribute)
@@ -84,7 +84,7 @@ public function getMutator($attribute)
8484
}
8585

8686
/**
87-
* @param mixed $attribute
87+
* @param mixed $attribute
8888
* @return bool
8989
*/
9090
public function hasMutator($attribute)

src/MutatorProvider.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ class MutatorProvider implements ArrayAccess
1414
protected $mutators = [];
1515

1616
/**
17-
* @param string $mutator
17+
* @param string $mutator
1818
* @return \Weebly\Mutate\Mutators\MutatorContract
19+
*
1920
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
2021
*/
2122
public function get($mutator)
@@ -31,8 +32,8 @@ public function get($mutator)
3132
}
3233

3334
/**
34-
* @param string $name
35-
* @param mixed $mutator
35+
* @param string $name
36+
* @param mixed $mutator
3637
* @return $this
3738
*/
3839
public function set($name, $mutator)
@@ -43,7 +44,7 @@ public function set($name, $mutator)
4344
}
4445

4546
/**
46-
* @param string $mutator
47+
* @param string $mutator
4748
* @return bool
4849
*/
4950
public function exists($mutator)
@@ -52,7 +53,7 @@ public function exists($mutator)
5253
}
5354

5455
/**
55-
* @param array $mutators
56+
* @param array $mutators
5657
*/
5758
public function registerMutators(array $mutators)
5859
{
@@ -63,45 +64,51 @@ public function registerMutators(array $mutators)
6364
}
6465

6566
/**
66-
* @param string $offset
67+
* @param string $offset
6768
* @return bool
6869
*/
70+
#[\ReturnTypeWillChange]
6971
public function offsetExists($offset)
7072
{
7173
return $this->exists($offset);
7274
}
7375

7476
/**
75-
* @param string $offset
77+
* @param string $offset
7678
* @return \Weebly\Mutate\Mutators\MutatorContract
79+
*
7780
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
7881
*/
82+
#[\ReturnTypeWillChange]
7983
public function offsetGet($offset)
8084
{
8185
return $this->get($offset);
8286
}
8387

8488
/**
85-
* @param string $offset
86-
* @param mixed $value
89+
* @param string $offset
90+
* @param mixed $value
8791
* @return \Weebly\Mutate\MutatorProvider
8892
*/
93+
#[\ReturnTypeWillChange]
8994
public function offsetSet($offset, $value)
9095
{
9196
return $this->set($offset, $value);
9297
}
9398

9499
/**
95-
* @param string $offset
100+
* @param string $offset
96101
*/
102+
#[\ReturnTypeWillChange]
97103
public function offsetUnset($offset)
98104
{
99105
unset($this->mutators[$offset]);
100106
}
101107

102108
/**
103-
* @param string $name
109+
* @param string $name
104110
* @return \Weebly\Mutate\Mutators\MutatorContract
111+
*
105112
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
106113
*/
107114
public function __get($name)
@@ -110,16 +117,16 @@ public function __get($name)
110117
}
111118

112119
/**
113-
* @param string $name
114-
* @param mixed $value
120+
* @param string $name
121+
* @param mixed $value
115122
*/
116123
public function __set($name, $value)
117124
{
118125
$this->set($name, $value);
119126
}
120127

121128
/**
122-
* @param string $key
129+
* @param string $key
123130
* @return bool
124131
*/
125132
public function __isset($key)
@@ -128,7 +135,7 @@ public function __isset($key)
128135
}
129136

130137
/**
131-
* @param string $key
138+
* @param string $key
132139
* @return void
133140
*/
134141
public function __unset($key)

src/Mutators/EncryptStringMutator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class EncryptStringMutator implements MutatorContract
1313
protected $encrypt;
1414

1515
/**
16-
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypt
16+
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypt
1717
*/
1818
public function __construct(Encrypter $encrypt)
1919
{

src/Mutators/IpBinaryMutator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class IpBinaryMutator implements MutatorContract
66
{
77
/**
8-
* @param mixed $value
8+
* @param mixed $value
99
* @return string
1010
*/
1111
public function serializeAttribute($value)
@@ -14,7 +14,7 @@ public function serializeAttribute($value)
1414
}
1515

1616
/**
17-
* @param mixed $value
17+
* @param mixed $value
1818
* @return bool|string
1919
*/
2020
public function unserializeAttribute($value)

0 commit comments

Comments
 (0)