System error: "Rector\NodeTypeResolver\NodeTypeResolver::getType(): Argument #1 ($node) must be of type PhpParser\Node, null given
Bug Report
| Subject | Details |
|---|---|
| Rector version | 0.13.10 |
Hi there. First, thanks for the great work put in this project!
While trying to run rector on an old project, i encoutered the following error:
System error: "Rector\NodeTypeResolver\NodeTypeResolver::getType(): Argument #1 ($node) must be of type PhpParser\Node, null given
Minimal PHP Code Causing Issue
You can reproduce the issue using the following link: https://getrector.org/demo/dabca986-73d1-4391-95eb-3650654bb966
Expected Behaviour
I'm just starting with rector but this doesn't seem like the appropriate behaviour.
crypt() function require 2 args, while you only provide 1 arg, it already error when check on https://3v4l.org/hrdFU , you need to pass 2 args instead, see https://www.php.net/manual/en/function.crypt.php
Ok, it seems got notice in php < 8, while it still run https://3v4l.org/GaksR
Ok ! Since i'm using rector to update old code, i didn't think it would break on such error but warn instead or even fix the old code. I'm asking too much :D
Thanks for your insight !
You're welcome, the optional notice happen since php 5.6 https://3v4l.org/GaksR#v5.6.1, so we may need to create new rule to fill default arg value on 2nd arg on crypt() function for it, eg: FillSecondArgCryptRector on php 5.6 rules set.
That might be harder than that since the second parameter must be a generated salt. A rule replacing crypt() by password_hash() could be more appropriate but might break code because of algorithm changes.
Ok, it seems the solution is to skip it instead for this
Thanks again :)