Skip to content

Commit 99c15c3

Browse files
authored
PHP 8.5 support (#368)
* Add PHP 8.5 to ci Signed-off-by: Pushpak Chhajed <[email protected]> * Add PHP 8.5 Guidelines Signed-off-by: Pushpak Chhajed <[email protected]> * Refine PHP 8.5 guidelines Signed-off-by: Pushpak Chhajed <[email protected]> * Update matrix to include PHP 8.5 compatibility Signed-off-by: Pushpak Chhajed <[email protected]> * Move fixtures to Fixtures Signed-off-by: Pushpak Chhajed <[email protected]> * fix Test Signed-off-by: Pushpak Chhajed <[email protected]> * Fix code styling * Fix Test Signed-off-by: Pushpak Chhajed <[email protected]> * Fix Test Signed-off-by: Pushpak Chhajed <[email protected]> * Fix Test Signed-off-by: Pushpak Chhajed <[email protected]> * Formatting Signed-off-by: Pushpak Chhajed <[email protected]> --------- Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent 321a4ec commit 99c15c3

27 files changed

+63
-34
lines changed

.ai/php/8.5/core.blade.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## PHP 8.5
2+
3+
- PHP 8.5 has new array functions that will make code simpler whenever we don't use Laravel's collections.
4+
- `array_first(array $array): mixed` - Get first value (or `null` if empty)
5+
- `array_last(array $array): mixed` - Get last value (or `null` if empty)
6+
7+
- Use `clone($object, ['property' => $value])` to modify properties during cloning—ideal for readonly classes.
8+
9+
### Pipe Operator
10+
- The pipe operator (`|>`) chains function calls left-to-right, replacing nested calls:
11+
<code-snippet name="Pipe Operator Example" lang="php">
12+
// Before PHP 8.5
13+
$slug = strtolower(str_replace(' ', '-', trim($title)));
14+
15+
// After PHP 8.5
16+
$slug = $title |> trim(...) |> (fn($s) => str_replace(' ', '-', $s)) |> strtolower(...);
17+
</code-snippet>

.github/workflows/tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ jobs:
2525
os: [ ubuntu-22.04, windows-latest ]
2626
php: [ 8.2, 8.3, 8.4 ]
2727
laravel: [ 11, 12 ]
28+
include:
29+
- php: 8.5
30+
laravel: 12
31+
os: ubuntu-22.04
32+
- php: 8.5
33+
laravel: 12
34+
os: windows-latest
2835

2936
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.os }}
3037

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"laravel/roster": "^0.2.9"
2525
},
2626
"require-dev": {
27-
"laravel/pint": "1.20",
27+
"laravel/pint": "^1.20.0",
2828
"mockery/mockery": "^1.6.12",
2929
"orchestra/testbench": "^8.36.0|^9.15.0|^10.6",
30-
"pestphp/pest": "^2.36.0|^3.8.4",
30+
"pestphp/pest": "^2.36.0|^3.8.4|^4.1.5",
3131
"phpstan/phpstan": "^2.1.27",
3232
"rector/rector": "^2.1"
3333
},

tests/Feature/Console/InstallCommandMultiselectTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,11 @@
7878
);
7979

8080
// Verify we get keys that can be used with in_array checks
81-
expect($result)->toBeArray();
82-
expect($result)->toHaveCount(3); // All 3 selected (2 default + 1 added)
83-
84-
// These are the exact checks used in InstallCommand
85-
expect(in_array('mcp_server', $result, true))->toBeTrue();
86-
expect(in_array('ai_guidelines', $result, true))->toBeTrue();
87-
expect(in_array('style_guidelines', $result, true))->toBeTrue();
88-
89-
// Verify it doesn't contain the display values
90-
expect(in_array('Boost MCP Server', $result, true))->toBeFalse();
91-
expect(in_array('Package AI Guidelines (i.e. Framework, Inertia, Pest)', $result, true))->toBeFalse();
81+
expect($result)->toBeArray()
82+
->and($result)->toHaveCount(3)
83+
->and($result)->toContain('mcp_server')
84+
->and($result)->toContain('ai_guidelines')
85+
->and($result)->toContain('style_guidelines')
86+
->and($result)->not->toContain('Boost MCP Server')
87+
->and($result)->not->toContain('Package AI Guidelines (i.e. Framework, Inertia, Pest)');
9288
})->skipOnWindows();

tests/Feature/Install/GuidelineComposerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
$composer = Mockery::mock(GuidelineComposer::class, [$this->roster, $this->herd])->makePartial();
314314
$composer
315315
->shouldReceive('customGuidelinePath')
316-
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
316+
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('Fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
317317

318318
expect($composer->compose())
319319
->toContain('=== .ai/custom-rule rules ===')
@@ -336,7 +336,7 @@
336336
$composer = Mockery::mock(GuidelineComposer::class, [$this->roster, $this->herd])->makePartial();
337337
$composer
338338
->shouldReceive('customGuidelinePath')
339-
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
339+
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('Fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
340340

341341
$guidelines = $composer->compose();
342342
$overrideStringCount = substr_count((string) $guidelines, 'Thanks though, appreciate you');
@@ -442,7 +442,7 @@
442442
$composer = Mockery::mock(GuidelineComposer::class, [$this->roster, $this->herd])->makePartial();
443443
$composer
444444
->shouldReceive('customGuidelinePath')
445-
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
445+
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('Fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
446446

447447
$guidelines = $composer->compose();
448448

@@ -640,7 +640,7 @@
640640
$composer = Mockery::mock(GuidelineComposer::class, [$this->roster, $this->herd])->makePartial();
641641
$composer
642642
->shouldReceive('customGuidelinePath')
643-
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
643+
->andReturnUsing(fn ($path = ''): string => realpath(testDirectory('Fixtures/.ai/guidelines')).'/'.ltrim((string) $path, '/'));
644644

645645
$packages = new PackageCollection([
646646
new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'),

tests/Feature/Middleware/InjectBoostTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\HttpFoundation\StreamedResponse;
1717

1818
beforeEach(function (): void {
19-
$this->app['view']->addNamespace('test', __DIR__.'/../../fixtures');
19+
$this->app['view']->addNamespace('test', __DIR__.'/../../Fixtures');
2020
});
2121

2222
function createMiddlewareResponse($response): SymfonyResponse

0 commit comments

Comments
 (0)