Skip to content

Commit edb6b37

Browse files
committed
Don't return bool from Phar::offsetUnset()
This violates the ArrayAccess interface. Use offsetExists() to check if an entry exists.
1 parent b9893c2 commit edb6b37

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ PHP 8.1 UPGRADE NOTES
147147
default connection is deprecated.
148148
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
149149

150+
- Phar:
151+
. To comply with the ArrayAccess interface, Phar::offsetUnset() and
152+
PharData::offsetUnset() no longer return a boolean.
153+
150154
- PSpell:
151155
. The PSpell functions now accept and return, respectively, PSpell\Dictionary objects
152156
instead of "pspell" resources. Return value checks using is_resource()

ext/phar/phar_object.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,11 +3759,7 @@ PHP_METHOD(Phar, offsetUnset)
37593759
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
37603760
efree(error);
37613761
}
3762-
3763-
RETURN_TRUE;
37643762
}
3765-
} else {
3766-
RETURN_FALSE;
37673763
}
37683764
}
37693765
/* }}} */

ext/phar/phar_object.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function offsetSet($localName, $value): void {}
119119
* @param string $localName
120120
* @tentative-return-type
121121
*/
122-
public function offsetUnset($localName): bool {}
122+
public function offsetUnset($localName): void {}
123123

124124
/** @tentative-return-type */
125125
public function setAlias(string $alias): bool {}
@@ -386,7 +386,7 @@ public function offsetSet($localName, $value): void {}
386386
* @tentative-return-type
387387
* @implementation-alias Phar::offsetUnset
388388
*/
389-
public function offsetUnset($localName): bool {}
389+
public function offsetUnset($localName): void {}
390390

391391
/**
392392
* @tentative-return-type

ext/phar/phar_object_arginfo.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: ac04a4161a11d054922cb04787f81f5661203e3e */
2+
* Stub hash: ddb04eb0a40f19ad06cb351e545895a8dd58fece */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
@@ -128,7 +128,9 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_offsetSet,
128128
ZEND_ARG_INFO(0, value)
129129
ZEND_END_ARG_INFO()
130130

131-
#define arginfo_class_Phar_offsetUnset arginfo_class_Phar_offsetExists
131+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_offsetUnset, 0, 1, IS_VOID, 0)
132+
ZEND_ARG_INFO(0, localName)
133+
ZEND_END_ARG_INFO()
132134

133135
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_setAlias, 0, 1, _IS_BOOL, 0)
134136
ZEND_ARG_TYPE_INFO(0, alias, IS_STRING, 0)
@@ -297,7 +299,7 @@ ZEND_END_ARG_INFO()
297299

298300
#define arginfo_class_PharData_offsetSet arginfo_class_Phar_offsetSet
299301

300-
#define arginfo_class_PharData_offsetUnset arginfo_class_Phar_offsetExists
302+
#define arginfo_class_PharData_offsetUnset arginfo_class_Phar_offsetUnset
301303

302304
#define arginfo_class_PharData_setAlias arginfo_class_Phar_setAlias
303305

0 commit comments

Comments
 (0)