From fbd30f0c2c47f5c4f372a055845886e95b1c0a83 Mon Sep 17 00:00:00 2001 From: Nat Zimmermann Date: Tue, 23 Mar 2021 12:14:35 +0000 Subject: [PATCH 1/2] use non-empty-string annoation --- src/Psl/Math/base_convert.php | 2 ++ src/Psl/Math/from_base.php | 2 ++ src/Psl/Str/Byte/pad_left.php | 2 ++ src/Psl/Str/Byte/pad_right.php | 2 ++ src/Psl/Str/pad_left.php | 2 ++ src/Psl/Str/pad_right.php | 2 ++ src/Psl/Str/wrap.php | 2 +- 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Psl/Math/base_convert.php b/src/Psl/Math/base_convert.php index 7a3114b3..1d6f4325 100644 --- a/src/Psl/Math/base_convert.php +++ b/src/Psl/Math/base_convert.php @@ -31,6 +31,8 @@ * Math\base_convert('2014587925987', 10, 36) * => Str('pphlmw9v') * + * @param non-empty-string $value + * * @pure * * @throws Psl\Exception\InvariantViolationException If $value is empty, $from_base and $to_base are diff --git a/src/Psl/Math/from_base.php b/src/Psl/Math/from_base.php index a7281ad7..59db1954 100644 --- a/src/Psl/Math/from_base.php +++ b/src/Psl/Math/from_base.php @@ -19,6 +19,8 @@ * Math\from_base('ff', 15) * => Int(255) * + * @param non-empty-string $number + * * @pure * * @throws Psl\Exception\InvariantViolationException If $number is empty, $from_base is outside the [2, 36] range, diff --git a/src/Psl/Str/Byte/pad_left.php b/src/Psl/Str/Byte/pad_left.php index 04f5b150..d592c5a8 100644 --- a/src/Psl/Str/Byte/pad_left.php +++ b/src/Psl/Str/Byte/pad_left.php @@ -18,6 +18,8 @@ * length, the pad string will be truncated. If the total length is less than or * equal to the length of the input string, no padding will occur. * + * @param non-empty-string $pad_string + * * @pure * * @throws Psl\Exception\InvariantViolationException If $pad_string is empty, or $total_length is negative. diff --git a/src/Psl/Str/Byte/pad_right.php b/src/Psl/Str/Byte/pad_right.php index 43621bdd..08790634 100644 --- a/src/Psl/Str/Byte/pad_right.php +++ b/src/Psl/Str/Byte/pad_right.php @@ -18,6 +18,8 @@ * length, the pad string will be truncated. If the total length is less than or * equal to the length of the input string, no padding will occur. * + * @param non-empty-string $pad_string + * * @pure * * @throws Psl\Exception\InvariantViolationException If $pad_string is empty, or $total_length is negative. diff --git a/src/Psl/Str/pad_left.php b/src/Psl/Str/pad_left.php index 32a6db42..0b2a3929 100644 --- a/src/Psl/Str/pad_left.php +++ b/src/Psl/Str/pad_left.php @@ -28,6 +28,8 @@ * Str\pad_left('مرحبا', 8, 'م') * => Str('ممممرحبا') * + * @param non-empty-string $pad_string + * * @pure * * @throws Psl\Exception\InvariantViolationException If the $pad_string is empty, a negative $total_length is given, diff --git a/src/Psl/Str/pad_right.php b/src/Psl/Str/pad_right.php index 8e773c9a..7ad36b1d 100644 --- a/src/Psl/Str/pad_right.php +++ b/src/Psl/Str/pad_right.php @@ -28,6 +28,8 @@ * Str\pad_right('مرحبا', 8, 'ا') * => Str('مرحباااا') * + * @param non-empty-string $pad_string + * * @pure * * @throws Psl\Exception\InvariantViolationException If the $pad_string is empty, a negative $total_length is given, diff --git a/src/Psl/Str/wrap.php b/src/Psl/Str/wrap.php index ef5215bd..85e49927 100644 --- a/src/Psl/Str/wrap.php +++ b/src/Psl/Str/wrap.php @@ -9,7 +9,7 @@ /** * Wraps a string to a given number of characters. * - * @param string $break the line is broken using the optional break parameter + * @param non-empty-string $break the line is broken using the optional break parameter * @param bool $cut If the cut is set to true, the string is always wrapped at or before the specified width. * so if you have a word that is larger than the given width, it is broken apart. * From 3a5f83ee2efc8a6ca2ff813b829d537694b81a99 Mon Sep 17 00:00:00 2001 From: Nat Zimmermann Date: Wed, 24 Mar 2021 12:32:03 +0000 Subject: [PATCH 2/2] docs --- docs/component/math.md | 4 ++-- docs/component/str-byte.md | 4 ++-- docs/component/str.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/component/math.md b/docs/component/math.md index 1eb61eb7..4435d78f 100644 --- a/docs/component/math.md +++ b/docs/component/math.md @@ -30,14 +30,14 @@ #### `Functions` - [abs](./../../src/Psl/Math/abs.php#L34) -- [base_convert](./../../src/Psl/Math/base_convert.php#L39) +- [base_convert](./../../src/Psl/Math/base_convert.php#L41) - [ceil](./../../src/Psl/Math/ceil.php#L25) - [clamp](./../../src/Psl/Math/clamp.php#L24) - [cos](./../../src/Psl/Math/cos.php#L22) - [div](./../../src/Psl/Math/div.php#L32) - [exp](./../../src/Psl/Math/exp.php#L22) - [floor](./../../src/Psl/Math/floor.php#L16) -- [from_base](./../../src/Psl/Math/from_base.php#L27) +- [from_base](./../../src/Psl/Math/from_base.php#L29) - [log](./../../src/Psl/Math/log.php#L18) - [max](./../../src/Psl/Math/max.php#L19) - [max_by](./../../src/Psl/Math/max_by.php#L21) diff --git a/docs/component/str-byte.md b/docs/component/str-byte.md index 48f1d9c9..b92d4dd3 100644 --- a/docs/component/str-byte.md +++ b/docs/component/str-byte.md @@ -33,8 +33,8 @@ - [length](./../../src/Psl/Str/Byte/length.php#L14) - [lowercase](./../../src/Psl/Str/Byte/lowercase.php#L14) - [ord](./../../src/Psl/Str/Byte/ord.php#L12) -- [pad_left](./../../src/Psl/Str/Byte/pad_left.php#L25) -- [pad_right](./../../src/Psl/Str/Byte/pad_right.php#L25) +- [pad_left](./../../src/Psl/Str/Byte/pad_left.php#L27) +- [pad_right](./../../src/Psl/Str/Byte/pad_right.php#L27) - [replace](./../../src/Psl/Str/Byte/replace.php#L15) - [replace_ci](./../../src/Psl/Str/Byte/replace_ci.php#L15) - [replace_every](./../../src/Psl/Str/Byte/replace_every.php#L17) diff --git a/docs/component/str.md b/docs/component/str.md index 782170a8..5aaa4daf 100644 --- a/docs/component/str.md +++ b/docs/component/str.md @@ -48,8 +48,8 @@ - [lowercase](./../../src/Psl/Str/lowercase.php#L35) - [metaphone](./../../src/Psl/Str/metaphone.php#L23) - [ord](./../../src/Psl/Str/ord.php#L27) -- [pad_left](./../../src/Psl/Str/pad_left.php#L36) -- [pad_right](./../../src/Psl/Str/pad_right.php#L36) +- [pad_left](./../../src/Psl/Str/pad_left.php#L38) +- [pad_right](./../../src/Psl/Str/pad_right.php#L38) - [repeat](./../../src/Psl/Str/repeat.php#L28) - [replace](./../../src/Psl/Str/replace.php#L19) - [replace_ci](./../../src/Psl/Str/replace_ci.php#L20)