nette / application

🏆 A full-stack component-based MVC kernel for PHP that helps you write powerful and modern web applications. Write less, have cleaner code and your work will bring you joy.
https://doc.nette.org/application
Other
412 stars 106 forks source link

ComponentReflection::convertType() empty string problem #318

Open romanbartl opened 12 months ago

romanbartl commented 12 months ago

Hey there,

When you declare persistent variable of int|null type inside of Control, and in URL coresponding parameter is empty string, than type error occurs. From what I've learnt this error happens in ComponentReflection in castScalar() method when you try to check whether data-loss happens. It seems that this peace of code does not count with nullable persistent parameters. It happens because strict typed comparassion.

I would expect that when there is given an empty string in GET/POST, and declared coresponding persistent variable is nullable, than 'null' should be assigned. If it makes sence.

Tested on version: 3.1.17.