Tootfinder

Opt-in global Mastodon full text search. Join the index!

No exact results. Similar results found.
@emd@cosocial.ca
2025-11-05 01:42:49

Any PHPStan/Larastan experts out there? Currently on level 2 and getting an error about a missing var. I don't really want to add another line to fix nor do I want to ignore this line, is there a better way?
Maybe @… knows?
#laravel

PHP code:

/** @var User $user */
if (is_null($user = auth()->user())) {
Variable $user in PHPDoc tag @var does not exist.
varTag.variableNotFound
@michabbb@social.vivaldi.net
2025-12-25 17:15:41

🔓 Problem 2: Zero type safety. Your age property can be int, string, null, array - PHP accepts anything without complaints. Type errors only surface at runtime, often in production.
🛠️ Problem 3: IDEs and tooling are blind. No autocomplete suggestions, no refactoring support, static analysis tools like PHPStan and Psalm cannot detect issues. You lose all modern developer experience benefits.

@michabbb@social.vivaldi.net
2025-12-25 17:15:42

⚡ Escape hatch exists: #[AllowDynamicProperties] attribute opts into old behavior. Use ONLY for legacy vendor code or gradual migration with a removal plan. Never use for new code.
📊 Timeline: PHP 8.1 = allowed | PHP 8.2 = deprecated warning | PHP 9.0 = fatal error. Start fixing now!
🎯 Migration strategy: Run PHPStan/Psalm analysis, fix domain models first (critical), then controllers/services, then DTOs. Add static analysis to CI pipeline to prevent regression.