Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Typed arguments #3

boenrobot opened this Issue Oct 1, 2011 · 1 comment


None yet
1 participant

boenrobot commented Oct 1, 2011

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.

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.


boenrobot commented Aug 15, 2013

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.

@boenrobot boenrobot closed this Aug 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment