Skip to content

PHPStan: SecretController mixed type warnings from request->input() #184

@kevalyq

Description

@kevalyq

Problem

PHPStan Level max reports 14 warnings in SecretController.php related to type casting from Request->input() which returns mixed.

Errors

  • Lines 108-114 (store method): Cannot cast mixed to string/array
  • Lines 152-170 (update method): Cannot cast mixed to string/array

Example

$secret->title_plain = (string) $request->input('title'); // PHPStan: Cannot cast mixed to string

Context

  • All tests passing (35/35 Secret+SecretShare tests)
  • Runtime behavior correct
  • Only static analysis warnings

Solutions to Consider

  1. @var DocBlocks before assignments (most common Laravel pattern)
  2. Custom type-safe Request classes with typed getters
  3. PHPStan baseline to suppress these specific warnings
  4. Validation-based type inference (PHPStan Laravel extension)

Priority

Low - Does not affect functionality, only static analysis

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions