| @@ -1,5 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Php.php | |
| 4 | + * | |
| 5 | + * The Php class file. | |
| 6 | + * | |
| 7 | + * PHP versions 5 | |
| 8 | + * | |
| 9 | + * @author Alexander Schneider <alexanderschneider85@gmail.com> | |
| 10 | + * @copyright 2008-2017 Alexander Schneider | |
| 11 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 | |
| 12 | + * @version SVN: $id$ | |
| 13 | + * @link http://wordpress.org/extend/plugins/user-access-manager/ | |
| 14 | + */ | |
| 2 | 15 | |
| 3 | 16 | declare(strict_types=1); |
| 4 | 17 | |
| 5 | 18 | namespace UserAccessManager\Wrapper; |
| @@ -4,13 +17,19 @@ | ||
| 4 | 17 | |
| 5 | 18 | namespace UserAccessManager\Wrapper; |
| 6 | 19 | |
| 7 | 20 | use Exception; |
| 8 | -use JetBrains\PhpStorm\NoReturn; | |
| 9 | 21 | |
| 22 | +/** | |
| 23 | + * Class Php | |
| 24 | + * | |
| 25 | + * @package UserAccessManager\Wrapper | |
| 26 | + */ | |
| 10 | 27 | class Php |
| 11 | 28 | { |
| 12 | 29 | /** |
| 30 | + * @param string $functionName | |
| 31 | + * @return bool | |
| 13 | 32 | * @see function_exists() |
| 14 | 33 | */ |
| 15 | 34 | public function functionExists(string $functionName): bool |
| 16 | 35 | { |
| @@ -17,19 +36,26 @@ | ||
| 17 | 36 | return function_exists($functionName); |
| 18 | 37 | } |
| 19 | 38 | |
| 20 | 39 | /** |
| 40 | + * @param int $startIndex | |
| 41 | + * @param int $numberOfElements | |
| 42 | + * @param mixed $value | |
| 43 | + * @return array | |
| 21 | 44 | * @see array_fill() |
| 22 | 45 | */ |
| 23 | - public function arrayFill(int $startIndex, int $numberOfElements, mixed $value): array | |
| 46 | + public function arrayFill(int $startIndex, int $numberOfElements, $value): array | |
| 24 | 47 | { |
| 25 | 48 | return array_fill($startIndex, $numberOfElements, $value); |
| 26 | 49 | } |
| 27 | 50 | |
| 28 | 51 | /** |
| 52 | + * @param int $length | |
| 53 | + * @param null|bool $strong | |
| 54 | + * @return false|string | |
| 29 | 55 | * @see openssl_random_pseudo_bytes() |
| 30 | 56 | */ |
| 31 | - public function opensslRandomPseudoBytes(int $length, ?bool &$strong = false): bool|string | |
| 57 | + public function opensslRandomPseudoBytes(int $length, ?bool &$strong = false) | |
| 32 | 58 | { |
| 33 | 59 | return openssl_random_pseudo_bytes($length, $strong); |
| 34 | 60 | } |
| 35 | 61 | |
| @@ -44,16 +70,20 @@ | ||
| 44 | 70 | return ($context !== null) ? unlink($filename, $context) : unlink($filename); |
| 45 | 71 | } |
| 46 | 72 | |
| 47 | 73 | /** |
| 74 | + * @param string $variableName | |
| 75 | + * @return int|string | |
| 48 | 76 | * @see ini_get() |
| 49 | 77 | */ |
| 50 | - public function iniGet(string $variableName): int|string|false | |
| 78 | + public function iniGet(string $variableName) | |
| 51 | 79 | { |
| 52 | 80 | return ini_get($variableName); |
| 53 | 81 | } |
| 54 | 82 | |
| 55 | 83 | /** |
| 84 | + * @param int $seconds | |
| 85 | + * @return bool | |
| 56 | 86 | * @see set_time_limit() |
| 57 | 87 | */ |
| 58 | 88 | public function setTimeLimit(int $seconds): bool |
| 59 | 89 | { |
| @@ -60,24 +90,30 @@ | ||
| 60 | 90 | return @set_time_limit($seconds); |
| 61 | 91 | } |
| 62 | 92 | |
| 63 | 93 | /** |
| 94 | + * @param resource $handle | |
| 95 | + * @param int $length | |
| 96 | + * @return bool|string | |
| 64 | 97 | * @see fread() |
| 65 | 98 | */ |
| 66 | - public function fread($handle, int $length): false|string | |
| 99 | + public function fread($handle, int $length) | |
| 67 | 100 | { |
| 68 | 101 | return fread($handle, $length); |
| 69 | 102 | } |
| 70 | 103 | |
| 71 | 104 | /** |
| 105 | + * @param mixed $controller | |
| 106 | + * @param string $file | |
| 72 | 107 | * @throws Exception |
| 73 | 108 | */ |
| 74 | - public function includeFile($controller, string $file): void | |
| 109 | + public function includeFile($controller, string $file) | |
| 75 | 110 | { |
| 76 | 111 | if ($controller === null) { |
| 77 | 112 | throw new Exception('Controller is required'); |
| 78 | 113 | } |
| 79 | 114 | |
| 115 | + /** @noinspection PhpIncludeInspection */ | |
| 80 | 116 | include $file; |
| 81 | 117 | } |
| 82 | 118 | |
| 83 | 119 | /** |
| @@ -82,49 +118,62 @@ | ||
| 82 | 118 | |
| 83 | 119 | /** |
| 84 | 120 | * @see exit() |
| 85 | 121 | */ |
| 86 | - #[NoReturn] | |
| 87 | - public function callExit(): void | |
| 122 | + public function callExit() | |
| 88 | 123 | { |
| 89 | 124 | exit; |
| 90 | 125 | } |
| 91 | 126 | |
| 92 | 127 | /** |
| 128 | + * @param string $filename | |
| 129 | + * @param mixed $data | |
| 130 | + * @param int $flags | |
| 131 | + * @param null $context | |
| 132 | + * @return bool|int | |
| 93 | 133 | * @see file_put_contents() |
| 94 | 134 | */ |
| 95 | - public function filePutContents(string $filename, mixed $data, int $flags = 0, $context = null): false|int | |
| 135 | + public function filePutContents(string $filename, $data, $flags = 0, $context = null) | |
| 96 | 136 | { |
| 97 | 137 | return file_put_contents($filename, $data, $flags, $context); |
| 98 | 138 | } |
| 99 | 139 | |
| 100 | 140 | /** |
| 141 | + * @param mixed $value | |
| 142 | + * @return string | |
| 101 | 143 | * @see igbinary_serialize() |
| 102 | 144 | */ |
| 103 | - public function igbinarySerialize(mixed $value): ?string | |
| 145 | + public function igbinarySerialize($value): string | |
| 104 | 146 | { |
| 105 | 147 | return igbinary_serialize($value); |
| 106 | 148 | } |
| 107 | 149 | |
| 108 | 150 | /** |
| 151 | + * @param string $key | |
| 152 | + * @return mixed | |
| 109 | 153 | * @see igbinary_unserialize() |
| 110 | 154 | */ |
| 111 | - public function igbinaryUnserialize(string $key): mixed | |
| 155 | + public function igbinaryUnserialize(string $key) | |
| 112 | 156 | { |
| 113 | 157 | return igbinary_unserialize($key); |
| 114 | 158 | } |
| 115 | 159 | |
| 116 | 160 | /** |
| 161 | + * @param string $pathname | |
| 162 | + * @param int $mode | |
| 163 | + * @param bool $recursive | |
| 164 | + * @param null $context | |
| 165 | + * @return bool | |
| 117 | 166 | * @see mkdir() |
| 118 | 167 | */ |
| 119 | - public function mkdir(string $pathname, int $mode = 0777, bool $recursive = false, $context = null): bool | |
| 168 | + public function mkdir(string $pathname, $mode = 0777, $recursive = false, $context = null): bool | |
| 120 | 169 | { |
| 121 | - return ($context !== null) | |
| 122 | - ? mkdir($pathname, $mode, $recursive, $context) | |
| 123 | - : mkdir($pathname, $mode, $recursive); | |
| 170 | + return ($context !== null) ? | |
| 171 | + mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive); | |
| 124 | 172 | } |
| 125 | 173 | |
| 126 | 174 | /** |
| 175 | + * @return int | |
| 127 | 176 | * @see connection_status() |
| 128 | 177 | */ |
| 129 | 178 | public function connectionStatus(): int |
| 130 | 179 | { |
| @@ -131,8 +180,10 @@ | ||
| 131 | 180 | return connection_status(); |
| 132 | 181 | } |
| 133 | 182 | |
| 134 | 183 | /** |
| 184 | + * @param resource $handle | |
| 185 | + * @return bool | |
| 135 | 186 | * @see fclose() |
| 136 | 187 | */ |
| 137 | 188 | public function fClose($handle): bool |
| 138 | 189 | { |