Support using <, > on DateTime and DateTimeImmutable
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- PHP
- Stars
- 5.6k
- Forks
- 365
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 6
Description
Followup to #2892
Some internal classes can be compared to related classes and subclasses because they define the comparator
<?php
// unexpected PhanSuspiciousWeakTypeComparison Suspicious attempt to compare new DateTimeImmutable('+1 day') of type \DateTimeImmutable to new DateTime('now') of type \DateTime
// actual output is true and false
var_export((new DateTimeImmutable('+1 day')) >= new DateTime('now'));
var_export((new DateTimeImmutable('-1 day')) >= new DateTime('now'));
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with follow-up issue #2892 and the analysis that emits PhanSuspiciousWeakTypeComparison for DateTime and DateTimeImmutable comparisons. Reproduce both examples, then trace the comparator handling and add coverage so valid related-class comparisons are accepted without weakening detection of invalid comparisons.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100