Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Sep 16, 2025

Description

This PR resolves multiple code quality issues in ResponseTest.php identified by PHPStan static analysis and IDE diagnostics. All changes are internal test improvements that maintain 100% backward compatibility.

Problem Solved

  • PHPStan errors: 2 type mismatches in anonymous classes implementing ProvidesInertiaProperties
  • Deprecated API usage: 5 instances of LazyProp (deprecated in favor of OptionalProp)
  • IDE warnings: Mockery syntax and Symfony constant reference issues
  • Code inconsistency: Mixed mocking patterns across test files

Changes Made

PHPStan Type Fixes

  • Fixed return type annotations from Collection<string, string> to array<string, mixed>
  • Updated implementations to return arrays instead of Collections to match interface contract

Deprecated API Replacement

  • Replaced LazyProp with OptionalProp (5 instances + import)
  • Follows deprecation guidance: "Use OptionalProp instead for clearer semantics"

Testing Pattern Consistency

  • Migrated from Mockery::mock() to Laravel testbench $this->mock() pattern
  • Aligns with existing project conventions (see CheckSsrTest.php)
  • Eliminates IDE type warnings

Minor Fixes

  • Fixed Symfony Request constant reference using fully qualified name
  • Cleaned up unused Mockery import

Why This Matters

For Contributors: Eliminates distracting IDE warnings that can mask real issues during development

For Maintainers: Resolves static analysis errors and removes deprecated API usage before breaking changes

For Code Quality: Ensures consistent testing patterns and adherence to type contracts

Compatibility & Testing

  • No breaking changes: All modifications are internal to test files
  • All tests pass: Full test suite passes (OK (160 tests, 664 assertions))
  • ResponseTest.php verified: All 39 ResponseTest cases pass with 193 assertions
  • Static analysis clean: PHPStan now reports [OK] No errors (was 2 errors)
  • Follows project patterns: Uses established conventions from existing test files

reinink and others added 30 commits January 12, 2023 21:18
* Auto enable SSR based on existence of SSR bundle

* Terminate SSR node process when PHP process dies

* Add missing comma
)

* Add pcntl to requirements

* Move ext-pcntl to suggest and add check to StartSsr command

* Tweak `ext-pcntl` suggestion message

* Update `inertia:start-ssr` command to only use `pcntl` when it's available

Co-authored-by: Jonathan Reinink <[email protected]>
Automatically update Facade docblocks
Restore request and session on redirects
* Add option for using the bun js runtime

* Tweak wording

---------

Co-authored-by: Jonathan Reinink <[email protected]>
pascalbaljet and others added 28 commits June 26, 2025 21:21
[2.x] Restore `testing.page_paths` and `testing.page_extensions` configs
update return type in Middleware share method
Fix project name in `SECURITY.md`
Improved the docblock for the inertia function, which will now be better processed by tools such as PHPStan. A similar structure is used, for example, in the response function in Laravel’s core framework.
[2.x] Improve inertia helper docblock
[2.x] Introduce `ProvidesInertiaProp` interface
[2.x] Introduce ProvidesInertiaProps interface
  - Fix PHPStan type errors: Change return types from Collection to array for ProvidesInertiaProperties
  - Replace deprecated LazyProp with OptionalProp (5 instances + import)
  - Fix Symfony Request constant reference using fully qualified name
  - Refactor Mockery to use Laravel testbench pattern with $this->mock()
  - Clean up unused imports
@ghost ghost force-pushed the fix-phpstan-type-errors branch from 8e81a79 to 959d16e Compare September 18, 2025 13:24
@ghost ghost closed this by deleting the head repository Sep 18, 2025
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.