• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valkyrjaio / valkyrja-php / 30417050344
100%

Build:
DEFAULT BRANCH: 26.x
Ran 29 Jul 2026 02:33AM UTC
Jobs 1
Files 1138
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Jul 2026 02:31AM UTC coverage: 100.0%. Remained the same
30417050344

push

github

web-flow
[Type] Move the enum json serialization branch out of the trait (#949)

# Description

`Type\Enum\Trait\JsonSerializable::jsonSerialize()` branched on
`$this instanceof BackedEnum` inside the trait itself, and that branch
could not
be covered reliably — not because a test was missing, but because of how
Xdebug
reports trait methods.

Xdebug emits exactly **one** function entry per file for a trait method,
keyed by
the trait rather than by the using class:

```
Type/Enum/Trait/JsonSerializable.php
  function: Valkyrja\Type\Enum\Trait\JsonSerializable->jsonSerialize
```

Every using class shares that entry, so which class's copy the hits
reflect
depends on class load order. A backed enum never runs `return
$this->name` and a
pure enum never runs `return $this->value`, so the file's reported
coverage
depends on which kind of enum happened to be loaded — and **adding tests
made it
worse**:

| Run | `if` | `return $this->value` | `return $this->name` | Result |
|-----|------|-----------------------|----------------------|--------|
| `--filter JsonSerializableTest` | hit | hit | hit | 3/3 |
| `--filter 'JsonSerializableTest\|ArrayableTest'` | hit | hit | miss |
2/3 |
| full `Type` shard | hit | hit | miss | 2/3 |

`ArrayableTest` never calls `jsonSerialize()`; it only loads the same
enum
fixtures first. That alone flips the pure-enum arm to unhit, so no test
can close
this gap. (php-code-coverage's own merging is a strict union —
`ProcessedBranchCoverageData::merge` and `markCodeAsExecutedByTestCase`
— so the
loss happens in Xdebug's raw per-test data, upstream of any merge.)

The fix keeps the branch but moves it out of the trait, following the
pattern
this namespace already uses: `Trait\Arrayable` holds no logic and
delegates to
`Support\Enumerable`. `Trait\JsonSerializable` now does the same, and
the
conditional lives in `Support\Enumerable::jsonSerialize()` — an ordinary
class,
where coverage is per-class and stable.

Public API is unchanged: `use JsonS... (continued)

5 of 0 new or added lines in 0 files covered. (NaN%)

12596 of 12596 relevant lines covered (100.0%)

23.75 hits per line

Jobs
ID Job ID Ran Files Coverage
1 30417050344.1 29 Jul 2026 02:33AM UTC 1138
100.0
GitHub Action Run
Source Files on build 30417050344
  • Tree
  • List 1138
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #30417050344
  • 6546e07f on github
  • Prev Build on 26.x (#30416951256)
  • Next Build on 26.x (#30420562655)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc