Doc #80543 [Ver->Csd]: ArrayObject::asort() and ::ksort() expect an optional int

From: Date: Tue, 22 Dec 2020 16:29:03 +0000
Subject: Doc #80543 [Ver->Csd]: ArrayObject::asort() and ::ksort() expect an optional int
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18312@lists.php.net to get a copy of this message
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:            ArrayObject::asort() and ::ksort() expect an
                     optional int
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            SPL related
 Operating System:   CentOS Linux release 7.3.1611 (C
 PHP Version:        Irrelevant
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


Previous Comments:
------------------------------------------------------------------------
[2020-12-22 16:28:27] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=352168
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int

------------------------------------------------------------------------
[2020-12-22 15:46:39] cmb@php.net

Thanks for reporting!

------------------------------------------------------------------------
[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)

« previous php.doc.bugs (#18312) next »