php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80543 ArrayObject::asort() and ::ksort() expect an optional int
Submitted: 2020-12-22 13:54 UTC Modified: 2020-12-22 16:29 UTC
From: 1592328848 at qq dot com Assigned: cmb (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS: CentOS Linux release 7.3.1611 (C
Private report: No CVE-ID: None
 [2020-12-22 13:54 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-22 15:46 UTC] cmb@php.net
-Summary: I think the document should be updated. +Summary: ArrayObject::asort() and ::ksort() expect an optional int -Status: Open +Status: Verified -Package: Documentation problem +Package: SPL related -PHP Version: 8.0.0 +PHP Version: Irrelevant -Assigned To: +Assigned To: cmb
 [2020-12-22 15:46 UTC] cmb@php.net
Thanks for reporting!
 [2020-12-22 16:28 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=352168
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int
 [2020-12-22 16:29 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-12-22 16:29 UTC] cmb@php.net
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.
 [2020-12-22 17:46 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=352171
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int
 [2020-12-22 17:50 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=ada82024c3f695de1bd59647a8ef1d9d79bdb862
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int
 [2020-12-25 20:10 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=2550f62c6a8e60a690a462e9b6eb60e08abcc61f
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=a8450db54482a0f7f2bec53b01b89c7b2f099525
Log: Fix #80543: ArrayObject::asort() and ::ksort() expect an optional int
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 07:03:34 2021 UTC