core
core copied to clipboard
Remove reflection from XP Core
This pull request implements https://github.com/xp-framework/rfc/issues/338 and removes reflection from XP Core.
Continuous disintegration
- [x] Access members (properties, methods, constants) via
lang.XPClass - [x] Member encapsulations in
lang.reflect - [x] Proxy and InvocationHandler classes from
lang.reflect - [x] Annotation API in
lang.XPClass - [x] Class details API for members
- [ ] Dependency of
lang.FunctionTypeon class details API - [ ] Remove class parser
Size
Before:
$ du -ksh src/*/php
831K src/main/php
1019K src/test/php
After:
$ du -ksh src/*/php
774K src/main/php
915K src/test/php
Generics use annotations, which means we have the following options:
- Drop generics support (see also https://github.com/xp-framework/rfc/issues/338#issuecomment-774665621)
- Rewrite generics support to use PHP 8 attributes via reflection, and drop PHP 7 support (see also https://github.com/xp-framework/rfc/issues/343)
- Same as 2) - but create a simple annotation parser for PHP 7 which is loaded only on demand.
- It might be possible to fold class parser and generics creation into a single-step process
Dependency of lang.FunctionType on class details API
For this to work, we need to be able to parse API doc types in FunctionType::verify(). This has the following 2 prerequisites:
Type::named()is more liberal about trailing comments, so we're able to parse@return self This instance. See handling inlang.reflect.ClassParser::typeIn()- We are somehow able to parse
usestatements to be able to resolve imports correctly. We already need this for running scripts, seexp.runtime.Code, the code there could be integrated with a slight refactoring.