Environment
- Phpactor VS Code extension: 1.7.6
- PHP: 8.5
- Carbon: 3.13.0
Description
CarbonImmutable::createFromFormat() is inferred as returning DateTimeImmutable, causing a false positive diagnostic:
Method "startOfDay" does not exist on class "DateTimeImmutable"
phpactor(worse.missing_member)
Minimal reproduction
use Carbon\CarbonImmutable;
CarbonImmutable::createFromFormat('Y-m-d', '2026-01-01')
->startOfDay();
Actual result
The diagnostic reports:
Method "startOfDay" does not exist on class "DateTimeImmutable"
Expected result
The inferred type should be Carbon\CarbonImmutable, so startOfDay() should be recognized.
Additional information
The following methods work correctly and infer the proper Carbon type:
CarbonImmutable::now()->startOfDay();
CarbonImmutable::parse('2026-01-01')->startOfDay();
CarbonImmutable::createFromTimestamp(0)->startOfDay();
Screenshot:
This suggests that Phpactor may be resolving the inherited DateTimeImmutable::createFromFormat() instead of Carbon's overridden implementation.
Environment
Description
CarbonImmutable::createFromFormat()is inferred as returningDateTimeImmutable, causing a false positive diagnostic:Minimal reproduction
Actual result
The diagnostic reports:
Expected result
The inferred type should be
Carbon\CarbonImmutable, sostartOfDay()should be recognized.Additional information
The following methods work correctly and infer the proper Carbon type:
Screenshot:
This suggests that Phpactor may be resolving the inherited
DateTimeImmutable::createFromFormat()instead of Carbon's overridden implementation.