Skip to content

Declare tentative return types for ext/spl - part 2 #7235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Zend/tests/ns_054.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
namespace test\ns1;

class Foo implements \SplObserver {
function update(\SplSubject $x) {
function update(\SplSubject $x): void {
echo "ok\n";
}
}

class Bar implements \SplSubject {
function attach(\SplObserver $x) {
function attach(\SplObserver $x): void {
echo "ok\n";
}
function notify() {
function notify(): void {
}
function detach(\SplObserver $x) {
function detach(\SplObserver $x): void {
}
}
$foo = new Foo();
Expand Down
8 changes: 4 additions & 4 deletions Zend/tests/ns_056.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ namespace test\ns1;
use \SplObserver;

class Foo implements SplObserver {
function update(\SplSubject $x) {
function update(\SplSubject $x): void {
echo "ok\n";
}
}

class Bar implements \SplSubject {
function attach(SplObserver $x) {
function attach(SplObserver $x): void {
echo "ok\n";
}
function notify() {
function notify(): void {
}
function detach(SplObserver $x) {
function detach(SplObserver $x): void {
}
}
$foo = new Foo();
Expand Down
112 changes: 56 additions & 56 deletions ext/spl/spl_dllist.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,110 +4,110 @@

class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable
{
/** @return void */
public function add(int $index, mixed $value) {}
/** @tentative-return-type */
public function add(int $index, mixed $value): void {}

/** @return mixed */
public function pop() {}
/** @tentative-return-type */
public function pop(): mixed {}

/** @return mixed */
public function shift() {}
/** @tentative-return-type */
public function shift(): mixed {}

/** @return void */
public function push(mixed $value) {}
/** @tentative-return-type */
public function push(mixed $value): void {}

/** @return void */
public function unshift(mixed $value) {}
/** @tentative-return-type */
public function unshift(mixed $value): void {}

/** @return mixed */
public function top() {}
/** @tentative-return-type */
public function top(): mixed {}

/** @return mixed */
public function bottom() {}
/** @tentative-return-type */
public function bottom(): mixed {}

/** @return array */
public function __debugInfo() {}
/** @tentative-return-type */
public function __debugInfo(): array {}

/** @return int */
public function count() {}
/** @tentative-return-type */
public function count(): int {}

/** @return bool */
public function isEmpty() {}
/** @tentative-return-type */
public function isEmpty(): bool {}

/** @return int */
public function setIteratorMode(int $mode) {}
/** @tentative-return-type */
public function setIteratorMode(int $mode): int {}

/** @return int */
public function getIteratorMode() {}
/** @tentative-return-type */
public function getIteratorMode(): int {}

/**
* @param int $index
* @return bool
* @tentative-return-type
*/
public function offsetExists($index) {}
public function offsetExists($index): bool {}

/**
* @param int $index
* @return mixed
* @tentative-return-type
*/
public function offsetGet($index) {}
public function offsetGet($index): mixed {}

/**
* @param int|null $index
* @return void
* @tentative-return-type
*/
public function offsetSet($index, mixed $value) {}
public function offsetSet($index, mixed $value): void {}

/**
* @param int $index
* @return void
* @tentative-return-type
*/
public function offsetUnset($index) {}
public function offsetUnset($index): void {}

/** @return void */
public function rewind() {}
/** @tentative-return-type */
public function rewind(): void {}

/** @return mixed */
public function current() {}
/** @tentative-return-type */
public function current(): mixed {}

/** @return int */
public function key() {}
/** @tentative-return-type */
public function key(): int {}

/** @return void */
public function prev() {}
/** @tentative-return-type */
public function prev(): void {}

/** @return void */
public function next() {}
/** @tentative-return-type */
public function next(): void {}

/** @return bool */
public function valid() {}
/** @tentative-return-type */
public function valid(): bool {}

/** @return void */
public function unserialize(string $data) {}
/** @tentative-return-type */
public function unserialize(string $data): void {}

/** @return string */
public function serialize() {}
/** @tentative-return-type */
public function serialize(): string {}

/** @return array */
public function __serialize() {}
/** @tentative-return-type */
public function __serialize(): array {}

/** @return void */
public function __unserialize(array $data) {}
/** @tentative-return-type */
public function __unserialize(array $data): void {}
}

class SplQueue extends SplDoublyLinkedList
{
/**
* @return void
* @tentative-return-type
* @implementation-alias SplDoublyLinkedList::push
*/
public function enqueue(mixed $value) {}
public function enqueue(mixed $value): void {}

/**
* @return mixed
* @tentative-return-type
* @implementation-alias SplDoublyLinkedList::shift
*/
public function dequeue() {}
public function dequeue(): mixed {}
}

class SplStack extends SplDoublyLinkedList
Expand Down
53 changes: 31 additions & 22 deletions ext/spl/spl_dllist_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: d0c98e1628895a81ac0b4abe62dede9ed2c7f55e */
* Stub hash: 4631669bb268bb2c9e005fa7ee385245604c1d71 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_add, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_add, 0, 2, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_pop, 0, 0, 0)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_pop, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_shift arginfo_class_SplDoublyLinkedList_pop

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_push, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_push, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()

Expand All @@ -21,52 +21,61 @@ ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_bottom arginfo_class_SplDoublyLinkedList_pop

#define arginfo_class_SplDoublyLinkedList___debugInfo arginfo_class_SplDoublyLinkedList_pop
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList___debugInfo, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_count arginfo_class_SplDoublyLinkedList_pop
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_count, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_isEmpty arginfo_class_SplDoublyLinkedList_pop
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_isEmpty, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_setIteratorMode, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_setIteratorMode, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_getIteratorMode arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList_getIteratorMode arginfo_class_SplDoublyLinkedList_count

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetExists, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetExists, 0, 1, _IS_BOOL, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_offsetGet arginfo_class_SplDoublyLinkedList_offsetExists
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetGet, 0, 1, IS_MIXED, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetSet, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetSet, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_offsetUnset arginfo_class_SplDoublyLinkedList_offsetExists
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetUnset, 0, 1, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_rewind arginfo_class_SplDoublyLinkedList_pop
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_rewind, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_current arginfo_class_SplDoublyLinkedList_pop

#define arginfo_class_SplDoublyLinkedList_key arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList_key arginfo_class_SplDoublyLinkedList_count

#define arginfo_class_SplDoublyLinkedList_prev arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList_prev arginfo_class_SplDoublyLinkedList_rewind

#define arginfo_class_SplDoublyLinkedList_next arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList_next arginfo_class_SplDoublyLinkedList_rewind

#define arginfo_class_SplDoublyLinkedList_valid arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList_valid arginfo_class_SplDoublyLinkedList_isEmpty

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_unserialize, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_unserialize, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList_serialize arginfo_class_SplDoublyLinkedList_pop
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList_serialize, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SplDoublyLinkedList___serialize arginfo_class_SplDoublyLinkedList_pop
#define arginfo_class_SplDoublyLinkedList___serialize arginfo_class_SplDoublyLinkedList___debugInfo

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList___unserialize, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplDoublyLinkedList___unserialize, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

Expand Down
40 changes: 20 additions & 20 deletions ext/spl/spl_fixedarray.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,47 @@ class SplFixedArray implements IteratorAggregate, ArrayAccess, Countable, JsonSe
{
public function __construct(int $size = 0) {}

/** @return void */
public function __wakeup() {}
/** @tentative-return-type */
public function __wakeup(): void {}

/** @return int */
public function count() {}
/** @tentative-return-type */
public function count(): int {}

/** @return array */
public function toArray() {}
/** @tentative-return-type */
public function toArray(): array {}

/** @return SplFixedArray */
public static function fromArray(array $array, bool $preserveKeys = true) {}
/** @tentative-return-type */
public static function fromArray(array $array, bool $preserveKeys = true): SplFixedArray {}

/** @return int */
public function getSize() {}
/** @tentative-return-type */
public function getSize(): int {}

/** @return bool */
public function setSize(int $size) {}
/** @tentative-return-type */
public function setSize(int $size): bool {}

/**
* @param int $index
* @return bool
* @tentative-return-type
*/
public function offsetExists($index) {}
public function offsetExists($index): bool {}

/**
* @param int $index
* @return mixed
* @tentative-return-type
*/
public function offsetGet($index) {}
public function offsetGet($index): mixed {}

/**
* @param int $index
* @return void
* @tentative-return-type
*/
public function offsetSet($index, mixed $value) {}
public function offsetSet($index, mixed $value): void {}

/**
* @param int $index
* @return void
* @tentative-return-type
*/
public function offsetUnset($index) {}
public function offsetUnset($index): void {}

public function getIterator(): Iterator {}

Expand Down
Loading