Skip to content

Commit

Permalink
Provide PHP 8 return types to function signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Nov 18, 2020
1 parent 11946d7 commit 43ce0bb
Show file tree
Hide file tree
Showing 61 changed files with 2,848 additions and 1,681 deletions.
174 changes: 109 additions & 65 deletions Core/Core.php

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion PDO/PDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,8 @@ final class PDORow {
* no drivers are available, it returns an empty array.
*/
#[Pure]
function pdo_drivers () {}
function pdo_drivers (): array
{}

// End of PDO v.1.0.4dev
?>
40 changes: 25 additions & 15 deletions SPL/SPL_f.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* @return array
*/
#[Pure]
function spl_classes () {}
function spl_classes (): array
{}

/**
* Default implementation for __autoload()
Expand All @@ -25,7 +26,7 @@ function spl_classes () {}
* @return void
* @since 5.1.2
*/
function spl_autoload (string $class, string $file_extensions)
function spl_autoload (string $class, string $file_extensions): void
{}

/**
Expand All @@ -42,7 +43,8 @@ function spl_autoload (string $class, string $file_extensions)
* spl_autoload.
* @since 5.1.2
*/
function spl_autoload_extensions (string $file_extensions) {}
function spl_autoload_extensions (string $file_extensions): string
{}

/**
* Register given function as __autoload() implementation
Expand All @@ -60,7 +62,8 @@ function spl_autoload_extensions (string $file_extensions) {}
* @throws TypeError Since 8.0.
* @since 5.1.2
*/
function spl_autoload_register (callable $callback, bool $throw = true, bool $prepend = false) {}
function spl_autoload_register (callable $callback, bool $throw = true, bool $prepend = false): bool
{}

/**
* Unregister given function as __autoload() implementation
Expand All @@ -71,7 +74,8 @@ function spl_autoload_register (callable $callback, bool $throw = true, bool $pr
* @return bool true on success or false on failure.
* @since 5.1.2
*/
function spl_autoload_unregister (callable $callback) {}
function spl_autoload_unregister (callable $callback): bool
{}

/**
* Return all registered __autoload() functions
Expand All @@ -81,7 +85,8 @@ function spl_autoload_unregister (callable $callback) {}
* If no function is registered the return value will be an empty array.
* @since 5.1.2
*/
function spl_autoload_functions () {}
function spl_autoload_functions (): array
{}

/**
* Try all registered __autoload() functions to load the requested class
Expand All @@ -92,7 +97,7 @@ function spl_autoload_functions () {}
* @return void
* @since 5.1.2
*/
function spl_autoload_call (string $class) {}
function spl_autoload_call (string $class): void {}

/**
* Return the parent classes of the given class
Expand All @@ -108,7 +113,7 @@ function spl_autoload_call (string $class) {}
* @return string[]|false An array on success, or false on error.
*/
#[Pure]
function class_parents ($object_or_class, bool $autoload)
function class_parents ($object_or_class, bool $autoload): array|false
{}

/**
Expand All @@ -125,7 +130,7 @@ function class_parents ($object_or_class, bool $autoload)
* @return string[]|false An array on success, or false on error.
*/
#[Pure]
function class_implements ($object_or_class, bool $autoload)
function class_implements ($object_or_class, bool $autoload): array|false
{}

/**
Expand All @@ -136,7 +141,8 @@ function class_implements ($object_or_class, bool $autoload)
* the same object.
*/
#[Pure]
function spl_object_hash (object $object) {}
function spl_object_hash (object $object): string
{}

/**
* Copy the iterator into an array
Expand All @@ -150,7 +156,8 @@ function spl_object_hash (object $object) {}
* @return array An array containing the elements of the iterator.
*/
#[Pure]
function iterator_to_array (Traversable $iterator, bool $preserve_keys = true) {}
function iterator_to_array (Traversable $iterator, bool $preserve_keys = true): array
{}

/**
* Count the elements in an iterator
Expand All @@ -161,7 +168,8 @@ function iterator_to_array (Traversable $iterator, bool $preserve_keys = true) {
* @return int The number of elements in iterator.
*/
#[Pure]
function iterator_count (Traversable $iterator) {}
function iterator_count (Traversable $iterator): int
{}

/**
* Call a function for every element in an iterator
Expand All @@ -179,7 +187,7 @@ function iterator_count (Traversable $iterator) {}
* </p>
* @return int the iteration count.
*/
function iterator_apply (Traversable $iterator, callable $callback, array $args)
function iterator_apply (Traversable $iterator, callable $callback, array $args): int
{}

// End of SPL v.0.2
Expand All @@ -194,14 +202,16 @@ function iterator_apply (Traversable $iterator, callable $callback, array $args)
* @see get_declared_traits()
* @since 5.4
*/
function class_uses($object_or_class, bool $autoload = true) {}
function class_uses($object_or_class, bool $autoload = true): array|false
{}

/**
* return the integer object handle for given object
* @param object $object
* @return int
* @since 7.2
*/
function spl_object_id(object $object) {}
function spl_object_id(object $object): int
{}

?>
10 changes: 5 additions & 5 deletions SimpleXML/SimpleXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ public function count () {}
* <b>TRUE</b> if <i>ns</i> is a prefix, <b>FALSE</b> if it's a URI;
* defaults to <b>FALSE</b>.
* </p>
* @return SimpleXMLElement an object of class SimpleXMLElement with
* @return SimpleXMLElement|false an object of class SimpleXMLElement with
* properties containing the data held within the XML document, or <b>FALSE</b> on failure.
*/
function simplexml_load_file (string $filename, string $class_name = "SimpleXMLElement", int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false) {}
function simplexml_load_file (string $filename, string $class_name = "SimpleXMLElement", int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false): SimpleXMLElement|false {}

/**
* Interprets a string of XML into an object
Expand All @@ -443,10 +443,10 @@ function simplexml_load_file (string $filename, string $class_name = "SimpleXMLE
* <b>TRUE</b> if <i>ns</i> is a prefix, <b>FALSE</b> if it's a URI;
* defaults to <b>FALSE</b>.
* </p>
* @return SimpleXMLElement an object of class SimpleXMLElement with
* @return SimpleXMLElement|false an object of class SimpleXMLElement with
* properties containing the data held within the xml document, or <b>FALSE</b> on failure.
*/
function simplexml_load_string (string $data, string $class_name = "SimpleXMLElement", int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false) {}
function simplexml_load_string (string $data, string $class_name = "SimpleXMLElement", int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false): SimpleXMLElement|false {}

/**
* Get a SimpleXMLElement object from a DOM node.
Expand All @@ -462,6 +462,6 @@ function simplexml_load_string (string $data, string $class_name = "SimpleXMLEle
* </p>
* @return SimpleXMLElement a SimpleXMLElement or <b>FALSE</b> on failure.
*/
function simplexml_import_dom (DOMNode $node, string $class_name = "SimpleXMLElement") {}
function simplexml_import_dom (DOMNode $node, string $class_name = "SimpleXMLElement"): SimpleXMLElement {}

// End of SimpleXML v.0.1
22 changes: 14 additions & 8 deletions Zend OPcache/OPcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* cache is disabled.
* @since 5.5
*/
function opcache_compile_file(string $filename) { }
function opcache_compile_file(string $filename): bool
{ }

/**
* (PHP 5 &gt;= 5.5.0, PECL ZendOpcache &gt;= 7.0.0 )<br/>
Expand All @@ -25,7 +26,8 @@ function opcache_compile_file(string $filename) { }
* cache is disabled.
* @since 5.5
*/
function opcache_invalidate(string $filename, bool $force = false) { }
function opcache_invalidate(string $filename, bool $force = false): bool
{ }

/**
* (PHP 5 &gt;= 5.5.0, PECL ZendOpcache &gt;= 7.0.0 )<br/>
Expand All @@ -34,26 +36,29 @@ function opcache_invalidate(string $filename, bool $force = false) { }
* @return bool Returns <b>TRUE</b> if the opcode cache was reset, or <b>FALSE</b> if the opcode cache is disabled.
* @since 5.5
*/
function opcache_reset() { }
function opcache_reset(): bool
{ }

/**
* (PHP 5 &gt;= 5.5.5, PECL ZendOpcache &gt;= 7.0.2 )<br/>
* Get status information about the cache
* @link https://php.net/manual/en/function.opcache-get-status.php
* @param bool $include_scripts <p>Include script specific state information</p>
* @return array <p>Returns an array of information, optionally containing script specific state information</p>
* @return array|false <p>Returns an array of information, optionally containing script specific state information</p>
* @since 5.5
*/
function opcache_get_status (bool $include_scripts = true) {}
function opcache_get_status (bool $include_scripts = true): array|false
{}

/**
* (PHP 5 &gt;= 5.5.5, PECL ZendOpcache &gt;= 7.0.2 )<br/>
* Get configuration information about the cache
* @link https://php.net/manual/en/function.opcache-get-configuration.php
* @return array <p>Returns an array of information, including ini, blacklist and version</p>
* @return array|false <p>Returns an array of information, including ini, blacklist and version</p>
* @since 5.5
*/
function opcache_get_configuration() {}
function opcache_get_configuration(): array|false
{}

/**
* (PHP 5 &gt;= 5.6, PECL ZendOpcache &gt;= 7.0.4 )<br/>
Expand All @@ -64,4 +69,5 @@ function opcache_get_configuration() {}
* @return bool Returns TRUE if file is cached in OPCache, FALSE otherwise.
* @since 5.6
*/
function opcache_is_script_cached(string $filename) {}
function opcache_is_script_cached(string $filename): bool
{}
30 changes: 20 additions & 10 deletions bcmath/bcmath.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* @return string The sum of the two operands, as a string.
*/
#[Pure]
function bcadd (string $num1, string $num2, int $scale = 0) {}
function bcadd (string $num1, string $num2, int $scale = 0): string
{}

/**
* Subtract one arbitrary precision number from another
Expand All @@ -40,7 +41,8 @@ function bcadd (string $num1, string $num2, int $scale = 0) {}
* @return string The result of the subtraction, as a string.
*/
#[Pure]
function bcsub (string $num1, string $num2, int $scale = 0) {}
function bcsub (string $num1, string $num2, int $scale = 0): string
{}

/**
* Multiply two arbitrary precision numbers
Expand All @@ -60,7 +62,8 @@ function bcsub (string $num1, string $num2, int $scale = 0) {}
* @return string the result as a string.
*/
#[Pure]
function bcmul (string $num1, string $num2, int $scale = 0) {}
function bcmul (string $num1, string $num2, int $scale = 0): string
{}

/**
* Divide two arbitrary precision numbers
Expand All @@ -81,7 +84,8 @@ function bcmul (string $num1, string $num2, int $scale = 0) {}
* <i>divisor</i> is 0.
*/
#[Pure]
function bcdiv (string $num1, string $num2, int $scale = 0) {}
function bcdiv (string $num1, string $num2, int $scale = 0): ?string
{}

/**
* Get modulus of an arbitrary precision number
Expand All @@ -102,7 +106,8 @@ function bcdiv (string $num1, string $num2, int $scale = 0) {}
* <i>divisor</i> is 0.
*/
#[Pure]
function bcmod (string $num1, string $num2, int $scale = 0) {}
function bcmod (string $num1, string $num2, int $scale = 0): ?string
{}

/**
* Raise an arbitrary precision number to another
Expand All @@ -124,7 +129,8 @@ function bcmod (string $num1, string $num2, int $scale = 0) {}
* @return string the result as a string.
*/
#[Pure]
function bcpow (string $num, string $exponent, int $scale = 0) {}
function bcpow (string $num, string $exponent, int $scale = 0): string
{}

/**
* Get the square root of an arbitrary precision number
Expand All @@ -137,7 +143,8 @@ function bcpow (string $num, string $exponent, int $scale = 0) {}
* <i>operand</i> is negative.
*/
#[Pure]
function bcsqrt (string $num, int $scale) {}
function bcsqrt (string $num, int $scale): ?string
{}

/**
* Set default scale parameter for all bc math functions
Expand All @@ -147,7 +154,8 @@ function bcsqrt (string $num, int $scale) {}
* </p>
* @return int|true <b>INT</b> since 7.3.0 and <b>TRUE</b> before.
*/
function bcscale (int $scale) {}
function bcscale (int $scale): int
{}

/**
* Compare two arbitrary precision numbers
Expand All @@ -168,7 +176,8 @@ function bcscale (int $scale) {}
* <i>right_operand</i>, -1 otherwise.
*/
#[Pure]
function bccomp (string $num1, string $num2, int $scale = 0) {}
function bccomp (string $num1, string $num2, int $scale = 0): int
{}

/**
* Raise an arbitrary precision number to another, reduced by a specified modulus
Expand All @@ -193,4 +202,5 @@ function bccomp (string $num1, string $num2, int $scale = 0) {}
* is 0 or <i>exponent</i> is negative.
*/
#[Pure]
function bcpowmod (string $num, string $exponent, string $modulus, int $scale = 0) {}
function bcpowmod (string $num, string $exponent, string $modulus, int $scale = 0): ?string
{}
Loading

0 comments on commit 43ce0bb

Please sign in to comment.