fix typehints in extensions according to reflections

This commit is contained in:
Ivan Fedorov 2021-07-07 13:27:37 +03:00 committed by Ivan Fedorov
parent ecd2627f47
commit b31c027ab4
9 changed files with 57 additions and 53 deletions

View File

@ -227,7 +227,7 @@ class SimpleXMLElement implements Traversable, ArrayAccess, Countable, Iterator,
*/
public function addAttribute(
#[LanguageLevelTypeAware(['8.1' => 'string'], default: '')] $qualifiedName,
#[LanguageLevelTypeAware(['8.1' => 'string|null'], default: '')] $value = null,
#[LanguageLevelTypeAware(['8.1' => 'string'], default: '')] $value = null,
#[LanguageLevelTypeAware(['8.1' => 'string|null'], default: '')] $namespace = null
) {}

View File

@ -262,7 +262,7 @@ function imagecreatefromstring(string $data): GdImage|false {}
* the specified one or <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorclosest(GdImage $image, int $red, int $green, int $blue): int|false {}
function imagecolorclosest(GdImage $image, int $red, int $green, int $blue): int {}
/**
* Get the index of the color which has the hue, white and blackness
@ -275,7 +275,7 @@ function imagecolorclosest(GdImage $image, int $red, int $green, int $blue): int
* the hue, white and blackness nearest the given color or <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorclosesthwb(GdImage $image, int $red, int $green, int $blue): int|false {}
function imagecolorclosesthwb(GdImage $image, int $red, int $green, int $blue): int {}
/**
* De-allocate a color for an image
@ -298,7 +298,7 @@ function imagecolordeallocate(GdImage $image, int $color): bool {}
* @return int|false a color index or <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorresolve(GdImage $image, int $red, int $green, int $blue): int|false {}
function imagecolorresolve(GdImage $image, int $red, int $green, int $blue): int {}
/**
* Get the index of the specified color
@ -311,7 +311,7 @@ function imagecolorresolve(GdImage $image, int $red, int $green, int $blue): int
* color does not exist, or <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorexact(GdImage $image, int $red, int $green, int $blue): int|false {}
function imagecolorexact(GdImage $image, int $red, int $green, int $blue): int {}
/**
* Set the color for the specified palette index
@ -701,7 +701,7 @@ function imagecolorallocatealpha(GdImage $image, int $red, int $green, int $blue
* @return int|false a color index or <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorresolvealpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
function imagecolorresolvealpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int {}
/**
* Get the index of the closest color to the specified color + alpha
@ -725,7 +725,7 @@ function imagecolorresolvealpha(GdImage $image, int $red, int $green, int $blue,
* <b>FALSE</b> on failure
*/
#[Pure]
function imagecolorclosestalpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
function imagecolorclosestalpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int {}
/**
* Get the index of the specified color + alpha

View File

@ -49,7 +49,7 @@ use JetBrains\PhpStorm\Internal\PhpStormStubsElementAvailable;
* @return resource|false an IMAP stream on success or <b>FALSE</b> on error.
*/
#[LanguageLevelTypeAware(['8.1' => 'IMAP\Connection|false'], default: 'resource|false')]
function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, ?array $options = null) {}
function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = null) {}
/**
* Reopen IMAP stream to new mailbox

View File

@ -137,7 +137,7 @@ namespace MongoDB\Driver {
* @throws WriteConcernException on Write Concern failure
* @since 1.4.0
*/
final public function executeReadWriteCommand($db, Command $command, array $options = []) {}
final public function executeReadWriteCommand($db, Command $command, $options = []) {}
/**
* @link https://php.net/manual/en/mongodb-driver-manager.executewritecommand.php
@ -268,7 +268,7 @@ namespace MongoDB\Driver {
* @return Cursor
* @since 1.0.0
*/
final public function executeCommand($db, Command $command, ReadPreference $options = null) {}
final public function executeCommand($db, Command $command, $options = null) {}
/**
* Execute a database command that reads on this server
@ -542,7 +542,7 @@ namespace MongoDB\Driver {
* @param array $options
* @throws InvalidArgumentException if mode is invalid or if tagSets is provided for a primary read preference.
*/
final public function __construct(string|int $mode, ?array $tagSets = null, ?array $options = []) {}
final public function __construct($mode, ?array $tagSets = null, ?array $options = []) {}
public static function __set_state(array $properties) {}
@ -1182,7 +1182,7 @@ namespace MongoDB\Driver {
* @throws \MongoDB\Driver\Exception\InvalidArgumentException On argument parsing errors
* @since 1.4.0
*/
final public function advanceOperationTime(\MongoDB\BSON\TimestampInterface $timestamp) {}
final public function advanceOperationTime($timestamp) {}
/**
* @link https://secure.php.net/manual/en/mongodb-driver-session.committransaction.php

View File

@ -1620,7 +1620,7 @@ function mysqli_commit(mysqli $mysql, int $flags = -1, ?string $name): bool {}
* @param string|null $socket Specifies the socket or named pipe that should be used.
* @return mysqli|false|null object which represents the connection to a MySQL Server or false if an error occurred.
*/
function mysqli_connect(?string $hostname = null, ?string $username = null, ?string $password = null, ?string $database = null, ?int $port = null, ?string $socket = null): mysqli|false|null {}
function mysqli_connect(?string $hostname = null, ?string $username = null, ?string $password = null, ?string $database = null, ?int $port = null, ?string $socket = null): mysqli|false {}
/**
* Returns the error code from last connect call
@ -2696,7 +2696,7 @@ function mysqli_send_long_data(mysqli_stmt $statement, int $param_num, string $d
* @param mixed $value
* @return bool
*/
function mysqli_set_opt(mysqli $mysql, int $option, mixed $value): bool {}
function mysqli_set_opt(mysqli $mysql, int $option, $value): bool {}
/**
* <p>

View File

@ -1100,7 +1100,8 @@ function setlocale(
#[PhpStormStubsElementAvailable(from: '5.3', to: '7.4')]
#[Required(from: '5.3', to: '7.4')]
...$locale,
#[PhpStormStubsElementAvailable(from: '8.0')] ...$rest): string|false {}
#[PhpStormStubsElementAvailable(from: '8.0')] ...$rest
): string|false {}
/**
* Get numeric formatting information

View File

@ -22,7 +22,7 @@ class SyncMutex
* @throws Exception if the mutex cannot be created or opened
* @link https://php.net/manual/en/syncmutex.construct.php
*/
public function __construct(string $name) {}
public function __construct($name) {}
/**
* Waits for an exclusive lock
@ -34,7 +34,7 @@ class SyncMutex
* @see SyncMutex::unlock()
* @link https://php.net/manual/en/syncmutex.lock.php
*/
public function lock(int $wait = -1) {}
public function lock($wait = -1) {}
/**
* Unlocks the mutex
@ -46,7 +46,7 @@ class SyncMutex
* @see SyncMutex::lock()
* @link https://php.net/manual/en/syncmutex.unlock.php
*/
public function unlock(bool $all = false) {}
public function unlock($all = false) {}
}
/**
@ -70,7 +70,7 @@ class SyncSemaphore
* @throws Exception if the semaphore cannot be created or opened
* @link https://php.net/manual/en/syncsemaphore.construct.php
*/
public function __construct(string $name, int $initialval = 1, bool $autounlock = true) {}
public function __construct($name, $initialval = 1, $autounlock = true) {}
/**
* Decreases the count of the semaphore or waits
@ -82,7 +82,7 @@ class SyncSemaphore
* @see SyncSemaphore::unlock()
* @link https://php.net/manual/en/syncsemaphore.lock.php
*/
public function lock(int $wait = -1) {}
public function lock($wait = -1) {}
/**
* Increases the count of the semaphore
@ -94,7 +94,7 @@ class SyncSemaphore
* @see SyncSemaphore::lock()
* @link https://php.net/manual/en/syncsemaphore.unlock.php
*/
public function unlock(int &$prevcount = 0) {}
public function unlock(&$prevcount = 0) {}
}
/**
@ -151,7 +151,7 @@ class SyncEvent
* @see SyncEvent::fire()
* @link https://php.net/manual/en/syncevent.wait.php
*/
public function wait(int $wait = -1) {}
public function wait($wait = -1) {}
}
/**
@ -174,7 +174,7 @@ class SyncReaderWriter
* @throws Exception if the reader-writer cannot be created or opened.
* @link https://php.net/manual/en/syncreaderwriter.construct.php
*/
public function __construct(string $name, bool $autounlock = true) {}
public function __construct($name, $autounlock = true) {}
/**
* Waits for a read lock
@ -186,7 +186,7 @@ class SyncReaderWriter
* @see SyncReaderWriter::readunlock()
* @link https://php.net/manual/en/syncreaderwriter.readlock.php
*/
public function readlock(int $wait = -1) {}
public function readlock($wait = -1) {}
/**
* Releases a read lock
@ -209,7 +209,7 @@ class SyncReaderWriter
* @see SyncReaderWriter::writeunlock()
* @link https://php.net/manual/en/syncreaderwriter.writelock.php
*/
public function writelock(int $wait = -1) {}
public function writelock($wait = -1) {}
/**
* Releases a write lock
@ -245,7 +245,7 @@ class SyncSharedMemory
* @throws Exception if the shared memory object cannot be created or opened.
* @link https://php.net/manual/en/syncsharedmemory.construct.php
*/
public function __construct(string $name, int $size) {}
public function __construct($name, $size) {}
/**
* Check to see if the object is the first instance system-wide of named shared memory
@ -268,7 +268,7 @@ class SyncSharedMemory
* @see SyncSharedMemory::write()
* @link https://php.net/manual/en/syncsharedmemory.read.php
*/
public function read(int $start = 0, int $length) {}
public function read($start = 0, $length) {}
/**
* Returns the size of the named shared memory
@ -290,5 +290,5 @@ class SyncSharedMemory
* @return int containing the number of bytes written to shared memory.
* @link https://php.net/manual/en/syncsharedmemory.write.php
*/
public function write(string $string, int $start = 0) {}
public function write($string, $start = 0) {}
}

View File

@ -165,7 +165,10 @@ abstract class BaseStubsTest extends TestCase
{
return !empty(array_filter(
$typesFromAttribute,
fn (array $types) => count(array_intersect($reflectionTypes, $types)) == count($reflectionTypes)
fn (array $types) => empty(array_merge(
array_diff($reflectionTypes, $types),
array_diff($types, $reflectionTypes)
))
));
}

View File

@ -164,7 +164,7 @@ final class Yaf_Application
* @param Yaf_Bootstrap_Abstract $bootstrap A Yaf_Bootstrap_Abstract instance
* @return Yaf_Application
*/
public function bootstrap(Yaf_Bootstrap_Abstract $bootstrap = null) {}
public function bootstrap($bootstrap = null) {}
/**
* @link https://secure.php.net/manual/en/yaf-application.getconfig.php
@ -370,7 +370,7 @@ final class Yaf_Dispatcher
* @param Yaf_View_Interface $view A Yaf_View_Interface instance
* @return Yaf_Dispatcher
*/
public function setView(Yaf_View_Interface $view) {}
public function setView($view) {}
/**
* @link https://secure.php.net/manual/en/yaf-dispatcher.setrequest.php
@ -378,7 +378,7 @@ final class Yaf_Dispatcher
* @param Yaf_Request_Abstract $request
* @return Yaf_Dispatcher
*/
public function setRequest(Yaf_Request_Abstract $request) {}
public function setRequest($request) {}
/**
* Retrieve the Yaf_Application instance. same as Yaf_Application::app().
@ -413,7 +413,7 @@ final class Yaf_Dispatcher
*
* @return Yaf_Dispatcher
*/
public function setErrorHandler(callable $callback, $error_types = YAF_ERR_TYPE_ERROR) {}
public function setErrorHandler($callback, $error_types = YAF_ERR_TYPE_ERROR) {}
/**
* Change default module name
@ -505,7 +505,7 @@ final class Yaf_Dispatcher
*
* @return Yaf_Response_Abstract
*/
public function dispatch(Yaf_Request_Abstract $request) {}
public function dispatch($request) {}
/**
* <p>Switch on/off exception throwing while unexpected error occurring. When this is on, Yaf will throwing exceptions instead of triggering catchable errors.</p><br/>
@ -537,7 +537,7 @@ final class Yaf_Dispatcher
* @param Yaf_Plugin_Abstract $plugin
* @return Yaf_Dispatcher
*/
public function registerPlugin(Yaf_Plugin_Abstract $plugin) {}
public function registerPlugin($plugin) {}
public function setResponse($response) {}
}
@ -964,7 +964,7 @@ class Yaf_Router
*
* @return Yaf_Router|false return FALSE on failure
*/
public function addRoute($name, Yaf_Route_Interface $route) {}
public function addRoute($name, $route) {}
/**
* <p>Add routes defined by configs into Yaf_Router's route stack</p>
@ -975,7 +975,7 @@ class Yaf_Router
*
* @return Yaf_Router|false return FALSE on failure
*/
public function addConfig(Yaf_Config_Abstract $config) {}
public function addConfig($config) {}
/**
* @link https://secure.php.net/manual/en/yaf-router.route.php
@ -984,7 +984,7 @@ class Yaf_Router
*
* @return Yaf_Router|false return FALSE on failure
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p>Retrieve a route by name, see also Yaf_Router::getCurrentRoute()</p>
@ -1222,7 +1222,7 @@ abstract class Yaf_Controller_Abstract
* @see Yaf_Controller_Abstract::init()
* @link https://secure.php.net/manual/en/yaf-controller-abstract.construct.php
*/
public function __construct(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response, Yaf_View_Interface $view, ?array $args = null) {}
public function __construct($request, $response, $view, ?array $args = null) {}
/**
* @link https://secure.php.net/manual/en/yaf-controller-abstract.clone.php
@ -1898,7 +1898,7 @@ interface Yaf_View_Interface
* @param array $tpl_vars
* @return bool
*/
public function display($tpl, array $tpl_vars = null);
public function display($tpl, $tpl_vars = null);
/**
* @link https://secure.php.net/manual/en/yaf-view-interface.getscriptpath.php
@ -1916,7 +1916,7 @@ interface Yaf_View_Interface
* @param array $tpl_vars
* @return string
*/
public function render($tpl, array $tpl_vars = null);
public function render($tpl, $tpl_vars = null);
/**
* Set the templates base directory, this is usually called by Yaf_Dispatcher
@ -1946,7 +1946,7 @@ interface Yaf_Route_Interface
* @param Yaf_Request_Abstract $request
* @return bool
*/
public function route(Yaf_Request_Abstract $request);
public function route($request);
/**
* <p><b>Yaf_Route_Interface::assemble()</b> - assemble a request</p><br/>
@ -2005,7 +2005,7 @@ class Yaf_Response_Http extends Yaf_Response_Abstract
*
* @return bool
*/
public function setAllHeaders(array $headers) {}
public function setAllHeaders($headers) {}
/**
* @link https://secure.php.net/manual/en/yaf-response-abstract.getheader.php
@ -2413,7 +2413,7 @@ class Yaf_Config_Simple extends Yaf_Config_Abstract implements Iterator, ArrayAc
* @param array $config
* @param bool $readonly
*/
public function __construct(array $config, $readonly = null) {}
public function __construct($config, $readonly = null) {}
/**
* @link https://secure.php.net/manual/en/yaf-config-simple.isset.php
@ -2532,7 +2532,7 @@ class Yaf_View_Simple implements Yaf_View_Interface
*
* @return string|void
*/
public function render($tpl, array $tpl_vars = null) {}
public function render($tpl, $tpl_vars = null) {}
/**
* <p>Render a template and display the result instantly.</p>
@ -2546,7 +2546,7 @@ class Yaf_View_Simple implements Yaf_View_Interface
*
* @return bool
*/
public function display($tpl, array $tpl_vars = null) {}
public function display($tpl, $tpl_vars = null) {}
/**
* <p>unlike Yaf_View_Simple::assign(), this method assign a ref value to engine.</p>
@ -2617,7 +2617,7 @@ class Yaf_View_Simple implements Yaf_View_Interface
* @param array $vars
* @return void|false return FALSE on failure
*/
public function eval(string $tpl_str, array $vars = null) {}
public function eval($tpl_str, $vars = null) {}
public function get($name = '') {}
}
@ -2650,7 +2650,7 @@ class Yaf_Route_Static implements Yaf_Route_Interface
*
* @return bool always TRUE
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Static::assemble()</b> - Assemble a url</p>
@ -2710,7 +2710,7 @@ final class Yaf_Route_Simple implements Yaf_Route_Interface
*
* @return bool always TRUE
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Simple::assemble()</b> - Assemble a url</p>
@ -2752,7 +2752,7 @@ final class Yaf_Route_Supervar implements Yaf_Route_Interface
*
* @return bool If there is a key(which was defined in Yaf_Route_Supervar::__construct()) in $_GET, return TRUE. otherwise return FALSE.
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Supervar::assemble()</b> - Assemble a url</p>
@ -2807,7 +2807,7 @@ final class Yaf_Route_Rewrite extends Yaf_Router implements Yaf_Route_Interface
*
* @return bool
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Rewrite::assemble()</b> - Assemble a url</p>
@ -2875,7 +2875,7 @@ final class Yaf_Route_Regex extends Yaf_Router implements Yaf_Route_Interface
*
* @return bool If the pattern given by the first parameter of Yaf_Route_Regex::_construct() matches the request uri, return TRUE, otherwise return FALSE.
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Regex::assemble()</b> - Assemble a url</p>
@ -2924,7 +2924,7 @@ final class Yaf_Route_Map implements Yaf_Route_Interface
*
* @return bool
*/
public function route(Yaf_Request_Abstract $request) {}
public function route($request) {}
/**
* <p><b>Yaf_Route_Map::assemble()</b> - Assemble a url</p>