Skip to content

Commit 1eb87f3

Browse files
committed
[phpstorm-stubs] update stubs to migration version for php 8.1
1 parent e16c171 commit 1eb87f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1645
-918
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
fail-fast: false
10-
name: Run tests against php 8.0
10+
name: Run tests against php 8.1
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414

1515
- name: Build Docker Container
1616
run: docker-compose -f docker-compose.yml build >/dev/null
1717
env:
18-
PHP_VERSION: '8.0'
18+
PHP_VERSION: '8.1'
1919

2020
- name: Composer Install
21-
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.0 test_runner composer update
21+
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.1 test_runner composer update
2222
env:
23-
PHP_VERSION: '8.0'
23+
PHP_VERSION: '8.1'
2424

2525
- name: Dump Reflection To File
26-
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.0 php_under_test /usr/local/bin/php tests/Tools/dump-reflection-to-file.php ReflectionData.json
26+
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.1 php_under_test /usr/local/bin/php tests/Tools/dump-reflection-to-file.php ReflectionData.json
2727
env:
28-
PHP_VERSION: '8.0'
28+
PHP_VERSION: '8.1'
2929

3030
- name: Run Tests
31-
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.0 test_runner vendor/bin/phpunit --testsuite PHP_8.0
31+
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=8.1 test_runner vendor/bin/phpunit --testsuite PHP_8.1
3232
env:
33-
PHP_VERSION: '8.0'
33+
PHP_VERSION: '8.1'
3434
additional:
3535
runs-on: ubuntu-latest
3636
name: Run cs-fixer and stubs structure tests

Core/Core.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function error_reporting(?int $error_level): int {}
335335
* </p>
336336
* @return bool true on success or false on failure.
337337
*/
338-
function define(string $constant_name, $value, #[Deprecated(since: "7.3")] bool $case_insensitive = false): bool {}
338+
function define(string $constant_name, mixed $value, #[Deprecated(since: "7.3")] bool $case_insensitive = false): bool {}
339339

340340
/**
341341
* Checks whether a given named constant exists
@@ -475,6 +475,21 @@ function interface_exists(string $interface, bool $autoload = true): bool {}
475475
#[Pure(true)]
476476
function function_exists(string $function): bool {}
477477

478+
/**
479+
* Checks if the enum has been defined
480+
* @link https://php.net/manual/en/function.enum-exists.php
481+
* @param string $enum <p>
482+
* The enum name. The name is matched in a case-insensitive manner.
483+
* </p>
484+
* @param bool $autoload [optional] <p>
485+
* Whether or not to call autoload by default.
486+
* </p>
487+
* @return bool true if <i>enum</i> is a defined enum,
488+
* false otherwise.
489+
* @since 8.1
490+
*/
491+
function enum_exists(string $enum, bool $autoload = true): bool {}
492+
478493
/**
479494
* Creates an alias for a class
480495
* @link https://php.net/manual/en/function.class-alias.php

Core/Core_c.php

Lines changed: 193 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,76 @@ interface Stringable
295295
public function __toString(): string;
296296
}
297297

298+
/**
299+
* @since 8.1
300+
*/
301+
interface UnitEnum
302+
{
303+
/**
304+
* @return static[]
305+
*/
306+
#[Pure]
307+
public static function cases(): array;
308+
}
309+
310+
/**
311+
* @since 8.1
312+
*/
313+
interface BackedEnum extends UnitEnum
314+
{
315+
/**
316+
* @param int|string $value
317+
* @return static
318+
*/
319+
#[Pure]
320+
public static function from(int|string $value): static;
321+
322+
/**
323+
* @param int|string $value
324+
* @return static|null
325+
*/
326+
#[Pure]
327+
public static function tryFrom(int|string $value): ?static;
328+
}
329+
330+
/**
331+
* @since 8.1
332+
* @internal
333+
*
334+
* Internal interface to ensure precise type inference
335+
*/
336+
interface IntBackedEnum extends BackedEnum
337+
{
338+
/**
339+
* @param int $value
340+
* @return static
341+
*/
342+
#[Pure]
343+
public static function from(int $value): static;
344+
345+
/**
346+
* @param int $value
347+
* @return static|null
348+
*/
349+
#[Pure]
350+
public static function tryFrom(int $value): ?static;
351+
}
352+
353+
/**
354+
* @since 8.1
355+
* @internal
356+
*
357+
* Internal interface to ensure precise type inference
358+
*/
359+
interface StringBackedEnum extends BackedEnum
360+
{
361+
#[Pure]
362+
public static function from(string $value): static;
363+
364+
#[Pure]
365+
public static function tryFrom(string $value): ?static;
366+
}
367+
298368
/**
299369
* Created by typecasting to object.
300370
* @link https://php.net/manual/en/reserved.classes.php
@@ -315,10 +385,10 @@ class Exception implements Throwable
315385
protected $code;
316386

317387
/** The filename where the error happened */
318-
protected $file;
388+
protected string $file;
319389

320390
/** The line where the error happened */
321-
protected $line;
391+
protected int $line;
322392

323393
/**
324394
* Construct the exception. Note: The message is NOT binary safe.
@@ -407,7 +477,7 @@ public function __wakeup(): void {}
407477
* @link https://php.net/manual/en/exception.clone.php
408478
* @return void
409479
*/
410-
final private function __clone(): void {}
480+
private function __clone(): void {}
411481
}
412482

413483
/**
@@ -424,10 +494,10 @@ class Error implements Throwable
424494
protected $code;
425495

426496
/** The filename where the error happened */
427-
protected $file;
497+
protected string $file;
428498

429499
/** The line where the error happened */
430-
protected $line;
500+
protected int $line;
431501

432502
/**
433503
* Construct the error object.
@@ -514,7 +584,7 @@ public function __wakeup(): void {}
514584
* @return void
515585
* @link https://php.net/manual/en/error.clone.php
516586
*/
517-
final private function __clone(): void {}
587+
private function __clone(): void {}
518588
}
519589

520590
class ValueError extends Error {}
@@ -579,7 +649,7 @@ class UnhandledMatchError extends Error {}
579649
*/
580650
class ErrorException extends Exception
581651
{
582-
protected $severity;
652+
protected int $severity;
583653

584654
/**
585655
* Constructs the exception
@@ -842,3 +912,119 @@ public function valid(): bool {}
842912

843913
public function rewind(): void {}
844914
}
915+
916+
/**
917+
* @since 8.1
918+
*
919+
* @template TStart
920+
* @template TResume
921+
* @template TReturn
922+
* @template TSuspend
923+
*/
924+
final class Fiber
925+
{
926+
/**
927+
* @param callable $callback Function to invoke when starting the fiber.
928+
*/
929+
public function __construct(callable $callback) {}
930+
931+
/**
932+
* @return self|null Returns the currently executing fiber instance or NULL if in {main}.
933+
*/
934+
public static function getCurrent(): ?Fiber {}
935+
936+
/**
937+
* Suspend execution of the fiber. The fiber may be resumed with {@see Fiber::resume()} or {@see Fiber::throw()}.
938+
*
939+
* Cannot be called from {main}.
940+
*
941+
* @param TSuspend $value Value to return from {@see Fiber::resume()} or {@see Fiber::throw()}.
942+
*
943+
* @return TResume Value provided to {@see Fiber::resume()}.
944+
*
945+
* @throws FiberError Thrown if not within a fiber (i.e., if called from {main}).
946+
* @throws Throwable Exception provided to {@see Fiber::throw()}.
947+
*/
948+
public static function suspend(mixed $value = null): mixed {}
949+
950+
/**
951+
* Starts execution of the fiber. Returns when the fiber suspends or terminates.
952+
*
953+
* @param TStart ...$args Arguments passed to fiber function.
954+
*
955+
* @return TSuspend|null Value from the first suspension point or NULL if the fiber returns.
956+
*
957+
* @throws FiberError If the fiber has already been started.
958+
* @throws Throwable If the fiber callable throws an uncaught exception.
959+
*/
960+
public function start(mixed ...$args): mixed {}
961+
962+
/**
963+
* Resumes the fiber, returning the given value from {@see Fiber::suspend()}.
964+
* Returns when the fiber suspends or terminates.
965+
*
966+
* @param TResume $value
967+
*
968+
* @return TSuspend|null Value from the next suspension point or NULL if the fiber returns.
969+
*
970+
* @throws FiberError If the fiber has not started, is running, or has terminated.
971+
* @throws Throwable If the fiber callable throws an uncaught exception.
972+
*/
973+
public function resume(mixed $value = null): mixed {}
974+
975+
/**
976+
* Throws the given exception into the fiber from {@see Fiber::suspend()}.
977+
* Returns when the fiber suspends or terminates.
978+
*
979+
* @param Throwable $exception
980+
*
981+
* @return TSuspend|null Value from the next suspension point or NULL if the fiber returns.
982+
*
983+
* @throws FiberError If the fiber has not started, is running, or has terminated.
984+
* @throws Throwable If the fiber callable throws an uncaught exception.
985+
*/
986+
public function throw(Throwable $exception): mixed {}
987+
988+
/**
989+
* @return bool True if the fiber has been started.
990+
*/
991+
public function isStarted(): bool {}
992+
993+
/**
994+
* @return bool True if the fiber is suspended.
995+
*/
996+
public function isSuspended(): bool {}
997+
998+
/**
999+
* @return bool True if the fiber is currently running.
1000+
*/
1001+
public function isRunning(): bool {}
1002+
1003+
/**
1004+
* @return bool True if the fiber has completed execution (returned or threw).
1005+
*/
1006+
public function isTerminated(): bool {}
1007+
1008+
/**
1009+
* @return TReturn Return value of the fiber callback. NULL is returned if the fiber does not have a return statement.
1010+
*
1011+
* @throws FiberError If the fiber has not terminated or the fiber threw an exception.
1012+
*/
1013+
public function getReturn(): mixed {}
1014+
}
1015+
1016+
/**
1017+
* @since 8.1
1018+
*/
1019+
final class FiberError extends Error
1020+
{
1021+
public function __construct() {}
1022+
}
1023+
1024+
/**
1025+
* @since 8.1
1026+
*/
1027+
final class ReturnTypeWillChange
1028+
{
1029+
public function __construct() {}
1030+
}

PDO/PDO.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function pdo_drivers(): array {}
2323
*/
2424
class PDOException extends RuntimeException
2525
{
26-
public $errorInfo;
26+
public array|null $errorInfo;
2727
protected $code;
2828
}
2929

@@ -762,6 +762,11 @@ class PDO
762762
*/
763763
public const MYSQL_ATTR_SSL_VERIFY_SERVER_CERT = 1014;
764764

765+
/**
766+
* @since 8.1
767+
*/
768+
public const MYSQL_ATTR_LOCAL_INFILE_DIRECTORY = 1015;
769+
765770
#[Deprecated("Use PDO::ATTR_EMULATE_PREPARES instead")]
766771
public const PGSQL_ASSOC = 1;
767772

@@ -924,9 +929,9 @@ class PDO
924929
* Creates a PDO instance representing a connection to a database
925930
* @link https://php.net/manual/en/pdo.construct.php
926931
* @param string $dsn
927-
* @param string|null $username [optional]
928-
* @param string|null $password [optional]
929-
* @param array|null $options [optional]
932+
* @param string $username [optional]
933+
* @param string $password [optional]
934+
* @param array $options [optional]
930935
* @throws PDOException if the attempt to connect to the requested database fails.
931936
*/
932937
public function __construct(string $dsn, string|null $username = null, string|null $password = null, array|null $options = null) {}
@@ -1420,7 +1425,7 @@ class PDOStatement implements IteratorAggregate
14201425
/**
14211426
* @var string
14221427
*/
1423-
public $queryString;
1428+
public string $queryString;
14241429

14251430
/**
14261431
* (PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.1.0)<br/>
@@ -1845,5 +1850,5 @@ public function getIterator(): Iterator {}
18451850

18461851
final class PDORow
18471852
{
1848-
public $queryString;
1853+
public string $queryString;
18491854
}

0 commit comments

Comments
 (0)