From 57976c102c1e96ba33354bd03e1cd105b3c00ec2 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:55:53 +0100 Subject: [PATCH 01/10] (feat) initial version --- .github/workflows/badges.yml | 72 --- README.md | 68 +-- composer.json | 6 +- composer.lock | 685 ++++++++++++++++++++++++- config/skeleton-package.php | 25 - configure.php | 154 ------ resources/views/example.blade.php | 1 - src/Bootstrap/LoadConfiguration.php | 39 ++ src/Console/ExampleCommand.php | 35 -- src/DefaultProviders.php | 28 + src/Example.php | 47 -- src/Facades/Example.php | 22 - src/ServiceProvider.php | 18 + src/SkeletonPackageServiceProvider.php | 31 -- src/View/ViewServiceProvider.php | 23 + 15 files changed, 803 insertions(+), 451 deletions(-) delete mode 100644 .github/workflows/badges.yml delete mode 100644 config/skeleton-package.php delete mode 100644 configure.php delete mode 100644 resources/views/example.blade.php create mode 100644 src/Bootstrap/LoadConfiguration.php delete mode 100644 src/Console/ExampleCommand.php create mode 100644 src/DefaultProviders.php delete mode 100644 src/Example.php delete mode 100644 src/Facades/Example.php create mode 100644 src/ServiceProvider.php delete mode 100644 src/SkeletonPackageServiceProvider.php create mode 100644 src/View/ViewServiceProvider.php diff --git a/.github/workflows/badges.yml b/.github/workflows/badges.yml deleted file mode 100644 index 09f2bea..0000000 --- a/.github/workflows/badges.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Create badges - -on: - release: - types: [published] - workflow_dispatch: - -permissions: - contents: write - pull-requests: write - -jobs: - badges: - name: Create badges - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@2.31.1 - with: - php-version: '8.1' - extensions: simplexml, dom, xml, xdebug, intl - tools: composer:v2 - env: - COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }} - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --prefer-dist - - - name: Recreate autoload file - run: composer dump-autoload - - - name: Run Unit Tests - run: XDEBUG_MODE_COVERAGE=coverage vendor/bin/pest --coverage-clover=clover.xml - - - name: Make lines of code badge - uses: DeathSy/GHA-LoC-Badge@1.0.3 - id: badge - with: - debug: true - directory: ./src - patterns: '**/*.php' - badge: ./output/lines-of-code.svg - - - name: Make code coverage badge - uses: timkrase/phpunit-coverage-badge@v1.2.1 - with: - coverage_badge_path: output/coverage.svg - push_badge: false - - - name: Git push to badges branch - uses: peaceiris/actions-gh-pages@v4 - with: - publish_dir: ./output - publish_branch: badges - github_token: ${{ secrets.GITHUB_TOKEN }} - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' diff --git a/README.md b/README.md index a406754..5215bb3 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,17 @@ -# Yard :package_name +# Yard Brave Child [![Code Style](https://github.com/yardinternet/skeleton-package/actions/workflows/format-php.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/format-php.yml) [![PHPStan](https://github.com/yardinternet/skeleton-package/actions/workflows/phpstan.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/phpstan.yml) -[![Tests](https://github.com/yardinternet/skeleton-package/actions/workflows/run-tests.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/run-tests.yml) -[![Code Coverage Badge](https://github.com/yardinternet/skeleton-package/blob/badges/coverage.svg)](https://github.com/yardinternet/skeleton-package/actions/workflows/badges.yml) -[![Lines of Code Badge](https://github.com/yardinternet/skeleton-package/blob/badges/lines-of-code.svg)](https://github.com/yardinternet/skeleton-package/actions/workflows/badges.yml) + + - ---- -This repository provides a scaffold for creating an Acorn package. For more detailed information, please refer to the [Acorn Package Development](https://roots.io/acorn/docs/package-development/) documentation. +Classes to use Acorn with child themes: -Follow these steps to get started: - -1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton. -2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files. -3. Have fun creating your package. - ---- - +- WP like inheritance for config files; child config will override parent config +- No directory scans, everything is config base ## Requirements -- [Sage](https://github.com/roots/sage) >= 10.0 - [Acorn](https://github.com/roots/acorn) >= 4.0 ## Installation @@ -33,38 +23,50 @@ To install this package using Composer, follow these steps: ```json { "type": "vcs", - "url": "git@github.com:yardinternet/skeleton-package.git" + "url": "git@github.com:yardinternet/brave-child.git" } ``` 2. Install this package with Composer: ```sh - composer require yard/skeleton-package + composer require yard/brave-child ``` -3. Run the Acorn WP-CLI command to discover this package: - - ```shell - wp acorn package:discover - ``` +## Configuration -You can publish the config file with: +Add the following line to your config: -```shell -wp acorn vendor:publish --provider="Yard\SkeletonPackage\SkeletonPackageServiceProvider" +```php +Config::define('ACORN_BASEPATH', Config::get('WP_CONTENT_DIR') . '/themes/sage'); ``` -## Usage +In `sage/config/app.php` change: + +```diff +-use Roots\Acorn\ServiceProvider; ++use Yard\BraveChild\ServiceProvider; +``` -From a Blade template: +In `sage/functions.php` change: -```blade -@include('skeleton-package::example') +```diff +-\Roots\Bootloader()->boot(); ++$bootloader = \Roots\bootloader(); ++$bootloader->getApplication()->bind( ++ \Roots\Acorn\Bootstrap\LoadConfiguration::class, ++ \Yare\BraveChild\Bootstrap\LoadConfiguration::class ++); ++$bootloader->boot(); ``` -From WP-CLI: +Add any view composers you have to `config/view.php`: -```shell -wp acorn example +```diff +- 'composers' => [], ++ 'composers => [ ++ 'app' => App\View\Composers\App::class, ++ 'comments' => App\View\Composers\Comments::class, ++ 'post' => App\View\Composers\Post::class, ++ ], ``` diff --git a/composer.json b/composer.json index 3528b51..4eaace1 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require": { "php": ">=8.1", - "spatie/laravel-package-tools": "^1.16" + "roots/acorn": "^4.3" }, "require-dev": { "10up/wp_mock": "^0.4.2", @@ -26,12 +26,12 @@ }, "autoload": { "psr-4": { - "Yard\\SkeletonPackage\\": "src/" + "Yard\\BraveChild\\": "src/" } }, "autoload-dev": { "psr-4": { - "Yard\\SkeletonPackage\\Tests\\": "tests/" + "Yard\\BraveChild\\Tests\\": "tests/" } }, "scripts": { diff --git a/composer.lock b/composer.lock index e2cde94..39db02a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "83278427e5ce0eeccfa9dbbaf2a13f18", + "content-hash": "aabe11df2ef902a58d78a48f4cfe3035", "packages": [ { "name": "brick/math", @@ -643,6 +643,331 @@ ], "time": "2024-07-20T21:45:45+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2024-07-24T11:22:20+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2024-10-17T10:06:22+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2024-07-18T11:15:46+00:00" + }, { "name": "guzzlehttp/uri-template", "version": "v1.0.3", @@ -2100,6 +2425,166 @@ }, "time": "2019-01-08T18:20:26+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, { "name": "psr/log", "version": "3.0.2", @@ -2201,6 +2686,50 @@ }, "time": "2021-10-29T13:26:27+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "ramsey/collection", "version": "2.0.0", @@ -2383,34 +2912,77 @@ "time": "2024-04-27T21:32:50+00:00" }, { - "name": "spatie/laravel-package-tools", - "version": "1.16.6", + "name": "roots/acorn", + "version": "v4.3.1", "source": { "type": "git", - "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "1f26942dc1e5c49eacfced34fdbc29ed234bd7b3" + "url": "https://github.com/roots/acorn.git", + "reference": "3c6040dcad79446be94e03fd2f09321fd581e40b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/1f26942dc1e5c49eacfced34fdbc29ed234bd7b3", - "reference": "1f26942dc1e5c49eacfced34fdbc29ed234bd7b3", + "url": "https://api.github.com/repos/roots/acorn/zipball/3c6040dcad79446be94e03fd2f09321fd581e40b", + "reference": "3c6040dcad79446be94e03fd2f09321fd581e40b", "shasum": "" }, "require": { - "illuminate/contracts": "^9.28|^10.0|^11.0", - "php": "^8.0" + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^7.8", + "illuminate/cache": "^10.43", + "illuminate/config": "^10.43", + "illuminate/console": "^10.43", + "illuminate/container": "^10.43", + "illuminate/contracts": "^10.43", + "illuminate/database": "^10.43", + "illuminate/encryption": "^10.43", + "illuminate/events": "^10.43", + "illuminate/filesystem": "^10.43", + "illuminate/http": "^10.43", + "illuminate/log": "^10.43", + "illuminate/queue": "^10.43", + "illuminate/routing": "^10.43", + "illuminate/support": "^10.43", + "illuminate/validation": "^10.43", + "illuminate/view": "^10.43", + "laravel/prompts": "^0.1.7", + "laravel/serializable-closure": "^1.3", + "league/flysystem": "^3.8", + "php": ">=8.1", + "ramsey/uuid": "^4.7", + "roots/support": "^1.0", + "symfony/error-handler": "^6.2", + "symfony/var-dumper": "^6.2", + "vlucas/phpdotenv": "^5.4.1" }, "require-dev": { - "mockery/mockery": "^1.5", - "orchestra/testbench": "^7.7|^8.0", - "pestphp/pest": "^1.22", - "phpunit/phpunit": "^9.5.24", - "spatie/pest-plugin-test-time": "^1.1" + "laravel/pint": "1.14", + "mockery/mockery": "^1.6", + "pestphp/pest": "^2.25", + "phpcompatibility/php-compatibility": "^9.3", + "roave/security-advisories": "dev-master", + "spatie/laravel-ignition": "^2.1", + "spatie/pest-plugin-snapshots": "^2.1", + "spatie/temporary-directory": "^2.0", + "tmarsteel/mockery-callable-mock": "^2.1", + "wp-cli/wp-cli": "^2.5" + }, + "suggest": { + "roots/acorn-prettify": "A collection of modules to apply theme-agnostic front-end modifications (^1.0).", + "spatie/laravel-ignition": "A beautiful error page for development (^2.0)." }, + "bin": [ + "bin/acorn" + ], "type": "library", "autoload": { + "files": [ + "src/Roots/helpers.php", + "src/Roots/globals.php" + ], "psr-4": { - "Spatie\\LaravelPackageTools\\": "src" + "Roots\\": "src/Roots/", + "Illuminate\\": "src/Illuminate/" } }, "notification-url": "https://packagist.org/downloads/", @@ -2419,28 +2991,85 @@ ], "authors": [ { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "role": "Developer" + "name": "QWp6t", + "email": "hi@qwp6t.me" + }, + { + "name": "Brandon Nifong", + "email": "brandon@tendency.me" } ], - "description": "Tools for creating Laravel packages", - "homepage": "https://github.com/spatie/laravel-package-tools", + "description": "Framework for Roots WordPress projects built with Laravel components.", + "homepage": "https://roots.io/acorn/", "keywords": [ - "laravel-package-tools", - "spatie" + "laravel", + "livewire", + "sage", + "wordpress" + ], + "support": { + "forum": "https://discourse.roots.io/", + "issues": "https://github.com/roots/acorn/issues", + "source": "https://github.com/roots/acorn/tree/v4.3.1" + }, + "funding": [ + { + "url": "https://github.com/roots", + "type": "github" + } + ], + "time": "2024-11-06T22:33:56+00:00" + }, + { + "name": "roots/support", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/roots/support.git", + "reference": "e1b76fb2feb806e195833b125b6d23d598a88bb3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roots/support/zipball/e1b76fb2feb806e195833b125b6d23d598a88bb3", + "reference": "e1b76fb2feb806e195833b125b6d23d598a88bb3", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "phpunit/phpunit": "^7.2", + "squizlabs/php_codesniffer": "^3.3" + }, + "type": "library", + "autoload": { + "files": [ + "helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "QWp6t", + "email": "hi@qwp6t.me" + } ], + "homepage": "https://github.com/roots/support/", "support": { - "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.6" + "forum": "https://discourse.roots.io/", + "issues": "https://github.com/roots/support/issues", + "source": "https://github.com/roots/support/tree/v1.0.1" }, "funding": [ { - "url": "https://github.com/spatie", + "url": "https://github.com/roots", "type": "github" } ], - "time": "2024-11-18T15:02:02+00:00" + "time": "2024-05-08T21:05:03+00:00" }, { "name": "symfony/console", @@ -10088,13 +10717,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=8.1" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.1" }, diff --git a/config/skeleton-package.php b/config/skeleton-package.php deleted file mode 100644 index da27760..0000000 --- a/config/skeleton-package.php +++ /dev/null @@ -1,25 +0,0 @@ - [ - 'For every Sage there is an Acorn.', - ], -]; diff --git a/configure.php b/configure.php deleted file mode 100644 index 451eace..0000000 --- a/configure.php +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env php -.*/s', '', $contents) ?: $contents - ); -} - -$currentDirectory = getcwd(); -$folderName = basename($currentDirectory); - -$packageName = ask('Package name', $folderName); -$packageSlug = slugify($packageName); - -$nameSpace = title_case($packageName); -$nameSpace = ask('Namespace', $nameSpace); -$className = ask('Class name', $nameSpace); -$classSlug = slugify($className); -$className = title_case($className); - -$description = ask('Package description', "This is my package {$packageName}"); - -writeln('------'); -writeln("Package : {$packageSlug} <{$description}>"); -writeln("Namespace : Yard\\{$nameSpace}"); -writeln("Class name : {$className}"); -writeln('------'); - -writeln('This script will replace the above values in all relevant files in the project directory.'); - -if (! confirm('Modify files?', true)) { - exit(1); -} - -$files = (str_starts_with(strtoupper(PHP_OS), 'WIN') ? replaceForWindows() : replaceForAllOtherOSes()); - -foreach ($files as $file) { - replace_in_file($file, [ - ':package_name' => $packageName, - 'skeleton-package' => $packageSlug, - 'Example' => $className, - 'SkeletonPackage' => $nameSpace, - 'example' => $classSlug, - ':package_description' => $description, - ]); - - match (true) { - str_contains($file, determineSeparator('src/Example.php')) => rename($file, determineSeparator('./src/'.$className.'.php')), - str_contains($file, determineSeparator('src/SkeletonPackageServiceProvider.php')) => rename($file, determineSeparator('./src/'.$nameSpace.'ServiceProvider.php')), - str_contains($file, determineSeparator('src/Console/ExampleCommand.php')) => rename($file, determineSeparator('./src/Console/'.$className.'Command.php')), - str_contains($file, determineSeparator('src/Facades/Example.php')) => rename($file, determineSeparator('./src/Facades/'.$className.'.php')), - str_contains($file, determineSeparator('resources/views/example.blade.php')) => rename($file, determineSeparator('./resources/views/'.$classSlug.'.blade.php')), - str_contains($file, determineSeparator('tests/ExampleTest.php')) => rename($file, determineSeparator('./tests/'.$className.'Test.php')), - str_contains($file, determineSeparator('tests/Console/ExampleCommandTest.php')) => rename($file, determineSeparator('./tests/Console/'.$className.'CommandTest.php')), - str_contains($file, determineSeparator('tests/Facades/ExampleTest.php')) => rename($file, determineSeparator('./tests/Facades/'.$className.'Test.php')), - str_contains($file, 'README.md') => remove_readme_paragraphs($file), - default => [], - }; -} - -rename(determineSeparator('./config/skeleton-package.php'), determineSeparator('./config/'.$packageSlug.'.php')); - -confirm('Execute `composer install`?') && run('composer install'); - -confirm('Let this script delete itself?', true) && unlink(__FILE__); diff --git a/resources/views/example.blade.php b/resources/views/example.blade.php deleted file mode 100644 index 04201f8..0000000 --- a/resources/views/example.blade.php +++ /dev/null @@ -1 +0,0 @@ -{{ Example::getQuote() }} diff --git a/src/Bootstrap/LoadConfiguration.php b/src/Bootstrap/LoadConfiguration.php new file mode 100644 index 0000000..0c21da6 --- /dev/null +++ b/src/Bootstrap/LoadConfiguration.php @@ -0,0 +1,39 @@ +useConfigPath(get_stylesheet_directory() . '/config'); + + $this->loadChildConfigurationFiles($childApp, $app['config']); + } + + public function loadChildConfigurationFiles(Application $app, RepositoryContract $repository) + { + $files = $this->getConfigurationFiles($app); + + if (! isset($files['app']) && ! $repository->has('app')) { + $repository->set('app', require dirname(__DIR__, 4).'/config/app.php'); + } + + foreach ($files as $key => $path) { + $repository->set($key, require $path); + } + } +} diff --git a/src/Console/ExampleCommand.php b/src/Console/ExampleCommand.php deleted file mode 100644 index 54cddd8..0000000 --- a/src/Console/ExampleCommand.php +++ /dev/null @@ -1,35 +0,0 @@ -info( - Example::getQuote() - ); - } -} diff --git a/src/DefaultProviders.php b/src/DefaultProviders.php new file mode 100644 index 0000000..b11b41f --- /dev/null +++ b/src/DefaultProviders.php @@ -0,0 +1,28 @@ + \Yard\BraveChild\View\ViewServiceProvider::class, + ]; + + public function __construct(?array $providers = null) + { + $this->acornProviders = array_map( + fn (string $provider): string => str_replace( + array_keys($this->acornProvidersReplacements), + array_values($this->acornProvidersReplacements), + $provider + ), + $this->acornProviders + ); + + parent::__construct($providers); + } +} diff --git a/src/Example.php b/src/Example.php deleted file mode 100644 index 4bec4f3..0000000 --- a/src/Example.php +++ /dev/null @@ -1,47 +0,0 @@ -post_content : 'Post not found'; - } -} diff --git a/src/Facades/Example.php b/src/Facades/Example.php deleted file mode 100644 index d99897b..0000000 --- a/src/Facades/Example.php +++ /dev/null @@ -1,22 +0,0 @@ -name('skeleton-package') - ->hasConfigFile() - ->hasViews() - ->hasCommand(ExampleCommand::class); - } - - public function packageRegistered(): void - { - $this->app->singleton('Example', fn () => new Example($this->app)); - } - - public function packageBooted(): void - { - $this->app->make('Example'); - } -} diff --git a/src/View/ViewServiceProvider.php b/src/View/ViewServiceProvider.php new file mode 100644 index 0000000..296f8e7 --- /dev/null +++ b/src/View/ViewServiceProvider.php @@ -0,0 +1,23 @@ +app->config['view.composers']; + + if (is_array($composers) && Arr::isAssoc($composers)) { + foreach ($composers as $composer) { + $this->view()->composer($composer::views(), $composer); + } + } + } +} From e041a07d3c5d1632ae09a76580594ccea612a75f Mon Sep 17 00:00:00 2001 From: ictbeheer Date: Tue, 26 Nov 2024 12:57:21 +0000 Subject: [PATCH 02/10] (auto): apply php-cs-fixer changes --- src/ServiceProvider.php | 20 +++++++++++--------- src/View/ViewServiceProvider.php | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index cd30e21..f9e4b6a 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -1,18 +1,20 @@ app->config['view.composers']; From 770b6525c1649a22c0ac909ce7d4c15031ff5945 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:06:17 +0100 Subject: [PATCH 03/10] (feat) merge config from parent and child --- src/Bootstrap/LoadConfiguration.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Bootstrap/LoadConfiguration.php b/src/Bootstrap/LoadConfiguration.php index 0c21da6..e920420 100644 --- a/src/Bootstrap/LoadConfiguration.php +++ b/src/Bootstrap/LoadConfiguration.php @@ -33,7 +33,9 @@ public function loadChildConfigurationFiles(Application $app, RepositoryContract } foreach ($files as $key => $path) { - $repository->set($key, require $path); + $repository->set($key, array_merge( + require $path, $repository->get($key, []) + )); } } } From 602f2062f062e2b8a80737d0ea1d74c57cf5361c Mon Sep 17 00:00:00 2001 From: ictbeheer Date: Thu, 28 Nov 2024 09:06:48 +0000 Subject: [PATCH 04/10] (auto): apply php-cs-fixer changes --- src/Bootstrap/LoadConfiguration.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bootstrap/LoadConfiguration.php b/src/Bootstrap/LoadConfiguration.php index e920420..02f1908 100644 --- a/src/Bootstrap/LoadConfiguration.php +++ b/src/Bootstrap/LoadConfiguration.php @@ -34,8 +34,9 @@ public function loadChildConfigurationFiles(Application $app, RepositoryContract foreach ($files as $key => $path) { $repository->set($key, array_merge( - require $path, $repository->get($key, []) - )); + require $path, + $repository->get($key, []) + )); } } } From 77899ac91f7943d171ac2f8adbd079585e0271c9 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:20:26 +0100 Subject: [PATCH 05/10] (chore) update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4eaace1..d39ec3b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "yard/skeleton-package", + "name": "yard/brave-child", "type": "package", - "description": ":package_description", + "description": "Package to enable Acorn in child thems", "license": "MIT", "config": { "sort-packages": true, From bb69840a02f6ff701557e526440ece7daa42e120 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:20:34 +0100 Subject: [PATCH 06/10] (feat) update readme --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5215bb3..f9ae886 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Classes to use Acorn with child themes: - WP like inheritance for config files; child config will override parent config -- No directory scans, everything is config base +- No directory scans, everything is config based ## Requirements @@ -35,32 +35,66 @@ To install this package using Composer, follow these steps: ## Configuration -Add the following line to your config: +1. Create a child theme with sage as the parent theme +[How To Create A Child Theme | Wordpress.org](https://developer.wordpress.org/themes/advanced-topics/child-themes/#how-to-create-a-child-theme) Example `style.css`: + +```css +/** + * Theme Name: Sage Child Theme + * Template: sage + * Theme URI: https://www.example.com/sage-child/ + * Description: Sage child theme + * Version: 1.0.0 + * Author: Example Inc. + * Author URI: http://www.example.com/ + * Text Domain: sage + * License: MIT License + * License URI: https://opensource.org/licenses/MIT + * Requires PHP: 8.1 + * Requires at least: 5.9 + */ +``` + +2. Add PSR-4 autoloading for your child theme to your composer.json: + +```diff +"autoload": { + "psr-4": { + "App\\": "web/app/themes/sage/app/", ++ "Child\\App\\": "web/app/themes/child-theme/app/", + } +}, +``` + +3. Add the following line to your config: ```php Config::define('ACORN_BASEPATH', Config::get('WP_CONTENT_DIR') . '/themes/sage'); ``` -In `sage/config/app.php` change: +4. In `sage/config/app.php` change: ```diff -use Roots\Acorn\ServiceProvider; +use Yard\BraveChild\ServiceProvider; ``` -In `sage/functions.php` change: +5. In `sage/functions.php` change: ```diff -\Roots\Bootloader()->boot(); +$bootloader = \Roots\bootloader(); +$bootloader->getApplication()->bind( + \Roots\Acorn\Bootstrap\LoadConfiguration::class, -+ \Yare\BraveChild\Bootstrap\LoadConfiguration::class ++ \Yard\BraveChild\Bootstrap\LoadConfiguration::class +); +$bootloader->boot(); ``` -Add any view composers you have to `config/view.php`: +6. Add view composers to `config/view.php` + +> [!IMPORTANT] +> After this change, View Composers in the app/View/Composers directory will no longer be loaded automatically. To ensure they are registered, you have to configure them manually. ```diff - 'composers' => [], @@ -70,3 +104,4 @@ Add any view composers you have to `config/view.php`: + 'post' => App\View\Composers\Post::class, + ], ``` + From b561ec517b61e62c052ff20929e7d0b3efa48193 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:05:21 +0100 Subject: [PATCH 07/10] (chore) fix markdown --- README.md | 105 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index f9ae886..c2dbf85 100644 --- a/README.md +++ b/README.md @@ -36,72 +36,71 @@ To install this package using Composer, follow these steps: ## Configuration 1. Create a child theme with sage as the parent theme -[How To Create A Child Theme | Wordpress.org](https://developer.wordpress.org/themes/advanced-topics/child-themes/#how-to-create-a-child-theme) Example `style.css`: - -```css -/** - * Theme Name: Sage Child Theme - * Template: sage - * Theme URI: https://www.example.com/sage-child/ - * Description: Sage child theme - * Version: 1.0.0 - * Author: Example Inc. - * Author URI: http://www.example.com/ - * Text Domain: sage - * License: MIT License - * License URI: https://opensource.org/licenses/MIT - * Requires PHP: 8.1 - * Requires at least: 5.9 - */ -``` + [How To Create A Child Theme | Wordpress.org](https://developer.wordpress.org/themes/advanced-topics/child-themes/#how-to-create-a-child-theme) Example `style.css`: + + ```css + /** + * Theme Name: Sage Child Theme + * Template: sage + * Theme URI: https://www.example.com/sage-child/ + * Description: Sage child theme + * Version: 1.0.0 + * Author: Example Inc. + * Author URI: http://www.example.com/ + * Text Domain: sage + * License: MIT License + * License URI: https://opensource.org/licenses/MIT + * Requires PHP: 8.1 + * Requires at least: 5.9 + */ + ``` 2. Add PSR-4 autoloading for your child theme to your composer.json: -```diff -"autoload": { - "psr-4": { - "App\\": "web/app/themes/sage/app/", -+ "Child\\App\\": "web/app/themes/child-theme/app/", - } -}, -``` + ```diff + "autoload": { + "psr-4": { + "App\\": "web/app/themes/sage/app/", + + "Child\\App\\": "web/app/themes/child-theme/app/", + } + }, + ``` 3. Add the following line to your config: -```php -Config::define('ACORN_BASEPATH', Config::get('WP_CONTENT_DIR') . '/themes/sage'); -``` + ```php + Config::define('ACORN_BASEPATH', Config::get('WP_CONTENT_DIR') . '/themes/sage'); + ``` 4. In `sage/config/app.php` change: -```diff --use Roots\Acorn\ServiceProvider; -+use Yard\BraveChild\ServiceProvider; -``` + ```diff + -use Roots\Acorn\ServiceProvider; + +use Yard\BraveChild\ServiceProvider; + ``` 5. In `sage/functions.php` change: -```diff --\Roots\Bootloader()->boot(); -+$bootloader = \Roots\bootloader(); -+$bootloader->getApplication()->bind( -+ \Roots\Acorn\Bootstrap\LoadConfiguration::class, -+ \Yard\BraveChild\Bootstrap\LoadConfiguration::class -+); -+$bootloader->boot(); -``` + ```diff + -\Roots\Bootloader()->boot(); + +$bootloader = \Roots\bootloader(); + +$bootloader->getApplication()->bind( + + \Roots\Acorn\Bootstrap\LoadConfiguration::class, + + \Yard\BraveChild\Bootstrap\LoadConfiguration::class + +); + +$bootloader->boot(); + ``` 6. Add view composers to `config/view.php` -> [!IMPORTANT] -> After this change, View Composers in the app/View/Composers directory will no longer be loaded automatically. To ensure they are registered, you have to configure them manually. - -```diff -- 'composers' => [], -+ 'composers => [ -+ 'app' => App\View\Composers\App::class, -+ 'comments' => App\View\Composers\Comments::class, -+ 'post' => App\View\Composers\Post::class, -+ ], -``` + > [!IMPORTANT] + > After this change, View Composers in the app/View/Composers directory will no longer be loaded automatically. To ensure they are registered, you have to configure them manually. + ```diff + - 'composers' => [], + + 'composers => [ + + 'app' => App\View\Composers\App::class, + + 'comments' => App\View\Composers\Comments::class, + + 'post' => App\View\Composers\Post::class, + + ], + ``` From 640b38a1c56b53a330c756cc162cd677bea507f6 Mon Sep 17 00:00:00 2001 From: Maarten Bruna <14947039+ictbeheer@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:14:44 +0100 Subject: [PATCH 08/10] (chore) remove tests --- .github/workflows/run-tests.yml | 20 --------------- tests/Console/ExampleCommandTest.php | 9 ------- tests/ExampleTest.php | 24 ------------------ tests/Facades/ExampleTest.php | 11 -------- tests/Pest.php | 7 ----- tests/TestCase.php | 38 ---------------------------- tests/bootstrap.php | 8 ------ 7 files changed, 117 deletions(-) delete mode 100644 .github/workflows/run-tests.yml delete mode 100644 tests/Console/ExampleCommandTest.php delete mode 100644 tests/ExampleTest.php delete mode 100644 tests/Facades/ExampleTest.php delete mode 100644 tests/Pest.php delete mode 100644 tests/TestCase.php delete mode 100644 tests/bootstrap.php diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 965e03d..0000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Tests - -on: - pull_request: - paths: - - '**.php' - - '.github/workflows/run-tests.yml' - - 'phpunit.xml.dist' - - 'composer.json' - - 'composer.lock' - workflow_dispatch: - -jobs: - test: - uses: yardinternet/workflows/.github/workflows/run-laravel-testbench-tests.yml@main - with: - php-versions: '["8.1","8.2"]' - laravel-versions: '["10.*"]' - testbench-versions: '["8.*"]' - secrets: inherit diff --git a/tests/Console/ExampleCommandTest.php b/tests/Console/ExampleCommandTest.php deleted file mode 100644 index a5bd064..0000000 --- a/tests/Console/ExampleCommandTest.php +++ /dev/null @@ -1,9 +0,0 @@ -artisan('example') - ->expectsOutput('For every Sage there is an Acorn.') - ->assertExitCode(0); -}); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php deleted file mode 100644 index 0e02ea9..0000000 --- a/tests/ExampleTest.php +++ /dev/null @@ -1,24 +0,0 @@ -make('Example')->getQuote(); - - expect($quote)->tobe('For every Sage there is an Acorn.'); -}); - -it('can retrieve post content', function () { - $postId = 123; - $post = new stdClass(); - $post->post_content = 'Hello World!'; - - WP_Mock::userFunction('get_post') - ->once() - ->with(123) - ->andReturn($post); - - $postContent = app()->make('Example')->getPostContent($postId); - - expect($postContent)->tobe('Hello World!'); -}); diff --git a/tests/Facades/ExampleTest.php b/tests/Facades/ExampleTest.php deleted file mode 100644 index 5f7a602..0000000 --- a/tests/Facades/ExampleTest.php +++ /dev/null @@ -1,11 +0,0 @@ -tobe('For every Sage there is an Acorn.'); -}); diff --git a/tests/Pest.php b/tests/Pest.php deleted file mode 100644 index 099c3bd..0000000 --- a/tests/Pest.php +++ /dev/null @@ -1,7 +0,0 @@ -in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php deleted file mode 100644 index 612ef40..0000000 --- a/tests/TestCase.php +++ /dev/null @@ -1,38 +0,0 @@ -> - */ - protected function getPackageProviders($app) - { - return [ - 'Yard\SkeletonPackage\SkeletonPackageServiceProvider', - ]; - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index ea6c2de..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,8 +0,0 @@ - Date: Wed, 4 Dec 2024 14:23:59 +0100 Subject: [PATCH 09/10] (chore) fix PHPstan errors --- composer.json | 2 +- src/Bootstrap/LoadConfiguration.php | 11 ++++++----- src/DefaultProviders.php | 6 ++++++ src/View/ViewServiceProvider.php | 5 ++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index d39ec3b..fe5ec2b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "yard/brave-child", "type": "package", - "description": "Package to enable Acorn in child thems", + "description": "Package to enable Acorn in child themes", "license": "MIT", "config": { "sort-packages": true, diff --git a/src/Bootstrap/LoadConfiguration.php b/src/Bootstrap/LoadConfiguration.php index 02f1908..2c924c9 100644 --- a/src/Bootstrap/LoadConfiguration.php +++ b/src/Bootstrap/LoadConfiguration.php @@ -5,26 +5,27 @@ namespace Yard\BraveChild\Bootstrap; use Illuminate\Contracts\Config\Repository as RepositoryContract; -use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Foundation\Application as ApplicationContract; +use Illuminate\Foundation\Application; use Roots\Acorn\Bootstrap\LoadConfiguration as AcornLoadConfiguration; class LoadConfiguration extends AcornLoadConfiguration { - public function bootstrap(Application $app) + public function bootstrap(ApplicationContract $app) { parent::bootstrap($app); if (! is_child_theme()) { return; } - + /** @var Application*/ $childApp = clone $app; $childApp->useConfigPath(get_stylesheet_directory() . '/config'); - $this->loadChildConfigurationFiles($childApp, $app['config']); + $this->loadChildConfigurationFiles($childApp, $app->get('config')); } - public function loadChildConfigurationFiles(Application $app, RepositoryContract $repository) + public function loadChildConfigurationFiles(Application $app, RepositoryContract $repository): void { $files = $this->getConfigurationFiles($app); diff --git a/src/DefaultProviders.php b/src/DefaultProviders.php index b11b41f..7805057 100644 --- a/src/DefaultProviders.php +++ b/src/DefaultProviders.php @@ -8,10 +8,16 @@ class DefaultProviders extends AcornDefaultProviders { + /** + * @var array $acornProvidersReplacements + */ protected array $acornProvidersReplacements = [ \Roots\Acorn\View\ViewServiceProvider::class => \Yard\BraveChild\View\ViewServiceProvider::class, ]; + /** + * @param array|null $providers + */ public function __construct(?array $providers = null) { $this->acornProviders = array_map( diff --git a/src/View/ViewServiceProvider.php b/src/View/ViewServiceProvider.php index 55c22b9..d96843d 100644 --- a/src/View/ViewServiceProvider.php +++ b/src/View/ViewServiceProvider.php @@ -5,16 +5,19 @@ namespace Yard\BraveChild\View; use Illuminate\Support\Arr; +use Roots\Acorn\View\Composer; use Roots\Acorn\View\ViewServiceProvider as ViewViewServiceProvider; class ViewServiceProvider extends ViewViewServiceProvider { public function attachComposers() { - $composers = $this->app->config['view.composers']; + /** @var array*/ + $composers = $this->app->get('config')->get('view.composers', []); if (is_array($composers) && Arr::isAssoc($composers)) { foreach ($composers as $composer) { + // @phpstan-ignore method.notFound $this->view()->composer($composer::views(), $composer); } } From c698009f065a6402669a966bc168f236c36ebccd Mon Sep 17 00:00:00 2001 From: ictbeheer Date: Wed, 4 Dec 2024 13:24:29 +0000 Subject: [PATCH 10/10] (auto): apply php-cs-fixer changes --- src/Bootstrap/LoadConfiguration.php | 2 +- src/DefaultProviders.php | 2 +- src/View/ViewServiceProvider.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bootstrap/LoadConfiguration.php b/src/Bootstrap/LoadConfiguration.php index 2c924c9..f724528 100644 --- a/src/Bootstrap/LoadConfiguration.php +++ b/src/Bootstrap/LoadConfiguration.php @@ -18,7 +18,7 @@ public function bootstrap(ApplicationContract $app) if (! is_child_theme()) { return; } - /** @var Application*/ + /** @var Application */ $childApp = clone $app; $childApp->useConfigPath(get_stylesheet_directory() . '/config'); diff --git a/src/DefaultProviders.php b/src/DefaultProviders.php index 7805057..389d0f4 100644 --- a/src/DefaultProviders.php +++ b/src/DefaultProviders.php @@ -9,7 +9,7 @@ class DefaultProviders extends AcornDefaultProviders { /** - * @var array $acornProvidersReplacements + * @var array */ protected array $acornProvidersReplacements = [ \Roots\Acorn\View\ViewServiceProvider::class => \Yard\BraveChild\View\ViewServiceProvider::class, diff --git a/src/View/ViewServiceProvider.php b/src/View/ViewServiceProvider.php index d96843d..57bee87 100644 --- a/src/View/ViewServiceProvider.php +++ b/src/View/ViewServiceProvider.php @@ -12,7 +12,7 @@ class ViewServiceProvider extends ViewViewServiceProvider { public function attachComposers() { - /** @var array*/ + /** @var array */ $composers = $this->app->get('config')->get('view.composers', []); if (is_array($composers) && Arr::isAssoc($composers)) {