Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed arguments #3

Closed
boenrobot opened this issue Oct 1, 2011 · 1 comment
Closed

Typed arguments #3

boenrobot opened this issue Oct 1, 2011 · 1 comment

Comments

@boenrobot
Copy link
Member

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.

@boenrobot
Copy link
Member Author

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.

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

No branches or pull requests

1 participant