|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-05 09:32 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 15:00:01 2025 UTC |
Description: ------------ Introducing a parameter with a default value in a function of a derived class, where the function in the parent does not have a default value, throws an E_STRICT. Introducing a default does NOT change the function's signature and should not cause any problems. It is possible in C++ and most other OO languages without any issues. In PHP it causes an E_STRICT to be thrown. This is especially an issue when working with third party libraries (i.e. Smarty) that need to be overridden to have defaults (i.e. display()/fetch()). This works fine, but does throw an E_STRICT. Reproduce code: --------------- class Parent { public function foo($bar) { } } class Child extends Parent { public function foo($bar = "test") { } } Expected result: ---------------- No E_STRICT thrown Actual result: -------------- E_STRICT thrown