Skip to content

Commit

Permalink
Merge pull request #136 from Roave/refactor-source-locators
Browse files Browse the repository at this point in the history
Internal refactoring of source locators
  • Loading branch information
Ocramius committed Nov 2, 2015
2 parents b17a3a4 + dcbae3e commit c7aa2c0
Show file tree
Hide file tree
Showing 64 changed files with 1,473 additions and 771 deletions.
6 changes: 1 addition & 5 deletions src/Reflection/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
use BetterReflection\Reflection\Exception\NotAString;
use BetterReflection\Reflector\ClassReflector;
use BetterReflection\Reflector\Reflector;
use BetterReflection\SourceLocator\AggregateSourceLocator;
use BetterReflection\SourceLocator\AutoloadSourceLocator;
use BetterReflection\SourceLocator\EvaledCodeSourceLocator;
use BetterReflection\SourceLocator\LocatedSource;
use BetterReflection\SourceLocator\PhpInternalSourceLocator;
use BetterReflection\SourceLocator\Located\LocatedSource;
use BetterReflection\TypesFinder\FindTypeFromAst;
use phpDocumentor\Reflection\Types\Object_;
use PhpParser\Node;
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/ReflectionFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use BetterReflection\Reflector\FunctionReflector;
use BetterReflection\Reflector\Reflector;
use BetterReflection\SourceLocator\AutoloadSourceLocator;
use BetterReflection\SourceLocator\LocatedSource;
use BetterReflection\SourceLocator\Type\AutoloadSourceLocator;
use BetterReflection\SourceLocator\Located\LocatedSource;
use PhpParser\Node\Stmt\Function_ as FunctionNode;
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;

Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ReflectionFunctionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace BetterReflection\Reflection;

use BetterReflection\Reflector\Reflector;
use BetterReflection\SourceLocator\LocatedSource;
use BetterReflection\SourceLocator\Located\LocatedSource;
use BetterReflection\TypesFinder\FindReturnType;
use PhpParser\Node;
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;
Expand Down
3 changes: 1 addition & 2 deletions src/Reflection/ReflectionObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use BetterReflection\Reflector\ClassReflector;
use BetterReflection\Reflector\Reflector;
use BetterReflection\SourceLocator\EvaledCodeSourceLocator;
use PhpParser\Node\Stmt\Property as PropertyNode;
use PhpParser\Builder\Property as PropertyNodeBuilder;
use PhpParser\Node\Stmt\ClassLike as ClassLikeNode;
use PhpParser\Node\Stmt\Namespace_ as NamespaceNode;
use BetterReflection\SourceLocator\LocatedSource;
use BetterReflection\SourceLocator\Located\LocatedSource;

class ReflectionObject extends ReflectionClass
{
Expand Down
1 change: 0 additions & 1 deletion src/Reflection/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use BetterReflection\NodeCompiler\CompilerContext;
use BetterReflection\Reflector\Reflector;
use BetterReflection\TypesFinder\FindPropertyType;
use BetterReflection\TypesFinder\FindTypeFromAst;
use PhpParser\Node\Stmt\Property as PropertyNode;
use phpDocumentor\Reflection\Type;

Expand Down
23 changes: 12 additions & 11 deletions src/Reflector/ClassReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@

use BetterReflection\Identifier\Identifier;
use BetterReflection\Identifier\IdentifierType;
use BetterReflection\Reflector\Generic as GenericReflector;
use BetterReflection\SourceLocator\AggregateSourceLocator;
use BetterReflection\SourceLocator\AutoloadSourceLocator;
use BetterReflection\SourceLocator\EvaledCodeSourceLocator;
use BetterReflection\SourceLocator\PhpInternalSourceLocator;
use BetterReflection\SourceLocator\SourceLocator;
use BetterReflection\SourceLocator\Type\AggregateSourceLocator;
use BetterReflection\SourceLocator\Type\AutoloadSourceLocator;
use BetterReflection\SourceLocator\Type\EvaledCodeSourceLocator;
use BetterReflection\SourceLocator\Type\PhpInternalSourceLocator;
use BetterReflection\SourceLocator\Type\SourceLocator;

class ClassReflector implements Reflector
{
/**
* @var GenericReflector
* @var SourceLocator
*/
private $reflector;
private $sourceLocator;

/**
* @param SourceLocator $sourceLocator
*/
public function __construct(SourceLocator $sourceLocator)
{
$this->reflector = new GenericReflector($sourceLocator);
$this->sourceLocator = $sourceLocator;
}

/**
Expand All @@ -46,7 +45,8 @@ public static function buildDefaultReflector()
*/
public function reflect($className)
{
return $this->reflector->reflect(
return $this->sourceLocator->locateIdentifier(
$this,
new Identifier($className, new IdentifierType(IdentifierType::IDENTIFIER_CLASS))
);
}
Expand All @@ -58,7 +58,8 @@ public function reflect($className)
*/
public function getAllClasses()
{
return $this->reflector->getAllByIdentifierType(
return $this->sourceLocator->locateIdentifiersByType(
$this,
new IdentifierType(IdentifierType::IDENTIFIER_CLASS)
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Reflector/FunctionReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

use BetterReflection\Identifier\Identifier;
use BetterReflection\Identifier\IdentifierType;
use BetterReflection\Reflector\Generic as GenericReflector;
use BetterReflection\SourceLocator\SourceLocator;
use BetterReflection\SourceLocator\Type\SourceLocator;

class FunctionReflector implements Reflector
{
/**
* @var GenericReflector
* @var SourceLocator
*/
private $reflector;
private $sourceLocator;

public function __construct(SourceLocator $sourceLocator)
{
$this->reflector = new GenericReflector($sourceLocator);
$this->sourceLocator = $sourceLocator;
}

/**
Expand All @@ -27,7 +26,8 @@ public function __construct(SourceLocator $sourceLocator)
*/
public function reflect($functionName)
{
return $this->reflector->reflect(
return $this->sourceLocator->locateIdentifier(
$this,
new Identifier($functionName, new IdentifierType(IdentifierType::IDENTIFIER_FUNCTION))
);
}
Expand Down
205 changes: 0 additions & 205 deletions src/Reflector/Generic.php

This file was deleted.

Loading

0 comments on commit c7aa2c0

Please sign in to comment.