diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 17a4a65..9330069 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Tests @@ -9,119 +9,119 @@ on: jobs: byte_level: - name: "0️⃣ Byte-level" - runs-on: "ubuntu-latest" + name: 0️⃣ Byte-level + runs-on: ubuntu-latest steps: - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Check file permissions" + - name: Check file permissions run: | - test "$(find . -type f -not -path './.git/*' -executable)" == "" - - name: "Find non-printable ASCII characters" + test $(find . -type f -not -path './.git/*' -executable) == + - name: Find non-printable ASCII characters run: | - ! LC_ALL=C.UTF-8 find ./src -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]" + ! LC_ALL=C.UTF-8 find ./src -type f -name *.php -print0 | xargs -0 -- grep -PHn [^ -~] syntax_errors: - name: "1️⃣ Syntax errors" - runs-on: "ubuntu-latest" + name: 1️⃣ Syntax errors + runs-on: ubuntu-latest steps: - - name: "Set up PHP" - uses: "shivammathur/setup-php@v2" + - name: Set up PHP + uses: shivammathur/setup-php@v2 with: - php-version: "latest" - tools: "parallel-lint" + php-version: latest + tools: parallel-lint - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Validate Composer configuration" - run: "composer validate --strict" + - name: Validate Composer configuration + run: composer validate --strict - - name: "Check source code for syntax errors" - run: "composer exec -- parallel-lint src/" + - name: Check source code for syntax errors + run: composer exec -- parallel-lint src/ unit_tests: - name: "2️⃣ Unit and Feature tests" + name: 2️⃣ Unit and Feature tests needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" + - byte_level + - syntax_errors + runs-on: ubuntu-latest strategy: matrix: php-version: - - "8.0" - - "8.1" - - "8.2" + - 8.1 + - 8.2 + - 8.3 laravel-constraint: - - "9.*" - - "10.*" + - 10.* + - 11.* dependencies: - - "lowest" - - "highest" + - lowest + - highest exclude: - - laravel-constraint: "10.*" - php-version: "8.0" + - laravel-constraint: 11.* + php-version: 8.1 steps: - - name: "Set up PHP" - uses: "shivammathur/setup-php@v2" + - name: Set up PHP + uses: shivammathur/setup-php@v2 with: - php-version: "${{ matrix.php-version }}" - extensions: "mbstring, intl" - coverage: "xdebug" + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl + coverage: xdebug - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Install dependencies" - uses: "ramsey/composer-install@v2" + - name: Install dependencies + uses: ramsey/composer-install@v2 with: - dependency-versions: "${{ matrix.dependencies }}" - composer-options: "--with=laravel/framework:${{ matrix.laravel-constraint }}" + dependency-versions: ${{ matrix.dependencies }} + composer-options: --with=laravel/framework:${{ matrix.laravel-constraint }} - - name: "Execute unit tests" - run: "composer run-script test" + - name: Execute unit tests + run: composer run-script test - - name: "Upload coverage to Codecov" - uses: "codecov/codecov-action@v2" + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 static_analysis: - name: "3️⃣ Static Analysis" + name: 3️⃣ Static Analysis needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" + - byte_level + - syntax_errors + runs-on: ubuntu-latest steps: - - name: "Set up PHP" - uses: "shivammathur/setup-php@v2" + - name: Set up PHP + uses: shivammathur/setup-php@v2 with: - tools: "phpstan" - php-version: "latest" - coverage: "none" + tools: phpstan + php-version: latest + coverage: none - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Install dependencies" - uses: "ramsey/composer-install@v2" + - name: Install dependencies + uses: ramsey/composer-install@v3 - - name: "Execute static analysis" - run: "composer exec -- phpstan analyze -l 5 src/" + - name: Execute static analysis + run: composer exec -- phpstan analyze -l 5 src/ exported_files: - name: "4️⃣ Exported files" + name: 4️⃣ Exported files needs: - - "byte_level" - - "syntax_errors" - runs-on: "ubuntu-latest" + - byte_level + - syntax_errors + runs-on: ubuntu-latest steps: - - name: "Checkout code" - uses: "actions/checkout@v3" + - name: Checkout code + uses: actions/checkout@v4 - - name: "Check exported files" + - name: Check exported files run: | - EXPECTED="LICENSE.md,README.md,composer.json" - CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" --exclude=".stubs" --exclude=".stubs/*" --exclude="stubs" --exclude="stubs/*" --exclude="lang" --exclude="lang/*" --exclude="config" --exclude="config/*" --exclude="database" --exclude="database/*" --exclude="resources" --exclude="resources/*" | paste -s -d ",")" - echo "CURRENT =${CURRENT}" - echo "EXPECTED=${EXPECTED}" - test "${CURRENT}" == "${EXPECTED}" + EXPECTED=LICENSE.md,README.md,composer.json + CURRENT=$(git archive HEAD | tar --list --exclude=src --exclude=src/* --exclude=.stubs --exclude=.stubs/* --exclude=stubs --exclude=stubs/* --exclude=lang --exclude=lang/* --exclude=config --exclude=config/* --exclude=database --exclude=database/* --exclude=resources --exclude=resources/* | paste -s -d ,) + echo CURRENT =${CURRENT} + echo EXPECTED=${EXPECTED} + test ${CURRENT} == ${EXPECTED} diff --git a/README.md b/README.md index 4d1919d..dfb1bc7 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ Your support allows me to keep this package free, up-to-date and maintainable. A ## Requirements -* PHP 8.0 or later -* Laravel 9, 10 or later +* Laravel 10 or later * [Opcache & Preloading enabled](https://www.php.net/manual/en/book.opcache.php) (`ext-zend-opcache`). ## Installation @@ -30,6 +29,8 @@ Require this using Composer into your project composer require laragear/preload ``` +> [!NOTE] +> > This package doesn't require the `ext-zend-opcache` extension to install. Just be sure to have it [enabled in your deployment server](https://www.php.net/manual/en/book.opcache.php). ## What is Preloading? Does it make my app FAST? @@ -47,7 +48,8 @@ opcache.preload = 'www/app/preload.php'; After that, the next time PHP starts, this list of files will be preloaded automatically. -> **Note** +> [!NOTE] +> > If you're behind a shared server, preloading may be not available for your application. Normally, shared servers also share the same PHP process, which configuration (`php.ini`) is not available for configuration. Check your server if you're not sure if Laragear Preload should be installed. ## Usage @@ -66,6 +68,8 @@ php artisan preload:placeholder # opcache.preload = '/www/app/preload.php'; ``` +> [!IMPORTANT] +> > The command won't replace the file if it exists. You can force the operation using `--force`. Add the preload file path in your `php.ini`: @@ -168,6 +172,8 @@ The memory limit, in MegaBytes, of the List. Once this threshold is reached, no For most applications, 32MB is fine, but you may fine-tune it for your project specifically. +> [!NOTE] +> > This is not Opcache memory limit, as its handled separately. #### Job configuration @@ -198,6 +204,8 @@ return [ By default, the script is saved in your project root path, but you can change the filename and path to save it as long PHP has permissions to write on it. Whatever you place it, never do it in a public/accessible directory, like `public` or `storage/app/public`. +> [!IMPORTANT] +> > Double-check your file permissions to avoid failures on production when reading the file. #### Method diff --git a/composer.json b/composer.json index ae8b768..d556575 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Effortlessly make a Preload script for your Laravel application.", "type": "library", "license": "MIT", - "minimum-stability": "stable", + "minimum-stability": "dev", "prefer-stable": true, "keywords": [ "laravel", @@ -21,21 +21,20 @@ } ], "require": { - "php": "8.*", + "php": "^8.1", "ext-json": "*", - "symfony/finder": "6.*", - "illuminate/config": "9.*|10.*", - "illuminate/console": "9.*|10.*", - "illuminate/contracts": "9.*|10.*", - "illuminate/events": "9.*|10.*", - "illuminate/http": "9.*|10.*", - "illuminate/pipeline": "9.*|10.*", - "illuminate/queue": "9.*|10.*", - "illuminate/support": "9.*|10.*" + "symfony/finder": "7.*", + "illuminate/config": "10.*|11.*", + "illuminate/console": "10.*|11.*", + "illuminate/contracts": "10.*|11.*", + "illuminate/events": "10.*|11.*", + "illuminate/http": "10.*|11.*", + "illuminate/pipeline": "10.*|11.*", + "illuminate/queue": "10.*|11.*", + "illuminate/support": "10.*|11.*" }, "require-dev": { - "orchestra/testbench": "^7.22|8.*", - "jetbrains/phpstorm-attributes": "*" + "orchestra/testbench": "8.*|9.*" }, "autoload": { "psr-4": { diff --git a/src/Compiler/Pipes/FireEvent.php b/src/Compiler/Pipes/FireEvent.php index 7e6cde4..3c45c2a 100644 --- a/src/Compiler/Pipes/FireEvent.php +++ b/src/Compiler/Pipes/FireEvent.php @@ -11,8 +11,6 @@ class FireEvent { /** * Create a new pipe instance. - * - * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher */ public function __construct(protected Dispatcher $dispatcher) { @@ -21,10 +19,6 @@ public function __construct(protected Dispatcher $dispatcher) /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Compiler/Pipes/LoadPreloadStub.php b/src/Compiler/Pipes/LoadPreloadStub.php index 2208eef..ca5e421 100644 --- a/src/Compiler/Pipes/LoadPreloadStub.php +++ b/src/Compiler/Pipes/LoadPreloadStub.php @@ -14,8 +14,6 @@ class LoadPreloadStub { /** * Create a new pipe instance. - * - * @param \Illuminate\Filesystem\Filesystem $files */ public function __construct(protected Filesystem $files) { @@ -24,10 +22,6 @@ public function __construct(protected Filesystem $files) /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Compiler/Pipes/UpdateListingConfig.php b/src/Compiler/Pipes/UpdateListingConfig.php index a7df8e8..b4a7802 100644 --- a/src/Compiler/Pipes/UpdateListingConfig.php +++ b/src/Compiler/Pipes/UpdateListingConfig.php @@ -10,8 +10,6 @@ class UpdateListingConfig { /** * Create a new pipe instance. - * - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(protected ConfigContract $config) { @@ -20,10 +18,6 @@ public function __construct(protected ConfigContract $config) /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { @@ -36,9 +30,6 @@ public function handle(Listing $listing, Closure $next): Listing /** * Returns a list of replaceable string with Preload data. - * - * @param \Laragear\Preload\Listing $listing - * @return array */ protected function listConfig(Listing $listing): array { diff --git a/src/Compiler/Pipes/UpdateListingFiles.php b/src/Compiler/Pipes/UpdateListingFiles.php index 04cf25d..d07d161 100644 --- a/src/Compiler/Pipes/UpdateListingFiles.php +++ b/src/Compiler/Pipes/UpdateListingFiles.php @@ -11,10 +11,6 @@ class UpdateListingFiles { /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Compiler/Pipes/UpdateListingStatistics.php b/src/Compiler/Pipes/UpdateListingStatistics.php index d626af0..79c77bf 100644 --- a/src/Compiler/Pipes/UpdateListingStatistics.php +++ b/src/Compiler/Pipes/UpdateListingStatistics.php @@ -15,8 +15,6 @@ class UpdateListingStatistics { /** * Create a new pipe instance. - * - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(protected ConfigContract $config) { @@ -25,10 +23,6 @@ public function __construct(protected ConfigContract $config) /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { @@ -43,9 +37,6 @@ public function handle(Listing $listing, Closure $next): Listing /** * Returns a list of replaceable string with statistical data. - * - * @param Listing $listing - * @return array */ protected function statistics(Listing $listing): array { @@ -71,9 +62,6 @@ protected function statistics(Listing $listing): array /** * Check if the Composer Autoload is required and exists. - * - * @param string $autoload - * @return bool */ protected function autoloadMissing(string $autoload): bool { diff --git a/src/Compiler/Pipes/UpdateOpcacheConfig.php b/src/Compiler/Pipes/UpdateOpcacheConfig.php index e8420d7..6483465 100644 --- a/src/Compiler/Pipes/UpdateOpcacheConfig.php +++ b/src/Compiler/Pipes/UpdateOpcacheConfig.php @@ -11,10 +11,6 @@ class UpdateOpcacheConfig { /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { @@ -25,9 +21,6 @@ public function handle(Listing $listing, Closure $next): Listing /** * Returns a list of replaceable string with Opcache data. - * - * @param array $opcache - * @return array */ protected function opcacheConfig(array $opcache): array { diff --git a/src/Compiler/Pipes/WritePreloadFile.php b/src/Compiler/Pipes/WritePreloadFile.php index 3e9044b..8c42a3a 100644 --- a/src/Compiler/Pipes/WritePreloadFile.php +++ b/src/Compiler/Pipes/WritePreloadFile.php @@ -11,8 +11,6 @@ class WritePreloadFile { /** * Create a new pipe instance. - * - * @param \Illuminate\Filesystem\Filesystem $files */ public function __construct(protected Filesystem $files) { @@ -21,10 +19,6 @@ public function __construct(protected Filesystem $files) /** * Handle the script generation. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Condition.php b/src/Condition.php index d40997e..ec81cac 100644 --- a/src/Condition.php +++ b/src/Condition.php @@ -4,7 +4,7 @@ use Closure; use Illuminate\Contracts\Cache\Factory as CacheContract; -use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Foundation\Application as ApplicationContract; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; @@ -13,10 +13,9 @@ class Condition /** * Create a new Condition instance. * - * @param \Illuminate\Contracts\Foundation\Application $app - * @param \Closure $callback + * @param \Closure(\Illuminate\Http\Request, \Symfony\Component\HttpFoundation\Response, array):bool $callback */ - public function __construct(protected Application $app, protected Closure $callback) + public function __construct(protected ApplicationContract $app, protected Closure $callback) { // } @@ -25,7 +24,6 @@ public function __construct(protected Application $app, protected Closure $callb * Use a callback for the condition. * * @param \Closure(\Illuminate\Http\Request, \Symfony\Component\HttpFoundation\Response, array):bool $callback - * @return void */ public function use(Closure $callback): void { @@ -34,10 +32,6 @@ public function use(Closure $callback): void /** * Check if the script should be generated. - * - * @param \Illuminate\Http\Request $request - * @param \Symfony\Component\HttpFoundation\Response $response - * @return bool */ public function shouldGenerate(Request $request, Response $response): bool { diff --git a/src/Console/Commands/Placeholder.php b/src/Console/Commands/Placeholder.php index 37f67f3..758fa63 100644 --- a/src/Console/Commands/Placeholder.php +++ b/src/Console/Commands/Placeholder.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Config\Repository as ConfigContract; use Illuminate\Filesystem\Filesystem; -use JetBrains\PhpStorm\Pure; use Laragear\Preload\Preloader; class Placeholder extends Command @@ -33,10 +32,6 @@ class Placeholder extends Command /** * Execute the console command. - * - * @param \Illuminate\Filesystem\Filesystem $file - * @param \Illuminate\Contracts\Config\Repository $config - * @return void */ public function handle(Filesystem $file, ConfigContract $config): void { @@ -66,12 +61,7 @@ public function handle(Filesystem $file, ConfigContract $config): void /** * Check if the placeholder file already exists (and it's the placeholder). - * - * @param \Illuminate\Filesystem\Filesystem $file - * @param mixed $path - * @return bool */ - #[Pure] protected function isPlaceholder(Filesystem $file, mixed $path): bool { return $file->hash($path) === $file->hash(Preloader::PLACEHOLDER); diff --git a/src/Events/ListGenerated.php b/src/Events/ListGenerated.php index fe8cf6d..ecf840d 100644 --- a/src/Events/ListGenerated.php +++ b/src/Events/ListGenerated.php @@ -11,8 +11,6 @@ class ListGenerated /** * Create a new event instance. - * - * @param \Laragear\Preload\Listing $listing */ public function __construct(public Listing $listing) { diff --git a/src/Events/PreloadGenerated.php b/src/Events/PreloadGenerated.php index 81f4d8e..a2c47e7 100644 --- a/src/Events/PreloadGenerated.php +++ b/src/Events/PreloadGenerated.php @@ -8,8 +8,6 @@ class PreloadGenerated { /** * Create a new event instance. - * - * @param \Laragear\Preload\Listing $listing */ public function __construct(public Listing $listing) { diff --git a/src/Facades/Preload.php b/src/Facades/Preload.php index 36b9e64..58d8cd2 100644 --- a/src/Facades/Preload.php +++ b/src/Facades/Preload.php @@ -21,8 +21,6 @@ class Preload extends Facade { /** * Get the registered name of the component. - * - * @return string */ protected static function getFacadeAccessor(): string { @@ -33,7 +31,6 @@ protected static function getFacadeAccessor(): string * Determine if the preload list should be generated using a custom condition. * * @param \Closure(\Illuminate\Http\Request, \Symfony\Component\HttpFoundation\Response, array):bool $condition - * @return void */ public static function condition(Closure $condition): void { diff --git a/src/Http/Middleware/PreloadMiddleware.php b/src/Http/Middleware/PreloadMiddleware.php index ad67df3..10cf93b 100644 --- a/src/Http/Middleware/PreloadMiddleware.php +++ b/src/Http/Middleware/PreloadMiddleware.php @@ -16,10 +16,6 @@ class PreloadMiddleware { /** * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed */ public function handle(Request $request, Closure $next): mixed { @@ -28,12 +24,8 @@ public function handle(Request $request, Closure $next): mixed /** * Perform any final actions for the request lifecycle. - * - * @param \Illuminate\Http\Request $request - * @param \Symfony\Component\HttpFoundation\Response $response - * @return void */ - public function terminate(Request $request, Response $response) + public function terminate(Request $request, Response $response): void { if ($response->isSuccessful() && $this->conditionIsTrue($request, $response)) { $config = Config::get([ @@ -48,10 +40,6 @@ public function terminate(Request $request, Response $response) /** * Checks if the given condition logic is true or false. - * - * @param \Illuminate\Http\Request $request - * @param \Symfony\Component\HttpFoundation\Response $response - * @return bool */ protected function conditionIsTrue(Request $request, Response $response): bool { diff --git a/src/Jobs/StorePreloadScript.php b/src/Jobs/StorePreloadScript.php index 66a9634..ee2e544 100644 --- a/src/Jobs/StorePreloadScript.php +++ b/src/Jobs/StorePreloadScript.php @@ -17,15 +17,11 @@ class StorePreloadScript implements ShouldQueue, ShouldBeUnique, ShouldBeUniqueU /** * Name of the overlap key to handle job uniqueness. - * - * @var string */ public const OVERLAP_KEY = 'write_preload_script'; /** * Create a new job instance. - * - * @param \Laragear\Preload\Listing $listing */ public function __construct(public Listing $listing) { @@ -34,9 +30,6 @@ public function __construct(public Listing $listing) /** * Execute the job. - * - * @param \Laragear\Preload\Preloader $preload - * @return void */ public function handle(Preloader $preload): void { diff --git a/src/Lister/Pipes/CutListByMemoryLimit.php b/src/Lister/Pipes/CutListByMemoryLimit.php index f235063..7ecd318 100644 --- a/src/Lister/Pipes/CutListByMemoryLimit.php +++ b/src/Lister/Pipes/CutListByMemoryLimit.php @@ -11,10 +11,6 @@ class CutListByMemoryLimit { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { @@ -27,9 +23,6 @@ public function handle(Listing $listing, Closure $next): Listing /** * Cut the listing until the memory threshold is set. - * - * @param Listing $listing - * @return void */ protected function cutList(Listing $listing): void { diff --git a/src/Lister/Pipes/ExcludePreloadVariable.php b/src/Lister/Pipes/ExcludePreloadVariable.php index 0aa3589..624d0d3 100644 --- a/src/Lister/Pipes/ExcludePreloadVariable.php +++ b/src/Lister/Pipes/ExcludePreloadVariable.php @@ -9,10 +9,6 @@ class ExcludePreloadVariable { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/FireEvent.php b/src/Lister/Pipes/FireEvent.php index 0bac780..74c5c59 100644 --- a/src/Lister/Pipes/FireEvent.php +++ b/src/Lister/Pipes/FireEvent.php @@ -10,10 +10,6 @@ class FireEvent { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/LoadAcceleratedFiles.php b/src/Lister/Pipes/LoadAcceleratedFiles.php index 3b2fc53..ba5fa01 100644 --- a/src/Lister/Pipes/LoadAcceleratedFiles.php +++ b/src/Lister/Pipes/LoadAcceleratedFiles.php @@ -12,8 +12,6 @@ class LoadAcceleratedFiles { /** * Create a new pipe instance. - * - * @param \Laragear\Preload\Opcache $opcache */ public function __construct(protected Opcache $opcache) { @@ -22,10 +20,6 @@ public function __construct(protected Opcache $opcache) /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/LoadOpcacheConfig.php b/src/Lister/Pipes/LoadOpcacheConfig.php index cc3e92c..e1f471f 100644 --- a/src/Lister/Pipes/LoadOpcacheConfig.php +++ b/src/Lister/Pipes/LoadOpcacheConfig.php @@ -12,8 +12,6 @@ class LoadOpcacheConfig { /** * Create a new pipe instance. - * - * @param Opcache $opcache */ public function __construct(protected Opcache $opcache) { @@ -22,10 +20,6 @@ public function __construct(protected Opcache $opcache) /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/LoadPreloadConfig.php b/src/Lister/Pipes/LoadPreloadConfig.php index 985ad07..ebf4993 100644 --- a/src/Lister/Pipes/LoadPreloadConfig.php +++ b/src/Lister/Pipes/LoadPreloadConfig.php @@ -10,8 +10,6 @@ class LoadPreloadConfig { /** * Create a new pipe instance. - * - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(protected ConfigContract $config) { @@ -20,10 +18,6 @@ public function __construct(protected ConfigContract $config) /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/MayAppendExternalFiles.php b/src/Lister/Pipes/MayAppendExternalFiles.php index 244adba..fa15f99 100644 --- a/src/Lister/Pipes/MayAppendExternalFiles.php +++ b/src/Lister/Pipes/MayAppendExternalFiles.php @@ -12,8 +12,6 @@ class MayAppendExternalFiles { /** * Create a new pipe instance. - * - * @param \Laragear\Preload\Preloader $preload */ public function __construct(protected Preloader $preload) { @@ -22,10 +20,6 @@ public function __construct(protected Preloader $preload) /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/MayExcludeExternalFiles.php b/src/Lister/Pipes/MayExcludeExternalFiles.php index 0773f89..8bac2e1 100644 --- a/src/Lister/Pipes/MayExcludeExternalFiles.php +++ b/src/Lister/Pipes/MayExcludeExternalFiles.php @@ -10,8 +10,6 @@ class MayExcludeExternalFiles { /** * Create a new pipe instance. - * - * @param \Laragear\Preload\Preloader $preload */ public function __construct(protected Preloader $preload) { @@ -20,10 +18,6 @@ public function __construct(protected Preloader $preload) /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/MayScopeFilesToProjectPath.php b/src/Lister/Pipes/MayScopeFilesToProjectPath.php index a0344fd..e4c9757 100644 --- a/src/Lister/Pipes/MayScopeFilesToProjectPath.php +++ b/src/Lister/Pipes/MayScopeFilesToProjectPath.php @@ -10,10 +10,6 @@ class MayScopeFilesToProjectPath { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { @@ -26,11 +22,8 @@ public function handle(Listing $listing, Closure $next): Listing /** * Removes all files that are not inside the project base path. - * - * @param \Laragear\Preload\Listing $listing - * @return void */ - protected function removeNonProjectFiles(Listing $listing) + protected function removeNonProjectFiles(Listing $listing): void { $listing->files = $listing->files->filter(static function (array $file, string $key): bool { return Str::startsWith($key, base_path()); diff --git a/src/Lister/Pipes/NormalizeList.php b/src/Lister/Pipes/NormalizeList.php index aec0552..362a348 100644 --- a/src/Lister/Pipes/NormalizeList.php +++ b/src/Lister/Pipes/NormalizeList.php @@ -9,10 +9,6 @@ class NormalizeList { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Lister/Pipes/SortScriptsByHitRatio.php b/src/Lister/Pipes/SortScriptsByHitRatio.php index e018f75..10b1089 100644 --- a/src/Lister/Pipes/SortScriptsByHitRatio.php +++ b/src/Lister/Pipes/SortScriptsByHitRatio.php @@ -9,10 +9,6 @@ class SortScriptsByHitRatio { /** * Handle the incoming preload listing. - * - * @param \Laragear\Preload\Listing $listing - * @param \Closure $next - * @return \Laragear\Preload\Listing */ public function handle(Listing $listing, Closure $next): Listing { diff --git a/src/Listing.php b/src/Listing.php index bb4e567..e5c40a6 100644 --- a/src/Listing.php +++ b/src/Listing.php @@ -10,15 +10,9 @@ class Listing /** * Create a new Listing instance. * - * @param \Illuminate\Support\Collection $files - * @param bool $projectOnly + * @param \Illuminate\Support\Collection $files * @param (\Closure(\Symfony\Component\Finder\Finder):void)[] $exclude * @param (\Closure(\Symfony\Component\Finder\Finder):void)[] $append - * @param int $excludeCount - * @param int $appendCount - * @param int $memory - * @param string $path - * @param \Illuminate\Support\Stringable|null $output * @param string[] $opcache */ public function __construct( diff --git a/src/Opcache.php b/src/Opcache.php index 3dbf45d..0667594 100644 --- a/src/Opcache.php +++ b/src/Opcache.php @@ -17,8 +17,6 @@ class Opcache { /** * Here we will save the Opcache status instead of retrieving it every time. - * - * @var array|false */ protected array|false $status; @@ -26,8 +24,6 @@ class Opcache * Get status information about the cache. * * @see https://www.php.net/manual/en/function.opcache-get-status.php - * - * @return array */ public function getStatus(): array { @@ -42,8 +38,6 @@ public function getStatus(): array /** * Returns if Opcache is enabled. - * - * @return bool */ public function isEnabled(): bool { @@ -52,8 +46,6 @@ public function isEnabled(): bool /** * Returns if Opcache is disabled. - * - * @return bool */ public function isDisabled(): bool { @@ -62,8 +54,6 @@ public function isDisabled(): bool /** * Returns the scripts used by Opcache. - * - * @return array */ public function getScripts(): array { @@ -72,8 +62,6 @@ public function getScripts(): array /** * Returns the memory usage of Opcache. - * - * @return array */ public function getMemoryUsage(): array { @@ -82,8 +70,6 @@ public function getMemoryUsage(): array /** * Return statistics of Opcache. - * - * @return array */ public function getStatistics(): array { @@ -92,8 +78,6 @@ public function getStatistics(): array /** * Returns the number of scripts cached. - * - * @return int */ public function getNumberCachedScripts(): int { @@ -102,8 +86,6 @@ public function getNumberCachedScripts(): int /** * Check if Opcache has any cached script. - * - * @return bool */ public function cachedScriptsFilled(): bool { @@ -112,8 +94,6 @@ public function cachedScriptsFilled(): bool /** * Check if Opcache has no cached scripts. - * - * @return bool */ public function cachedScriptsEmpty(): bool { @@ -122,8 +102,6 @@ public function cachedScriptsEmpty(): bool /** * Returns the number of hits in Opcache. - * - * @return int */ public function getHits(): int { diff --git a/src/PreloadServiceProvider.php b/src/PreloadServiceProvider.php index 9d61c04..f06caaf 100644 --- a/src/PreloadServiceProvider.php +++ b/src/PreloadServiceProvider.php @@ -2,9 +2,9 @@ namespace Laragear\Preload; -use Illuminate\Contracts\Config\Repository; +use Illuminate\Contracts\Config\Repository as ConfigContract; use Illuminate\Contracts\Foundation\Application; -use Illuminate\Contracts\Http\Kernel; +use Illuminate\Contracts\Http\Kernel as HttpContract; use Illuminate\Support\ServiceProvider; use Laragear\Preload\Http\Middleware\PreloadMiddleware; @@ -12,15 +12,11 @@ class PreloadServiceProvider extends ServiceProvider { /** * Location of the package config. - * - * @var string */ public const CONFIG = __DIR__.'/../config/preload.php'; /** * Register the application services. - * - * @return void */ public function register(): void { @@ -35,12 +31,8 @@ public function register(): void /** * Bootstrap the application services. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Http\Kernel $kernel - * @return void */ - public function boot(Repository $config, Kernel $kernel): void + public function boot(ConfigContract $config, HttpContract $kernel): void { // We will only register the middleware if not Running Unit Tests if ($this->shouldRun($config)) { @@ -62,7 +54,7 @@ public function boot(Repository $config, Kernel $kernel): void * * @codeCoverageIgnore */ - protected function shouldRun(Repository $config): bool + protected function shouldRun(ConfigContract $config): bool { // If it's null run only on production, otherwise the developer decides. return $config->get('preload.enabled') ?? $this->app->environment('production'); diff --git a/src/Preloader.php b/src/Preloader.php index b339ece..659bfbf 100644 --- a/src/Preloader.php +++ b/src/Preloader.php @@ -15,25 +15,17 @@ class Preloader { /** * The location of the preload script stub. - * - * @var string */ public const STUB = __DIR__.'/../stubs/preload.php.stub'; /** * The location of the placeholder preload stub. - * - * @var string */ public const PLACEHOLDER = __DIR__.'/../stubs/preload.php.placeholder.stub'; /** * Create a new Preload instance. * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Laragear\Preload\Opcache $opcache - * @param \Laragear\Preload\Lister\Lister $lister - * @param \Laragear\Preload\Compiler\Compiler $compiler * @param array $append * @param array $exclude */ @@ -51,10 +43,9 @@ public function __construct( /** * Exclude files from the given paths. * - * @param \Closure|string ...$exclude - * @return void + * @param (\Closure(\Symfony\Component\Finder\Finder):void)|string ...$exclude */ - public function exclude(Closure | string ...$exclude): void + public function exclude(string ...$exclude): void { $this->exclude = $this->normalizeListing($exclude); } @@ -62,8 +53,7 @@ public function exclude(Closure | string ...$exclude): void /** * Append files from the given paths. * - * @param \Closure|string ...$append - * @return void + * @param (\Closure(\Symfony\Component\Finder\Finder):void)|string ...$append */ public function append(Closure | string ...$append): void { @@ -73,8 +63,8 @@ public function append(Closure | string ...$append): void /** * Normalize the listing from the user. * - * @param array $listing - * @return \Closure[] + * @param array $listing + * @return (\Closure(\Symfony\Component\Finder\Finder):void)[] */ protected function normalizeListing(array $listing): array { @@ -91,8 +81,6 @@ protected function normalizeListing(array $listing): array /** * Creates a new list. - * - * @return \Laragear\Preload\Listing */ public function list(): Listing { @@ -106,9 +94,6 @@ public function list(): Listing /** * Writes a listing to the filesystem. - * - * @param \Laragear\Preload\Listing|null $listing - * @return \Laragear\Preload\Listing */ public function generate(Listing $listing = null): Listing { @@ -118,7 +103,7 @@ public function generate(Listing $listing = null): Listing /** * Return an array of the files from the Finder. * - * @param \Closure $callback + * @param \Closure(\Symfony\Component\Finder\Finder):void $callback * @return \Illuminate\Support\Collection */ public function getFilesFromFinder(Closure $callback): Collection