Skip to content

Fix Undefined Method Calls

Priority: 🔴 P0 - CRITICAL Status: Planning Related Analysis: phpstan-rector-analysis-overview.md

Problem Statement

24 PHPStan errors for calls to undefined methods (excluding deploy.php). These are potential runtime fatal errors.

Impact

  • Severity: CRITICAL - Each could cause a fatal error
  • Bug Risk: High - runtime crashes
  • Production Impact: May already be causing issues
  • User Impact: Feature failures

PHPStan Error Category

  • Error ID: method.notFound
  • Count: 24 (excluding 115 deploy.php errors)
  • Priority: Must fix before deployment

Investigation Required

Each error needs individual investigation to determine:

  1. Is the method genuinely missing?
  2. Was the method recently removed?
  3. Is this in dead code that's never executed?
  4. Is there a typo in the method name?
  5. Is the type inference wrong?

Known Issues

Issue 1: RoasterCrawlConfig::getDefaultInstruction()

  • Status: Covered in separate plan
  • File: fix-missing-default-instruction-method.md
  • Action: Already planned

Issue 2-24: To Be Investigated

Full list requires checking PHPStan output for actual locations.

Implementation Plan

Step 1: Get Complete List

make phpstan 2>&1 | grep "method.notFound" | grep "src/" > /tmp/undefined-methods.txt

Step 2: Categorize Errors

For each error, determine:

  • File location
  • Method being called
  • Type it's being called on
  • Context of the call

Step 3: Investigation Approach

For each undefined method:

A. Check if method exists:

# Search for method definition
grep -r "function methodName" src/

B. Check git history:

# Was it recently removed?
git log -S "function methodName" -- src/

C. Check for typos:

  • Look for similar method names
  • Check PHPDoc type hints

D. Check if dead code:

  • Is this code path ever executed?
  • Can we add a test that triggers it?

Step 4: Fix Categories

Category A: Typos

  • Fix the method name

Category B: Method Removed

  • Remove the call or update to new method
  • Check git history for migration path

Category C: Missing Method

  • Add the method if it should exist
  • Or remove the call if it shouldn't

Category D: Type Inference Issue

  • Fix PHPDoc or type hints
  • Ensure PHPStan understands the type

Category E: Dead Code

  • Remove the dead code

Success Criteria

  • All method.notFound errors in src/ resolved
  • No new runtime errors introduced
  • All tests passing
  • Code is clearer about what methods exist

Risk Assessment

High Risk:

  • Each fix could introduce bugs
  • May reveal actual runtime issues
  • Could affect multiple features

Mitigation:

  • Fix one at a time
  • Add tests for each fix
  • Review git history carefully
  • Test affected features thoroughly

Estimated Effort

Per Method:

  • Investigation: 15-30 min
  • Fix: 15-60 min
  • Testing: 15-30 min
  • Average: 1 hour per method

Total for 24 methods:

  • Best case (mostly typos): 12 hours
  • Worst case (complex fixes): 40 hours
  • Estimate: 20-30 hours

Dependencies

  • Should be done AFTER fix-missing-default-instruction-method.md
  • May require coordination with other refactoring

Notes

This plan is a placeholder - needs to be fleshed out once the complete list of undefined methods is extracted and analyzed.

TODO:

  1. Extract full list from PHPStan
  2. Categorize each error
  3. Create detailed fix plan for each
  4. Prioritize by impact