From dada3067a344aa6a9d413588623d8b7717831593 Mon Sep 17 00:00:00 2001
From: Dobando <1692898084@qq.com>
Date: Sat, 26 Oct 2024 21:57:27 +0800
Subject: [PATCH] BREAKING CHANGE: upgrade to PHP 8.0 and PHP-Casbin 4.0
---
.github/workflows/build.yml | 66 ---------------------------
composer.json | 5 +-
phpunit.10.xml | 42 -----------------
phpunit.xml | 64 ++++++++++++--------------
src/EnforcerManager.php | 8 ++--
tests/DatabaseAdapterForCacheTest.php | 4 +-
6 files changed, 36 insertions(+), 153 deletions(-)
delete mode 100644 phpunit.10.xml
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8dbd181..6afb60b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -27,73 +27,7 @@ jobs:
# laravel: [ ]
# stability: [ prefer-lowest, prefer-stable ]
include:
- # Laravel 5.5
- - php: 7.1
- laravel: 5.5.*
- phpunit: ~6.0
- - php: 7.2
- laravel: 5.5.*
- phpunit: ~6.0
- - php: 7.3
- laravel: 5.5.*
- phpunit: ~6.0
-
- # Laravel 5.6
- - php: 7.1
- laravel: 5.6.*
- phpunit: ~7.0
- - php: 7.2
- laravel: 5.6.*
- phpunit: ~7.0
- - php: 7.3
- laravel: 5.6.*
- phpunit: ~7.0
-
- # Laravel 5.7
- - php: 7.1
- laravel: 5.7.*
- phpunit: ~7.5
- - php: 7.2
- laravel: 5.7.*
- phpunit: ~7.5
- - php: 7.3
- laravel: 5.7.*
- phpunit: ~7.5
-
- # Laravel 5.8
- - php: 7.1
- laravel: 5.8.*
- phpunit: ~7.5
- - php: 7.2
- laravel: 5.8.*
- phpunit: ~8.0
- - php: 7.3
- laravel: 5.8.*
- phpunit: ~8.0
-
- # Laravel 6.x
- - php: 7.2
- laravel: 6.*
- phpunit: ~8.0
- - php: 7.3
- laravel: 6.*
- phpunit: ~8.0
-
- # Laravel 7.x
- - php: 7.3
- laravel: 7.*
- phpunit: ~9.0
- - php: 7.4
- laravel: 7.*
- phpunit: ~9.0
-
# Laravel 8.x
- - php: 7.3
- laravel: 8.*
- phpunit: ~9.0
- - php: 7.4
- laravel: 8.*
- phpunit: ~9.0
- php: 8.0
laravel: 8.*
phpunit: ~9.0
diff --git a/composer.json b/composer.json
index 76b38ed..9b5f766 100755
--- a/composer.json
+++ b/composer.json
@@ -20,12 +20,11 @@
],
"license": "Apache-2.0",
"require": {
- "php": ">=7.1.0",
+ "php": ">=8.0",
"illuminate/support": "~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0",
"illuminate/database": "~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0",
"illuminate/console": "~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0",
- "casbin/casbin": "~3.1",
- "casbin/psr3-bridge": "^1.1"
+ "casbin/casbin": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0|~9.0|~10.5",
diff --git a/phpunit.10.xml b/phpunit.10.xml
deleted file mode 100644
index b0bf020..0000000
--- a/phpunit.10.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- ./tests/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 6d45124..dd9f5ee 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,36 +1,30 @@
-
-
-
- ./tests/
-
-
-
-
- ./src
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+ ./tests/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/EnforcerManager.php b/src/EnforcerManager.php
index 0c08164..62e3a47 100755
--- a/src/EnforcerManager.php
+++ b/src/EnforcerManager.php
@@ -2,10 +2,10 @@
namespace Lauthz;
-use Casbin\Bridge\Logger\LoggerBridge;
use Casbin\Enforcer;
use Casbin\Model\Model;
use Casbin\Log\Log;
+use Casbin\Log\Logger\DefaultLogger;
use Lauthz\Contracts\Factory;
use Lauthz\Models\Rule;
use Illuminate\Support\Arr;
@@ -80,10 +80,10 @@ protected function resolve($name)
if ($logger = Arr::get($config, 'log.logger')) {
if (is_string($logger)) {
- $logger = $this->app->make($logger);
+ $logger = new DefaultLogger($this->app->make($logger));
}
- Log::setLogger(new LoggerBridge($logger));
+ Log::setLogger($logger);
}
$model = new Model();
@@ -98,7 +98,7 @@ protected function resolve($name)
]);
}
- return new Enforcer($model, $adapter, Arr::get($config, 'log.enabled', false));
+ return new Enforcer($model, $adapter, $logger, Arr::get($config, 'log.enabled', false));
}
/**
diff --git a/tests/DatabaseAdapterForCacheTest.php b/tests/DatabaseAdapterForCacheTest.php
index dca8d0e..906e095 100644
--- a/tests/DatabaseAdapterForCacheTest.php
+++ b/tests/DatabaseAdapterForCacheTest.php
@@ -2,11 +2,9 @@
namespace Lauthz\Tests;
-use Enforcer;
use Lauthz\Models\Rule;
use Illuminate\Foundation\Testing\DatabaseMigrations;
-use Casbin\Persist\Adapters\Filter;
-use Casbin\Exceptions\InvalidFilterTypeException;
+use Lauthz\Facades\Enforcer;
class DatabaseAdapterForCacheTest extends TestCase
{