Req #9195 [Ana->Bgs]: Allow this be passed as default class function parameter
| From: | laruence@php.net | Date: | Fri, 18 Nov 2011 06:23:33 +0000 |
| Subject: | Req #9195 [Ana->Bgs]: Allow this be passed as default class function parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165310@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=9195&edit=1
ID: 9195
Updated by: laruence@php.net
Reported by: nathan at cjhunter dot com
Summary: Allow this be passed as default class function
parameter
-Status: Analyzed
+Status: Bogus
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2011-07-06 11:31:09] laruence@php.net
sorry for misspell:
class A {
const FOO=2;
public function dummy($a = self::FOO) {
}
}
------------------------------------------------------------------------
[2011-07-06 11:29:40] laruence@php.net
$this is in execute process, function declaring is in compile process,
but you can use a compiling variable:
class A {
const FOO = 2;
public function dummy($a = FOO) {
}
}
------------------------------------------------------------------------
[2001-02-09 13:00:53] nathan at cjhunter dot com
I'm requesting that the default function arguments for a class method be able to reference the
class variable members in it's definition.
Here is an example of it's use:
class searchclass {
var $hits;
var $results;
function save($filename, $start = 0, $end = $this->hits){ /* <- this returns Parse error: */
if($fp = @fopen($filename, "w")){
for($i = $start; $i < $end; $i++){
fwrite($fp, implode("|", $this->results[$i]));
}
}else{
return false;
}
}
function search(){
/* ... */
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=9195&edit=1