qossmic / deptrac

Keep your architecture clean.
https://qossmic.github.io/deptrac
MIT License
2.59k stars 136 forks source link

Uncaught Error: Typed property Qossmic\Deptrac\Core\Ast\AstMap\DependencyToken::$context must not be accessed before initialization #1411

Closed mrsamse closed 2 months ago

mrsamse commented 3 months ago

Yesterday I updated my php version to 8.3.6 and now I get the following error message:

Uncaught Error: Typed property Qossmic\Deptrac\Core\Ast\AstMap\DependencyToken::$context must not be accessed before initialization in /vendor/qossmic/deptrac/src/Core/Dependency/Emitter/ClassDependencyEmitter.php

OS version: macOS Sonoma 14.4.1

deptrac version: 2.0.0.beta

PHP version: 8.3.6

If I switch back to php version 8.2.18 it works fine.

mrsamse commented 3 months ago

Side note: I also get a lot of deprecated errors:

Deprecated: Creation of dynamic property Qossmic\Deptrac\Core\Ast\AstMap\DependencyToken::$type is deprecated in /vendor/qossmic/deptrac/src/Core/Ast/Parser/Cache/AstFileReferenceFileCache.php

xabbuh commented 3 months ago

Does the error go away if you purge the Deptrac cache? I guess it is related to the unserialization here: https://github.com/qossmic/deptrac/commit/5da9063f0192bc1aa43de93e65feb5f46eee274e#diff-5bc528256de0b49467ca4973847c042aac17273c894a2993cd88df523a538f11

mrsamse commented 3 months ago

@xabbuh Yes, it works with php 8.3.6, if I execute the command vendor/bin/deptrac --clear-cache

Thanks!