Skip to content

Commit

Permalink
Merge pull request #264 from munkie/doc-blocks
Browse files Browse the repository at this point in the history
Fix incorrect docblock var and return types
  • Loading branch information
tshelburne committed Mar 21, 2016
2 parents 9c05a91 + 55ef3a2 commit 3bf8e6f
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/Nelmio/Alice/Fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function addProcessor(ProcessorInterface $processor)
$this->processors[] = $processor;
}

protected function persist($persister, $objects)
protected function persist(PersisterInterface $persister, $objects)
{
foreach ($this->processors as $proc) {
foreach ($objects as $obj) {
Expand Down
13 changes: 10 additions & 3 deletions src/Nelmio/Alice/Fixtures/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@

use InvalidArgumentException;
use Nelmio\Alice\Fixtures\Builder\Methods\MethodInterface;
use Nelmio\Alice\Fixtures\Fixture;

class Builder
{
/**
* @var array
**/
* @var MethodInterface[]
*/
protected $methods;

/**
* @var array
*/
protected $templates;

/**
* @param MethodInterface[] $methods
*/
public function __construct(array $methods)
{
foreach ($methods as $method) {
Expand All @@ -51,7 +55,10 @@ public function addBuilder(MethodInterface $builder)
/**
* builds a single fixture from a "raw" definition
*
* @param array $rawData
* @param string $class
* @param string $name
* @param array $spec
* @return Fixture[]
*/
public function build($class, $name, array $spec)
{
Expand Down
14 changes: 8 additions & 6 deletions src/Nelmio/Alice/Fixtures/Builder/Methods/MethodInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@

namespace Nelmio\Alice\Fixtures\Builder\Methods;

use Nelmio\Alice\Fixtures\Fixture;

interface MethodInterface
{
/**
* tests whether this class can build an fixture with the given name
*
* @param string $name
* @return boolean
* @param string $name
* @return bool
*/
public function canBuild($name);

/**
* builds an fixture from the given class, name, and spec
*
* @param string $class
* @param string $name
* @param array $spec
* @return array
* @param string $class
* @param string $name
* @param array $spec
* @return Fixture[]
*/
public function build($class, $name, array $spec);
}
27 changes: 18 additions & 9 deletions src/Nelmio/Alice/Fixtures/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Fixture
protected $spec;

/**
* @var array
* @var PropertyDefinition[]
*/
protected $properties;

Expand Down Expand Up @@ -164,11 +164,16 @@ public function getName()
/**
* returns the list of properties with the complex properties (__construct, __set, etc) filtered out
*
* @return array
* @return PropertyDefinition[]
*/
public function getProperties()
{
return array_filter($this->properties, function ($property) { return $property->isBasic(); });
return array_filter(
$this->properties,
function (PropertyDefinition $property) {
return $property->isBasic();
}
);
}

/**
Expand All @@ -184,7 +189,8 @@ public function getClassFlags()
/**
* returns true if this fixture has the given class flag
*
* @return boolean
* @param string $flag
* @return bool
*/
public function hasClassFlag($flag)
{
Expand All @@ -204,7 +210,8 @@ public function getNameFlags()
/**
* returns true if this fixture has the given name flag
*
* @return boolean
* @param string $flag
* @return bool
*/
public function hasNameFlag($flag)
{
Expand Down Expand Up @@ -266,7 +273,7 @@ public function hasCustomSetter()
/**
* returns the name of the method to use as the custom setter
*
* @return string
* @return PropertyDefinition
*/
public function getCustomSetter()
{
Expand All @@ -287,7 +294,8 @@ public function setPropertyValue($property, $value)
/**
* returns the value of a property that has been registered as set
*
* @return mixed $value
* @param string $property
* @return mixed
*/
public function getPropertyValue($property)
{
Expand Down Expand Up @@ -315,8 +323,9 @@ public function __toString()
/**
* creates and adds a PropertyDefinition to the fixture with the given name and value
*
* @param string $name
* @param mixed $value
* @param string $name
* @param mixed $value
* @return PropertyDefinition
*/
protected function addProperty($name, $value)
{
Expand Down
49 changes: 28 additions & 21 deletions src/Nelmio/Alice/Fixtures/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@

namespace Nelmio\Alice\Fixtures;

use Nelmio\Alice\Instances\Processor\Methods\Faker;
use Nelmio\Alice\Fixtures\ParameterBag;
use Psr\Log\LoggerInterface;
use Nelmio\Alice\PersisterInterface;
use Nelmio\Alice\Instances\Collection;
use Nelmio\Alice\Instances\Instantiator;
use Nelmio\Alice\Instances\Populator;
use Nelmio\Alice\Instances\Processor;
use Nelmio\Alice\Instances\Processor\Methods\Faker;
use Nelmio\Alice\Instances\Processor\Providers\IdentityProvider;
use Nelmio\Alice\PersisterInterface;
use Nelmio\Alice\Util\TypeHintChecker;
use Psr\Log\LoggerInterface;

/**
* Loads fixtures from an array or file
Expand All @@ -38,12 +37,17 @@ class Loader
protected $typeHintChecker;

/**
* @var Parser
* @var Processor\Processor
*/
protected $processor;

/**
* @var Parser\Parser
**/
protected $parser;

/**
* @var Builder
* @var Builder\Builder
*/
protected $builder;

Expand All @@ -53,12 +57,12 @@ class Loader
protected $fakerProcessorMethod;

/**
* @var Instantiator
* @var Instantiator\Instantiator
*/
protected $instantiator;

/**
* @var Populator
* @var Populator\Populator
*/
protected $populator;

Expand All @@ -68,7 +72,7 @@ class Loader
protected $manager;

/**
* @var \Nelmio\Alice\Fixtures\ParameterBag
* @var ParameterBag
*/
protected $parameterBag;

Expand Down Expand Up @@ -125,7 +129,8 @@ public function __construct($locale = 'en_US', array $providers = [], $seed = 1,
/**
* Loads a fixture file
*
* @param string|array $dataOrFilename data array or filename
* @param string|array $dataOrFilename data array or filename
* @return object[]
*/
public function load($dataOrFilename)
{
Expand Down Expand Up @@ -157,7 +162,7 @@ public function getReference($name, $property = null)
/**
* Returns all references created by the loader
*
* @return array[object]
* @return object[]
*/
public function getReferences()
{
Expand All @@ -181,12 +186,14 @@ public function addProvider($provider)
}

/**
* @param array $references
* References are objects which the loader is aware of while loading fixtures.
*
* @param object[] $references Array of object where the key is the name of the reference
*/
public function setReferences(array $objects)
public function setReferences(array $references)
{
$this->objects->clear();
foreach ($objects as $name => $object) {
foreach ($references as $name => $object) {
$this->objects->set($name, $object);
}
}
Expand Down Expand Up @@ -244,8 +251,8 @@ public function addPopulator(Populator\Methods\MethodInterface $populator)
/**
* parses a file at the given filename
*
* @param string filename
* @return array data
* @param string $filename
* @return array data
*/
protected function parseFile($filename)
{
Expand All @@ -255,8 +262,8 @@ protected function parseFile($filename)
/**
* builds a collection of fixtures
*
* @param array $rawData
* @return array
* @param array $rawData
* @return Fixture[]
*/
protected function buildFixtures(array $rawData)
{
Expand All @@ -275,7 +282,7 @@ protected function buildFixtures(array $rawData)
/**
* creates an empty instance for each fixture, and adds it to our object collection
*
* @param array $fixtures
* @param Fixture[] $fixtures
*/
protected function instantiateFixtures(array $fixtures)
{
Expand All @@ -290,8 +297,8 @@ protected function instantiateFixtures(array $fixtures)
/**
* hydrates each instance described by fixtures and returns the final non-local list
*
* @param array $fixtures
* @return array
* @param Fixture[] $fixtures
* @return object[] List of object created
*/
protected function populateObjects(array $fixtures)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Nelmio/Alice/Fixtures/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function get($key)
}

/**
* @param mixed $value
* @param string $key
* @param mixed $value
*/
public function set($key, $value)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Nelmio/Alice/Fixtures/Parser/Methods/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ protected function compilePhp($file)
return ob_get_clean();
}

/**
* @return \Closure|void
*/
protected function createFakerClosure()
{
if (!$this->context instanceof Loader) {
Expand Down Expand Up @@ -100,8 +103,8 @@ protected function processIncludes($data, $filename)
}

/**
* @param array $data
* @param array $includeData
* @param array $data
* @param array $includeData
* @return array
*/
protected function mergeIncludeData($data, $includeData)
Expand Down
9 changes: 7 additions & 2 deletions src/Nelmio/Alice/Fixtures/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
class Parser
{
/**
* @var array
**/
* @var MethodInterface[]
*/
private $parsers = [];

/**
* Parser constructor.
*
* @param MethodInterface[] $parsers
*/
public function __construct(array $parsers)
{
foreach ($parsers as $parser) {
Expand Down
5 changes: 4 additions & 1 deletion src/Nelmio/Alice/Instances/Instantiator/Instantiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
class Instantiator
{
/**
* @var array
* @var MethodInterface[]
**/
protected $methods;

/**
* @param MethodInterface[] $methods
*/
public function __construct(array $methods)
{
foreach ($methods as $method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ interface MethodInterface
/**
* returns true if this method can instantiate the object described in the fixture
*
* @param Fixture
* @return boolean
* @param Fixture $fixture
* @return bool
*/
public function canInstantiate(Fixture $fixture);

/**
* returns an empty instance of the class the fixture describes
*
* @param Fixture
* @return mixed
* @param Fixture $fixture
* @return object
*/
public function instantiate(Fixture $fixture);
}
5 changes: 3 additions & 2 deletions src/Nelmio/Alice/Instances/Populator/Methods/ArrayAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public function set(Fixture $fixture, $object, $property, $value)
/**
* finds the method used to append values to the named property
*
* @param mixed $object
* @param string $property
* @param mixed $object
* @param string $property
* @return string Method name or null if adder method not detected
*/
private function findAdderMethod($object, $property)
{
Expand Down
Loading

0 comments on commit 3bf8e6f

Please sign in to comment.