MyCLabsMethodCallToEnumConstRector should only refactor according to RuleDefinition
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with the MyCLabsMethodCallToEnumConstRector rule class and its getRuleDefinition() CodeSample, which shows SomeEnum::VALUE()->getKey() becoming SomeEnum::VALUE->name. The report says the rewrite also fires where the enum constructor expects an enum object, causing a TypeError. Reproduce with the linked demo, then find which call sites the rule should skip. Done means the reported case produces no change and the rule's existing tests still pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.8.3 |
Hi,
the rule MyCLabsMethodCallToEnumConstRector should only refactor according to the rule definiton:
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Refactor MyCLabs enum fetch to Enum const', [
new CodeSample(
<<<'CODE_SAMPLE'
$name = SomeEnum::VALUE()->getKey();
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
$name = SomeEnum::VALUE->name;
CODE_SAMPLE
),
]);
}
Always changing SomeEnum::VALUE() to SomeEnum::VALUE can produce fatal errors like in the example:
Fatal error: Uncaught TypeError: test\A::__construct(): Argument #1 ($evl) must be of type Endroid\QrCode\ErrorCorrectionLevel, string given, called in
Best regards
Minimal PHP Code Causing Issue
https://getrector.com/demo/fd1ed71b-d792-4531-a52a-0679bce0c134
Expected Behaviour
No change
- Lingua principale
- PHP
- Stelle
- 10.5k
- Fork
- 742
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rectorphp/rector
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
RemoveDefaultValueFromAssignedPropertyRector does not work with nested conditional assignmentsApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
-
[PHPUnit] AddInstanceofAssertForNullableInstanceRector enters an infinite loop on a test traitForse già presa @samsonasik l’ha presa oggi. Apertabug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 25/100
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
Tutte le issue di rectorphp/rector
Issue simili
-
Issue: ready for confirmation Reported on 2.4.9 Triage: Dev.Experience
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
magento/magento2#41773 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
[BUG] Add bounds validation for numberOfContestants in TeamsGroup::apiCreate()Forse già presa @RAJJADHAV10 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
omegaup/omegaup#10512 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sorocharge/sorocharge-php#14 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
filesender/filesender#2898 ·
I maintainer di solito rispondono entro 1 giorno
-
cleanup
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno