Closed boenrobot closed 11 years ago
At 1.0.0b4, there's now Util::parseValue() that attempts to do most of such interpretations if needed, except that IPs and IDs are essentially preserved as strings.
Due to the lack of type hints, this function is not called automatically, but at least it's now there for those who need it and understand how it works.
Right now, all arguments are strings... or streams of strings. RouterOS' scripting language defines several types, some of which have direct PHP equivalents. Because it doesn't hint them in any way, there's no way for the client to automatically do type casting.
A good workaround though would be to make classes that when passed to setArgument() can be converted to a proper raw string, and which if constructed from a getArgument() string can give a proper PHP typed value.
IDs will be a particular beneficiary of this.
In terms of the type "IP", there is a need for a little more research.
edit: There are some talks in internals about a magic cast() method (or toInt(), etc.)... if any one of those becomes part of an official PHP release, THAT would be the thing to implement.
Alternatively, if MikroTik implement some form of type hinting (although that's unlikely given this topic in the MikroTik forum), automatic casting would be implemented, with or without PHP magic methods.
If there's a demand, some less elegant alternatives might be implemented.