Skip to content

Commit

Permalink
Merge pull request #33 from Weebly/php-8-support
Browse files Browse the repository at this point in the history
PHP 8.x Support
  • Loading branch information
Zain Mehdi authored Aug 26, 2022
2 parents 0f3f7ea + aab32b1 commit 9260fb5
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 60 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
php: [7.2, 7.3, 7.4, 8.0]
php: [7.2, 7.3, 7.4, 8.0, 8.1]
laravel: [6.*, 7.*, 8.*]
include:
- laravel: 6.*
Expand All @@ -37,6 +37,12 @@ jobs:
php: 7.1
- laravel: 8.*
php: 7.2
# Laravel 6 only support PHP <=8.0
- laravel: 6.*
php: 8.1
# Laravel 7 only support PHP <=8.0
- laravel: 7.*
php: 8.1


name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
Expand Down Expand Up @@ -65,3 +71,6 @@ jobs:
run: vendor/bin/phpunit --testsuite Integration
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}

- name: Run PHPStan
run: vendor/bin/phpstan analyze
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
"license": "BSD-2-Clause",
"keywords": ["laravel", "eloquent", "uuid", "encrypt", "database"],
"require": {
"php": ">=7.2",
"php": ">=7.2 || ^8.0",
"ramsey/uuid": "~3.0 || ~4.0",
"illuminate/database": "^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
"illuminate/encryption": "^6.0 || ^7.0 || ^8.0"
"laravel/framework": "^6.0 || ^7.0 || ^8.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^8.0",
"laravel/framework": "8.*",
"orchestra/testbench": "^6.0"
"orchestra/testbench": "^6.0",
"phpstan/phpstan": "^1.8"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 1
paths:
- src
- config
4 changes: 2 additions & 2 deletions src/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function buildDictionary(Collection $results)
/**
* Create a new pivot attachment record.
*
* @param int $id
* @param int $id
* @param bool $timed
* @return array
*/
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function parseIds($value)
* Sync the intermediate tables with a list of IDs or collection of models.
*
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids
* @param bool $detaching
* @param bool $detaching
* @return array
*/
public function sync($ids, $detaching = true)
Expand Down
3 changes: 2 additions & 1 deletion src/Database/EloquentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Weebly\Mutate\Database;

use Closure;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Eloquent\Builder as BaseEloquentBuilder;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\Expression;
Expand Down Expand Up @@ -195,7 +196,7 @@ public function pluck($column, $key = null)
/**
* Get the column name without any table prefix.
*
* @param string $column
* @param string $column
* @return string
*/
protected function getUnqualifiedColumnName($column)
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class Model extends Eloquent
use HasMutators;

/**
* @param string $key
* @param string $key
* @return \Illuminate\Foundation\Application|mixed
*/
public function getAttribute($key)
Expand Down
14 changes: 7 additions & 7 deletions src/Database/Traits/HasMutators.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ trait HasMutators
protected $mutatedCache = [];

/**
* @param string $attribute
* @param mixed $value
* @param string $attribute
* @param mixed $value
* @return \Illuminate\Foundation\Application|mixed
*/
public function serializeAttribute($attribute, $value)
Expand All @@ -39,9 +39,9 @@ public function serializeAttribute($attribute, $value)
}

/**
* @param string $attribute
* @param mixed $value
* @param bool $force
* @param string $attribute
* @param mixed $value
* @param bool $force
* @return mixed
*/
public function unserializeAttribute($attribute, $value, $force = false)
Expand Down Expand Up @@ -73,7 +73,7 @@ public function getMutators()
}

/**
* @param string $attribute
* @param string $attribute
* @return mixed|null
*/
public function getMutator($attribute)
Expand All @@ -84,7 +84,7 @@ public function getMutator($attribute)
}

/**
* @param mixed $attribute
* @param mixed $attribute
* @return bool
*/
public function hasMutator($attribute)
Expand Down
37 changes: 22 additions & 15 deletions src/MutatorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class MutatorProvider implements ArrayAccess
protected $mutators = [];

/**
* @param string $mutator
* @param string $mutator
* @return \Weebly\Mutate\Mutators\MutatorContract
*
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
*/
public function get($mutator)
Expand All @@ -31,8 +32,8 @@ public function get($mutator)
}

/**
* @param string $name
* @param mixed $mutator
* @param string $name
* @param mixed $mutator
* @return $this
*/
public function set($name, $mutator)
Expand All @@ -43,7 +44,7 @@ public function set($name, $mutator)
}

/**
* @param string $mutator
* @param string $mutator
* @return bool
*/
public function exists($mutator)
Expand All @@ -52,7 +53,7 @@ public function exists($mutator)
}

/**
* @param array $mutators
* @param array $mutators
*/
public function registerMutators(array $mutators)
{
Expand All @@ -63,45 +64,51 @@ public function registerMutators(array $mutators)
}

/**
* @param string $offset
* @param string $offset
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return $this->exists($offset);
}

/**
* @param string $offset
* @param string $offset
* @return \Weebly\Mutate\Mutators\MutatorContract
*
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($offset);
}

/**
* @param string $offset
* @param mixed $value
* @param string $offset
* @param mixed $value
* @return \Weebly\Mutate\MutatorProvider
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
return $this->set($offset, $value);
}

/**
* @param string $offset
* @param string $offset
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->mutators[$offset]);
}

/**
* @param string $name
* @param string $name
* @return \Weebly\Mutate\Mutators\MutatorContract
*
* @throws \Weebly\Mutate\Exceptions\MutatorNotFoundException
*/
public function __get($name)
Expand All @@ -110,16 +117,16 @@ public function __get($name)
}

/**
* @param string $name
* @param mixed $value
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
$this->set($name, $value);
}

/**
* @param string $key
* @param string $key
* @return bool
*/
public function __isset($key)
Expand All @@ -128,7 +135,7 @@ public function __isset($key)
}

/**
* @param string $key
* @param string $key
* @return void
*/
public function __unset($key)
Expand Down
2 changes: 1 addition & 1 deletion src/Mutators/EncryptStringMutator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EncryptStringMutator implements MutatorContract
protected $encrypt;

/**
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypt
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypt
*/
public function __construct(Encrypter $encrypt)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Mutators/IpBinaryMutator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class IpBinaryMutator implements MutatorContract
{
/**
* @param mixed $value
* @param mixed $value
* @return string
*/
public function serializeAttribute($value)
Expand All @@ -14,7 +14,7 @@ public function serializeAttribute($value)
}

/**
* @param mixed $value
* @param mixed $value
* @return bool|string
*/
public function unserializeAttribute($value)
Expand Down
4 changes: 2 additions & 2 deletions src/Mutators/MutatorContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
interface MutatorContract
{
/**
* @param mixed $value
* @param mixed $value
*/
public function serializeAttribute($value);

/**
* @param mixed $value
* @param mixed $value
* @return mixed
*/
public function unserializeAttribute($value);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/BelongsToManyMutatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class BelongsToManyMutatedTest extends TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/MutatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class MutatorTest extends TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/PivotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class PivotTest extends TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Mutators/HexBinaryMutatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
class HexBinaryMutatorTest extends TestCase
{
/**
* @param string $hex
* @param string $expected
* @param string $hex
* @param string $expected
* @dataProvider hexProvider
*/
public function testSerialize($hex, $expected)
Expand All @@ -18,8 +18,8 @@ public function testSerialize($hex, $expected)
}

/**
* @param string $expected
* @param string $binary
* @param string $expected
* @param string $binary
* @dataProvider hexProvider
*/
public function testUnserialize($expected, $binary)
Expand Down Expand Up @@ -49,7 +49,7 @@ public function hexProvider()
}

/**
* @param mixed $value
* @param mixed $value
* @dataProvider notHexProvider
*/
public function testWrongFormat($value)
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Mutators/IpBinaryMutatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class IpBinaryMutatorTest extends TestCase
{
/**
* @param string $ip
* @param string $expected
* @param string $ip
* @param string $expected
* @dataProvider readableIpDataProvider
*/
public function testSerializeAttribute($ip, $expected)
Expand All @@ -17,8 +17,8 @@ public function testSerializeAttribute($ip, $expected)
}

/**
* @param string $ip
* @param string $expected
* @param string $ip
* @param string $expected
* @dataProvider packedIpDataProvider
*/
public function testUnserializeAttribute($ip, $expected)
Expand Down
Loading

0 comments on commit 9260fb5

Please sign in to comment.