php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79653 Unexpected error for ArrayIterator::ksort()
Submitted: 2020-05-30 06:25 UTC Modified: 2020-05-30 09:05 UTC
From: admad dot coder at gmail dot com Assigned: kocsismate (profile)
Status: Closed Package: SPL related
PHP Version: master-Git-2020-05-29 (Git) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admad dot coder at gmail dot com
New email:
PHP Version: OS:

 

 [2020-05-30 06:25 UTC] admad dot coder at gmail dot com
Description:
------------
Using ArrayIterator::ksort() without any arguments generates ArgumentCountError error.

Issue seems related to implementation of this feature request https://bugs.php.net/bug.php?id=62840.

Test script:
---------------
<?php
$array = [];
$arrIter = new ArrayIterator($array);
$arrIter->ksort();

Expected result:
----------------
As per https://github.com/php/php-src/blob/4fa3687e56050a111e8eaffe330258003628225e/ext/spl/spl_array.stub.php#L191
the new $sort_flags arguments has a default value. (In PHP 7 the method does not have any arguments).

So I do not expect any error to be generated when calling the method without any argument.

Actual result:
--------------
Above example code generate error like:

Fatal error: Uncaught ArgumentCountError: ArrayIterator::ksort() expects exactly 1 parameter, 0 given

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-30 09:02 UTC] kocsismate@php.net
-Summary: Unexpected error for ArrayIterator::ksort() +Summary: Wrong ReflectionType for sprintf/printf args parameter -Status: Open +Status: Verified -PHP Version: master-Git-2020-05-30 (Git) +PHP Version: master-Git-2020-05-29 (Git) -Assigned To: +Assigned To: kocsismate
 [2020-05-30 09:02 UTC] kocsismate@php.net
Thank you for reporting the issue! I managed to verify the problem, which was caused by a refactoring.
 [2020-05-30 09:05 UTC] kocsismate@php.net
-Summary: Wrong ReflectionType for sprintf/printf args parameter +Summary: Unexpected error for ArrayIterator::ksort()
 [2020-05-30 09:05 UTC] kocsismate@php.net
Uh, I think the browser autocomplete messed up the title, sorry.
 [2020-05-30 09:16 UTC] kocsismate@php.net
The following pull request has been associated:

Patch Name: Fix #79653 Unexpected error for ArrayIterator::ksort()
On GitHub:  https://github.com/php/php-src/pull/5644
Patch:      https://github.com/php/php-src/pull/5644.patch
 [2020-05-30 15:00 UTC] kocsismate@php.net
Automatic comment on behalf of kocsismate@woohoolabs.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4a10eb4f53dbe1b543e9043fd2e249200291abcc
Log: Fix #79653 Unexpected error for ArrayIterator::ksort()
 [2020-05-30 15:00 UTC] kocsismate@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC