Skip to content

Commit

Permalink
Bulk changes based on #1411
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTronin committed Jul 27, 2022
1 parent 08b9e06 commit 3b14ae6
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 120 deletions.
28 changes: 19 additions & 9 deletions PhpStormStubsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions SPL/SPL_f.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function spl_object_hash(object $object): string {}
* </p>
* @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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions filter/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions imap/imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,7 @@ function imap_mail(string $to, string $subject, string $message, ?string $additi
* <dt>fetchsubject</dt><dd>subject line formatted to fit subjectlength characters</dd>
* </dl>
*/
#[PhpStormStubsElementAvailable(to: '7.4')]
function imap_header($stream_id, $msg_no, $from_length = 0, $subject_length = 0, $default_host = null) {}

/**
Expand Down
10 changes: 10 additions & 0 deletions mysqli/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pcre/pcre.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
213 changes: 213 additions & 0 deletions random/random.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<?php

namespace {
use JetBrains\PhpStorm\Internal\PhpStormStubsElementAvailable;
use JetBrains\PhpStorm\Pure;

/**
* 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 {}

/**
* Seeds the Mersenne Twister Random Number Generator
* @link https://php.net/manual/en/function.mt-srand.php
* @param int $seed <p>
* An optional seed value
* </p>
* @param int $mode [optional] <p>
* Use one of the following constants to specify the implementation of the algorithm to use.
* </p>
* @return void
*/
function mt_srand(
int $seed = 0,
#[PhpStormStubsElementAvailable(from: '7.1')] int $mode = MT_RAND_MT19937
): void {}

/**
* Seed the random number generator
* <p><strong>Note</strong>: As of PHP 7.1.0, {@see srand()} has been made
* an alias of {@see mt_srand()}.
* </p>
* @link https://php.net/manual/en/function.srand.php
* @param int $seed <p>
* Optional seed value
* </p>
* @param int $mode [optional] <p>
* Use one of the following constants to specify the implementation of the algorithm to use.
* </p>
* @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 <p>
* Optional lowest value to be returned (default: 0)
* </p>
* @param int $max [optional] <p>
* Optional highest value to be returned (default: mt_getrandmax())
* </p>
* @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 {}
}
}
14 changes: 14 additions & 0 deletions sockets/sockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Loading

0 comments on commit 3b14ae6

Please sign in to comment.