From b6341f0fac8b06331ceabaf761ae95a9a36ada47 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 20 Jan 2017 22:02:35 +0100 Subject: [PATCH] removed useless annotations @param and @return --- src/Iterators/CachingIterator.php | 17 +--- src/Utils/ArrayHash.php | 5 -- src/Utils/ArrayList.php | 5 -- src/Utils/Arrays.php | 19 +---- src/Utils/Callback.php | 18 +---- src/Utils/DateTime.php | 11 +-- src/Utils/FileSystem.php | 2 - src/Utils/Html.php | 50 ++---------- src/Utils/IHtmlString.php | 2 +- src/Utils/ITranslator.php | 3 - src/Utils/Image.php | 66 ++++----------- src/Utils/Json.php | 17 ++-- src/Utils/ObjectMixin.php | 24 +----- src/Utils/Paginator.php | 12 --- src/Utils/Random.php | 3 - src/Utils/Reflection.php | 15 +--- src/Utils/SmartObject.php | 5 +- src/Utils/Strings.php | 129 +++++------------------------- src/Utils/Validators.php | 42 ++-------- 19 files changed, 70 insertions(+), 375 deletions(-) diff --git a/src/Iterators/CachingIterator.php b/src/Iterators/CachingIterator.php index 7d4d0f23c..6e870c713 100644 --- a/src/Iterators/CachingIterator.php +++ b/src/Iterators/CachingIterator.php @@ -56,29 +56,24 @@ public function __construct($iterator) /** * Is the current element the first one? - * @param int grid width - * @return bool */ - public function isFirst(int $width = NULL): bool + public function isFirst(int $gridWidth = NULL): bool { - return $this->counter === 1 || ($width && $this->counter !== 0 && (($this->counter - 1) % $width) === 0); + return $this->counter === 1 || ($gridWidth && $this->counter !== 0 && (($this->counter - 1) % $gridWidth) === 0); } /** * Is the current element the last one? - * @param int grid width - * @return bool */ - public function isLast(int $width = NULL): bool + public function isLast(int $gridWidth = NULL): bool { - return !$this->hasNext() || ($width && ($this->counter % $width) === 0); + return !$this->hasNext() || ($gridWidth && ($this->counter % $gridWidth) === 0); } /** * Is the iterator empty? - * @return bool */ public function isEmpty(): bool { @@ -88,7 +83,6 @@ public function isEmpty(): bool /** * Is the counter odd? - * @return bool */ public function isOdd(): bool { @@ -98,7 +92,6 @@ public function isOdd(): bool /** * Is the counter even? - * @return bool */ public function isEven(): bool { @@ -108,7 +101,6 @@ public function isEven(): bool /** * Returns the counter. - * @return int */ public function getCounter(): int { @@ -118,7 +110,6 @@ public function getCounter(): int /** * Returns the count of elements. - * @return int */ public function count(): int { diff --git a/src/Utils/ArrayHash.php b/src/Utils/ArrayHash.php index e5356f37d..cd055c297 100644 --- a/src/Utils/ArrayHash.php +++ b/src/Utils/ArrayHash.php @@ -19,8 +19,6 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator { /** - * @param array to wrap - * @param bool * @return static */ public static function from(array $arr, bool $recursive = TRUE): self @@ -39,7 +37,6 @@ public static function from(array $arr, bool $recursive = TRUE): self /** * Returns an iterator over all items. - * @return \RecursiveArrayIterator */ public function getIterator(): \RecursiveArrayIterator { @@ -49,7 +46,6 @@ public function getIterator(): \RecursiveArrayIterator /** * Returns items count. - * @return int */ public function count(): int { @@ -82,7 +78,6 @@ public function offsetGet($key) /** * Determines whether a item exists. - * @return bool */ public function offsetExists($key): bool { diff --git a/src/Utils/ArrayList.php b/src/Utils/ArrayList.php index b1d50ee7a..f10e3d0c9 100644 --- a/src/Utils/ArrayList.php +++ b/src/Utils/ArrayList.php @@ -24,7 +24,6 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate /** * Returns an iterator over all items. - * @return \ArrayIterator */ public function getIterator(): \ArrayIterator { @@ -34,7 +33,6 @@ public function getIterator(): \ArrayIterator /** * Returns items count. - * @return int */ public function count(): int { @@ -45,7 +43,6 @@ public function count(): int /** * Replaces or appends a item. * @param int|NULL - * @param mixed * @return void * @throws Nette\OutOfRangeException */ @@ -81,7 +78,6 @@ public function offsetGet($index) /** * Determines whether a item exists. * @param int - * @return bool */ public function offsetExists($index): bool { @@ -106,7 +102,6 @@ public function offsetUnset($index) /** * Prepends a item. - * @param mixed * @return void */ public function prepend($value) diff --git a/src/Utils/Arrays.php b/src/Utils/Arrays.php index 9c8806ec7..17ca1c54a 100644 --- a/src/Utils/Arrays.php +++ b/src/Utils/Arrays.php @@ -22,9 +22,7 @@ class Arrays /** * Returns item from array or $default if item is not set. - * @param array - * @param string|int|array one or more keys - * @param mixed + * @param string|int|array $key one or more keys * @return mixed * @throws Nette\InvalidArgumentException if item does not exist and default value is not provided */ @@ -46,8 +44,7 @@ public static function get(array $arr, $key, $default = NULL) /** * Returns reference to array item. - * @param array - * @param string|int|array one or more keys + * @param string|int|array $key one or more keys * @return mixed * @throws Nette\InvalidArgumentException if traversed item is not an array */ @@ -66,7 +63,6 @@ public static function &getRef(array &$arr, $key) /** * Recursively appends elements of remaining keys from the second array to the first. - * @return array */ public static function mergeTree(array $arr1, array $arr2): array { @@ -131,7 +127,6 @@ public static function renameKey(array &$arr, $oldKey, $newKey) /** * Returns array entries that match the pattern. - * @return array */ public static function grep(array $arr, string $pattern, int $flags = 0): array { @@ -141,7 +136,6 @@ public static function grep(array $arr, string $pattern, int $flags = 0): array /** * Returns flattened array. - * @return array */ public static function flatten(array $arr, bool $preserveKeys = FALSE): array { @@ -156,7 +150,6 @@ public static function flatten(array $arr, bool $preserveKeys = FALSE): array /** * Finds whether a variable is a zero-based integer indexed array. - * @return bool */ public static function isList($value): bool { @@ -218,7 +211,6 @@ public static function associate(array $arr, $path) /** * Normalizes to associative array. - * @return array */ public static function normalize(array $arr, $filling = NULL): array { @@ -232,9 +224,7 @@ public static function normalize(array $arr, $filling = NULL): array /** * Picks element from the array by key and return its value. - * @param array - * @param string|int array key - * @param mixed + * @param string|int $key array key * @return mixed * @throws Nette\InvalidArgumentException if item does not exist and default value is not provided */ @@ -256,7 +246,6 @@ public static function pick(array &$arr, $key, $default = NULL) /** * Tests whether some element in the array passes the callback test. - * @return bool */ public static function some(array $arr, callable $callback): bool { @@ -271,7 +260,6 @@ public static function some(array $arr, callable $callback): bool /** * Tests whether all elements in the array pass the callback test. - * @return bool */ public static function every(array $arr, callable $callback): bool { @@ -286,7 +274,6 @@ public static function every(array $arr, callable $callback): bool /** * Applies the callback to the elements of the array. - * @return array */ public static function map(array $arr, callable $callback): array { diff --git a/src/Utils/Callback.php b/src/Utils/Callback.php index c11db923b..780ae65a2 100644 --- a/src/Utils/Callback.php +++ b/src/Utils/Callback.php @@ -21,14 +21,12 @@ class Callback use Nette\StaticClass; /** - * @param mixed class, object, callable - * @param string method - * @return \Closure + * @param string|object|callable class, object, callable */ - public static function closure($callable, string $m = NULL): \Closure + public static function closure($callable, string $method = NULL): \Closure { - if ($m !== NULL) { - $callable = [$callable, $m]; + if ($method !== NULL) { + $callable = [$callable, $method]; } elseif (is_string($callable) && count($tmp = explode('::', $callable)) === 2) { $callable = $tmp; @@ -79,7 +77,6 @@ public static function invokeArgs($callable, array $args = []) /** * Invokes internal PHP function with own error handler. - * @param string * @return mixed */ public static function invokeSafe(string $function, array $args, callable $onError) @@ -120,9 +117,6 @@ public static function check($callable, bool $syntax = FALSE) } - /** - * @return string - */ public static function toString($callable): string { if ($callable instanceof \Closure) { @@ -160,9 +154,6 @@ public static function toReflection($callable) } - /** - * @return bool - */ public static function isStatic(callable $callable): bool { return is_array($callable) ? is_string($callable[0]) : is_string($callable); @@ -172,7 +163,6 @@ public static function isStatic(callable $callable): bool /** * Unwraps closure created by self::closure() * @internal - * @return callable */ public static function unwrap(\Closure $closure): callable { diff --git a/src/Utils/DateTime.php b/src/Utils/DateTime.php index af88b5301..69ba5940a 100644 --- a/src/Utils/DateTime.php +++ b/src/Utils/DateTime.php @@ -74,9 +74,6 @@ public static function fromParts(int $year, int $month, int $day, int $hour = 0, } - /** - * @return string - */ public function __toString(): string { return $this->format('Y-m-d H:i:s'); @@ -84,7 +81,6 @@ public function __toString(): string /** - * @param string * @return static */ public function modifyClone(string $modify = ''): self @@ -118,9 +114,9 @@ public function getTimestamp() /** * Returns new DateTime object formatted according to the specified format. - * @param string The format the $time parameter should be in - * @param string String representing the time - * @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed) + * @param string The format the $time parameter should be in + * @param string String representing the time + * @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed) * @return static|FALSE */ public static function createFromFormat($format, $time, $timezone = NULL) @@ -142,7 +138,6 @@ public static function createFromFormat($format, $time, $timezone = NULL) /** * Returns JSON representation in ISO 8601 (used by JavaScript). - * @return string */ public function jsonSerialize(): string { diff --git a/src/Utils/FileSystem.php b/src/Utils/FileSystem.php index a7060ee24..d211f5fd0 100644 --- a/src/Utils/FileSystem.php +++ b/src/Utils/FileSystem.php @@ -117,7 +117,6 @@ public static function rename(string $name, string $newName, bool $overwrite = T /** * Reads file content. - * @return string * @throws Nette\IOException */ public static function read(string $file): string @@ -149,7 +148,6 @@ public static function write(string $file, string $content, int $mode = 0666) /** * Is path absolute? - * @return bool */ public static function isAbsolute(string $path): bool { diff --git a/src/Utils/Html.php b/src/Utils/Html.php index e7b281d62..79f2bdfb0 100644 --- a/src/Utils/Html.php +++ b/src/Utils/Html.php @@ -53,8 +53,7 @@ class Html implements \ArrayAccess, \Countable, \IteratorAggregate, IHtmlString /** * Static factory. - * @param string element name (or NULL) - * @param array|string element's attributes or plain text content + * @param array|string $attrs element's attributes or plain text content * @return static */ public static function el(string $name = NULL, $attrs = NULL): self @@ -82,8 +81,6 @@ public static function el(string $name = NULL, $attrs = NULL): self /** * Changes element's name. - * @param string - * @param bool Is element empty? * @return static * @throws Nette\InvalidArgumentException */ @@ -97,7 +94,6 @@ public function setName(string $name, bool $isEmpty = NULL): self /** * Returns element's name. - * @return string */ public function getName(): string { @@ -107,7 +103,6 @@ public function getName(): string /** * Is element empty? - * @return bool */ public function isEmpty(): bool { @@ -117,7 +112,6 @@ public function isEmpty(): bool /** * Sets multiple attributes. - * @param array * @return static */ public function addAttributes(array $attrs): self @@ -129,9 +123,6 @@ public function addAttributes(array $attrs): self /** * Appends value to element's attribute. - * @param string - * @param string|array value to append - * @param string|bool value option * @return static */ public function appendAttribute(string $name, $value, $option = TRUE): self @@ -155,8 +146,6 @@ public function appendAttribute(string $name, $value, $option = TRUE): self /** * Sets element's attribute. - * @param string - * @param mixed * @return static */ public function setAttribute(string $name, $value): self @@ -168,7 +157,6 @@ public function setAttribute(string $name, $value): self /** * Returns element's attribute. - * @param string * @return mixed */ public function getAttribute(string $name) @@ -179,7 +167,6 @@ public function getAttribute(string $name) /** * Unsets element's attribute. - * @param string * @return static */ public function removeAttribute(string $name): self @@ -191,8 +178,6 @@ public function removeAttribute(string $name): self /** * Overloaded setter for element's attribute. - * @param string HTML attribute name - * @param mixed HTML attribute value * @return void */ public function __set(string $name, $value) @@ -203,8 +188,7 @@ public function __set(string $name, $value) /** * Overloaded getter for element's attribute. - * @param string HTML attribute name - * @return mixed HTML attribute value + * @return mixed */ public function &__get(string $name) { @@ -214,8 +198,6 @@ public function &__get(string $name) /** * Overloaded tester for element's attribute. - * @param string HTML attribute name - * @return bool */ public function __isset(string $name): bool { @@ -225,7 +207,6 @@ public function __isset(string $name): bool /** * Overloaded unsetter for element's attribute. - * @param string HTML attribute name * @return void */ public function __unset(string $name) @@ -236,8 +217,6 @@ public function __unset(string $name) /** * Overloaded setter for element's attribute. - * @param string HTML attribute name - * @param array (string) HTML attribute value or pair? * @return mixed */ public function __call(string $m, array $args) @@ -269,8 +248,6 @@ public function __call(string $m, array $args) /** * Special setter for element's attribute. - * @param string path - * @param array query * @return static */ public function href(string $path, array $query = NULL): self @@ -303,7 +280,6 @@ public function data(string $name, $value = NULL): self /** * Sets element's HTML content. - * @param string raw HTML string * @return static * @throws Nette\InvalidArgumentException */ @@ -320,7 +296,6 @@ public function setHtml($html): self /** * Returns element's HTML content. - * @return string */ public function getHtml(): string { @@ -338,7 +313,6 @@ public function getHtml(): string /** * Sets element's textual content. - * @param string * @return static * @throws Nette\InvalidArgumentException */ @@ -353,7 +327,6 @@ public function setText($text): self /** * Returns element's textual content. - * @return string */ public function getText(): string { @@ -363,7 +336,7 @@ public function getText(): string /** * Adds new element's child. - * @param Html|string Html node or raw HTML string + * @param Html|string Html node or raw HTML string * @return static */ public function addHtml($child): self @@ -374,7 +347,6 @@ public function addHtml($child): self /** * Appends plain-text string to element content. - * @param string plain-text string * @return static */ public function addText(string $text): self @@ -386,8 +358,7 @@ public function addText(string $text): self /** * Creates and adds a new Html child. - * @param string elements's name - * @param array|string element's attributes or raw HTML string + * @param array|string $attrs element's attributes or raw HTML string * @return static created element */ public function create(string $name, $attrs = NULL): self @@ -399,9 +370,7 @@ public function create(string $name, $attrs = NULL): self /** * Inserts child node. - * @param int|NULL position or NULL for appending - * @param Html|string Html node or raw HTML string - * @param bool + * @param Html|string $child Html node or raw HTML string * @return static * @throws Nette\InvalidArgumentException */ @@ -449,7 +418,6 @@ public function offsetGet($index) /** * Exists child node? (\ArrayAccess implementation). * @param int - * @return bool */ public function offsetExists($index): bool { @@ -472,7 +440,6 @@ public function offsetUnset($index) /** * Returns children count. - * @return int */ public function count(): int { @@ -492,7 +459,6 @@ public function removeChildren() /** * Iterates over elements. - * @return \ArrayIterator */ public function getIterator(): \ArrayIterator { @@ -502,7 +468,6 @@ public function getIterator(): \ArrayIterator /** * Returns all children. - * @return array */ public function getChildren(): array { @@ -512,8 +477,6 @@ public function getChildren(): array /** * Renders element's start tag, content and end tag. - * @param int - * @return string */ public function render(int $indent = NULL): string { @@ -555,7 +518,6 @@ public function __toString(): string /** * Returns element's start tag. - * @return string */ public function startTag(): string { @@ -570,7 +532,6 @@ public function startTag(): string /** * Returns element's end tag. - * @return string */ public function endTag(): string { @@ -580,7 +541,6 @@ public function endTag(): string /** * Returns element's attributes. - * @return string * @internal */ public function attributes(): string diff --git a/src/Utils/IHtmlString.php b/src/Utils/IHtmlString.php index 8552ea952..07f09fafc 100644 --- a/src/Utils/IHtmlString.php +++ b/src/Utils/IHtmlString.php @@ -14,7 +14,7 @@ interface IHtmlString { /** - * @return string in HTML format + * Returns string in HTML format */ function __toString(): string; diff --git a/src/Utils/ITranslator.php b/src/Utils/ITranslator.php index a29e52eb3..7ec978098 100644 --- a/src/Utils/ITranslator.php +++ b/src/Utils/ITranslator.php @@ -18,9 +18,6 @@ interface ITranslator /** * Translates the given string. - * @param string message - * @param int plural count - * @return string */ function translate($message, int $count = NULL): string; diff --git a/src/Utils/Image.php b/src/Utils/Image.php index 2af02e2f7..6527cf411 100644 --- a/src/Utils/Image.php +++ b/src/Utils/Image.php @@ -122,12 +122,7 @@ class Image /** - * Returns RGB color. - * @param int red 0..255 - * @param int green 0..255 - * @param int blue 0..255 - * @param int transparency 0..127 - * @return array + * Returns RGB color (0..255) and transparency (0..127). */ public static function rgb(int $red, int $green, int $blue, int $transparency = 0): array { @@ -142,27 +137,25 @@ public static function rgb(int $red, int $green, int $blue, int $transparency = /** * Opens image from file. - * @param string - * @param mixed detected image format * @throws Nette\NotSupportedException if gd extension is not loaded * @throws UnknownImageFileException if file not found or file type is not known * @return static */ - public static function fromFile(string $file, int &$format = NULL): self + public static function fromFile(string $file, int &$detectedFormat = NULL): self { if (!extension_loaded('gd')) { throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); } - $format = @getimagesize($file)[2]; // @ - files smaller than 12 bytes causes read error - if (!$format && PHP_VERSION_ID < 70100 && @file_get_contents($file, FALSE, NULL, 8, 4) === 'WEBP') { // @ - may not exists - $format = self::WEBP; + $detectedFormat = @getimagesize($file)[2]; // @ - files smaller than 12 bytes causes read error + if (!$detectedFormat && PHP_VERSION_ID < 70100 && @file_get_contents($file, FALSE, NULL, 8, 4) === 'WEBP') { // @ - may not exists + $detectedFormat = self::WEBP; } - if (!isset(self::$formats[$format])) { - $format = NULL; + if (!isset(self::$formats[$detectedFormat])) { + $detectedFormat = NULL; throw new UnknownImageFileException(is_file($file) ? "Unknown type of file '$file'." : "File '$file' not found."); } - return new static(Callback::invokeSafe('imagecreatefrom' . self::$formats[$format], [$file], function (string $message) { + return new static(Callback::invokeSafe('imagecreatefrom' . self::$formats[$detectedFormat], [$file], function (string $message) { throw new ImageException($message); })); } @@ -170,12 +163,10 @@ public static function fromFile(string $file, int &$format = NULL): self /** * Create a new image from the image stream in the string. - * @param string - * @param mixed detected image format * @return static * @throws ImageException */ - public static function fromString(string $s, int &$format = NULL): self + public static function fromString(string $s, int &$detectedFormat = NULL): self { if (!extension_loaded('gd')) { throw new Nette\NotSupportedException('PHP extension GD is not loaded.'); @@ -183,7 +174,7 @@ public static function fromString(string $s, int &$format = NULL): self if (func_num_args() > 1) { $tmp = @getimagesizefromstring($s)[2]; // @ - strings smaller than 12 bytes causes read error - $format = isset(self::$formats[$tmp]) ? $tmp : NULL; + $detectedFormat = isset(self::$formats[$tmp]) ? $tmp : NULL; } return new static(Callback::invokeSafe('imagecreatefromstring', [$s], function (string $message) { @@ -194,9 +185,6 @@ public static function fromString(string $s, int &$format = NULL): self /** * Creates blank image. - * @param int - * @param int - * @param array * @return static */ public static function fromBlank(int $width, int $height, array $color = NULL): self @@ -234,7 +222,6 @@ public function __construct($image) /** * Returns image width. - * @return int */ public function getWidth(): int { @@ -244,7 +231,6 @@ public function getWidth(): int /** * Returns image height. - * @return int */ public function getHeight(): int { @@ -281,7 +267,6 @@ public function getImageResource() * Resizes image. * @param mixed width in pixels or percent * @param mixed height in pixels or percent - * @param int flags * @return static */ public function resize($width, $height, int $flags = self::FIT): self @@ -311,12 +296,8 @@ public function resize($width, $height, int $flags = self::FIT): self /** * Calculates dimensions of resized image. - * @param mixed source width - * @param mixed source height - * @param mixed width in pixels or percent - * @param mixed height in pixels or percent - * @param int flags - * @return array + * @param mixed $newWidth in pixels or percent + * @param mixed $newHeight in pixels or percent */ public static function calculateSize(int $srcWidth, int $srcHeight, $newWidth, $newHeight, int $flags = self::FIT): array { @@ -394,13 +375,12 @@ public function crop($left, $top, $width, $height): self /** * Calculates dimensions of cutout in image. - * @param mixed source width - * @param mixed source height + * @param int + * @param int * @param mixed x-offset in pixels or percent * @param mixed y-offset in pixels or percent * @param mixed width in pixels or percent * @param mixed height in pixels or percent - * @return array */ public static function calculateCutout(int $srcWidth, int $srcHeight, $left, $top, $newWidth, $newHeight): array { @@ -503,10 +483,7 @@ public function place(Image $image, $left = 0, $top = 0, int $opacity = 100): se /** - * Saves image to the file. - * @param string filename - * @param int quality (0..100 for JPEG and WEBP, 0..9 for PNG) - * @param int optional image type + * Saves image to the file. Quality is 0..100 for JPEG and WEBP, 0..9 for PNG. * @return void * @throws ImageException */ @@ -551,10 +528,7 @@ public function save(string $file = NULL, int $quality = NULL, int $type = NULL) /** - * Outputs image to string. - * @param int image type - * @param int quality (0..100 for JPEG and WEBP, 0..9 for PNG) - * @return string + * Outputs image to string. Quality is 0..100 for JPEG and WEBP, 0..9 for PNG. */ public function toString(int $type = self::JPEG, int $quality = NULL): string { @@ -566,7 +540,6 @@ public function toString(int $type = self::JPEG, int $quality = NULL): string /** * Outputs image to string. - * @return string */ public function __toString(): string { @@ -582,9 +555,7 @@ public function __toString(): string /** - * Outputs image to browser. - * @param int image type - * @param int quality (0..100 for JPEG and WEBP, 0..9 for PNG) + * Outputs image to browser. Quality is 0..100 for JPEG and WEBP, 0..9 for PNG. * @return void * @throws ImageException */ @@ -600,9 +571,6 @@ public function send(int $type = self::JPEG, int $quality = NULL) /** * Call to undefined method. - * - * @param string method name - * @param array arguments * @return mixed * @throws Nette\MemberAccessException */ diff --git a/src/Utils/Json.php b/src/Utils/Json.php index b7ac106aa..53bc90844 100644 --- a/src/Utils/Json.php +++ b/src/Utils/Json.php @@ -24,15 +24,12 @@ class Json /** - * Returns the JSON representation of a value. - * @param mixed - * @param int accepts Json::PRETTY - * @return string + * Returns the JSON representation of a value. Accepts flag Json::PRETTY. */ - public static function encode($value, int $options = 0): string + public static function encode($value, int $flags = 0): string { $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES - | ($options & self::PRETTY ? JSON_PRETTY_PRINT : 0) + | ($flags & self::PRETTY ? JSON_PRETTY_PRINT : 0) | (defined('JSON_PRESERVE_ZERO_FRACTION') ? JSON_PRESERVE_ZERO_FRACTION : 0); // since PHP 5.6.6 & PECL JSON-C 1.3.7 $json = json_encode($value, $flags); @@ -49,14 +46,12 @@ public static function encode($value, int $options = 0): string /** - * Decodes a JSON string. - * @param string - * @param int accepts Json::FORCE_ARRAY + * Decodes a JSON string. Accepts flag Json::FORCE_ARRAY. * @return mixed */ - public static function decode(string $json, int $options = 0) + public static function decode(string $json, int $flags = 0) { - $forceArray = (bool) ($options & self::FORCE_ARRAY); + $forceArray = (bool) ($flags & self::FORCE_ARRAY); $value = json_decode($json, $forceArray, 512, JSON_BIGINT_AS_STRING); if ($error = json_last_error()) { throw new JsonException(json_last_error_msg(), $error); diff --git a/src/Utils/ObjectMixin.php b/src/Utils/ObjectMixin.php index d87c711cf..950a6514a 100644 --- a/src/Utils/ObjectMixin.php +++ b/src/Utils/ObjectMixin.php @@ -92,8 +92,6 @@ public static function strictStaticCall(string $class, string $method) /** * __call() implementation. * @param object - * @param string - * @param array * @return mixed * @throws MemberAccessException */ @@ -148,9 +146,6 @@ public static function call($_this, string $name, array $args) /** * __callStatic() implementation. - * @param string - * @param string - * @param array * @return void * @throws MemberAccessException */ @@ -163,7 +158,6 @@ public static function callStatic(string $class, string $method, array $args) /** * __get() implementation. * @param object - * @param string property name * @return mixed property value * @throws MemberAccessException if the property is not defined. */ @@ -206,8 +200,6 @@ public static function &get($_this, string $name) /** * __set() implementation. * @param object - * @param string property name - * @param mixed property value * @return void * @throws MemberAccessException if the property is not defined or is read-only */ @@ -238,7 +230,6 @@ public static function set($_this, string $name, $value) /** * __unset() implementation. * @param object - * @param string property name * @return void * @throws MemberAccessException */ @@ -254,8 +245,6 @@ public static function remove($_this, string $name) /** * __isset() implementation. * @param object - * @param string property name - * @return bool */ public static function has($_this, string $name): bool { @@ -269,8 +258,7 @@ public static function has($_this, string $name): bool /** - * Returns array of magic properties defined by annotation @property. - * @return array of [name => bit mask] + * Returns array [name => bit mask] of magic properties defined by annotation @property. */ public static function getMagicProperties(string $class): array { @@ -317,7 +305,6 @@ public static function getMagicProperties(string $class): array /** * Returns array of magic methods defined by annotation @method. - * @return array */ public static function getMagicMethods(string $class): array { @@ -356,7 +343,6 @@ public static function getMagicMethods(string $class): array /** * Finds whether a variable is of expected type and do non-data-loss conversion. - * @return bool * @internal */ public static function checkType(&$val, string $type): bool @@ -426,9 +412,6 @@ public static function checkType(&$val, string $type): bool /** * Adds a method to class. - * @param string - * @param string - * @param mixed callable * @return void */ public static function setExtensionMethod(string $class, string $name, /*callable*/ $callback) @@ -441,8 +424,6 @@ public static function setExtensionMethod(string $class, string $name, /*callabl /** * Returns extension method. - * @param string - * @param string * @return mixed */ public static function getExtensionMethod(string $class, string $name) @@ -464,8 +445,6 @@ public static function getExtensionMethod(string $class, string $name) /** * Returns extension methods. - * @param string - * @return array */ public static function getExtensionMethods(string $class): array { @@ -545,7 +524,6 @@ public static function hasProperty(string $class, string $name) /** * Returns array of public (static, non-static and magic) methods. - * @return array */ private static function &getMethods(string $class): array { diff --git a/src/Utils/Paginator.php b/src/Utils/Paginator.php index 9dee66f24..0a919c889 100644 --- a/src/Utils/Paginator.php +++ b/src/Utils/Paginator.php @@ -47,7 +47,6 @@ class Paginator /** * Sets current page number. - * @param int * @return static */ public function setPage(int $page): self @@ -59,7 +58,6 @@ public function setPage(int $page): self /** * Returns current page number. - * @return int */ public function getPage(): int { @@ -69,7 +67,6 @@ public function getPage(): int /** * Returns first page number. - * @return int */ public function getFirstPage(): int { @@ -89,7 +86,6 @@ public function getLastPage() /** * Sets first page (base) number. - * @param int * @return static */ public function setBase(int $base): self @@ -101,7 +97,6 @@ public function setBase(int $base): self /** * Returns first page (base) number. - * @return int */ public function getBase(): int { @@ -111,7 +106,6 @@ public function getBase(): int /** * Returns zero-based page number. - * @return int */ protected function getPageIndex(): int { @@ -122,7 +116,6 @@ protected function getPageIndex(): int /** * Is the current page the first one? - * @return bool */ public function isFirst(): bool { @@ -132,7 +125,6 @@ public function isFirst(): bool /** * Is the current page the last one? - * @return bool */ public function isLast(): bool { @@ -152,7 +144,6 @@ public function getPageCount() /** * Sets the number of items to display on a single page. - * @param int * @return static */ public function setItemsPerPage(int $itemsPerPage): self @@ -164,7 +155,6 @@ public function setItemsPerPage(int $itemsPerPage): self /** * Returns the number of items to display on a single page. - * @return int */ public function getItemsPerPage(): int { @@ -174,7 +164,6 @@ public function getItemsPerPage(): int /** * Sets the total number of items. - * @param int (or NULL as infinity) * @return static */ public function setItemCount(int $itemCount = NULL): self @@ -196,7 +185,6 @@ public function getItemCount() /** * Returns the absolute index of the first item on current page. - * @return int */ public function getOffset(): int { diff --git a/src/Utils/Random.php b/src/Utils/Random.php index 24297c310..cd0318ad8 100644 --- a/src/Utils/Random.php +++ b/src/Utils/Random.php @@ -21,9 +21,6 @@ class Random /** * Generate random string. - * @param int - * @param string - * @return string */ public static function generate(int $length = 10, string $charlist = '0-9a-z'): string { diff --git a/src/Utils/Reflection.php b/src/Utils/Reflection.php index 0324e70db..f528e244e 100644 --- a/src/Utils/Reflection.php +++ b/src/Utils/Reflection.php @@ -25,10 +25,6 @@ class Reflection ]; - /** - * @param string - * @return bool - */ public static function isBuiltinType(string $type): bool { return isset(self::$builtinTypes[strtolower($type)]); @@ -86,7 +82,6 @@ public static function getParameterDefaultValue(\ReflectionParameter $param) /** * Returns declaring class or trait. - * @return \ReflectionClass */ public static function getPropertyDeclaringClass(\ReflectionProperty $prop): \ReflectionClass { @@ -101,7 +96,6 @@ public static function getPropertyDeclaringClass(\ReflectionProperty $prop): \Re /** * Are documentation comments available? - * @return bool */ public static function areCommentsAvailable(): bool { @@ -112,9 +106,6 @@ public static function areCommentsAvailable(): bool } - /** - * @return string - */ public static function toString(\Reflector $ref): string { if ($ref instanceof \ReflectionClass) { @@ -135,8 +126,6 @@ public static function toString(\Reflector $ref): string /** * Expands class name into full name. - * @param string - * @return string full name * @throws Nette\InvalidArgumentException */ public static function expandClassName(string $name, \ReflectionClass $rc): string @@ -189,9 +178,7 @@ public static function getUseStatements(\ReflectionClass $class): array /** - * Parses PHP code. - * @param string - * @return array of [class => [alias => class, ...]] + * Parses PHP code to [class => [alias => class, ...]] */ private static function parseUseStatements(string $code, string $forClass = NULL): array { diff --git a/src/Utils/SmartObject.php b/src/Utils/SmartObject.php index 8e68426e9..dd5225c5d 100644 --- a/src/Utils/SmartObject.php +++ b/src/Utils/SmartObject.php @@ -57,7 +57,7 @@ public static function __callStatic($name, $args) /** - * @return mixed property value + * @return mixed * @throws MemberAccessException if the property is not defined. */ public function &__get($name) @@ -117,9 +117,6 @@ public function __unset($name) } - /** - * @return bool - */ public function __isset($name): bool { return isset(ObjectMixin::getMagicProperties(get_class($this))[$name]); diff --git a/src/Utils/Strings.php b/src/Utils/Strings.php index 4f9f53f31..41b5eb8ac 100644 --- a/src/Utils/Strings.php +++ b/src/Utils/Strings.php @@ -25,8 +25,6 @@ class Strings /** * Checks if the string is valid for UTF-8 encoding. - * @param string byte stream to check - * @return bool */ public static function checkEncoding(string $s): bool { @@ -36,8 +34,6 @@ public static function checkEncoding(string $s): bool /** * Removes invalid code unit sequences from UTF-8 string. - * @param string byte stream to fix - * @return string */ public static function fixEncoding(string $s): string { @@ -47,9 +43,7 @@ public static function fixEncoding(string $s): string /** - * Returns a specific character in UTF-8. - * @param int code point (0x0 to 0xD7FF or 0xE000 to 0x10FFFF) - * @return string + * Returns a specific character in UTF-8 from code point (0x0 to 0xD7FF or 0xE000 to 0x10FFFF). * @throws Nette\InvalidArgumentException if code point is not in valid range */ public static function chr(int $code): string @@ -63,9 +57,6 @@ public static function chr(int $code): string /** * Starts the $haystack string with the prefix $needle? - * @param string - * @param string - * @return bool */ public static function startsWith(string $haystack, string $needle): bool { @@ -75,9 +66,6 @@ public static function startsWith(string $haystack, string $needle): bool /** * Ends the $haystack string with the suffix $needle? - * @param string - * @param string - * @return bool */ public static function endsWith(string $haystack, string $needle): bool { @@ -87,9 +75,6 @@ public static function endsWith(string $haystack, string $needle): bool /** * Does $haystack contain $needle? - * @param string - * @param string - * @return bool */ public static function contains(string $haystack, string $needle): bool { @@ -99,10 +84,6 @@ public static function contains(string $haystack, string $needle): bool /** * Returns a part of UTF-8 string. - * @param string - * @param int in characters (code points) - * @param int in characters (code points) - * @return string */ public static function substring(string $s, int $start, int $length = NULL): string { @@ -118,9 +99,7 @@ public static function substring(string $s, int $start, int $length = NULL): str /** - * Removes special controls characters and normalizes line endings and spaces. - * @param string UTF-8 encoding - * @return string + * Removes special controls characters and normalizes line endings and spaces in UTF-8 string. */ public static function normalize(string $s): string { @@ -141,8 +120,6 @@ public static function normalize(string $s): string /** * Standardize line endings to unix-like. - * @param string UTF-8 encoding or 8-bit - * @return string */ public static function normalizeNewLines(string $s): string { @@ -151,9 +128,7 @@ public static function normalizeNewLines(string $s): string /** - * Converts to ASCII. - * @param string UTF-8 encoding - * @return string ASCII + * Converts UTF-8 string to ASCII. */ public static function toAscii(string $s): string { @@ -193,11 +168,7 @@ public static function toAscii(string $s): string /** - * Converts to web safe characters [a-z0-9-] text. - * @param string UTF-8 encoding - * @param string allowed characters - * @param bool - * @return string + * Converts UTF-8 string to web safe characters [a-z0-9-] text. */ public static function webalize(string $s, string $charlist = NULL, bool $lower = TRUE): string { @@ -212,11 +183,7 @@ public static function webalize(string $s, string $charlist = NULL, bool $lower /** - * Truncates string to maximal length. - * @param string UTF-8 encoding - * @param int - * @param string UTF-8 encoding - * @return string + * Truncates UTF-8 string to maximal length. */ public static function truncate(string $s, int $maxLen, string $append = "\xE2\x80\xA6"): string { @@ -237,11 +204,7 @@ public static function truncate(string $s, int $maxLen, string $append = "\xE2\x /** - * Indents the content from the left. - * @param string UTF-8 encoding or 8-bit - * @param int - * @param string - * @return string + * Indents UTF-8 string from the left. */ public static function indent(string $s, int $level = 1, string $chars = "\t"): string { @@ -253,9 +216,7 @@ public static function indent(string $s, int $level = 1, string $chars = "\t"): /** - * Convert to lower case. - * @param string UTF-8 encoding - * @return string + * Converts UTF-8 string to lower case. */ public static function lower(string $s): string { @@ -264,9 +225,7 @@ public static function lower(string $s): string /** - * Convert first character to lower case. - * @param string UTF-8 encoding - * @return string + * Converts first character to lower case. */ public static function firstLower(string $s): string { @@ -275,9 +234,7 @@ public static function firstLower(string $s): string /** - * Convert to upper case. - * @param string UTF-8 encoding - * @return string + * Converts UTF-8 string to upper case. */ public static function upper(string $s): string { @@ -286,9 +243,7 @@ public static function upper(string $s): string /** - * Convert first character to upper case. - * @param string UTF-8 encoding - * @return string + * Converts first character to upper case. */ public static function firstUpper(string $s): string { @@ -297,9 +252,7 @@ public static function firstUpper(string $s): string /** - * Capitalize string. - * @param string UTF-8 encoding - * @return string + * Capitalizes UTF-8 string. */ public static function capitalize(string $s): string { @@ -309,10 +262,6 @@ public static function capitalize(string $s): string /** * Case-insensitive compares UTF-8 strings. - * @param string - * @param string - * @param int - * @return bool */ public static function compare(string $left, string $right, int $len = NULL): bool { @@ -330,7 +279,6 @@ public static function compare(string $left, string $right, int $len = NULL): bo /** * Finds the length of common prefix of strings. * @param string|array - * @return string */ public static function findPrefix(...$strings): string { @@ -355,8 +303,6 @@ public static function findPrefix(...$strings): string /** * Returns number of characters (not bytes) in UTF-8 string. * That is the number of Unicode code points which may differ from the number of graphemes. - * @param string - * @return int */ public static function length(string $s): int { @@ -365,10 +311,7 @@ public static function length(string $s): int /** - * Strips whitespace. - * @param string UTF-8 encoding - * @param string - * @return string + * Strips whitespace from UTF-8 string. */ public static function trim(string $s, string $charlist = self::TRIM_CHARACTERS): string { @@ -378,11 +321,7 @@ public static function trim(string $s, string $charlist = self::TRIM_CHARACTERS) /** - * Pad a string to a certain length with another string. - * @param string UTF-8 encoding - * @param int - * @param string - * @return string + * Pad a UTF-8 string to a certain length with another string. */ public static function padLeft(string $s, int $length, string $pad = ' '): string { @@ -393,11 +332,7 @@ public static function padLeft(string $s, int $length, string $pad = ' '): strin /** - * Pad a string to a certain length with another string. - * @param string UTF-8 encoding - * @param int - * @param string - * @return string + * Pad a UTF-8 string to a certain length with another string. */ public static function padRight(string $s, int $length, string $pad = ' '): string { @@ -409,8 +344,6 @@ public static function padRight(string $s, int $length, string $pad = ' '): stri /** * Reverse string. - * @param string UTF-8 encoding - * @return string */ public static function reverse(string $s): string { @@ -419,10 +352,7 @@ public static function reverse(string $s): string /** - * Returns part of $haystack before $nth occurence of $needle. - * @param string - * @param string - * @param int negative value means searching from the end + * Returns part of $haystack before $nth occurence of $needle (negative value means searching from the end). * @return string|FALSE returns FALSE if the needle was not found */ public static function before(string $haystack, string $needle, int $nth = 1) @@ -435,10 +365,7 @@ public static function before(string $haystack, string $needle, int $nth = 1) /** - * Returns part of $haystack after $nth occurence of $needle. - * @param string - * @param string - * @param int negative value means searching from the end + * Returns part of $haystack after $nth occurence of $needle (negative value means searching from the end). * @return string|FALSE returns FALSE if the needle was not found */ public static function after(string $haystack, string $needle, int $nth = 1) @@ -451,10 +378,7 @@ public static function after(string $haystack, string $needle, int $nth = 1) /** - * Returns position of $nth occurence of $needle in $haystack. - * @param string - * @param string - * @param int negative value means searching from the end + * Returns position of $nth occurence of $needle in $haystack (negative value means searching from the end). * @return int|FALSE offset in characters or FALSE if the needle was not found */ public static function indexOf(string $haystack, string $needle, int $nth = 1) @@ -498,10 +422,6 @@ private static function pos(string $haystack, string $needle, int $nth = 1) /** * Splits string by a regular expression. - * @param string - * @param string - * @param int - * @return array */ public static function split(string $subject, string $pattern, int $flags = 0): array { @@ -510,11 +430,7 @@ public static function split(string $subject, string $pattern, int $flags = 0): /** - * Performs a regular expression match. - * @param string - * @param string - * @param int can be PREG_OFFSET_CAPTURE (returned in bytes) - * @param int offset in bytes + * Performs a regular expression match. Accepts flag PREG_OFFSET_CAPTURE (returned in bytes). * @return mixed */ public static function match(string $subject, string $pattern, int $flags = 0, int $offset = 0) @@ -529,12 +445,7 @@ public static function match(string $subject, string $pattern, int $flags = 0, i /** - * Performs a global regular expression match. - * @param string - * @param string - * @param int can be PREG_OFFSET_CAPTURE (returned in bytes); PREG_SET_ORDER is default - * @param int offset in bytes - * @return array + * Performs a global regular expression match. Accepts flag PREG_OFFSET_CAPTURE (returned in bytes), PREG_SET_ORDER is default. */ public static function matchAll(string $subject, string $pattern, int $flags = 0, int $offset = 0): array { @@ -555,8 +466,6 @@ public static function matchAll(string $subject, string $pattern, int $flags = 0 * @param string * @param string|array * @param string|callable - * @param int - * @return string */ public static function replace(string $subject, $pattern, $replacement = NULL, int $limit = -1): string { diff --git a/src/Utils/Validators.php b/src/Utils/Validators.php index aaf3e3129..8e6756b5a 100644 --- a/src/Utils/Validators.php +++ b/src/Utils/Validators.php @@ -70,10 +70,7 @@ class Validators /** - * Throws exception if a variable is of unexpected type. - * @param mixed - * @param string expected types separated by pipe - * @param string label + * Throws exception if a variable is of unexpected type (separated by pipe). * @return void */ public static function assert($value, string $expected, string $label = 'variable') @@ -95,11 +92,8 @@ public static function assert($value, string $expected, string $label = 'variabl /** - * Throws exception if an array field is missing or of unexpected type. + * Throws exception if an array field is missing or of unexpected type (separated by pipe). * @param array - * @param string item - * @param string expected types separated by pipe - * @param string * @return void */ public static function assertField($arr, $field, string $expected = NULL, string $label = "item '%' in array") @@ -115,10 +109,7 @@ public static function assertField($arr, $field, string $expected = NULL, string /** - * Finds whether a variable is of expected type. - * @param mixed - * @param string expected types separated by pipe with optional ranges - * @return bool + * Finds whether a variable is of expected type (separated by pipe). */ public static function is($value, string $expected): bool { @@ -165,9 +156,8 @@ public static function is($value, string $expected): bool /** * Finds whether all values are of expected type. + * Finds whether all values are of expected type (separated by pipe). * @param iterable - * @param string expected types separated by pipe with optional ranges - * @return bool */ public static function everyIs($values, string $expected): bool { @@ -185,7 +175,6 @@ public static function everyIs($values, string $expected): bool /** * Finds whether a value is an integer or a float. - * @return bool */ public static function isNumber($value): bool { @@ -195,7 +184,6 @@ public static function isNumber($value): bool /** * Finds whether a value is an integer. - * @return bool */ public static function isNumericInt($value): bool { @@ -205,7 +193,6 @@ public static function isNumericInt($value): bool /** * Finds whether a string is a floating point number in decimal base. - * @return bool */ public static function isNumeric($value): bool { @@ -215,7 +202,6 @@ public static function isNumeric($value): bool /** * Finds whether a value is a syntactically correct callback. - * @return bool */ public static function isCallable($value): bool { @@ -225,8 +211,6 @@ public static function isCallable($value): bool /** * Finds whether a value is an UTF-8 encoded string. - * @param string - * @return bool */ public static function isUnicode($value): bool { @@ -236,7 +220,6 @@ public static function isUnicode($value): bool /** * Finds whether a value is "falsy". - * @return bool */ public static function isNone($value): bool { @@ -246,8 +229,6 @@ public static function isNone($value): bool /** * Finds whether a variable is a zero-based integer indexed array. - * @param array - * @return bool */ public static function isList($value): bool { @@ -256,10 +237,7 @@ public static function isList($value): bool /** - * Is a value in specified range? - * @param mixed - * @param array min and max value pair - * @return bool + * Is a value in specified min and max value pair? */ public static function isInRange($value, array $range): bool { @@ -270,8 +248,6 @@ public static function isInRange($value, array $range): bool /** * Finds whether a string is a valid email address. - * @param string - * @return bool */ public static function isEmail(string $value): bool { @@ -288,8 +264,6 @@ public static function isEmail(string $value): bool /** * Finds whether a string is a valid http(s) URL. - * @param string - * @return bool */ public static function isUrl(string $value): bool { @@ -309,8 +283,6 @@ public static function isUrl(string $value): bool /** * Finds whether a string is a valid URI according to RFC 1738. - * @param string - * @return bool */ public static function isUri(string $value): bool { @@ -320,8 +292,6 @@ public static function isUri(string $value): bool /** * Checks whether the input is a class, interface or trait. - * @param string - * @return bool */ public static function isType(string $type): bool { @@ -331,7 +301,6 @@ public static function isType(string $type): bool /** * Checks whether the input is a valid PHP identifier. - * @return bool */ public static function isPhpIdentifier(string $value): bool { @@ -341,7 +310,6 @@ public static function isPhpIdentifier(string $value): bool /** * Returns true if value is iterable (array or instance of Traversable). - * @return bool */ private static function isIterable($value): bool {