phpsa
phpsa copied to clipboard
Implement support for Unset operator
$a = 1;
unset($a);
var_dump($a); // Undefined?
i think unset() is a function and no operator. Maybe we should also add a warning to the (unset) cast since it is not the same as the unset() function. (and the (unset) cast is pretty useless)
@ddmler Hey!
Unset can be
- Operator
unset $a;
- Function http://php.net/manual/ru/function.unset.php
unset($a):
I created another issue for unset fcall https://github.com/ovr/phpsa/issues/70
So, I am wrong unset is an operator (because it's handled by VM OPCODE) but with function call like syntax
And @nikic's php-parser named it like PhpParser\Node\Stmt\Unset_
From PHP-src I didnt find PHP_FUNCTION(unset) but find statement with opcode
Review https://github.com/php/php-src/blob/2ae21abdf7b87ee95d76aca22e787408d7c766cf/Zend/zend_vm_opcodes.c#L99
Seems there are some parts
- [ ] Unset variable from Context->SymbolTable
- [ ] Unset referenced variables
- [ ] Unset for object property
- [ ] Magic __unset method
- [ ] Unset for array type