phan / phan/phan

Support using <, > on DateTime and DateTimeImmutable

Open
#2,907 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.