Skip to content

Commit

Permalink
Scalar type hints and return types
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Oct 4, 2017
1 parent 6f65fa9 commit 80060ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private function __construct(\libphonenumber\PhoneNumber $phoneNumber)
*
* @throws PhoneNumberParseException
*/
public static function parse($phoneNumber, $regionCode = null)
public static function parse(string $phoneNumber, string $regionCode = null) : PhoneNumber
{
try {
return new PhoneNumber(
Expand All @@ -56,7 +56,7 @@ public static function parse($phoneNumber, $regionCode = null)
*
* @throws PhoneNumberException If no example number is available for this region and type.
*/
public static function getExampleNumber($regionCode, $phoneNumberType = PhoneNumberType::FIXED_LINE)
public static function getExampleNumber(string $regionCode, int $phoneNumberType = PhoneNumberType::FIXED_LINE) : PhoneNumber
{
$phoneNumber = PhoneNumberUtil::getInstance()->getExampleNumberForType($regionCode, $phoneNumberType);

Expand All @@ -74,7 +74,7 @@ public static function getExampleNumber($regionCode, $phoneNumberType = PhoneNum
*
* @return string
*/
public function getCountryCode()
public function getCountryCode() : string
{
return (string) $this->phoneNumber->getCountryCode();
}
Expand All @@ -86,7 +86,7 @@ public function getCountryCode()
*
* @return string
*/
public function getNationalNumber()
public function getNationalNumber() : string
{
return $this->phoneNumber->getNationalNumber();
}
Expand All @@ -101,7 +101,7 @@ public function getNationalNumber()
*
* @return string|null The region code, or null if the number does not map to a geographic region.
*/
public function getRegionCode()
public function getRegionCode() : ?string
{
$regionCode = PhoneNumberUtil::getInstance()->getRegionCodeForNumber($this->phoneNumber);

Expand All @@ -120,7 +120,7 @@ public function getRegionCode()
*
* @return bool
*/
public function isValidNumber()
public function isValidNumber() : bool
{
return PhoneNumberUtil::getInstance()->isValidNumber($this->phoneNumber);
}
Expand All @@ -130,7 +130,7 @@ public function isValidNumber()
*
* @return int One of the PhoneNumberType constants.
*/
public function getNumberType()
public function getNumberType() : int
{
return PhoneNumberUtil::getInstance()->getNumberType($this->phoneNumber);
}
Expand All @@ -142,7 +142,7 @@ public function getNumberType()
*
* @return string
*/
public function format($format)
public function format(int $format) : string
{
return PhoneNumberUtil::getInstance()->format($this->phoneNumber, $format);
}
Expand All @@ -154,7 +154,7 @@ public function format($format)
*
* @return string
*/
public function formatForCallingFrom($regionCode)
public function formatForCallingFrom(string $regionCode) : string
{
return PhoneNumberUtil::getInstance()->formatOutOfCountryCallingNumber($this->phoneNumber, $regionCode);
}
Expand All @@ -164,7 +164,7 @@ public function formatForCallingFrom($regionCode)
*
* @return string
*/
public function __toString()
public function __toString() : string
{
return $this->format(PhoneNumberFormat::E164);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhoneNumberParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PhoneNumberParseException extends PhoneNumberException
*
* @return PhoneNumberParseException
*/
public static function wrap(\Exception $e)
public static function wrap(\Exception $e) : PhoneNumberParseException
{
return new PhoneNumberParseException($e->getMessage(), $e->getCode(), $e);
}
Expand Down

0 comments on commit 80060ac

Please sign in to comment.