-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Scope of Change
The core of the XP7-SERIES should be reduced drastically.
Rationale
There are several modules in the XP Framework's surroundings which people might want to use. However, regarding their dependency on the still heavy-weight felt xp-framework/core makes them skip these opportunities. Therefore, the goal is to reduce the framework core to the absolute minimum size.
Functionality
Currently, the Framework's core consists of:
- The core functionality in lang.base.php
- Base classes and exceptions
- Class loading infrastructure and modules
- Type system and reflection, including annotations and generics
- Wrapper types
- I/O, Networking
- Date and time handling
- Money and currency
- Collections
- Unit test API
- Logging
- Profiling
- Properties
- Command line handling
- Regular expressions, scanners and tokenizers
- Checksums & Hashing
- Certificate
- Math support for big numbers
The smallest possible would be the core functionality, base classes and exceptions as well as class loading, and a reduced type system.
Reduced type system
The XP Framework's type system builds upon a hierarchy of the lang.Type class:
lang.Type
|-- Type::$VOID
|-- Type::$VAR
|-+ lang.Primitive
| |-- Primitive::$STRING
| |-- Primitive::$INT
| |-- Primitive::$DOUBLE
| `-- Primitive::$BOOL
|-- lang.ArrayType
|-- lang.MapType
|-- lang.FunctionType
|-- lang.WildcardType
`-- lang.XPClass
The reduced type system would provide an entry-level reference type reflection via lang.XPClass but without member reflection and support for generics.
To access e.g. a class' methods reflectively, one would need to import the xp-framework/reflection library and use its "reflection" extension method:
$class= $instance->type()->reflection();
foreach ($class->methods() as $method) {
// ...
}To reflect generic types, one would again use the "reflection" entry point:
$class= $instance->type()->reflection();
if ($class->isGeneric()) {
$types= $class->genericArguments();
// ...
}The create() method would be moved to the xp-framework/generics library. Its wrapping "new" statements purpose has been obsolete since XP6 and the possibility to write (new T())->member().
Methods removed from lang.XPClass would be:
- getMethods(), getMethod(), hasMethod()
- getConstructor(), hasConstructor()
- getFields(), getField(), hasField()
- getConstants(), getConstant(), hasConstant()
- getInterfaces()
- getAnnotations(), getAnnotation(), hasAnnotation()
- newGenericType(), genericComponents(), genericDefinition(), genericArguments(), isGeneric()
To make it easier, the XP Framework's extension method mechanism would be extended to allow omnipresent extension methods.
Libraries extracted from core
- Wrapper types
- Collections
- Unit test API
- Logging
- Regular expressions, scanners and tokenizers
- Checksums & Hashing
- Certificate
- Math support for big numbers
- Networking
Libraries under consideration to be extracted
The io package and it io.streams and io.sys subpackages:
- I/O
- Date and time handling
- Money and currency
- Profiling
- Properties
- Command line handling
Security considerations
Speed impact
Dependencies
Related documents
- https://www.dartlang.org/articles/reflection-with-mirrors/
- https://msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx
- Split up framework into minimal pieces #262 (implemented in XP 6)
- RFC Extract unittest from core #293 - Extract unittests from core
- RFC Extract logging from core #301 - Extract logging from core