You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a discussion in the PR #123 about possible removing of low-level scanners in the Zend\Code\Scanner subnamespace for 4.0. Reason for that is to avoid keeping support for low-level code analysis via tokens inside scanners, this job can be performed by external libraries, such as nikic/php-parser, roave/better-reflection, goaop/parser-reflection, etc.
There are only dependencies on Scanner namespace in the Reflection namespace, eg. Zend\Code\Reflection\DocBlockReflection::reflect uses DocBlockScanner class, as well Zend\Code\Reflection\FileReflection::reflect uses CachingFileScanner. All remaining integration parts could be removed as they unused.
Classes from the Reflection namespace adds some public API to the PHP internal classes, thus Reflection namespace could not be easily dropped if we want to support *Generator::fromReflection() methods that accept only Zend\Code\Reflection classes and use specific methods from reflection.
If we decide to drop fromReflection() method from all generators or replace typehint in them with built-in PHP classes, then whole Scanner and Reflection namespace could be dropped, but it will be significant BC break as we remove all functionality that are not related directly to the code generation.
Whole Scanner namespace could be removed, there are only dependencies in Reflection namespace, eg. Zend\Code\Reflection\DocBlockReflection::reflect uses DocBlockScanner class, as well Zend\Code\Reflection\FileReflection::reflect uses CachingFileScanner. All remaining integration parts could be removed as they unused.
Yeah, this stuff can be dropped. At this point, pointing to roave/better-reflection for most of the "brute-forcing the filesystem, looking for symbols"
Classes from the Reflection namespace adds some public API to the PHP internal classes, thus Reflection namespace could not be easily dropped if we want to support *Generator::fromReflection() methods that accept only Zend\Code\Reflection classes and use specific methods from reflection.
Not sure about this one. I think the initial idea was that ext-reflection had huge potholes, and the library tried to fill them. I'd keep this for a separate issue, to figure out if the Zend\Code\Reflection namespace actually does anything more than ext-reflection these days. Considering that Zend\Code\Reflection is the entry point to all of the usages of this library (including the generators), I think that would make the migration path too painful at first.
If we decide to drop fromReflection() method from all generators or replace typehint in them with built-in PHP classes, then whole Scanner and Reflection namespace could be dropped, but it will be significant BC break as we remove all functionality that are not related directly to the code generation.
The ::fromReflection() constructors are extremely useful to mimick API without rewriting all of it manually, so I'd probably keep them in place. Instead, I think that allowing core reflection classes as parameters would be a better solution here.
I like the idea to drop both Scanner and Reflection namespaces from the code.
Yeah, this stuff can be dropped. At this point, pointing to roave/better-reflection for most of the "brute-forcing the filesystem, looking for symbols"
@Ocramius So, we are going to drop both DocBlockReflection and FileReflection classes, right? Or keep them but use external libs? For example, DocBlockReflection contains sensitive logic for accessing tags, however we can mimic this logic via optional dependency phpdocumentor/reflection-docblock that provides good API for that.
The ::fromReflection() constructors are extremely useful to mimick API without rewriting all of it manually, so I'd probably keep them in place. Instead, I think that allowing core reflection classes as parameters would be a better solution here.
Ok, I will check if it's possible to switch to the core classes without pain.
There is a discussion in the PR #123 about possible removing of low-level scanners in the
Zend\Code\Scanner
subnamespace for 4.0. Reason for that is to avoid keeping support for low-level code analysis via tokens inside scanners, this job can be performed by external libraries, such asnikic/php-parser
,roave/better-reflection
,goaop/parser-reflection
, etc.Some facts about
Scanner
code usage in the project zendframework/zend-code#123 (comment):Scanner
namespace in theReflection
namespace, eg.Zend\Code\Reflection\DocBlockReflection::reflect
usesDocBlockScanner
class, as wellZend\Code\Reflection\FileReflection::reflect
usesCachingFileScanner
. All remaining integration parts could be removed as they unused.Reflection
namespace adds some public API to the PHP internal classes, thusReflection
namespace could not be easily dropped if we want to support*Generator::fromReflection()
methods that accept onlyZend\Code\Reflection
classes and use specific methods from reflection.fromReflection()
method from all generators or replace typehint in them with built-in PHP classes, then wholeScanner
andReflection
namespace could be dropped, but it will be significant BC break as we remove all functionality that are not related directly to the code generation.@Ocramius suggestions from zendframework/zend-code#123 (comment):
Originally posted by @lisachenko at zendframework/zend-code#155
The text was updated successfully, but these errors were encountered: