Doc #80543 [Opn->Ver]: ArrayObject::asort() and ::ksort() expect an optional int
Edit report at https://bugs.php.net/bug.php?id=80543&edit=1
ID: 80543
Updated by: cmb@php.net
Reported by: 1592328848 at qq dot com
-Summary: I think the document should be updated.
+Summary: ArrayObject::asort() and ::ksort() expect an
optional int
-Status: Open
+Status: Verified
Type: Documentation Problem
-Package: Documentation problem
+Package: SPL related
Operating System: CentOS Linux release 7.3.1611 (C
-PHP Version: 8.0.0
+PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thanks for reporting!
Previous Comments:
------------------------------------------------------------------------
[2020-12-22 13:54:09] 1592328848 at qq dot com
Description:
------------
---
From manual page: https://php.net/class.arrayobject
---
When My class inherits the ArrayOsbject class of PHP, the parameters I need to pass are inconsistent
with the PHP Arrayobject document. I think the document should be updated.
Test script:
---------------
In PHP 7,it is normal.As follows:
<?php
class MyArrayObject extends ArrayObject
{
public function asort()
{
// parent::asort(); // TODO: Change the autogenerated stub
}
public function ksort()
{
// parent::ksort(); // TODO: Change the autogenerated stub
}
}
?>
In PHP 8,there was a fatal error.
<?php
class MyArrayObject extends ArrayObject
{
public function asort()
{
// parent::asort(); // TODO: Change the autogenerated stub
}
public function ksort()
{
// parent::ksort(); // TODO: Change the autogenerated stub
}
}
?>
Run it In PHP 8,it happens a PHP Fatal error.As follows:
PHP Fatal error: Declaration of MyArrayObject::asort() must be compatible with
ArrayObject::asort(int $flags = SORT_REGULAR) in MyArrayObject_In_PHP8.php on line 13
Fatal error: Declaration of MyArrayObject::asort() must be compatible with ArrayObject::asort(int
$flags = SORT_REGULAR) in MyArrayObject_In_PHP8.php on line 13
PHP Fatal error: Declaration of MyArrayObject::ksort() must be compatible with
ArrayObject::ksort(int $flags = SORT_REGULAR) in MyArrayObject_In_PHP7.php on line 19
Fatal error: Declaration of MyArrayObject::ksort() must be compatible with ArrayObject::ksort(int
$flags = SORT_REGULAR) in MyArrayObject_In_PHP7.php on line 19
Expected result:
----------------
PHP Fatal error: Declaration of MyArrayObject::asort() must be compatible with
ArrayObject::asort(int $flags = SORT_REGULAR) in MyArrayObject_In_PHP8.php on line 13
Fatal error: Declaration of MyArrayObject::asort() must be compatible with ArrayObject::asort(int
$flags = SORT_REGULAR) in MyArrayObject_In_PHP8.php on line 13
PHP Fatal error: Declaration of MyArrayObject::ksort() must be compatible with
ArrayObject::ksort(int $flags = SORT_REGULAR) in MyArrayObject_In_PHP7.php on line 19
Fatal error: Declaration of MyArrayObject::ksort() must be compatible with ArrayObject::ksort(int
$flags = SORT_REGULAR) in MyArrayObject_In_PHP7.php on line 19
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80543&edit=1
Thread (3 messages)