Skip to content

Commit b7abddd

Browse files
committed
Merge pull request #75 from jaapio/feature/projectFactoryInstanciator
add createInstance to project factory
2 parents 87e4789 + a3f72c9 commit b7abddd

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

src/phpDocumentor/Reflection/Php/ProjectFactory.php

Lines changed: 26 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,29 @@ public function __construct($strategies)
3639
$this->strategies = new ProjectFactoryStrategies($strategies);
3740
}
3841

42+
/**
43+
* Creates a new instance of this factory. With all default strategies.
44+
*
45+
* @return static;
46+
*/
47+
public static function createInstance()
48+
{
49+
return new static(
50+
[
51+
new Factory\Argument(),
52+
new Factory\Class_(),
53+
new Factory\Constant(),
54+
new Factory\DocBlock(DocBlockFactory::createInstance()),
55+
new Factory\File(NodesFactory::createInstance()),
56+
new Factory\Function_(),
57+
new Factory\Interface_(),
58+
new Factory\Method(),
59+
new Factory\Property(new PrettyPrinter()),
60+
new Factory\Trait_(),
61+
]
62+
);
63+
}
64+
3965
/**
4066
* Creates a project from the set of files.
4167
*

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)