Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

added PHPDocs, removed unused variable #738

Merged
merged 4 commits into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Faker/Calculator/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static function checksum($iban)
return str_pad($checksum, 2, '0', STR_PAD_LEFT);
}

/**
* @return int
*/
private static function alphaToNumberCallback($match)
{
return self::alphaToNumber($match[0]);
Expand All @@ -44,7 +47,6 @@ public static function alphaToNumber($char)
* Calculates mod97 on a numeric string
*
* @param string $number Numeric string
* @param int
* @return int
*/
public static function mod97($number)
Expand All @@ -59,6 +61,7 @@ public static function mod97($number)
/**
* Checks whether an IBAN has a valid checksum
*
* @param string $iban
* @return boolean
*/
public static function isValid($iban)
Expand Down
5 changes: 4 additions & 1 deletion src/Faker/Calculator/Luhn.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class Luhn
{
/**
* @param string $number
* @return int
*/
private static function checksum($number)
Expand All @@ -31,6 +32,7 @@ private static function checksum($number)
}

/**
* @param $partialNumber
* @return string
*/
public static function computeCheckDigit($partialNumber)
Expand All @@ -46,7 +48,8 @@ public static function computeCheckDigit($partialNumber)
/**
* Checks whether a number (partial number + check digit) is Luhn compliant
*
* @return boolean
* @param string $number
* @return bool
*/
public static function isValid($number)
{
Expand Down
7 changes: 7 additions & 0 deletions src/Faker/DefaultGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ public function __construct($default = null)
$this->default = $default;
}

/**
* @param string $attribute
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, not necessarily string. Same for __call

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forget that.

*/
public function __get($attribute)
{
return $this->default;
}

/**
* @param string $method
* @param array $attributes
*/
public function __call($method, $attributes)
{
return $this->default;
Expand Down
6 changes: 6 additions & 0 deletions src/Faker/Documentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ class Documentor
{
protected $generator;

/**
* @param Generator $generator
*/
public function __construct(Generator $generator)
{
$this->generator = $generator;
}

/**
* @return array
*/
public function getFormatters()
{
$formatters = array();
Expand Down
10 changes: 10 additions & 0 deletions src/Faker/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static function create($locale = self::DEFAULT_LOCALE)
return $generator;
}

/**
* @param string $provider
* @param string $locale
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you document $provider, too? (string). Same for findProviderClassname

* @return string
*/
protected static function getProviderClassname($provider, $locale = '')
{
if ($providerClass = self::findProviderClassname($provider, $locale)) {
Expand All @@ -41,6 +46,11 @@ protected static function getProviderClassname($provider, $locale = '')
throw new \InvalidArgumentException(sprintf('Unable to find provider "%s" with locale "%s"', $provider, $locale));
}

/**
* @param string $provider
* @param string $locale
* @return string
*/
protected static function findProviderClassname($provider, $locale = '')
{
$providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));
Expand Down
7 changes: 7 additions & 0 deletions src/Faker/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,18 @@ protected function callFormatWithMatches($matches)
return $this->format($matches[1]);
}

/**
* @param string $attribute
*/
public function __get($attribute)
{
return $this->format($attribute);
}

/**
* @param string $method
* @param array $attributes
*/
public function __call($method, $attributes)
{
return $this->format($method, $attributes);
Expand Down
3 changes: 3 additions & 0 deletions src/Faker/Guesser/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class Name
{
protected $generator;

/**
* @param \Faker\Generator $generator
*/
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
Expand Down
3 changes: 3 additions & 0 deletions src/Faker/ORM/CakePHP/ColumnTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public function __construct(\Faker\Generator $generator)
$this->generator = $generator;
}

/**
* @return \Closure|null
*/
public function guessFormat($column, $table)
{
$generator = $this->generator;
Expand Down
17 changes: 16 additions & 1 deletion src/Faker/ORM/CakePHP/EntityPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ public function __construct($class)
$this->class = $class;
}

/**
* @param string $name
*/
public function __get($name)
{
return $this->{$name};
}

/**
* @param string $name
*/
public function __set($name, $value)
{
$this->{$name} = $value;
Expand All @@ -37,6 +43,9 @@ public function mergeModifiersWith($modifiers)
$this->modifiers = array_merge($this->modifiers, $modifiers);
}

/**
* @return array
*/
public function guessColumnFormatters($populator)
{
$formatters = [];
Expand Down Expand Up @@ -71,7 +80,10 @@ public function guessColumnFormatters($populator)
return $formatters;
}

public function guessModifiers($populator)
/**
* @return array
*/
public function guessModifiers()
{
$modifiers = [];
$table = $this->getTable($this->class);
Expand Down Expand Up @@ -109,6 +121,9 @@ public function guessModifiers($populator)
return $modifiers;
}

/**
* @param array $options
*/
public function execute($class, $insertedEntities, $options = [])
{
$table = $this->getTable($class);
Expand Down
27 changes: 26 additions & 1 deletion src/Faker/ORM/CakePHP/Populator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,33 @@ class Populator
protected $quantities = [];
protected $guessers = [];

/**
* @param \Faker\Generator $generator
*/
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}

/**
* @return \Faker\Generator
*/
public function getGenerator()
{
return $this->generator;
}

/**
* @return array
*/
public function getGuessers()
{
return $this->guessers;
}

/**
* @return $this
*/
public function removeGuesser($name)
{
if ($this->guessers[$name]) {
Expand All @@ -33,6 +45,10 @@ public function removeGuesser($name)
return $this;
}

/**
* @return $this
* @throws \Exception
*/
public function addGuesser($class)
{
if (!is_object($class)) {
Expand All @@ -47,7 +63,12 @@ public function addGuesser($class)
return $this;
}

public function addEntity($entity, $number, $customColumnFormatters = [], $customModifiers = [])
/**
* @param array $customColumnFormatters
* @param array $customModifiers
* @return $this
*/
public function addEntEntityPopulatority($entity, $number, $customColumnFormatters = [], $customModifiers = [])
{
if (!$entity instanceof EntityPopulator) {
$entity = new EntityPopulator($entity);
Expand All @@ -69,6 +90,10 @@ public function addEntity($entity, $number, $customColumnFormatters = [], $custo
return $this;
}

/**
* @param array $options
* @return array
*/
public function execute($options = [])
{
$insertedEntities = [];
Expand Down
7 changes: 7 additions & 0 deletions src/Faker/ORM/Doctrine/ColumnTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ class ColumnTypeGuesser
{
protected $generator;

/**
* @param \Faker\Generator $generator
*/
public function __construct(\Faker\Generator $generator)
{
$this->generator = $generator;
}

/**
* @param ClassMetadata $class
* @return \Closure|null
*/
public function guessFormat($fieldName, ClassMetadata $class)
{
$generator = $this->generator;
Expand Down
26 changes: 26 additions & 0 deletions src/Faker/ORM/Doctrine/EntityPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ public function getClass()
return $this->class->getName();
}

/**
* @param $columnFormatters
*/
public function setColumnFormatters($columnFormatters)
{
$this->columnFormatters = $columnFormatters;
}

/**
* @return array
*/
public function getColumnFormatters()
{
return $this->columnFormatters;
Expand All @@ -57,21 +63,34 @@ public function mergeColumnFormattersWith($columnFormatters)
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
}

/**
* @param array $modifiers
*/
public function setModifiers(array $modifiers)
{
$this->modifiers = $modifiers;
}

/**
* @return array
*/
public function getModifiers()
{
return $this->modifiers;
}

/**
* @param array $modifiers
*/
public function mergeModifiersWith(array $modifiers)
{
$this->modifiers = array_merge($this->modifiers, $modifiers);
}

/**
* @param \Faker\Generator $generator
* @return array
*/
public function guessColumnFormatters(\Faker\Generator $generator)
{
$formatters = array();
Expand Down Expand Up @@ -139,6 +158,9 @@ public function guessColumnFormatters(\Faker\Generator $generator)

/**
* Insert one new record using the Entity class.
* @param ObjectManager $manager
* @param bool $generateId
* @return EntityPopulator
*/
public function execute(ObjectManager $manager, $insertedEntities, $generateId = false)
{
Expand Down Expand Up @@ -177,6 +199,10 @@ private function callMethods($obj, $insertedEntities)
}
}

/**
* @param EntityManagerInterface $manager
* @return int|null
*/
private function generateId($obj, $column, EntityManagerInterface $manager)
{
/* @var $repository \Doctrine\ORM\EntityRepository */
Expand Down
6 changes: 5 additions & 1 deletion src/Faker/ORM/Doctrine/Populator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class Populator
protected $quantities = array();
protected $generateId = array();

/**
* @param \Faker\Generator $generator
* @param ObjectManager|null $manager
*/
public function __construct(\Faker\Generator $generator, ObjectManager $manager = null)
{
$this->generator = $generator;
Expand Down Expand Up @@ -51,7 +55,7 @@ public function addEntity($entity, $number, $customColumnFormatters = array(), $
/**
* Populate the database using all the Entity classes previously added.
*
* @param EntityManager $entityManager A Doctrine connection object
* @param null|EntityManager $entityManager A Doctrine connection object
*
* @return array A list of the inserted PKs
*/
Expand Down
Loading