diff --git a/PhpStormStubsMap.php b/PhpStormStubsMap.php index ac4eca69f..cd7722697 100644 --- a/PhpStormStubsMap.php +++ b/PhpStormStubsMap.php @@ -734,6 +734,13 @@ final class PhpStormStubsMap 'RRDCreator' => 'rrd/rrd.php', 'RRDGraph' => 'rrd/rrd.php', 'RRDUpdater' => 'rrd/rrd.php', + 'Random\\CryptoSafeEngine' => 'random/random.php', + 'Random\\Engine' => 'random/random.php', + 'Random\\Engine\\Mt19937' => 'random/random.php', + 'Random\\Engine\\PcgOneseq128XslRr64' => 'random/random.php', + 'Random\\Engine\\Secure' => 'random/random.php', + 'Random\\Engine\\Xoshiro256StarStar' => 'random/random.php', + 'Random\\Randomizer' => 'random/random.php', 'RangeException' => 'SPL/SPL.php', 'RarArchive' => 'rar/rar.php', 'RarEntry' => 'rar/rar.php', @@ -2661,7 +2668,7 @@ final class PhpStormStubsMap 'getopt' => 'standard/standard_3.php', 'getprotobyname' => 'standard/standard_2.php', 'getprotobynumber' => 'standard/standard_2.php', - 'getrandmax' => 'standard/standard_2.php', + 'getrandmax' => 'random/random.php', 'getrusage' => 'standard/standard_3.php', 'getservbyname' => 'standard/standard_2.php', 'getservbyport' => 'standard/standard_2.php', @@ -3299,7 +3306,7 @@ final class PhpStormStubsMap 'krsort' => 'standard/standard_8.php', 'ksort' => 'standard/standard_8.php', 'lcfirst' => 'standard/standard_1.php', - 'lcg_value' => 'standard/standard_8.php', + 'lcg_value' => 'random/random.php', 'lchgrp' => 'standard/standard_7.php', 'lchown' => 'standard/standard_7.php', 'ldap_8859_to_t61' => 'ldap/ldap.php', @@ -3848,9 +3855,9 @@ final class PhpStormStubsMap 'mssql_result' => 'mssql/mssql.php', 'mssql_rows_affected' => 'mssql/mssql.php', 'mssql_select_db' => 'mssql/mssql.php', - 'mt_getrandmax' => 'standard/standard_2.php', - 'mt_rand' => 'standard/standard_2.php', - 'mt_srand' => 'standard/standard_2.php', + 'mt_getrandmax' => 'random/random.php', + 'mt_rand' => 'random/random.php', + 'mt_srand' => 'random/random.php', 'mysql' => 'mysql/mysql.php', 'mysql_affected_rows' => 'mysql/mysql.php', 'mysql_client_encoding' => 'mysql/mysql.php', @@ -4777,9 +4784,9 @@ final class PhpStormStubsMap 'radius_close' => 'radius/radius.php', 'radius_config' => 'radius/radius.php', 'radius_create_request' => 'radius/radius.php', - 'rand' => 'standard/standard_2.php', - 'random_bytes' => 'standard/CSPRNG.php', - 'random_int' => 'standard/CSPRNG.php', + 'rand' => 'random/random.php', + 'random_bytes' => 'random/random.php', + 'random_int' => 'random/random.php', 'range' => 'standard/standard_8.php', 'rawurldecode' => 'standard/standard_2.php', 'rawurlencode' => 'standard/standard_2.php', @@ -5190,7 +5197,7 @@ final class PhpStormStubsMap 'sqlsrv_send_stream_data' => 'sqlsrv/sqlsrv.php', 'sqlsrv_server_info' => 'sqlsrv/sqlsrv.php', 'sqrt' => 'standard/standard_3.php', - 'srand' => 'standard/standard_2.php', + 'srand' => 'random/random.php', 'sscanf' => 'standard/standard_2.php', 'ssh2_auth_agent' => 'ssh2/ssh2.php', 'ssh2_auth_hostbased_file' => 'ssh2/ssh2.php', @@ -7346,6 +7353,7 @@ final class PhpStormStubsMap 'FILTER_FLAG_ENCODE_AMP' => 'filter/filter.php', 'FILTER_FLAG_ENCODE_HIGH' => 'filter/filter.php', 'FILTER_FLAG_ENCODE_LOW' => 'filter/filter.php', + 'FILTER_FLAG_GLOBAL_RANGE' => 'filter/filter.php', 'FILTER_FLAG_HOSTNAME' => 'filter/filter.php', 'FILTER_FLAG_HOST_REQUIRED' => 'filter/filter.php', 'FILTER_FLAG_IPV4' => 'filter/filter.php', @@ -9852,6 +9860,7 @@ final class PhpStormStubsMap 'MSG_TRUNC' => 'sockets/sockets.php', 'MSG_WAITALL' => 'sockets/sockets.php', 'MSG_WAITFORONE' => 'sockets/sockets.php', + 'MSG_ZEROCOPY' => 'sockets/sockets.php', 'MSSQL_ASSOC' => 'mssql/mssql.php', 'MSSQL_BOTH' => 'mssql/mssql.php', 'MSSQL_NUM' => 'mssql/mssql.php', @@ -11796,6 +11805,7 @@ final class PhpStormStubsMap 'SO_SNDLOWAT' => 'sockets/sockets.php', 'SO_SNDTIMEO' => 'sockets/sockets.php', 'SO_TYPE' => 'sockets/sockets.php', + 'SO_ZEROCOPY' => 'sockets/sockets.php', 'SQLBIT' => 'mssql/mssql.php', 'SQLCHAR' => 'mssql/mssql.php', 'SQLFLT4' => 'mssql/mssql.php', diff --git a/SPL/SPL_f.php b/SPL/SPL_f.php index d874bb033..b0cb5f791 100644 --- a/SPL/SPL_f.php +++ b/SPL/SPL_f.php @@ -147,7 +147,7 @@ function spl_object_hash(object $object): string {} *

* @return array An array containing the elements of the iterator. */ -function iterator_to_array(Traversable $iterator, bool $preserve_keys = true): array {} +function iterator_to_array(#[LanguageLevelTypeAware(['8.2' => 'Traversable|array'], default: 'Traversable')] $iterator, bool $preserve_keys = true): array {} /** * Count the elements in an iterator @@ -158,7 +158,7 @@ function iterator_to_array(Traversable $iterator, bool $preserve_keys = true): a * @return int The number of elements in iterator. */ #[Pure] -function iterator_count(Traversable $iterator): int {} +function iterator_count(#[LanguageLevelTypeAware(['8.2' => 'Traversable|array'], default: 'Traversable')] $iterator): int {} /** * Call a function for every element in an iterator diff --git a/filter/filter.php b/filter/filter.php index d135e773d..c928e2d0d 100644 --- a/filter/filter.php +++ b/filter/filter.php @@ -526,4 +526,11 @@ function filter_id(string $name): int|false {} define('FILTER_FLAG_HOSTNAME', 1048576); define('FILTER_FLAG_EMAIL_UNICODE', 1048576); + +/** + * filters Global IPs per RFC 6890 + * @since 8.2 + */ +define('FILTER_FLAG_GLOBAL_RANGE', 268435456); + // End of filter v.0.11.0 diff --git a/imap/imap.php b/imap/imap.php index 60e117377..99e4e0a78 100644 --- a/imap/imap.php +++ b/imap/imap.php @@ -1384,6 +1384,7 @@ function imap_mail(string $to, string $subject, string $message, ?string $additi *
fetchsubject
subject line formatted to fit subjectlength characters
* */ +#[PhpStormStubsElementAvailable(to: '7.4')] function imap_header($stream_id, $msg_no, $from_length = 0, $subject_length = 0, $default_host = null) {} /** diff --git a/mysqli/mysqli.php b/mysqli/mysqli.php index 3cca19c21..8bb972691 100644 --- a/mysqli/mysqli.php +++ b/mysqli/mysqli.php @@ -350,6 +350,16 @@ public function debug(string $options) {} #[TentativeType] public function get_charset(): ?object {} + /** + * @param mysqli $mysql + * @param string $query + * @param array|null $params + * @return mysqli_result|bool + * @see mysqli_execute_query + * @since 8.2 + */ + public function execute_query(string $query, ?array $params = null): mysqli_result|bool {} + /** * Returns the MySQL client version as a string * @link https://php.net/manual/en/mysqli.get-client-info.php diff --git a/pcre/pcre.php b/pcre/pcre.php index 34386bfb6..7baccb4d3 100644 --- a/pcre/pcre.php +++ b/pcre/pcre.php @@ -629,7 +629,7 @@ function preg_last_error_msg(): string {} /** * @since 7.3 */ -define('PCRE_VERSION_MINOR', 39); +define('PCRE_VERSION_MINOR', 40); /** * @since 7.3 diff --git a/random/random.php b/random/random.php new file mode 100644 index 000000000..ecfdab157 --- /dev/null +++ b/random/random.php @@ -0,0 +1,213 @@ + + * An optional seed value + *

+ * @param int $mode [optional]

+ * Use one of the following constants to specify the implementation of the algorithm to use. + *

+ * @return void + */ + function mt_srand( + int $seed = 0, + #[PhpStormStubsElementAvailable(from: '7.1')] int $mode = MT_RAND_MT19937 + ): void {} + + /** + * Seed the random number generator + *

Note: As of PHP 7.1.0, {@see srand()} has been made + * an alias of {@see mt_srand()}. + *

+ * @link https://php.net/manual/en/function.srand.php + * @param int $seed

+ * Optional seed value + *

+ * @param int $mode [optional]

+ * Use one of the following constants to specify the implementation of the algorithm to use. + *

+ * @return void + */ + function srand( + int $seed = 0, + #[PhpStormStubsElementAvailable(from: '7.1')] int $mode = MT_RAND_MT19937 + ): void {} + + /** + * Generate a random integer + * @link https://php.net/manual/en/function.rand.php + * @param int $min + * @param int $max [optional] + * @return int A pseudo random value between min + * (or 0) and max (or getrandmax, inclusive). + */ + function rand(int $min = null, int $max): int {} + + /** + * Generate a random value via the Mersenne Twister Random Number Generator + * @link https://php.net/manual/en/function.mt-rand.php + * @param int $min

+ * Optional lowest value to be returned (default: 0) + *

+ * @param int $max [optional]

+ * Optional highest value to be returned (default: mt_getrandmax()) + *

+ * @return int A random integer value between min (or 0) + * and max (or mt_getrandmax, inclusive) + */ + function mt_rand(int $min = null, int $max): int {} + + /** + * Show largest possible random value + * @link https://php.net/manual/en/function.mt-getrandmax.php + * @return int the maximum random value returned by mt_rand + */ + #[Pure] + function mt_getrandmax(): int {} + + /** + * Show largest possible random value + * @link https://php.net/manual/en/function.getrandmax.php + * @return int The largest possible random value returned by rand + */ + #[Pure] + function getrandmax(): int {} + + /** + * Generates cryptographically secure pseudo-random bytes + * @link https://php.net/manual/en/function.random-bytes.php + * @param int $length The length of the random string that should be returned in bytes. + * @return string Returns a string containing the requested number of cryptographically secure random bytes. + * @since 7.0 + * @throws Exception if an appropriate source of randomness cannot be found. + */ + function random_bytes(int $length): string {} + + /** + * Generates cryptographically secure pseudo-random integers + * @link https://php.net/manual/en/function.random-int.php + * @param int $min The lowest value to be returned, which must be PHP_INT_MIN or higher. + * @param int $max The highest value to be returned, which must be less than or equal to PHP_INT_MAX. + * @return int Returns a cryptographically secure random integer in the range min to max, inclusive. + * @since 7.0 + * @throws Exception if an appropriate source of randomness cannot be found. + */ + function random_int(int $min, int $max): int {} +} + +namespace Random\Engine +{ + /** + * @since 8.2 + */ + final class Mt19937 implements \Random\Engine + { + public function __construct(int|null $seed = null, int $mode = MT_RAND_MT19937) {} + + public function generate(): string {} + + public function __serialize(): array {} + + public function __unserialize(array $data): void {} + + public function __debugInfo(): array {} + } + + /** + * @since 8.2 + */ + final class PcgOneseq128XslRr64 implements \Random\Engine + { + public function __construct(string|int|null $seed = null, string|int $sequence = 0) {} + + public function generate(): string {} + + public function jump(int $advance): void {} + + public function __serialize(): array {} + + public function __unserialize(array $data): void {} + + public function __debugInfo(): array {} + } + + /** + * @since 8.2 + */ + final class Xoshiro256StarStar implements \Random\Engine + { + public function __construct(string|int|null $seed = null) {} + + public function generate(): string {} + + public function jump(): void {} + + public function jumpLong(): void {} + + public function __serialize(): array {} + + public function __unserialize(array $data): void {} + + public function __debugInfo(): array {} + } + + /** + * @since 8.2 + */ + final class Secure implements \Random\CryptoSafeEngine + { + public function generate(): string {} + } +} + +namespace Random +{ + /** + * @since 8.2 + */ + interface Engine + { + public function generate(): string; + } + /** + * @since 8.2 + */ + interface CryptoSafeEngine extends Engine {} + + /** + * @since 8.2 + */ + final class Randomizer + { + public readonly Engine $engine; + + public function __construct(?Engine $engine = null) {} + + public function getInt(int $min = UNKNOWN, int $max = UNKNOWN): int {} + + public function getBytes(int $length): string {} + + public function shuffleArray(array $array): array {} + + public function shuffleBytes(string $bytes): string {} + + public function pickArrayKeys(array $array, int $num): array {} + + public function __serialize(): array {} + + public function __unserialize(array $data): void {} + } +} diff --git a/sockets/sockets.php b/sockets/sockets.php index 73cb44387..212b8a24e 100644 --- a/sockets/sockets.php +++ b/sockets/sockets.php @@ -2312,6 +2312,20 @@ function socket_wsaprotocol_info_release($info_id) {} */ define('TCP_KEEPCNT', 6); +/** + * Socket_set_option for the socket_send* functions. + * It avoids copy b/w userland and kernel for both TCP and UDP protocols. + * @since 8.2 + */ +define('SO_ZEROCOPY', 60); + +/** + * Socket_set_option for the socket_send* functions. + * It avoids copy b/w userland and kernel for both TCP and UDP protocols. + * @since 8.2 + */ +define('MSG_ZEROCOPY', 67108864); + /** * @since 8.0 */ diff --git a/standard/CSPRNG.php b/standard/CSPRNG.php deleted file mode 100644 index 069a9fa03..000000000 --- a/standard/CSPRNG.php +++ /dev/null @@ -1,21 +0,0 @@ - 'string'], default: '')] + #[PhpStormStubsElementAvailable(to: '8.0')] public $path; + /** + * @var string The directory that was opened. + */ + #[PhpStormStubsElementAvailable(from: '8.1')] + public readonly string $path; + /** * @var resource Can be used with other directory functions such as {@see readdir()}, {@see rewinddir()} and {@see closedir()}. */ - #[LanguageLevelTypeAware(['8.1' => 'mixed'], default: '')] + #[PhpStormStubsElementAvailable(to: '8.0')] public $handle; + /** + * @var resource Can be used with other directory functions such as {@see readdir()}, {@see rewinddir()} and {@see closedir()}. + */ + #[PhpStormStubsElementAvailable(from: '8.1')] + public readonly mixed $handle; + /** * Close directory handle. * Same as closedir(), only dir_handle defaults to $this. diff --git a/standard/standard_2.php b/standard/standard_2.php index 6d8ef8993..1f04e40ff 100644 --- a/standard/standard_2.php +++ b/standard/standard_2.php @@ -930,81 +930,6 @@ function proc_get_status($process) {} */ function proc_nice(int $priority): bool {} -/** - * Generate a random integer - * @link https://php.net/manual/en/function.rand.php - * @param int $min - * @param int $max [optional] - * @return int A pseudo random value between min - * (or 0) and max (or getrandmax, inclusive). - */ -function rand(int $min = null, int $max): int {} - -/** - * Seed the random number generator - *

Note: As of PHP 7.1.0, {@see srand()} has been made - * an alias of {@see mt_srand()}. - *

- * @link https://php.net/manual/en/function.srand.php - * @param int $seed

- * Optional seed value - *

- * @param int $mode [optional]

- * Use one of the following constants to specify the implementation of the algorithm to use. - *

- * @return void - */ -function srand( - int $seed = 0, - #[PhpStormStubsElementAvailable(from: '7.1')] int $mode = MT_RAND_MT19937 -): void {} - -/** - * Show largest possible random value - * @link https://php.net/manual/en/function.getrandmax.php - * @return int The largest possible random value returned by rand - */ -#[Pure] -function getrandmax(): int {} - -/** - * Generate a random value via the Mersenne Twister Random Number Generator - * @link https://php.net/manual/en/function.mt-rand.php - * @param int $min

- * Optional lowest value to be returned (default: 0) - *

- * @param int $max [optional]

- * Optional highest value to be returned (default: mt_getrandmax()) - *

- * @return int A random integer value between min (or 0) - * and max (or mt_getrandmax, inclusive) - */ -function mt_rand(int $min = null, int $max): int {} - -/** - * Seeds the Mersenne Twister Random Number Generator - * @link https://php.net/manual/en/function.mt-srand.php - * @param int $seed

- * An optional seed value - *

- * @param int $mode [optional]

- * Use one of the following constants to specify the implementation of the algorithm to use. - *

- * @return void - */ -function mt_srand( - int $seed = 0, - #[PhpStormStubsElementAvailable(from: '7.1')] int $mode = MT_RAND_MT19937 -): void {} - -/** - * Show largest possible random value - * @link https://php.net/manual/en/function.mt-getrandmax.php - * @return int the maximum random value returned by mt_rand - */ -#[Pure] -function mt_getrandmax(): int {} - /** * Get port number associated with an Internet service and protocol * @link https://php.net/manual/en/function.getservbyname.php diff --git a/standard/standard_8.php b/standard/standard_8.php index fc3682dbf..3f9f1a6e1 100644 --- a/standard/standard_8.php +++ b/standard/standard_8.php @@ -124,13 +124,6 @@ function stream_set_chunk_size($stream, int $size) {} #[Deprecated(since: '5.3')] function define_syslog_variables() {} -/** - * Combined linear congruential generator - * @link https://php.net/manual/en/function.lcg-value.php - * @return float A pseudo random float value in the range of (0, 1) - */ -function lcg_value(): float {} - /** * Calculate the metaphone key of a string * @link https://php.net/manual/en/function.metaphone.php diff --git a/tests/DockerImages/8.2/Dockerfile b/tests/DockerImages/8.2/Dockerfile index 2bb53fb15..cf16647d8 100644 --- a/tests/DockerImages/8.2/Dockerfile +++ b/tests/DockerImages/8.2/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2.0alpha3-zts-alpine +FROM php:8.2.0beta1-zts-alpine RUN set -eux; \ apk add --no-cache --virtual .build-deps \ diff --git a/tests/Model/PHPProperty.php b/tests/Model/PHPProperty.php index 0a8313fe5..1b467a4c1 100644 --- a/tests/Model/PHPProperty.php +++ b/tests/Model/PHPProperty.php @@ -49,8 +49,8 @@ public function readObjectFromReflection($reflectionObject) if (method_exists($reflectionObject, 'getType')) { $this->typesFromSignature = self::getReflectionTypeAsArray($reflectionObject->getType()); } - if (property_exists($reflectionObject, 'isReadonly')) { - $this->isReadonly = $reflectionObject->isReadonly; + if (method_exists($reflectionObject, 'isReadonly')) { + $this->isReadonly = $reflectionObject->isReadOnly(); } return $this; } diff --git a/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php b/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php index d2d59ad6d..bbddad73a 100644 --- a/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php +++ b/tests/TestData/Providers/Stubs/PhpCoreStubsProvider.php @@ -16,6 +16,7 @@ class PhpCoreStubsProvider 'hash', 'meta', 'pcre', + 'random', 'Phar', 'Reflection', 'regex',