-
Couldn't load subscription status.
- Fork 1
Closed
Labels
Description
Scope of Change
A way to create anonymous instances of interfaces and abstract classes will
be provided.
Rationale
Throw-away classes / migration.
Functionality
newinstance() declaration
&lang.Object newinstance(
string classname,
mixed[] args,
string bytes
)
</pre>
Arguments:
- baseclass is the fully qualified class name of the interface to
implement or the abstract class to inherit from.
- args are the constructor arguments
- source is the class' sourcecode, including a leading "{" and a
trailing "}"
Creating an anonymous instance will bail with an error...
- ...in case the class "classname" cannot be found.
- ...in case the source code specified by the bytes argument doesn't
parse.
- ...in case classname refers to an interface and the declared class
fails to implement the interface.
Creating an anonymous instance of an interface:
----
```php
<?php
$filter= &newinstance('io.collections.iterate.IterationFilter', array(&$properties), '{
var
$properties= NULL;
function __construct(&$properties) {
$this->properties= &$properties;
}
function accept(&$element) {
return (
4 == sscanf(basename($element->getURI()), "%[^-]-%d-%d-%d.log", $type, $y, $m, $d) &&
$this->properties->hasSection($type)
);
}
}');
?>
Security considerations
n/a
Speed impact
Slower than declaring real classes.
Dependencies
This patch will increase the XP framework's minor version (4.1.0)