Skip to content

Commit

Permalink
Merge pull request #335 from thecodingmachine/phpstan/update
Browse files Browse the repository at this point in the history
Phpstan/update
  • Loading branch information
Kharhamel authored Mar 25, 2022
2 parents a809a19 + e87c187 commit 68096ae
Show file tree
Hide file tree
Showing 25 changed files with 611 additions and 453 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"php": "^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12",
"thecodingmachine/phpstan-strict-rules": "^0.12",
"phpstan/phpstan": "^1.5",
"thecodingmachine/phpstan-strict-rules": "^1.0",
"squizlabs/php_codesniffer": "^3.2",
"phpunit/phpunit": "^9.5"
},
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.7'
services:

app:
image: thecodingmachine/php:8.1-v4-apache
volumes:
- ./:/var/www/html
8 changes: 4 additions & 4 deletions generated/datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*
* @param string $format Format accepted by DateTime::createFromFormat.
* @param string $datetime String representing the date/time.
* @return array Returns associative array with detailed info about given date/time.
* @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.
* @throws DatetimeException
*
*/
function date_parse_from_format(string $format, string $datetime): array
function date_parse_from_format(string $format, string $datetime): ?array
{
error_clear_last();
$result = \date_parse_from_format($format, $datetime);
Expand All @@ -29,12 +29,12 @@ function date_parse_from_format(string $format, string $datetime): array
*
* @param string $datetime Date/time in format accepted by
* DateTimeImmutable::__construct.
* @return array Returns array with information about the parsed date/time
* @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
* on success.
* @throws DatetimeException
*
*/
function date_parse(string $datetime): array
function date_parse(string $datetime): ?array
{
error_clear_last();
$result = \date_parse($datetime);
Expand Down
36 changes: 18 additions & 18 deletions generated/filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function fflush($stream): void
* @param resource $stream A valid file pointer to a file successfully opened by
* fopen, popen, or
* fsockopen.
* @param int $length Must be greater than the longest line (in characters) to be found in
* @param \0|int $length Must be greater than the longest line (in characters) to be found in
* the CSV file (allowing for trailing line-end characters). Otherwise the
* line is split in chunks of length characters,
* unless the split would occur inside an enclosure.
Expand All @@ -251,7 +251,7 @@ function fflush($stream): void
* @throws FilesystemException
*
*/
function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\")
function fgetcsv($stream, $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\")
{
error_clear_last();
if ($escape !== "\\") {
Expand Down Expand Up @@ -299,14 +299,14 @@ function fgetcsv($stream, int $length = null, string $separator = ",", string $e
* Seeking (offset) is not supported with remote files.
* Attempting to seek on non-local files may work with small offsets, but this
* is unpredictable because it works on the buffered stream.
* @param int $length Maximum length of data read. The default is to read until end
* @param \0|int $length Maximum length of data read. The default is to read until end
* of file is reached. Note that this parameter is applied to the
* stream processed by the filters.
* @return string The function returns the read data.
* @throws FilesystemException
*
*/
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, int $length = null): string
function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, $length = null): string
{
error_clear_last();
if ($length !== null) {
Expand Down Expand Up @@ -395,11 +395,11 @@ function file_get_contents(string $filename, bool $use_include_path = false, $co
*
* @param resource|null $context A valid context resource created with
* stream_context_create.
* @return int This function returns the number of bytes that were written to the file.
* @return \0|int This function returns the number of bytes that were written to the file.
* @throws FilesystemException
*
*/
function file_put_contents(string $filename, $data, int $flags = 0, $context = null): int
function file_put_contents(string $filename, $data, int $flags = 0, $context = null)
{
error_clear_last();
if ($context !== null) {
Expand Down Expand Up @@ -613,12 +613,12 @@ function fileperms(string $filename): int
* Gets the size for the given file.
*
* @param string $filename Path to the file.
* @return int Returns the size of the file in bytes, or FALSE (and generates an error
* @return \0|int Returns the size of the file in bytes, or FALSE (and generates an error
* of level E_WARNING) in case of an error.
* @throws FilesystemException
*
*/
function filesize(string $filename): int
function filesize(string $filename)
{
error_clear_last();
$result = \filesize($filename);
Expand Down Expand Up @@ -874,7 +874,7 @@ function flock($stream, int $operation, ?int &$would_block = null): void
* @param bool $use_include_path The optional third use_include_path parameter
* can be set to '1' or TRUE if you want to search for the file in the
* include_path, too.
* @param resource $context A context stream
* @param resource|null $context A context stream
* resource.
* @return resource Returns a file pointer resource on success
* @throws FilesystemException
Expand Down Expand Up @@ -929,12 +929,12 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $
*
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @param int $length Up to length number of bytes read.
* @param \0|int $length Up to length number of bytes read.
* @return string Returns the read string.
* @throws FilesystemException
*
*/
function fread($stream, int $length): string
function fread($stream, $length): string
{
error_clear_last();
$result = \fread($stream, $length);
Expand Down Expand Up @@ -998,7 +998,7 @@ function fsync($stream): void
* @param resource $stream The file pointer.
*
* The stream must be open for writing.
* @param int $size The size to truncate to.
* @param \0|int $size The size to truncate to.
*
* If size is larger than the file then the file
* is extended with null bytes.
Expand All @@ -1008,7 +1008,7 @@ function fsync($stream): void
* @throws FilesystemException
*
*/
function ftruncate($stream, int $size): void
function ftruncate($stream, $size): void
{
error_clear_last();
$result = \ftruncate($stream, $size);
Expand All @@ -1024,14 +1024,14 @@ function ftruncate($stream, int $size): void
* @param resource $stream A file system pointer resource
* that is typically created using fopen.
* @param string $data The string that is to be written.
* @param int $length If length is an integer, writing will stop
* @param \0|int $length If length is an integer, writing will stop
* after length bytes have been written or the
* end of data is reached, whichever comes first.
* @return int
* @return \0|int
* @throws FilesystemException
*
*/
function fwrite($stream, string $data, int $length = null): int
function fwrite($stream, string $data, $length = null)
{
error_clear_last();
if ($length !== null) {
Expand Down Expand Up @@ -1356,11 +1356,11 @@ function parse_ini_string(string $ini_string, bool $process_sections = false, in
* you want to search for the file in the include_path, too.
* @param resource $context A context stream
* resource.
* @return int Returns the number of bytes read from the file on success
* @return \0|int Returns the number of bytes read from the file on success
* @throws FilesystemException
*
*/
function readfile(string $filename, bool $use_include_path = false, $context = null): int
function readfile(string $filename, bool $use_include_path = false, $context = null)
{
error_clear_last();
if ($context !== null) {
Expand Down
4 changes: 2 additions & 2 deletions generated/imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2234,14 +2234,14 @@ function imap_timeout(int $timeout_type, int $timeout = -1)
* imap_delete or imap_mail_move.
*
* @param resource $imap An IMAP\Connection instance.
* @param int $message_nums A string representing one or more messages in IMAP4-style sequence format
* @param string $message_nums A string representing one or more messages in IMAP4-style sequence format
* ("n", "n:m", or combination of these
* delimited by commas).
* @param int $flags
* @throws ImapException
*
*/
function imap_undelete($imap, int $message_nums, int $flags = 0): void
function imap_undelete($imap, string $message_nums, int $flags = 0): void
{
error_clear_last();
$result = \imap_undelete($imap, $message_nums, $flags);
Expand Down
2 changes: 1 addition & 1 deletion generated/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function getmyuid(): int
* @param string $short_options
* @param array $long_options
* @param int|null $rest_index
* @return array|array|array This function will return an array of option / argument pairs.
* @return \__benevolent This function will return an array of option / argument pairs.
* @throws InfoException
*
*/
Expand Down
8 changes: 4 additions & 4 deletions generated/mbstring.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ function mb_encoding_aliases(string $encoding): array
* not used anywhere else.
* @param string $string The string being checked.
* @param string $options The search option. See mb_regex_set_options for explanation.
* @return string The resultant string on success.
* @return string|null The resultant string on success.
* If string is not valid for the current encoding, NULL
* is returned.
* @throws MbstringException
*
*/
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): string
function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $options = null): ?string
{
error_clear_last();
if ($options !== null) {
Expand All @@ -191,13 +191,13 @@ function mb_ereg_replace_callback(string $pattern, callable $callback, string $s
* @param string $replacement The replacement text.
* @param string $string The string being checked.
* @param string $options
* @return string The resultant string on success.
* @return string|null The resultant string on success.
* If string is not valid for the current encoding, NULL
* is returned.
* @throws MbstringException
*
*/
function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): string
function mb_ereg_replace(string $pattern, string $replacement, string $string, string $options = null): ?string
{
error_clear_last();
if ($options !== null) {
Expand Down
2 changes: 1 addition & 1 deletion generated/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function sleep(int $seconds): int
*
* @param int $seconds Must be a non-negative integer.
* @param int $nanoseconds Must be a non-negative integer less than 1 billion.
* @return array{0:int,1:int}|bool Returns TRUE on success.
* @return array{0:0|positive-int,1:0|positive-int}|bool Returns TRUE on success.
*
* If the delay was interrupted by a signal, an associative array will be
* returned with the components:
Expand Down
4 changes: 2 additions & 2 deletions generated/pcre.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ function preg_grep(string $pattern, array $array, int $flags = 0): array
*
*
* The above example will output:
* @return int Returns the number of full pattern matches (which might be zero).
* @return \0|int|null Returns the number of full pattern matches (which might be zero).
* @throws PcreException
*
*/
function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
function preg_match_all(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)
{
error_clear_last();
$result = \preg_match_all($pattern, $subject, $matches, $flags, $offset);
Expand Down
4 changes: 2 additions & 2 deletions generated/zlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ function inflate_init(int $encoding, array $options = [])
* contents written to standard output.
* @param int $use_include_path You can set this optional parameter to 1, if you
* want to search for the file in the include_path too.
* @return int Returns the number of (uncompressed) bytes read from the file on success
* @return \0|int Returns the number of (uncompressed) bytes read from the file on success
* @throws ZlibException
*
*/
function readgzfile(string $filename, int $use_include_path = 0): int
function readgzfile(string $filename, int $use_include_path = 0)
{
error_clear_last();
$result = \readgzfile($filename, $use_include_path);
Expand Down
7 changes: 4 additions & 3 deletions generator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"symfony/finder": "^4.1"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"thecodingmachine/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^9.5",
"thecodingmachine/phpstan-strict-rules": "^1.0",
"squizlabs/php_codesniffer": "^3.2",
"php-coveralls/php-coveralls": "^2.1",
"phpstan/phpstan": "^0.12.68"
"phpstan/phpstan": "^1.5"
},
"scripts": {
"test": "vendor/bin/phpunit",
"phpstan": "phpstan analyse src -c phpstan.neon --level=max --no-progress -vvv",
"cs-fix": "phpcbf",
"cs-check": "phpcs"
Expand Down
Loading

0 comments on commit 68096ae

Please sign in to comment.