|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-08-05 22:20 UTC] slowlychillin at yahoo dot com
Description:
------------
My code that worked in php 5.4.0alpha2 is not working in 5.4.0alpha3. When I stripped down the code to nail down exactly where things were going wrong, it turns out that I have a trait with a method with a parameter that has a default. When I remove the default, the script works just fine. When the default is there, I get this error message showing up in my browser (Firefox 5):
"The connection was reset
The connection to the server was reset while the page was loading."
Test script:
---------------
// This does not work:
trait example_trait {
public function example_method($example_paramter = 1) {
echo $example_paramter;
}
}
// This does work:
trait example_trait {
public function example_method($example_paramter) {
echo $example_paramter;
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 18:00:01 2025 UTC |
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. I can't reproduce some problem. <?php trait example_trait { public function example_method($example_paramter = 1) { echo $example_paramter; } } class foo { use example_trait; } $x = new foo; $x->example_method();Apologies for not providing a better code snippet. Here's one you can try out of the box. When I uncomment the IF block, the script will hang. But if I have it commented out, like in the example below, the script works. <?php trait testTrait { public function testMethod() { //if (1) { $letters1 = range('a', 'z', 1); $letters2 = range('A', 'Z', 1); var_dump($letters1); var_dump($letters2); //} } } class foo { use testTrait; } $x = new foo; $x->testMethod(); ?> ------------ The script works both ways in php 5.4.0alpha2. Let me know if you need any other feedback!