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

Commit f0ec03f

Browse files
committed
Merge pull request #738 from daniel-mueller/master
added PHPDocs, removed unused variable
2 parents 9198c2f + 0077ef8 commit f0ec03f

20 files changed

+183
-5
lines changed

src/Faker/Calculator/Iban.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public static function checksum($iban)
2424
return str_pad($checksum, 2, '0', STR_PAD_LEFT);
2525
}
2626

27+
/**
28+
* @return int
29+
*/
2730
private static function alphaToNumberCallback($match)
2831
{
2932
return self::alphaToNumber($match[0]);
@@ -44,7 +47,6 @@ public static function alphaToNumber($char)
4447
* Calculates mod97 on a numeric string
4548
*
4649
* @param string $number Numeric string
47-
* @param int
4850
* @return int
4951
*/
5052
public static function mod97($number)
@@ -59,6 +61,7 @@ public static function mod97($number)
5961
/**
6062
* Checks whether an IBAN has a valid checksum
6163
*
64+
* @param string $iban
6265
* @return boolean
6366
*/
6467
public static function isValid($iban)

src/Faker/Calculator/Luhn.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class Luhn
1414
{
1515
/**
16+
* @param string $number
1617
* @return int
1718
*/
1819
private static function checksum($number)
@@ -31,6 +32,7 @@ private static function checksum($number)
3132
}
3233

3334
/**
35+
* @param $partialNumber
3436
* @return string
3537
*/
3638
public static function computeCheckDigit($partialNumber)
@@ -46,7 +48,8 @@ public static function computeCheckDigit($partialNumber)
4648
/**
4749
* Checks whether a number (partial number + check digit) is Luhn compliant
4850
*
49-
* @return boolean
51+
* @param string $number
52+
* @return bool
5053
*/
5154
public static function isValid($number)
5255
{

src/Faker/DefaultGenerator.php

+7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ public function __construct($default = null)
1515
$this->default = $default;
1616
}
1717

18+
/**
19+
* @param string $attribute
20+
*/
1821
public function __get($attribute)
1922
{
2023
return $this->default;
2124
}
2225

26+
/**
27+
* @param string $method
28+
* @param array $attributes
29+
*/
2330
public function __call($method, $attributes)
2431
{
2532
return $this->default;

src/Faker/Documentor.php

+6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ class Documentor
66
{
77
protected $generator;
88

9+
/**
10+
* @param Generator $generator
11+
*/
912
public function __construct(Generator $generator)
1013
{
1114
$this->generator = $generator;
1215
}
1316

17+
/**
18+
* @return array
19+
*/
1420
public function getFormatters()
1521
{
1622
$formatters = array();

src/Faker/Factory.php

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public static function create($locale = self::DEFAULT_LOCALE)
2525
return $generator;
2626
}
2727

28+
/**
29+
* @param string $provider
30+
* @param string $locale
31+
* @return string
32+
*/
2833
protected static function getProviderClassname($provider, $locale = '')
2934
{
3035
if ($providerClass = self::findProviderClassname($provider, $locale)) {
@@ -41,6 +46,11 @@ protected static function getProviderClassname($provider, $locale = '')
4146
throw new \InvalidArgumentException(sprintf('Unable to find provider "%s" with locale "%s"', $provider, $locale));
4247
}
4348

49+
/**
50+
* @param string $provider
51+
* @param string $locale
52+
* @return string
53+
*/
4454
protected static function findProviderClassname($provider, $locale = '')
4555
{
4656
$providerClass = 'Faker\\' . ($locale ? sprintf('Provider\%s\%s', $locale, $provider) : sprintf('Provider\%s', $provider));

src/Faker/Generator.php

+7
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,18 @@ protected function callFormatWithMatches($matches)
228228
return $this->format($matches[1]);
229229
}
230230

231+
/**
232+
* @param string $attribute
233+
*/
231234
public function __get($attribute)
232235
{
233236
return $this->format($attribute);
234237
}
235238

239+
/**
240+
* @param string $method
241+
* @param array $attributes
242+
*/
236243
public function __call($method, $attributes)
237244
{
238245
return $this->format($method, $attributes);

src/Faker/Guesser/Name.php

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class Name
88
{
99
protected $generator;
1010

11+
/**
12+
* @param \Faker\Generator $generator
13+
*/
1114
public function __construct(\Faker\Generator $generator)
1215
{
1316
$this->generator = $generator;

src/Faker/ORM/CakePHP/ColumnTypeGuesser.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public function __construct(\Faker\Generator $generator)
1111
$this->generator = $generator;
1212
}
1313

14+
/**
15+
* @return \Closure|null
16+
*/
1417
public function guessFormat($column, $table)
1518
{
1619
$generator = $this->generator;

src/Faker/ORM/CakePHP/EntityPopulator.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ public function __construct($class)
1717
$this->class = $class;
1818
}
1919

20+
/**
21+
* @param string $name
22+
*/
2023
public function __get($name)
2124
{
2225
return $this->{$name};
2326
}
2427

28+
/**
29+
* @param string $name
30+
*/
2531
public function __set($name, $value)
2632
{
2733
$this->{$name} = $value;
@@ -37,6 +43,9 @@ public function mergeModifiersWith($modifiers)
3743
$this->modifiers = array_merge($this->modifiers, $modifiers);
3844
}
3945

46+
/**
47+
* @return array
48+
*/
4049
public function guessColumnFormatters($populator)
4150
{
4251
$formatters = [];
@@ -71,7 +80,10 @@ public function guessColumnFormatters($populator)
7180
return $formatters;
7281
}
7382

74-
public function guessModifiers($populator)
83+
/**
84+
* @return array
85+
*/
86+
public function guessModifiers()
7587
{
7688
$modifiers = [];
7789
$table = $this->getTable($this->class);
@@ -109,6 +121,9 @@ public function guessModifiers($populator)
109121
return $modifiers;
110122
}
111123

124+
/**
125+
* @param array $options
126+
*/
112127
public function execute($class, $insertedEntities, $options = [])
113128
{
114129
$table = $this->getTable($class);

src/Faker/ORM/CakePHP/Populator.php

+26-1
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,33 @@ class Populator
1010
protected $quantities = [];
1111
protected $guessers = [];
1212

13+
/**
14+
* @param \Faker\Generator $generator
15+
*/
1316
public function __construct(\Faker\Generator $generator)
1417
{
1518
$this->generator = $generator;
1619
}
1720

21+
/**
22+
* @return \Faker\Generator
23+
*/
1824
public function getGenerator()
1925
{
2026
return $this->generator;
2127
}
2228

29+
/**
30+
* @return array
31+
*/
2332
public function getGuessers()
2433
{
2534
return $this->guessers;
2635
}
2736

37+
/**
38+
* @return $this
39+
*/
2840
public function removeGuesser($name)
2941
{
3042
if ($this->guessers[$name]) {
@@ -33,6 +45,10 @@ public function removeGuesser($name)
3345
return $this;
3446
}
3547

48+
/**
49+
* @return $this
50+
* @throws \Exception
51+
*/
3652
public function addGuesser($class)
3753
{
3854
if (!is_object($class)) {
@@ -47,7 +63,12 @@ public function addGuesser($class)
4763
return $this;
4864
}
4965

50-
public function addEntity($entity, $number, $customColumnFormatters = [], $customModifiers = [])
66+
/**
67+
* @param array $customColumnFormatters
68+
* @param array $customModifiers
69+
* @return $this
70+
*/
71+
public function addEntEntityPopulatority($entity, $number, $customColumnFormatters = [], $customModifiers = [])
5172
{
5273
if (!$entity instanceof EntityPopulator) {
5374
$entity = new EntityPopulator($entity);
@@ -69,6 +90,10 @@ public function addEntity($entity, $number, $customColumnFormatters = [], $custo
6990
return $this;
7091
}
7192

93+
/**
94+
* @param array $options
95+
* @return array
96+
*/
7297
public function execute($options = [])
7398
{
7499
$insertedEntities = [];

src/Faker/ORM/Doctrine/ColumnTypeGuesser.php

+7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ class ColumnTypeGuesser
88
{
99
protected $generator;
1010

11+
/**
12+
* @param \Faker\Generator $generator
13+
*/
1114
public function __construct(\Faker\Generator $generator)
1215
{
1316
$this->generator = $generator;
1417
}
1518

19+
/**
20+
* @param ClassMetadata $class
21+
* @return \Closure|null
22+
*/
1623
public function guessFormat($fieldName, ClassMetadata $class)
1724
{
1825
$generator = $this->generator;

src/Faker/ORM/Doctrine/EntityPopulator.php

+26
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@ public function getClass()
4242
return $this->class->getName();
4343
}
4444

45+
/**
46+
* @param $columnFormatters
47+
*/
4548
public function setColumnFormatters($columnFormatters)
4649
{
4750
$this->columnFormatters = $columnFormatters;
4851
}
4952

53+
/**
54+
* @return array
55+
*/
5056
public function getColumnFormatters()
5157
{
5258
return $this->columnFormatters;
@@ -57,21 +63,34 @@ public function mergeColumnFormattersWith($columnFormatters)
5763
$this->columnFormatters = array_merge($this->columnFormatters, $columnFormatters);
5864
}
5965

66+
/**
67+
* @param array $modifiers
68+
*/
6069
public function setModifiers(array $modifiers)
6170
{
6271
$this->modifiers = $modifiers;
6372
}
6473

74+
/**
75+
* @return array
76+
*/
6577
public function getModifiers()
6678
{
6779
return $this->modifiers;
6880
}
6981

82+
/**
83+
* @param array $modifiers
84+
*/
7085
public function mergeModifiersWith(array $modifiers)
7186
{
7287
$this->modifiers = array_merge($this->modifiers, $modifiers);
7388
}
7489

90+
/**
91+
* @param \Faker\Generator $generator
92+
* @return array
93+
*/
7594
public function guessColumnFormatters(\Faker\Generator $generator)
7695
{
7796
$formatters = array();
@@ -139,6 +158,9 @@ public function guessColumnFormatters(\Faker\Generator $generator)
139158

140159
/**
141160
* Insert one new record using the Entity class.
161+
* @param ObjectManager $manager
162+
* @param bool $generateId
163+
* @return EntityPopulator
142164
*/
143165
public function execute(ObjectManager $manager, $insertedEntities, $generateId = false)
144166
{
@@ -177,6 +199,10 @@ private function callMethods($obj, $insertedEntities)
177199
}
178200
}
179201

202+
/**
203+
* @param EntityManagerInterface $manager
204+
* @return int|null
205+
*/
180206
private function generateId($obj, $column, EntityManagerInterface $manager)
181207
{
182208
/* @var $repository \Doctrine\ORM\EntityRepository */

src/Faker/ORM/Doctrine/Populator.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class Populator
1616
protected $quantities = array();
1717
protected $generateId = array();
1818

19+
/**
20+
* @param \Faker\Generator $generator
21+
* @param ObjectManager|null $manager
22+
*/
1923
public function __construct(\Faker\Generator $generator, ObjectManager $manager = null)
2024
{
2125
$this->generator = $generator;
@@ -51,7 +55,7 @@ public function addEntity($entity, $number, $customColumnFormatters = array(), $
5155
/**
5256
* Populate the database using all the Entity classes previously added.
5357
*
54-
* @param EntityManager $entityManager A Doctrine connection object
58+
* @param null|EntityManager $entityManager A Doctrine connection object
5559
*
5660
* @return array A list of the inserted PKs
5761
*/

0 commit comments

Comments
 (0)