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

Commit

Permalink
Merge pull request #1170 from ankitpokhrel/master
Browse files Browse the repository at this point in the history
Typos and doc block fixes
  • Loading branch information
fzaninotto authored Mar 26, 2017
2 parents 489dec4 + d01627e commit 3860fbe
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/Faker/Calculator/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public static function checksum($iban)
}

/**
* @param string $match
*
* @return int
*/
private static function alphaToNumberCallback($match)
Expand Down
3 changes: 2 additions & 1 deletion src/Faker/Calculator/Luhn.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public static function isValid($number)
/**
* Generate a Luhn compliant number.
*
* @param string $prefix
* @param string $partialValue
*
* @return string
*/
public static function generateLuhnNumber($partialValue)
Expand Down
4 changes: 4 additions & 0 deletions src/Faker/DefaultGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function __construct($default = null)

/**
* @param string $attribute
*
* @return mixed
*/
public function __get($attribute)
{
Expand All @@ -26,6 +28,8 @@ public function __get($attribute)
/**
* @param string $method
* @param array $attributes
*
* @return mixed
*/
public function __call($method, $attributes)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Faker/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public function format($formatter, $arguments = array())
}

/**
* @param string $formatter
*
* @return Callable
*/
public function getFormatter($formatter)
Expand Down Expand Up @@ -243,6 +245,8 @@ protected function callFormatWithMatches($matches)

/**
* @param string $attribute
*
* @return mixed
*/
public function __get($attribute)
{
Expand All @@ -252,6 +256,8 @@ public function __get($attribute)
/**
* @param string $method
* @param array $attributes
*
* @return mixed
*/
public function __call($method, $attributes)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Faker/Provider/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ private function ean($length = 13)

/**
* Utility function for computing EAN checksums
*
* @param string $input
*
* @return integer
*/
protected static function eanChecksum($input)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Faker/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public static function shuffle($arg = '')
* Returns a shuffled version of the array.
*
* This function does not mutate the original array. It uses the
* Fisher–Yates algorithm, which is unbiaised, together with a Mersenne
* Fisher–Yates algorithm, which is unbiased, together with a Mersenne
* twister random generator. This function is therefore more random than
* PHP's shuffle() function, and it is seedable.
*
Expand Down Expand Up @@ -297,7 +297,7 @@ public static function shuffleArray($array = array())
* Returns a shuffled version of the string.
*
* This function does not mutate the original string. It uses the
* Fisher–Yates algorithm, which is unbiaised, together with a Mersenne
* Fisher–Yates algorithm, which is unbiased, together with a Mersenne
* twister random generator. This function is therefore more random than
* PHP's shuffle() function, and it is seedable. Additionally, it is
* UTF8 safe if the mb extension is available.
Expand Down Expand Up @@ -422,7 +422,7 @@ public static function asciify($string = '****')
* Regex delimiters '/.../' and begin/end markers '^...$' are ignored.
*
* Only supports a small subset of the regex syntax. For instance,
* unicode, negated classes, unbouned ranges, subpatterns, back references,
* unicode, negated classes, unbounded ranges, subpatterns, back references,
* assertions, recursive patterns, and comments are not supported. Escaping
* support is extremely fragile.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Faker/Provider/Biased.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
$x = mt_rand() / mt_getrandmax();
$y = mt_rand() / (mt_getrandmax() + 1);
} while (call_user_func($function, $x) < $y);

return floor($x * ($max - $min + 1) + $min);
}

Expand All @@ -35,7 +35,7 @@ public function biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
*
* @return integer
*/
protected static function unbiased($x)
protected static function unbiased()
{
return 1;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Faker/Provider/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ public static function timezone()

/**
* Internal method to set the time zone on a DateTime.
*
* @param \DateTime $dt
* @param string $timezone
*
* @return $this
*/
private static function setTimezone(\DateTime $dt, $timezone)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Faker/Provider/HtmlLorem.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function __construct(Generator $generator)
}

/**
* @param integer $maxDepth
* @param integer $maxWidth
*
* @return string
*/
public function randomHtml($maxDepth = 4, $maxWidth = 4)
Expand Down Expand Up @@ -221,7 +224,7 @@ private function addLoginForm(\DOMElement $element)

$submit = $element->ownerDocument->createElement(static::FORM_TAG);
$submit->setAttribute("action", $this->generator->safeEmailDomain);
$submit->SetAttribute("method", "POST");
$submit->setAttribute("method", "POST");
$submit->appendChild($textLabel);
$submit->appendChild($textInput);
$submit->appendChild($passwordLabel);
Expand Down
13 changes: 11 additions & 2 deletions src/Faker/Provider/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ class Image extends Base
* Set randomize to false to remove the random GET parameter at the end of the url.
*
* @example 'http://lorempixel.com/640/480/?12345'
*
* @param integer $width
* @param integer $height
* @param string|null $category
* @param bool $randomize
* @param string|null $word
* @param bool $gray
*
* @return string
*/
public static function imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false)
{
$baseUrl = "http://lorempixel.com/";
$url = "{$width}/{$height}/";

if ($gray) {
$url = "gray/" . $url;
}

if ($category) {
if (!in_array($category, static::$categories)) {
throw new \InvalidArgumentException(sprintf('Unknown image category "%s"', $category));
Expand Down
12 changes: 5 additions & 7 deletions src/Faker/Provider/Internet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Faker\Provider;

class Internet extends \Faker\Provider\Base
class Internet extends Base
{
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com');
protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org');
Expand Down Expand Up @@ -36,7 +36,7 @@ class Internet extends \Faker\Provider\Base
public function email()
{
$format = static::randomElement(static::$emailFormats);

return $this->generator->parse($format);
}

Expand Down Expand Up @@ -206,13 +206,11 @@ public static function localIpv4()
{
if (static::numberBetween(0, 1) === 0) {
// 10.x.x.x range
$ip = long2ip(static::numberBetween(ip2long("10.0.0.0"), ip2long("10.255.255.255")));
} else {
// 192.168.x.x range
$ip = long2ip(static::numberBetween(ip2long("192.168.0.0"), ip2long("192.168.255.255")));
return long2ip(static::numberBetween(ip2long("10.0.0.0"), ip2long("10.255.255.255")));
}

return $ip;
// 192.168.x.x range
return long2ip(static::numberBetween(ip2long("192.168.0.0"), ip2long("192.168.255.255")));
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Faker/Provider/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function realText($maxNbChars = 200, $indexSize = 2)
throw new \InvalidArgumentException('indexSize must be at most 5');
}


$words = $this->getConsecutiveWords($indexSize);
$result = array();
$resultLength = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/Faker/Provider/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function safari()
} else {
$ver = mt_rand(4, 5) . '.0.' . mt_rand(1, 5);
}

$mobileDevices = array(
'iPhone; CPU iPhone OS',
'iPad; CPU OS'
Expand All @@ -122,7 +122,6 @@ public static function safari()

return "Mozilla/5.0 " . static::randomElement($platforms);
}


/**
* Generate Opera user agent
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/UniqueGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UniqueGenerator

/**
* @param Generator $generator
* @param $maxRetries
* @param integer $maxRetries
*/
public function __construct(Generator $generator, $maxRetries = 10000)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Faker/ValidGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ValidGenerator

/**
* @param Generator $generator
* @param callable|null $validator
* @param integer $maxRetries
*/
public function __construct(Generator $generator, $validator = null, $maxRetries = 10000)
{
Expand All @@ -32,6 +34,8 @@ public function __construct(Generator $generator, $validator = null, $maxRetries
/**
* Catch and proxy all generator calls but return only valid values
* @param string $attribute
*
* @return mixed
*/
public function __get($attribute)
{
Expand All @@ -42,6 +46,8 @@ public function __get($attribute)
* Catch and proxy all generator calls with arguments but return only valid values
* @param string $name
* @param array $arguments
*
* @return mixed
*/
public function __call($name, $arguments)
{
Expand Down

0 comments on commit 3860fbe

Please sign in to comment.