Skip to content

Commit 68096ae

Browse files
authored
Merge pull request #335 from thecodingmachine/phpstan/update
Phpstan/update
2 parents a809a19 + e87c187 commit 68096ae

25 files changed

+611
-453
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
"php": "^8.0"
105105
},
106106
"require-dev": {
107-
"phpstan/phpstan": "^0.12",
108-
"thecodingmachine/phpstan-strict-rules": "^0.12",
107+
"phpstan/phpstan": "^1.5",
108+
"thecodingmachine/phpstan-strict-rules": "^1.0",
109109
"squizlabs/php_codesniffer": "^3.2",
110110
"phpunit/phpunit": "^9.5"
111111
},

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.7'
2+
services:
3+
4+
app:
5+
image: thecodingmachine/php:8.1-v4-apache
6+
volumes:
7+
- ./:/var/www/html

generated/datetime.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
*
1010
* @param string $format Format accepted by DateTime::createFromFormat.
1111
* @param string $datetime String representing the date/time.
12-
* @return array Returns associative array with detailed info about given date/time.
12+
* @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns associative array with detailed info about given date/time.
1313
* @throws DatetimeException
1414
*
1515
*/
16-
function date_parse_from_format(string $format, string $datetime): array
16+
function date_parse_from_format(string $format, string $datetime): ?array
1717
{
1818
error_clear_last();
1919
$result = \date_parse_from_format($format, $datetime);
@@ -29,12 +29,12 @@ function date_parse_from_format(string $format, string $datetime): array
2929
*
3030
* @param string $datetime Date/time in format accepted by
3131
* DateTimeImmutable::__construct.
32-
* @return array Returns array with information about the parsed date/time
32+
* @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns array with information about the parsed date/time
3333
* on success.
3434
* @throws DatetimeException
3535
*
3636
*/
37-
function date_parse(string $datetime): array
37+
function date_parse(string $datetime): ?array
3838
{
3939
error_clear_last();
4040
$result = \date_parse($datetime);

generated/filesystem.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ function fflush($stream): void
235235
* @param resource $stream A valid file pointer to a file successfully opened by
236236
* fopen, popen, or
237237
* fsockopen.
238-
* @param int $length Must be greater than the longest line (in characters) to be found in
238+
* @param \0|int $length Must be greater than the longest line (in characters) to be found in
239239
* the CSV file (allowing for trailing line-end characters). Otherwise the
240240
* line is split in chunks of length characters,
241241
* unless the split would occur inside an enclosure.
@@ -251,7 +251,7 @@ function fflush($stream): void
251251
* @throws FilesystemException
252252
*
253253
*/
254-
function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\")
254+
function fgetcsv($stream, $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\")
255255
{
256256
error_clear_last();
257257
if ($escape !== "\\") {
@@ -299,14 +299,14 @@ function fgetcsv($stream, int $length = null, string $separator = ",", string $e
299299
* Seeking (offset) is not supported with remote files.
300300
* Attempting to seek on non-local files may work with small offsets, but this
301301
* is unpredictable because it works on the buffered stream.
302-
* @param int $length Maximum length of data read. The default is to read until end
302+
* @param \0|int $length Maximum length of data read. The default is to read until end
303303
* of file is reached. Note that this parameter is applied to the
304304
* stream processed by the filters.
305305
* @return string The function returns the read data.
306306
* @throws FilesystemException
307307
*
308308
*/
309-
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string
309+
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, $length = null): string
310310
{
311311
error_clear_last();
312312
if ($length !== null) {
@@ -395,11 +395,11 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co
395395
*
396396
* @param resource|null $context A valid context resource created with
397397
* stream_context_create.
398-
* @return int This function returns the number of bytes that were written to the file.
398+
* @return \0|int This function returns the number of bytes that were written to the file.
399399
* @throws FilesystemException
400400
*
401401
*/
402-
function file_put_contents(string $filename, $data, int $flags = 0, $context = null): int
402+
function file_put_contents(string $filename, $data, int $flags = 0, $context = null)
403403
{
404404
error_clear_last();
405405
if ($context !== null) {
@@ -613,12 +613,12 @@ function fileperms(string $filename): int
613613
* Gets the size for the given file.
614614
*
615615
* @param string $filename Path to the file.
616-
* @return int Returns the size of the file in bytes, or FALSE (and generates an error
616+
* @return \0|int Returns the size of the file in bytes, or FALSE (and generates an error
617617
* of level E_WARNING) in case of an error.
618618
* @throws FilesystemException
619619
*
620620
*/
621-
function filesize(string $filename): int
621+
function filesize(string $filename)
622622
{
623623
error_clear_last();
624624
$result = \filesize($filename);
@@ -874,7 +874,7 @@ function flock($stream, int $operation, ?int &$would_block = null): void
874874
* @param bool $use_include_path The optional third use_include_path parameter
875875
* can be set to '1' or TRUE if you want to search for the file in the
876876
* include_path, too.
877-
* @param resource $context A context stream
877+
* @param resource|null $context A context stream
878878
* resource.
879879
* @return resource Returns a file pointer resource on success
880880
* @throws FilesystemException
@@ -929,12 +929,12 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $
929929
*
930930
* @param resource $stream A file system pointer resource
931931
* that is typically created using fopen.
932-
* @param int $length Up to length number of bytes read.
932+
* @param \0|int $length Up to length number of bytes read.
933933
* @return string Returns the read string.
934934
* @throws FilesystemException
935935
*
936936
*/
937-
function fread($stream, int $length): string
937+
function fread($stream, $length): string
938938
{
939939
error_clear_last();
940940
$result = \fread($stream, $length);
@@ -998,7 +998,7 @@ function fsync($stream): void
998998
* @param resource $stream The file pointer.
999999
*
10001000
* The stream must be open for writing.
1001-
* @param int $size The size to truncate to.
1001+
* @param \0|int $size The size to truncate to.
10021002
*
10031003
* If size is larger than the file then the file
10041004
* is extended with null bytes.
@@ -1008,7 +1008,7 @@ function fsync($stream): void
10081008
* @throws FilesystemException
10091009
*
10101010
*/
1011-
function ftruncate($stream, int $size): void
1011+
function ftruncate($stream, $size): void
10121012
{
10131013
error_clear_last();
10141014
$result = \ftruncate($stream, $size);
@@ -1024,14 +1024,14 @@ function ftruncate($stream, int $size): void
10241024
* @param resource $stream A file system pointer resource
10251025
* that is typically created using fopen.
10261026
* @param string $data The string that is to be written.
1027-
* @param int $length If length is an integer, writing will stop
1027+
* @param \0|int $length If length is an integer, writing will stop
10281028
* after length bytes have been written or the
10291029
* end of data is reached, whichever comes first.
1030-
* @return int
1030+
* @return \0|int
10311031
* @throws FilesystemException
10321032
*
10331033
*/
1034-
function fwrite($stream, string $data, int $length = null): int
1034+
function fwrite($stream, string $data, $length = null)
10351035
{
10361036
error_clear_last();
10371037
if ($length !== null) {
@@ -1356,11 +1356,11 @@ function parse_ini_string(string $ini_string, bool $process_sections = false, in
13561356
* you want to search for the file in the include_path, too.
13571357
* @param resource $context A context stream
13581358
* resource.
1359-
* @return int Returns the number of bytes read from the file on success
1359+
* @return \0|int Returns the number of bytes read from the file on success
13601360
* @throws FilesystemException
13611361
*
13621362
*/
1363-
function readfile(string $filename, bool $use_include_path = false, $context = null): int
1363+
function readfile(string $filename, bool $use_include_path = false, $context = null)
13641364
{
13651365
error_clear_last();
13661366
if ($context !== null) {

generated/imap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,14 +2234,14 @@ function imap_timeout(int $timeout_type, int $timeout = -1)
22342234
* imap_delete or imap_mail_move.
22352235
*
22362236
* @param resource $imap An IMAP\Connection instance.
2237-
* @param int $message_nums A string representing one or more messages in IMAP4-style sequence format
2237+
* @param string $message_nums A string representing one or more messages in IMAP4-style sequence format
22382238
* ("n", "n:m", or combination of these
22392239
* delimited by commas).
22402240
* @param int $flags
22412241
* @throws ImapException
22422242
*
22432243
*/
2244-
function imap_undelete($imap, int $message_nums, int $flags = 0): void
2244+
function imap_undelete($imap, string $message_nums, int $flags = 0): void
22452245
{
22462246
error_clear_last();
22472247
$result = \imap_undelete($imap, $message_nums, $flags);

generated/info.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function getmyuid(): int
323323
* @param string $short_options
324324
* @param array $long_options
325325
* @param int|null $rest_index
326-
* @return array|array|array This function will return an array of option / argument pairs.
326+
* @return \__benevolent This function will return an array of option / argument pairs.
327327
* @throws InfoException
328328
*
329329
*/

generated/mbstring.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ function mb_encoding_aliases(string $encoding): array
161161
* not used anywhere else.
162162
* @param string $string The string being checked.
163163
* @param string $options The search option. See mb_regex_set_options for explanation.
164-
* @return string The resultant string on success.
164+
* @return string|null The resultant string on success.
165165
* If string is not valid for the current encoding, NULL
166166
* is returned.
167167
* @throws MbstringException
168168
*
169169
*/
170-
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): string
170+
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): ?string
171171
{
172172
error_clear_last();
173173
if ($options !== null) {
@@ -191,13 +191,13 @@ function mb_ereg_replace_callback(string $pattern, callable $callback, string $s
191191
* @param string $replacement The replacement text.
192192
* @param string $string The string being checked.
193193
* @param string $options
194-
* @return string The resultant string on success.
194+
* @return string|null The resultant string on success.
195195
* If string is not valid for the current encoding, NULL
196196
* is returned.
197197
* @throws MbstringException
198198
*
199199
*/
200-
function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): string
200+
function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): ?string
201201
{
202202
error_clear_last();
203203
if ($options !== null) {

generated/misc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function sleep(int $seconds): int
450450
*
451451
* @param int $seconds Must be a non-negative integer.
452452
* @param int $nanoseconds Must be a non-negative integer less than 1 billion.
453-
* @return array{0:int,1:int}|bool Returns TRUE on success.
453+
* @return array{0:0|positive-int,1:0|positive-int}|bool Returns TRUE on success.
454454
*
455455
* If the delay was interrupted by a signal, an associative array will be
456456
* returned with the components:

generated/pcre.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ function preg_grep(string $pattern, array $array, int $flags = 0): array
369369
*
370370
*
371371
* The above example will output:
372-
* @return int Returns the number of full pattern matches (which might be zero).
372+
* @return \0|int|null Returns the number of full pattern matches (which might be zero).
373373
* @throws PcreException
374374
*
375375
*/
376-
function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
376+
function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)
377377
{
378378
error_clear_last();
379379
$result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);

generated/zlib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,11 @@ function inflate_init(int $encoding, array $options = [])
686686
* contents written to standard output.
687687
* @param int $use_include_path You can set this optional parameter to 1, if you
688688
* want to search for the file in the include_path too.
689-
* @return int Returns the number of (uncompressed) bytes read from the file on success
689+
* @return \0|int Returns the number of (uncompressed) bytes read from the file on success
690690
* @throws ZlibException
691691
*
692692
*/
693-
function readgzfile(string $filename, int $use_include_path = 0): int
693+
function readgzfile(string $filename, int $use_include_path = 0)
694694
{
695695
error_clear_last();
696696
$result = \readgzfile($filename, $use_include_path);

0 commit comments

Comments
 (0)