diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 764cfb0..56610cf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + branches: + - main jobs: composer: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2775009..0dac0c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + branches: + - main jobs: pest: @@ -14,9 +16,9 @@ jobs: fail-fast: false matrix: php: - - "8.2" - "8.3" - "8.4" + - "8.5" steps: - name: Checkout uses: actions/checkout@v7 diff --git a/README.md b/README.md index 1ae5ec6..a702861 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Replace every placeholder before publishing: | `{{ namespace }}` | PHP namespace, for example `Acme\\MobileBattery`. | | `{{ description }}` | Short package description. | -## NativePHP Mobile v3 and v4\n\nThe template supports `nativephp/mobile` v3 and v4. The manifest format and bridge source layout are shared by the versions supported here.\n\nKeep the generated package dependency as `^3.0|^4.0` unless the plugin intentionally targets a single NativePHP Mobile version.\n\n## How NativePHP Plugins Work +## NativePHP Mobile v3 and v4\n\nThe template supports `nativephp/mobile` v3 and v4 and requires PHP 8.3 or newer. The manifest format and bridge source layout are shared by the versions supported here.\n\nKeep the generated package dependency as `^3.0|^4.0` unless the plugin intentionally targets a single NativePHP Mobile version.\n\n## How NativePHP Plugins Work NativePHP Mobile plugins are Composer packages with `type: nativephp-plugin`. diff --git a/composer.json b/composer.json index 74015ef..4b16e5f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "source": "https://github.com/{{ vendor }}/{{ package }}" }, "require": { - "php": "^8.2", + "php": "^8.3", "illuminate/contracts": "^11.0|^12.0", "illuminate/support": "^11.0|^12.0", "nativephp/mobile": "^3.0|^4.0" diff --git a/configure.php b/configure.php index fb60506..ac36622 100644 --- a/configure.php +++ b/configure.php @@ -335,7 +335,7 @@ private function rewriteComposerJson( 'source' => 'https://github.com/'.$github.'/'.$package, ], 'require' => [ - 'php' => '^8.2', + 'php' => '^8.3', 'illuminate/contracts' => '^11.0|^12.0', 'illuminate/support' => '^11.0|^12.0', 'nativephp/mobile' => '^3.0|^4.0', diff --git a/pint.json b/pint.json index d559909..5181c3f 100644 --- a/pint.json +++ b/pint.json @@ -4,10 +4,12 @@ "android", "ios", "resources", - "stubs" + "stubs", + ".github" ], "notPath": [ - "vendor" + "vendor", + "rector.php" ], "rules": { "declare_strict_types": true, diff --git a/rector.php b/rector.php index 6da6224..810956c 100644 --- a/rector.php +++ b/rector.php @@ -9,14 +9,13 @@ __DIR__.'/src', __DIR__.'/tests', ]) - ->withPhpSets(php82: true) + ->withPhpSets(php83: true) ->withPreparedSets( deadCode: true, codeQuality: true, typeDeclarations: true, privatization: true, earlyReturn: true, - strictBooleans: true, ) ->withSkip([ __DIR__.'/stubs', diff --git a/src/Contracts/{{ plugin }}Contract.php b/src/Contracts/{{ plugin }}Contract.php index 83bba11..507c5df 100644 --- a/src/Contracts/{{ plugin }}Contract.php +++ b/src/Contracts/{{ plugin }}Contract.php @@ -10,7 +10,6 @@ interface {{ plugin }}Contract * Invoke the template bridge function and return the normalized native response. * * @param array $payload - * * @return array */ public function example(array $payload = []): array; diff --git a/src/Events/{{ plugin }}Event.php b/src/Events/{{ plugin }}Event.php index 3103f2a..ef17514 100644 --- a/src/Events/{{ plugin }}Event.php +++ b/src/Events/{{ plugin }}Event.php @@ -7,7 +7,7 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -final class {{ plugin }}Event +final readonly class {{ plugin }}Event { use Dispatchable; use SerializesModels; @@ -16,8 +16,7 @@ final class {{ plugin }}Event * @param array $payload */ public function __construct( - public readonly string $name, - public readonly array $payload = [], - ) { - } + public string $name, + public array $payload = [], + ) {} } diff --git a/src/Plugin.php b/src/Plugin.php index ce64319..9332ba6 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -4,18 +4,17 @@ namespace {{ namespace }}; +use {{ namespace }}\Contracts\{{ plugin }}Contract; use Illuminate\Contracts\Foundation\Application; use Illuminate\Support\Facades\File; use InvalidArgumentException; use RuntimeException; -use {{ namespace }}\Contracts\{{ plugin }}Contract; -final class Plugin implements {{ plugin }}Contract +final readonly class Plugin implements {{ plugin }}Contract { public function __construct( - private readonly Application $app, - ) { - } + private Application $app, + ) {} public function example(array $payload = []): array { @@ -24,7 +23,7 @@ public function example(array $payload = []): array public function manifest(): array { - $path = dirname(__DIR__).DIRECTORY_SEPARATOR.'nativephp.json'; + $path = __DIR__.'/../nativephp.json'; if (! File::exists($path)) { throw new InvalidArgumentException('The {{ vendor }}/{{ package }} NativePHP manifest is missing.'); @@ -49,7 +48,6 @@ public function isAvailable(): bool /** * @param array $payload - * * @return array */ private function callBridge(string $function, array $payload): array diff --git a/src/Providers/{{ plugin }}ServiceProvider.php b/src/Providers/{{ plugin }}ServiceProvider.php index fbcacef..12ad51c 100644 --- a/src/Providers/{{ plugin }}ServiceProvider.php +++ b/src/Providers/{{ plugin }}ServiceProvider.php @@ -4,9 +4,9 @@ namespace {{ namespace }}\Providers; -use Illuminate\Support\ServiceProvider; use {{ namespace }}\Contracts\{{ plugin }}Contract; use {{ namespace }}\Plugin; +use Illuminate\Support\ServiceProvider; final class {{ plugin }}ServiceProvider extends ServiceProvider { @@ -19,7 +19,7 @@ public function register(): void public function boot(): void { $this->publishes([ - dirname(__DIR__, 2).'/nativephp.json' => base_path('nativephp/{{ package }}.json'), + __DIR__.'/../../nativephp.json' => base_path('nativephp/{{ package }}.json'), ], '{{ package }}-nativephp-manifest'); } } diff --git a/src/Support/Manifest.php b/src/Support/Manifest.php index ca454d3..a110df4 100644 --- a/src/Support/Manifest.php +++ b/src/Support/Manifest.php @@ -6,15 +6,14 @@ use InvalidArgumentException; -final class Manifest +final readonly class Manifest { /** * @param array $manifest */ public function __construct( - private readonly array $manifest, - ) { - } + private array $manifest, + ) {} public function namespace(): string { diff --git a/src/Testing/BridgeFake.php b/src/Testing/BridgeFake.php index 2003964..f7394ff 100644 --- a/src/Testing/BridgeFake.php +++ b/src/Testing/BridgeFake.php @@ -20,9 +20,7 @@ final class BridgeFake /** * @param array|Closure> $responses */ - public function __construct(private array $responses = []) - { - } + public function __construct(private array $responses = []) {} /** * @param array $payload diff --git a/tests/ManifestTest.php b/tests/ManifestTest.php index 9939424..31116a3 100644 --- a/tests/ManifestTest.php +++ b/tests/ManifestTest.php @@ -5,7 +5,7 @@ use {{ namespace }}\Support\Manifest; it('ships a valid NativePHP manifest', function (): void { - $path = dirname(__DIR__).'/nativephp.json'; + $path = __DIR__.'/../nativephp.json'; expect($path)->toBeFile(); @@ -22,9 +22,9 @@ it('documents every required replacement placeholder', function (): void { $files = [ - dirname(__DIR__).'/composer.json', - dirname(__DIR__).'/nativephp.json', - dirname(__DIR__).'/docs/manifest-fields.md', + __DIR__.'/../composer.json', + __DIR__.'/../nativephp.json', + __DIR__.'/../docs/manifest-fields.md', ]; foreach (['{{ vendor }}', '{{ package }}', '{{ plugin }}', '{{ namespace }}', '{{ description }}'] as $placeholder) { diff --git a/tests/PluginTest.php b/tests/PluginTest.php index d3c992e..8fb1cf3 100644 --- a/tests/PluginTest.php +++ b/tests/PluginTest.php @@ -10,7 +10,6 @@ { /** * @param array $payload - * * @return array */ public function call(string $function, array $payload): array diff --git a/tests/TestCase.php b/tests/TestCase.php index d4da75b..73d7cd3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,14 +4,14 @@ namespace {{ namespace }}\Tests; -use Orchestra\Testbench\TestCase as Orchestra; use {{ namespace }}\Providers\{{ plugin }}ServiceProvider; +use Illuminate\Foundation\Application; +use Orchestra\Testbench\TestCase as Orchestra; abstract class TestCase extends Orchestra { /** - * @param \Illuminate\Foundation\Application $app - * + * @param Application $app * @return list */ protected function getPackageProviders($app): array