Feature #46371

Support compilation of static information in proxy classes

Added by Christopher Hlubek over 2 years ago.

Status:New Start date:2013-03-16
Priority:Should have Due date:
Assigned To:Christopher Hlubek % Done:

0%

Category:-
Target version:-
PHP Version: Complexity:
Has patch:No

Description

We use the ReflectionService during runtime to get information about interface implementations, method parameters or other reflection data that will never change after compilation. If we can manage to store that information inside the classes that need that specific information we can save the initialization of the ReflectionService and cache accesses for some invocations.

An annotation CompileStatic should be used to mark static methods inside proxyable classes as compilable. The object manager is passed to the method as the only context beside the current class (which can be accessed with get_called_class with late static bind) and allows access to the ReflectionService. During compilation the proxy builder will call these methods and override the method with the computed return value in the generated proxy class.

Besides reflection data anything that doesn't change after the compile run can be pre-computed with this approach.

Associated revisions

Revision c6329565
Added by Christopher Hlubek over 2 years ago

[FEATURE] Static compilation of compile time data

Implement a CompileStatic annotation for static methods that will be
evaluated by the proxy builder in production. Update bootstrap and some
classes to enable efficient caching of reflection information and lazy
loading of the reflection service.

Note: It is not possible to give a type hint to those static methods,
since it could be a DependencyProxy that is actually passed.

Change-Id: Ic29505a98a04091320294c5e389cc4e09d514fcd
Related: #46371
Releases: master

Revision 6d56d5f7
Added by Christopher Hlubek over 2 years ago

[FEATURE] Static compilation of compile time data

Implement a CompileStatic annotation for static methods that will be
evaluated by the proxy builder in production. Update bootstrap and some
classes to enable efficient caching of reflection information and lazy
loading of the reflection service.

Note: It is not possible to give a type hint to those static methods,
since it could be a DependencyProxy that is actually passed.

Change-Id: Ic29505a98a04091320294c5e389cc4e09d514fcd
Related: #46371
Releases: 2.0, master

Also available in: Atom PDF