Doc #76090 [Fbk->Csd]: Use self instead of class name in example
| From: | istvan at palocz dot hu | Date: | Tue, 13 Mar 2018 15:27:41 +0000 |
| Subject: | Doc #76090 [Fbk->Csd]: Use self instead of class name in example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15521@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76090&edit=1
ID: 76090
User updated by: istvan at palocz dot hu
Reported by: istvan at palocz dot hu
Summary: Use self instead of class name in example
-Status: Feedback
+Status: Closed
Type: Documentation Problem
Package: Scripting Engine problem
PHP Version: 7.2.3
Block user comment: N
Private report: N
New Comment:
Ok, I missed the private keyword.
Agree
Previous Comments:
------------------------------------------------------------------------
[2018-03-13 14:44:34] requinix@php.net
Actually it wouldn't work because $sfoo is private. https://3v4l.org/iLVpZ
A::$sfoo demonstrates that the code can access the property member, while self::$sfoo would
demonstrate that the code is running from "within" the A class. Both mean the same thing.
But the second callback already shows the "within the A class" aspect by using $this, so I
think having A::$sfoo being clearer about accessing members is good.
Does that make sense? Agree or disagree?
------------------------------------------------------------------------
[2018-03-13 14:25:58] istvan at palocz dot hu
Description:
------------
---
From manual page: http://www.php.net/closure.bind
---
Example 1 contains a following code:
<?php
$cl1 = static function() {
return A::$sfoo;
};
?>
My suggestion:
<?php
$cl1 = static function() {
return self::$sfoo;
};
?>
This example show why use bind(), but A:: works without bind().
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76090&edit=1