Skip to content

Commit d439ee9

Browse files
committed
add createInstance to project factory
1 parent da27bc2 commit d439ee9

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

src/phpDocumentor/Reflection/Php/ProjectFactory.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
namespace phpDocumentor\Reflection\Php;
1414

15+
use phpDocumentor\Reflection\DocBlockFactory;
1516
use phpDocumentor\Reflection\Exception;
1617
use phpDocumentor\Reflection\Fqsen;
18+
use phpDocumentor\Reflection\PrettyPrinter;
1719
use phpDocumentor\Reflection\ProjectFactory as ProjectFactoryInterface;
20+
use phpDocumentor\Reflection\Php\Factory as Factory;
1821

1922
/**
2023
* Factory class to transform files into a project description.
@@ -36,6 +39,24 @@ public function __construct($strategies)
3639
$this->strategies = new ProjectFactoryStrategies($strategies);
3740
}
3841

42+
public static function createInstance()
43+
{
44+
new ProjectFactory(
45+
[
46+
new Factory\Argument(),
47+
new Factory\Class_(),
48+
new Factory\Constant(),
49+
new Factory\DocBlock(DocBlockFactory::createInstance()),
50+
new Factory\File(NodesFactory::createInstance()),
51+
new Factory\Function_(),
52+
new Factory\Interface_(),
53+
new Factory\Method(),
54+
new Factory\Property(new PrettyPrinter()),
55+
new Factory\Trait_(),
56+
]
57+
);
58+
}
59+
3960
/**
4061
* Creates a project from the set of files.
4162
*

tests/component/ProjectCreationTest.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@
1414

1515
use Mockery as m;
1616
use phpDocumentor\Reflection\DocBlock\Tags\Param;
17-
use phpDocumentor\Reflection\Php\Factory\Argument;
18-
use phpDocumentor\Reflection\Php\Factory\Class_;
19-
use phpDocumentor\Reflection\Php\Factory\Constant;
20-
use phpDocumentor\Reflection\Php\Factory\DocBlock as DocBlockStrategy;
21-
use phpDocumentor\Reflection\Php\Factory\File;
22-
use phpDocumentor\Reflection\Php\Factory\Function_;
23-
use phpDocumentor\Reflection\Php\Factory\Interface_;
24-
use phpDocumentor\Reflection\Php\Factory\Method;
25-
use phpDocumentor\Reflection\Php\Factory\Property;
26-
use phpDocumentor\Reflection\Php\Factory\Trait_;
27-
use phpDocumentor\Reflection\Php\NodesFactory;
2817
use phpDocumentor\Reflection\Php\ProjectFactory;
2918
use phpDocumentor\Reflection\Types\Object_;
3019

@@ -42,25 +31,9 @@ class ProjectCreationTest extends \PHPUnit_Framework_TestCase
4231

4332
protected function setUp()
4433
{
45-
$docBlockFactory = DocBlockFactory::createInstance();
46-
47-
$this->fixture = new ProjectFactory(
48-
[
49-
new Argument(),
50-
new Class_(),
51-
new Constant(),
52-
new DocBlockStrategy($docBlockFactory),
53-
new File(NodesFactory::createInstance()),
54-
new Function_(),
55-
new Interface_(),
56-
new Method(),
57-
new Property(new PrettyPrinter()),
58-
new Trait_(),
59-
]
60-
);
34+
$this->fixture = ProjectFactory::createInstance();
6135
}
6236

63-
6437
public function testCreateProjectWithFunctions()
6538
{
6639
$fileName = __DIR__ . '/project/simpleFunction.php';

0 commit comments

Comments
 (0)