|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-25 07:18 UTC] colder@php.net
[2010-04-25 07:19 UTC] colder@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: colder
[2010-04-25 07:19 UTC] colder@php.net
[2010-04-27 07:03 UTC] colder@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 17:00:01 2025 UTC |
Description: ------------ There seems to be a problem with overriding SPLFileObject::fscanf() method. I'm not sure whether this is PHP language-related issue or issue with method definition in SPLFileObject. When you look at 'splfileobject.inc' file from PHP 5.3.2 source code you can see that method definition is: function fscanf($format /* , ... */) so it seems logical to assume only one parameter in overridden method. However, using Reflection API to get fscanf parameters: $class = new ReflectionClass('SPLFileObject'); $method = $class->getMethod('fscanf'); $params = $method->getParameters(); foreach ($params as $p) { echo $p->getName() . PHP_EOL; } Prints out: format ... Yes - '...' is literally printed out. So it leaves me puzzled - either I am missing something very obvious or fscanf is handling variable-length method arguments in some non-standard way (like using func_get_args()). All in all - overriding fscanf in a way like in specified example test script results in strict standards notice. Test script: --------------- class SomeOtherFileObject extends SPLFileObject { function fscanf($format) { echo 'my little dummy'; } } $test = new SomeOtherFileObject('test.php'); $test->fscanf('%s'); Expected result: ---------------- The fscanf method is overridden without PHP notices, warnings and errors. Actual result: -------------- Strict standards: Declaration of SomeOtherFileObject::fscanf() should be compatible with that of SplFileObject::fscanf()