Skip to content

Fix PHPStan reported issues#109

Merged
Crell merged 1 commit into
Crell:masterfrom
agustingomes:phpstan-latest-erros
Apr 29, 2026
Merged

Fix PHPStan reported issues#109
Crell merged 1 commit into
Crell:masterfrom
agustingomes:phpstan-latest-erros

Conversation

@agustingomes
Copy link
Copy Markdown
Contributor

Description

Describe your changes in detail.

Motivation and context

These PHPStan errors started being flagged without code changes:

Error: Property Crell\Serde\Attributes\ClassSettings::$omitNullFields (bool) on left side of ?? is not nullable.
Error: Match arm comparison between Crell\Serde\TypeCategory::StringEnum and Crell\Serde\TypeCategory::StringEnum is always true.
 ------ -----------------------------------------------------------------------
  Line   src/Attributes/Field.php
 ------ -----------------------------------------------------------------------
  242    Property Crell\Serde\Attributes\ClassSettings::$omitNullFields (bool)
         on left side of ?? is not nullable.
         🪪  nullCoalesce.property
 ------ -----------------------------------------------------------------------

 ------ -----------------------------------------------------------------------
  Line   src/PropertyHandler/EnumExporter.php
 ------ -----------------------------------------------------------------------
  56     Match arm comparison between Crell\Serde\TypeCategory::StringEnum and
         Crell\Serde\TypeCategory::StringEnum is always true.
         🪪  match.alwaysTrue
         💡  Remove remaining cases below this one and this error will
         disappear too.
 ------ -----------------------------------------------------------------------

The changes in this PR solve the new errors flagged under PHPStan version 2.1.51

How has this been tested?

Automated checks with composer all-checks

These started being flagged without code changes:

```log
Error: Property Crell\Serde\Attributes\ClassSettings::$omitNullFields (bool) on left side of ?? is not nullable.
Error: Match arm comparison between Crell\Serde\TypeCategory::StringEnum and Crell\Serde\TypeCategory::StringEnum is always true.
 ------ -----------------------------------------------------------------------
  Line   src/Attributes/Field.php
 ------ -----------------------------------------------------------------------
  242    Property Crell\Serde\Attributes\ClassSettings::$omitNullFields (bool)
         on left side of ?? is not nullable.
         🪪  nullCoalesce.property
 ------ -----------------------------------------------------------------------

 ------ -----------------------------------------------------------------------
  Line   src/PropertyHandler/EnumExporter.php
 ------ -----------------------------------------------------------------------
  56     Match arm comparison between Crell\Serde\TypeCategory::StringEnum and
         Crell\Serde\TypeCategory::StringEnum is always true.
         🪪  match.alwaysTrue
         💡  Remove remaining cases below this one and this error will
         disappear too.
 ------ -----------------------------------------------------------------------
```
@Crell Crell merged commit a25999f into Crell:master Apr 29, 2026
12 checks passed
@Crell
Copy link
Copy Markdown
Owner

Crell commented Apr 29, 2026

Verified the issue locally as well. Looks like bug fixes in some recent PHPStan version. Thanks!

@agustingomes agustingomes deleted the phpstan-latest-erros branch April 29, 2026 15:47
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.

2 participants