Refactored entire Reflector to be more flexible#3
Merged
Conversation
README.md
Outdated
Member
There was a problem hiding this comment.
As per discussion, FilenameSourceLocator should probably be something like InSingleFileSourceLocator
Reflector to use a SourceLocator to load classes/files/codeReflector to use a SourceLocator to load classes/files/code
10 tasks
src/Reflector/ClassReflector.php
Outdated
Member
Author
Ocramius
added a commit
that referenced
this pull request
Jul 2, 2015
Refactored entire Reflector to be more flexible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initial Changes
new Reflectornow requires something implementingSourceLocatorinterfaceSourceLocatorinterface has a single method that should return a value objectLocatedSourceLocatedSourceVO is used to load the class requested internally byReflectorReflectoris now much simpler, and only has:$reflector->reflect($className)$reflector->getClassesFromFile()(only works whenFilenameSourceLocator)SourceLocator-implementing classes:ComposerSourceLocator- has a constructor dependency onComposer\Autoload\ClassLoaderFilenameSourceLocator- constructor dep is the filename as a stringStringSourceLocator- constructor dep is valid PHP code in a stringREADME.mdis updated to show example usage of creating theReflectionClassinstancesReflector::compileNodeExpressionwas moved to own classNodeCompiler::compilefor easier refactoring laterMethodsTestfixture as PHPUnit was loading the fileRefactored changes
SymbolVO that identifies a symbol with a name and type (checks types are valid)Reflectorto use theSymbolto generically identify "symbols" (instead of just classes)Reflector::getClassesFromFilewithReflector::getAllSymbolsto be more generic and also fixes Replace getClassesFromFile with a better API for getAllClasses #4BetterReflection\Reflection\Reflectioninterface that identifies symbols that can be reflected (currently onlyReflectionClass)ClassReflectorwhich simplfies the API to calling$reflector->reflect(..)so externally, users don't have to worry about creatingSymbols etc.. In future, we can createFunctionReflector,TraitReflectorand so on.Todo
SourceLocatorsomehow to accomodate for other types of symbols: