Dealing with extensions overriding arithmetic operators such as php-decimal
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 5.6k
- Forks
- 365
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 6
Description
I am working on a code base that makes heavy use of php-decimal[0].
The extension provides a new type "Decimal" which also supports arithemtic and comparion operators.
This causes Phan to issue a bunch of PhanTypeInvalid{Left|Right}OperandOf*Op.
Current Workarounds:
- Wrap every arithmetic operation in a new Decimal, "return new Decimal($dec1 + $dec2)"
- add all emitted issues types caused by Decimal to the global suppress_issue_types array.
So the question is: how would one deal with this?
- Is there a way to tell Phan to treat Decimal just like a regular number?
- What part of the source would one have to read to extend Phan to make it work with Decimal?
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
No source file, test, or entry point is named. Start by locating Phan's checks for invalid arithmetic and comparison operands, then inspect how extension-provided Decimal types are represented; done means a documented, tested way to recognize such types without suppressing unrelated diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100