-
Notifications
You must be signed in to change notification settings - Fork 1
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
Extract reflection to its own library #338
Comments
The xp-framework/reflection library comes in at around 1700 LOC: $ cloc-1.82.pl src/main/
43 text files.
43 unique files.
8 files ignored.
github.com/AlDanial/cloc v 1.82 T=0.15 s (280.1 files/s, 19744.7 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
PHP 42 380 861 1720
-------------------------------------------------------------------------------
SUM: 42 380 861 1720
------------------------------------------------------------------------------- The code in the core library's |
|
|
...and reduce reliance on reflection at the same time, see xp-framework/rfc#338
The following changes make the transition to
|
Before this can be implemented, XP core needs to be migrated to the new testing library, see #344. Otherwise, we'll simply see
|
The /**
* Returns XPClass instances for all classes inside a given package
*
* @param string $package
* @return iterable
*/
private static function classesIn($package) {
$offset= -strlen(\xp::CLASS_FILE_EXT);
$cl= ClassLoader::getDefault();
foreach ($cl->packageContents($package) as $item) {
if (0 === substr_compare($item, \xp::CLASS_FILE_EXT, $offset)) {
yield $cl->loadClass($package.'.'.substr($item, 0, $offset));
}
}
} ...which exposes quite a bit of internals. Maybe the |
The Proxy class will be removed in XP 12, see xp-framework/core#341 |
The |
The |
Scope of Change
This RFC suggests extracting reflection to its own library, while the type system will continue to exist.
Rationale
Reflection is a big block of code with quite a bit of legacy, including an outdated concept of annotations which doesn't fit PHP 8 attributes well.
Functionality
This is the
lang.reflect
package, which will be replaced by https://github.com/xp-framework/reflection except for theProxy
class, which we might extract to its own library or simply move to the mocking library:The
lang.XPClass
class will be stripped down to its essentials, where it will serve the purpose of reflecting value types.Security considerations
None.
Speed impact
Reduces the size of XP core:
Dependencies
Generics.
Related documents
xp-framework/unittest#43
The text was updated successfully, but these errors were encountered: