Skip to content

Readonly Class Side Effects Issue (PHP 8.2) #637

@IanLChapman87

Description

@IanLChapman87
Q A
Bug report? yes
Feature request? no
Library version 2.8.0

If you have a class like this:

readonly class FetchFiltersAction
 {
     public function __construct(
         private FilterOptionsRepository $filterOptionsRepository
     ) {
     }

     public function handle(FilterCollection $appliedFilters): FilterOptions
     {
         return $this->filterOptionsRepository->getFilterOptions($appliedFilters);
     }
 }

Then the following failure is shown:

  • [Side effects] A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 11 and the first side effect is on line 11.

(In this case line 11 references the first line in the code snippet above.)

I believe this might be a php 8.2 issue as readonly classes were only recently introduced.

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions