diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7722e93..9145f12 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,10 +7,3 @@ updates: time: "08:00" timezone: US/Central open-pull-requests-limit: 10 - ignore: - - dependency-name: spatie/temporary-directory - versions: - - 2.0.0 - - dependency-name: league/flysystem - versions: - - 2.0.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dfba2b5..538df96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: - php: ["8.0"] + php: ['8.0', '8.1'] steps: - name: Checkout the project diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4366e63..d49fbee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.3', '7.4', '8.0'] + php-versions: ['8.0', '8.1'] steps: - name: Checkout @@ -23,9 +23,6 @@ jobs: coverage: xdebug env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Remove incompatible dependencies - run: composer remove pestphp/pest pestphp/pest-plugin-mock spatie/pest-plugin-snapshots --dev --no-interaction - if: matrix.php < 8 - name: Install Composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader --no-dev --no-interaction - name: Cleanup unnecessary files diff --git a/composer.json b/composer.json index 11d5adb..a5dff36 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,7 @@ "phpcompatibility/php-compatibility": "^9.3", "roave/security-advisories": "dev-master", "spatie/pest-plugin-snapshots": "^1.0", - "spatie/temporary-directory": "^1.3", + "spatie/temporary-directory": "^2.0", "squizlabs/php_codesniffer": "^3.5", "tmarsteel/mockery-callable-mock": "^2.1", "wp-cli/wp-cli": "^2.5" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 143d5be..1160676 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,6 @@ - PSR12 with PHP 7.2+ compatibility + PSR12 with PHP 8.0+ compatibility @@ -12,8 +12,8 @@ src/Illuminate/* - - + + acorn.php src/Roots diff --git a/src/Roots/Acorn/Bootloader.php b/src/Roots/Acorn/Bootloader.php index 627569c..6a47b6a 100644 --- a/src/Roots/Acorn/Bootloader.php +++ b/src/Roots/Acorn/Bootloader.php @@ -57,11 +57,7 @@ public static function setInstance(?self $bootloader) */ public static function getInstance(?ApplicationContract $app = null) { - if (static::$instance) { - return static::$instance; - } - - return static::$instance = new static($app); + return static::$instance ??= new static($app); } /** @@ -73,9 +69,7 @@ public function __construct(?ApplicationContract $app = null) { $this->app = $app; - if (! static::$instance) { - static::$instance = $this; - } + static::$instance ??= $this; } /** @@ -232,9 +226,7 @@ protected function bootWordPress(ApplicationContract $app) */ public function getApplication(): ApplicationContract { - if (! $this->app) { - $this->app = new Application($this->basePath(), $this->usePaths()); - } + $this->app ??= new Application($this->basePath(), $this->usePaths()); $this->app->singleton( \Illuminate\Contracts\Http\Kernel::class, @@ -273,27 +265,19 @@ protected function basePath(): string return $this->basePath; } - if (isset($_ENV['APP_BASE_PATH'])) { - return $this->basePath = $_ENV['APP_BASE_PATH']; - } + return $this->basePath = match (true) { + isset($_ENV['APP_BASE_PATH']) => $_ENV['APP_BASE_PATH'], - if (defined('ACORN_BASEPATH')) { - return $this->basePath = constant('ACORN_BASEPATH'); - } + defined('ACORN_BASEPATH') => constant('ACORN_BASEPATH'), - if (is_file($composer_path = get_theme_file_path('composer.json'))) { - return $this->basePath = dirname($composer_path); - } + is_file($composer_path = get_theme_file_path('composer.json')) => dirname($composer_path), - if (is_dir($app_path = get_theme_file_path('app'))) { - return $this->basePath = dirname($app_path); - } + is_dir($app_path = get_theme_file_path('app')) => dirname($app_path), - if ($vendor_path = (new Filesystem())->closest(dirname(__DIR__, 4), 'composer.json')) { - return $this->basePath = dirname($vendor_path); - } + $vendor_path = (new Filesystem())->closest(dirname(__DIR__, 4), 'composer.json') => dirname($vendor_path), - return $this->basePath = dirname(__DIR__, 3); + default => dirname(__DIR__, 3) + }; } /** @@ -383,19 +367,12 @@ protected function findPath($path): string */ protected function fallbackPath(string $path): string { - if ($path === 'storage') { - return $this->fallbackStoragePath(); - } - - if ($path === 'app') { - return $this->basePath() . DIRECTORY_SEPARATOR . 'app'; - } - - if ($path === 'public') { - return $this->basePath() . DIRECTORY_SEPARATOR . 'public'; - } - - return dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . $path; + return match ($path) { + 'storage' => $this->fallbackStoragePath(), + 'app' => $this->basePath() . DIRECTORY_SEPARATOR . 'app', + 'public' => $this->basePath() . DIRECTORY_SEPARATOR . 'public', + default => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . $path, + }; } /** diff --git a/src/Roots/Acorn/Kernel.php b/src/Roots/Acorn/Kernel.php index 49443fd..bcf285f 100644 --- a/src/Roots/Acorn/Kernel.php +++ b/src/Roots/Acorn/Kernel.php @@ -2,6 +2,7 @@ namespace Roots\Acorn; +use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Http\Kernel as KernelContract; class Kernel implements KernelContract diff --git a/src/Roots/Acorn/PackageManifest.php b/src/Roots/Acorn/PackageManifest.php index 870af7a..9326237 100644 --- a/src/Roots/Acorn/PackageManifest.php +++ b/src/Roots/Acorn/PackageManifest.php @@ -2,8 +2,8 @@ namespace Roots\Acorn; -use Illuminate\Contracts\Filesystem\FileNotFoundException; use Exception; +use Illuminate\Contracts\Filesystem\FileNotFoundException; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\PackageManifest as FoundationPackageManifest;