Skip to content

Add layer tests with phpat based on deptrac layers, remove deptrac#832

Merged
DanielBadura merged 2 commits into3.20.xfrom
phpat-layer
Apr 20, 2026
Merged

Add layer tests with phpat based on deptrac layers, remove deptrac#832
DanielBadura merged 2 commits into3.20.xfrom
phpat-layer

Conversation

@DanielBadura
Copy link
Copy Markdown
Member

This is the next step into removing deptrac in favor of phpat.

These 3 violations, which are in the deptrace baseline, are not covered right now:

    Patchlevel\EventSourcing\Aggregate\CustomId:
      - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer
    Patchlevel\EventSourcing\Aggregate\Uuid:
      - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer
    Patchlevel\EventSourcing\Attribute\Stream:
      - Patchlevel\EventSourcing\Aggregate\AggregateRoot

These 2 are false positives from deptrac imho:

    Patchlevel\EventSourcing\Aggregate\CustomId:
      - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer
    Patchlevel\EventSourcing\Aggregate\Uuid:
      - Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer

As the AggregateRootId interface as a dependency on the attribute Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer and not the concrete classes. So this is a good that these 2 are not picked up.

    Patchlevel\EventSourcing\Attribute\Stream:
      - Patchlevel\EventSourcing\Aggregate\AggregateRoot

Is due the dependecy is coming from a union type inside the phpdoc. As soon as I change /** @param string|class-string<AggregateRoot> $name */ to /** @param class-string<AggregateRoot> $name */ it gets picked up correctly:

 ------ ----------------------------------------------------------------------------------------------------------------- 
  Line   src/Attribute/Stream.php                                                                                         
 ------ ----------------------------------------------------------------------------------------------------------------- 
  14     Patchlevel\EventSourcing\Attribute\Stream should not depend on Patchlevel\EventSourcing\Aggregate\AggregateRoot  
         🪪  phpat.testAttributeCanOnlyDependOnAllowedLayers                                                              
 ------ ----------------------------------------------------------------------------------------------------------------- 

So this is a bug on phpat side.

With this change, we can remove deptrac as an dependency and still have our layers protected. WDYT @DavidBadura ?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 16, 2026

Hello 👋

here is the most recent benchmark result:

SimpleSetupBench
================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.049ms (±0.00%)   | 1.030ms (±0.00%)   | +1.77%    | 35.044mb        | 35.562mb   | -1.45%      |
| benchLoad10000Events ()                | 56.945ms (±0.00%)  | 57.551ms (±0.00%)  | -1.05%    | 35.044mb        | 35.562mb   | -1.45%      |
| benchSave1Event ()                     | 1.091ms (±0.00%)   | 1.150ms (±0.00%)   | -5.17%    | 35.044mb        | 35.044mb   | 0.00%       |
| benchSave10000Events ()                | 218.887ms (±0.00%) | 220.547ms (±0.00%) | -0.75%    | 35.044mb        | 35.044mb   | 0.00%       |
| benchSave10000Aggregates ()            | 6.298s (±0.00%)    | 6.681s (±0.00%)    | -5.73%    | 35.044mb        | 35.044mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 3.837s (±0.00%)    | 3.865s (±0.00%)    | -0.73%    | 35.044mb        | 35.044mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SnapshotsBench
==============

+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                   | memory                                     |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchLoad10000EventsMissingSnapshot () | 56.063ms (±0.00%) | 56.531ms (±0.00%) | -0.83%    | 35.049mb        | 35.049mb   | 0.00%       |
| benchLoad10000Events ()                | 1.211ms (±0.00%)  | 1.230ms (±0.00%)  | -1.59%    | 35.049mb        | 35.049mb   | 0.00%       |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

CommandToQueryBench
===================

+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
|                | time (kde mode)                                 | memory                                     |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| subject        | Tag: <current>   | Tag: base        | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| benchCreate () | 2.578ms (±0.00%) | 2.585ms (±0.00%) | -0.28%    | 4.896mb         | 4.896mb    | +0.02%      |
| benchUpdate () | 4.282ms (±0.00%) | 4.305ms (±0.00%) | -0.55%    | 5.031mb         | 5.031mb    | 0.00%       |
| benchBoth ()   | 6.375ms (±0.00%) | 6.057ms (±0.00%) | +5.26%    | 4.883mb         | 4.883mb    | 0.00%       |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+

SplitStreamBench
================

+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                         | time (kde mode)                                     | memory                                     |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                 | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000Events () | 5.087ms (±0.00%)   | 5.142ms (±0.00%)   | -1.06%    | 35.649mb        | 35.649mb   | 0.00%       |
| benchSave10000Events () | 331.360ms (±0.00%) | 329.287ms (±0.00%) | +0.63%    | 35.652mb        | 35.651mb   | +0.00%      |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBench
=======================

+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                               | memory                                     |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>  | Tag: base       | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 2.692s (±0.00%) | 2.725s (±0.00%) | -1.21%    | 47.557mb        | 47.557mb   | 0.00%       |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+

SimpleSetupStreamStoreBench
===========================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 985.100μs (±0.00%) | 1.013ms (±0.00%)   | -2.79%    | 35.206mb        | 35.206mb   | 0.00%       |
| benchLoad10000Events ()                | 63.346ms (±0.00%)  | 61.537ms (±0.00%)  | +2.94%    | 35.206mb        | 35.206mb   | 0.00%       |
| benchSave1Event ()                     | 1.061ms (±0.00%)   | 1.055ms (±0.00%)   | +0.60%    | 35.206mb        | 35.206mb   | 0.00%       |
| benchSave10000Events ()                | 281.812ms (±0.00%) | 277.102ms (±0.00%) | +1.70%    | 35.206mb        | 35.206mb   | 0.00%       |
| benchSave10000Aggregates ()            | 6.563s (±0.00%)    | 6.471s (±0.00%)    | +1.42%    | 35.206mb        | 35.206mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 4.025s (±0.00%)    | 4.070s (±0.00%)    | -1.10%    | 35.206mb        | 35.206mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBatchBench
============================

+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                   | memory                                     |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 75.200ms (±0.00%) | 75.085ms (±0.00%) | +0.15%    | 35.544mb        | 35.544mb   | 0.00%       |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

PersonalDataBench
=================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.174ms (±0.00%)   | 1.134ms (±0.00%)   | +3.51%    | 35.585mb        | 35.585mb   | 0.00%       |
| benchLoad10000Events ()                | 89.282ms (±0.00%)  | 84.880ms (±0.00%)  | +5.19%    | 35.585mb        | 35.585mb   | 0.00%       |
| benchSave1Event ()                     | 1.677ms (±0.00%)   | 1.595ms (±0.00%)   | +5.13%    | 35.585mb        | 35.585mb   | 0.00%       |
| benchSave10000Events ()                | 242.582ms (±0.00%) | 243.897ms (±0.00%) | -0.54%    | 35.586mb        | 35.586mb   | 0.00%       |
| benchSave10000Aggregates ()            | 10.014s (±0.00%)   | 9.757s (±0.00%)    | +2.63%    | 35.585mb        | 35.585mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 7.279s (±0.00%)    | 7.234s (±0.00%)    | +0.62%    | 36.044mb        | 36.044mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

This comment gets update everytime a new commit comes in!

@DanielBadura DanielBadura changed the base branch from 3.19.x to 3.20.x April 16, 2026 09:49
This is the next step into removing deptrac in favor of phpat
@DanielBadura DanielBadura marked this pull request as ready for review April 19, 2026 13:28
@DanielBadura
Copy link
Copy Markdown
Member Author

@DavidBadura not sure what the error is in the BC-Check. But it's for sure unrelated :D

@DanielBadura DanielBadura changed the title Add layer tests based on deptrac layers. Add layer tests with phpat based on deptrac layers, remove deptrac Apr 19, 2026
@DanielBadura DanielBadura self-assigned this Apr 19, 2026
@DanielBadura DanielBadura added the enhancement New feature or request label Apr 19, 2026
@DanielBadura DanielBadura added this to the 3.20.0 milestone Apr 19, 2026
Copy link
Copy Markdown
Member

@DavidBadura DavidBadura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@DanielBadura DanielBadura merged commit bc39921 into 3.20.x Apr 20, 2026
39 of 40 checks passed
@DanielBadura DanielBadura deleted the phpat-layer branch April 20, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants