Skip to content

Commit

Permalink
PHP 8 stubs
Browse files Browse the repository at this point in the history
Continue
  • Loading branch information
MaXal committed Jul 16, 2020
1 parent b91de0e commit f23297f
Show file tree
Hide file tree
Showing 22 changed files with 213 additions and 48 deletions.
30 changes: 18 additions & 12 deletions Core/Core_c.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ public function __toString();
// TODO Uncomment after PHP 8.0 release:
// @@Attribute(Attribute::TARGET_CLASS)
final class Attribute {
public int $flags;
/**
* Marks that attribute declaration is allowed only in classes.
*/
Expand Down Expand Up @@ -812,31 +813,23 @@ class PhpToken implements Stringable {
/**
* One of the T_* constants, or an integer < 256 representing a
* single-char token.
*
* @var int
*/
public $id;
public int $id;

/**
* The textual content of the token.
*
* @var string
*/
public $text;
public string $text;

/**
* The starting line number (1-based) of the token.
*
* @var int
*/
public $line;
public int $line;

/**
* The starting position (0-based) in the tokenized string.
*
* @var int
*/
public $pos;
public int $pos;

/**
* Same as {@see token_get_all()}, but returning array of {@see PhpToken}
Expand Down Expand Up @@ -896,3 +889,16 @@ public function __toString()
{
}
}

final class InternalIterator implements Iterator{
private function __construct(){}
public function current(){}

public function next(){}

public function key(){}

public function valid(){}

public function rewind(){}
}
7 changes: 6 additions & 1 deletion PDO/PDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@ public function sqliteCreateFunction($function_name, $callback, $num_args = -1,
* associated result set.
* @link https://php.net/manual/en/class.pdostatement.php
*/
class PDOStatement implements Traversable {
class PDOStatement implements IteratorAggregate
{
/**
* @var string
*/
Expand Down Expand Up @@ -1584,6 +1585,10 @@ final public function __wakeup () {}

final public function __sleep () {}

/**
* @since 8.0
*/
public function getIterator(){}
}

final class PDORow {
Expand Down
32 changes: 32 additions & 0 deletions PhpStormStubsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ final class PhpStormStubsMap
'Crypto\\PBKDF2Exception' => 'crypto/crypto.php',
'Crypto\\Rand' => 'crypto/crypto.php',
'Crypto\\RandException' => 'crypto/crypto.php',
'CurlHandle' => 'curl/curl.php',
'CurlMultiHandle' => 'curl/curl.php',
'CurlShareHandle' => 'curl/curl.php',
'DOMAttr' => 'dom/dom_c.php',
'DOMCdataSection' => 'dom/dom_c.php',
'DOMCharacterData' => 'dom/dom_c.php',
Expand Down Expand Up @@ -258,6 +261,7 @@ final class PhpStormStubsMap
'DateTimeInterface' => 'date/date_c.php',
'DateTimeZone' => 'date/date_c.php',
'Decimal\\Decimal' => 'decimal/decimal.php',
'DeflateContext' => 'zlib/zlib.php',
'Directory' => 'standard/standard_0.php',
'DirectoryIterator' => 'SPL/SPL_c1.php',
'DivisionByZeroError' => 'Core/Core_c.php',
Expand Down Expand Up @@ -370,6 +374,8 @@ final class PhpStormStubsMap
'ImagickPixelIterator' => 'imagick/imagick.php',
'ImagickPixelIteratorException' => 'imagick/imagick.php',
'InfiniteIterator' => 'SPL/SPL.php',
'InflateContext' => 'zlib/zlib.php',
'InternalIterator' => 'Core/Core_c.php',
'IntlBreakIterator' => 'intl/intl.php',
'IntlCalendar' => 'intl/intl.php',
'IntlChar' => 'intl/IntlChar.php',
Expand Down Expand Up @@ -631,6 +637,7 @@ final class PhpStormStubsMap
'SessionHandlerInterface' => 'session/SessionHandler.php',
'SessionIdInterface' => 'session/SessionHandler.php',
'SessionUpdateTimestampHandlerInterface' => 'session/SessionHandler.php',
'Shmop' => 'shmop/shmop.php',
'SimpleXMLElement' => 'SimpleXML/SimpleXML.php',
'SimpleXMLIterator' => 'SimpleXML/SimpleXML.php',
'SoapClient' => 'soap/soap.php',
Expand Down Expand Up @@ -675,6 +682,9 @@ final class PhpStormStubsMap
'SyncReaderWriter' => 'sync/sync.php',
'SyncSemaphore' => 'sync/sync.php',
'SyncSharedMemory' => 'sync/sync.php',
'SysvMessageQueue' => 'sysvmsg/sysvmsg.php',
'SysvSemaphore' => 'sysvsem/sysvsem.php',
'SysvSharedMemory' => 'sysvshm/sysvshm.php',
'Thread' => 'pthreads/pthreads.php',
'Threaded' => 'pthreads/pthreads.php',
'Throwable' => 'Core/Core_c.php',
Expand All @@ -690,6 +700,7 @@ final class PhpStormStubsMap
'V8JsScriptException' => 'v8js/v8js.php',
'V8JsTimeLimitException' => 'v8js/v8js.php',
'VARIANT' => 'com_dotnet/com_dotnet.php',
'ValueError' => 'mbstring/mbstring.php',
'Volatile' => 'pthreads/pthreads.php',
'WeakMap' => 'Core/Core_c.php',
'WeakReference' => 'Core/Core_c.php',
Expand All @@ -698,6 +709,7 @@ final class PhpStormStubsMap
'XMLWriter' => 'xmlwriter/xmlwriter.php',
'XSLTProcessor' => 'xsl/xsl.php',
'XXTEA' => 'xxtea/xxtea.php',
'XmlParser' => 'xml/xml.php',
'Yaf\\Action_Abstract' => 'yaf/yaf_namespace.php',
'Yaf\\Application' => 'yaf/yaf_namespace.php',
'Yaf\\Bootstrap_Abstract' => 'yaf/yaf_namespace.php',
Expand Down Expand Up @@ -1954,6 +1966,7 @@ final class PhpStormStubsMap
'fbird_trans' => 'interbase/interbase.php',
'fbird_wait_event' => 'interbase/interbase.php',
'fclose' => 'standard/standard_5.php',
'fdiv' => 'standard/standard_3.php',
'feof' => 'standard/standard_5.php',
'fflush' => 'standard/standard_5.php',
'fgetc' => 'standard/standard_5.php',
Expand Down Expand Up @@ -2200,6 +2213,7 @@ final class PhpStormStubsMap
'getallheaders' => 'apache/apache.php',
'getcwd' => 'standard/standard_7.php',
'getdate' => 'date/date.php',
'getdir' => 'standard/standard_7.php',
'getenv' => 'standard/standard_3.php',
'gethostbyaddr' => 'standard/standard_4.php',
'gethostbyname' => 'standard/standard_4.php',
Expand Down Expand Up @@ -2830,6 +2844,7 @@ final class PhpStormStubsMap
'ldap_control_paged_result' => 'ldap/ldap.php',
'ldap_control_paged_result_response' => 'ldap/ldap.php',
'ldap_count_entries' => 'ldap/ldap.php',
'ldap_count_references' => 'ldap/ldap.php',
'ldap_delete' => 'ldap/ldap.php',
'ldap_delete_ext' => 'ldap/ldap.php',
'ldap_dn2ufn' => 'ldap/ldap.php',
Expand Down Expand Up @@ -3736,6 +3751,11 @@ final class PhpStormStubsMap
'opendir' => 'standard/standard_7.php',
'openlog' => 'standard/standard_7.php',
'openssl_cipher_iv_length' => 'openssl/openssl.php',
'openssl_cms_decrypt' => 'openssl/openssl.php',
'openssl_cms_encrypt' => 'openssl/openssl.php',
'openssl_cms_read' => 'openssl/openssl.php',
'openssl_cms_sign' => 'openssl/openssl.php',
'openssl_cms_verify' => 'openssl/openssl.php',
'openssl_csr_export' => 'openssl/openssl.php',
'openssl_csr_export_to_file' => 'openssl/openssl.php',
'openssl_csr_get_public_key' => 'openssl/openssl.php',
Expand Down Expand Up @@ -6519,6 +6539,7 @@ final class PhpStormStubsMap
'FILTER_SANITIZE_STRIPPED' => 'filter/filter.php',
'FILTER_SANITIZE_URL' => 'filter/filter.php',
'FILTER_UNSAFE_RAW' => 'filter/filter.php',
'FILTER_VALIDATE_BOOL' => 'filter/filter.php',
'FILTER_VALIDATE_BOOLEAN' => 'filter/filter.php',
'FILTER_VALIDATE_DOMAIN' => 'filter/filter.php',
'FILTER_VALIDATE_EMAIL' => 'filter/filter.php',
Expand Down Expand Up @@ -9509,8 +9530,19 @@ final class PhpStormStubsMap
'OPENSSL_CIPHER_RC2_128' => 'openssl/openssl.php',
'OPENSSL_CIPHER_RC2_40' => 'openssl/openssl.php',
'OPENSSL_CIPHER_RC2_64' => 'openssl/openssl.php',
'OPENSSL_CMS_BINARY' => 'openssl/openssl.php',
'OPENSSL_CMS_DETACHED' => 'openssl/openssl.php',
'OPENSSL_CMS_NOATTR' => 'openssl/openssl.php',
'OPENSSL_CMS_NOCERTS' => 'openssl/openssl.php',
'OPENSSL_CMS_NOINTERN' => 'openssl/openssl.php',
'OPENSSL_CMS_NOSIGS' => 'openssl/openssl.php',
'OPENSSL_CMS_NOVERIFY' => 'openssl/openssl.php',
'OPENSSL_CMS_TEXT' => 'openssl/openssl.php',
'OPENSSL_DEFAULT_STREAM_CIPHERS' => 'openssl/openssl.php',
'OPENSSL_DONT_ZERO_PAD_KEY' => 'openssl/openssl.php',
'OPENSSL_ENCODING_DER' => 'openssl/openssl.php',
'OPENSSL_ENCODING_PEM' => 'openssl/openssl.php',
'OPENSSL_ENCODING_SMIME' => 'openssl/openssl.php',
'OPENSSL_KEYTYPE_DH' => 'openssl/openssl.php',
'OPENSSL_KEYTYPE_DSA' => 'openssl/openssl.php',
'OPENSSL_KEYTYPE_EC' => 'openssl/openssl.php',
Expand Down
18 changes: 18 additions & 0 deletions Reflection/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,22 @@ public function isPromoted()
final private function __clone()
{
}

/**
* @return bool
* @since 8.0
*/
public function hasDefaultValue(){}

/**
* @return mixed
* @since 8.0
*/
public function getDefaultValue(){}

/**
* @return ReflectionAttribute[]
* @since 8.0
*/
public function getAttributes(?string $name = null, int $flags = 0): array {}
}
2 changes: 1 addition & 1 deletion SPL/SPL.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public function getInnerIterator() { }
* This object supports cached iteration over another iterator.
* @link https://php.net/manual/en/class.cachingiterator.php
*/
class CachingIterator extends IteratorIterator implements ArrayAccess, Countable {
class CachingIterator extends IteratorIterator implements ArrayAccess, Countable, Stringable {

/**
* String conversion flag (mutually exclusive): Uses the current element for the iterator's string conversion.
Expand Down
31 changes: 20 additions & 11 deletions SimpleXML/SimpleXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SimpleXMLElement implements Traversable, ArrayAccess, Countable, Iterator
* @param bool $is_prefix TRUE if ns is a prefix, FALSE if it's a URI; defaults to FALSE.
* @since 5.0.1
*/
final public function __construct ($data, $options = 0, $data_is_url = false, $ns = "", $is_prefix = false) {}
public function __construct ($data, $options = 0, $data_is_url = false, $ns = "", $is_prefix = false) {}

/**
* Provides access to element's children
Expand Down Expand Up @@ -218,15 +218,15 @@ public function count () {}
* @param string|int $offset
* @return bool true on success or false on failure.
*/
private function offsetExists ($offset) {}
public function offsetExists ($offset) {}

/**
* Class provides access to children by position, and attributes by name
* private Method not callable directly, stub exists for typehint only
* @param string|int $offset
* @return static Either a named attribute or an element from a list of children
*/
private function offsetGet ($offset) {}
public function offsetGet ($offset) {}

/**
* Class provides access to children by position, and attributes by name
Expand All @@ -235,57 +235,66 @@ private function offsetGet ($offset) {}
* @param mixed $value
* @return void
*/
private function offsetSet ($offset, $value) {}
public function offsetSet ($offset, $value) {}

/**
* Class provides access to children by position, and attributes by name
* private Method not callable directly, stub exists for typehint only
* @param string|int $offset
* @return void
*/
private function offsetUnset ($offset) {}
public function offsetUnset ($offset) {}

/**
* Rewind to the first element
* @link https://php.net/manual/en/simplexmliterator.rewind.php
* @return void No value is returned.
*/
private function rewind () {}
public function rewind () {}

/**
* Check whether the current element is valid
* @link https://php.net/manual/en/simplexmliterator.valid.php
* @return bool <b>TRUE</b> if the current element is valid, otherwise <b>FALSE</b>
*/
private function valid () {}
public function valid () {}

/**
* Returns the current element
* @link https://php.net/manual/en/simplexmliterator.current.php
* @return static|null the current element as a <b>SimpleXMLElement</b> object or <b>NULL</b> on failure.
*/
private function current () {}
public function current () {}

/**
* Return current key
* @link https://php.net/manual/en/simplexmliterator.key.php
* @return string|false the XML tag name of the element referenced by the current <b>SimpleXMLIterator</b> object or <b>FALSE</b>
*/
private function key () {}
public function key () {}

/**
* Move to next element
* @link https://php.net/manual/en/simplexmliterator.next.php
* @return void No value is returned.
*/
private function next () {}
public function next () {}

/**
* @return bool
* @since 8.0
*/
public function hasChildren()
{

}
}

/**
* The SimpleXMLIterator provides recursive iteration over all nodes of a <b>SimpleXMLElement</b> object.
* @link https://php.net/manual/en/class.simplexmliterator.php
*/
class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, Countable {
class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, Countable, Stringable {

/**
* Rewind to the first element
Expand Down
21 changes: 18 additions & 3 deletions curl/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __wakeup() {
* to its value. You can manually set this using the
* curl_setopt function.
* </p>
* @return resource|false a cURL handle on success, false on errors.
* @return resource|false|CurlHandle a cURL handle on success, false on errors.
*/
function curl_init ($url = null) {}

Expand Down Expand Up @@ -2137,7 +2137,7 @@ function curl_share_close ($sh) {}
* (PHP 5 &gt;=5.5.0)<br/>
* Initialize a cURL share handle
* @link https://secure.php.net/manual/en/function.curl-share-init.php
* @return resource Returns resource of type "cURL Share Handle".
* @return resource|CurlShareHandle Returns resource of type "cURL Share Handle".
* @since 5.5
*/
function curl_share_init () {}
Expand Down Expand Up @@ -2345,7 +2345,7 @@ function curl_close ($ch) {}
/**
* Returns a new cURL multi handle
* @link https://php.net/manual/en/function.curl-multi-init.php
* @return resource|false a cURL multi handle resource on success, false on failure.
* @return resource|false|CurlMultiHandle a cURL multi handle resource on success, false on failure.
*/
function curl_multi_init () {}

Expand Down Expand Up @@ -2531,3 +2531,18 @@ function curl_share_errno($rh) {}
* @return string
*/
function curl_share_strerror($errno){}

/**
* @since 8.0
*/
final class CurlHandle{}

/**
* @since 8.0
*/
final class CurlMultiHandle{}

/**
* @since 8.0
*/
final class CurlShareHandle{}

0 comments on commit f23297f

Please sign in to comment.