Doc #76090 [Csd->Nab]: Use self instead of class name in example
| From: | cmb@php.net | Date: | Tue, 13 Mar 2018 23:12:40 +0000 |
| Subject: | Doc #76090 [Csd->Nab]: Use self instead of class name in example | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15522@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
Updated by: cmb@php.net
Reported by: istvan at palocz dot hu
Summary: Use self instead of class name in example
-Status: Closed
+Status: Not a bug
Type: Documentation Problem
Package: Scripting Engine problem
PHP Version: 7.2.3
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2018-03-13 15:27:40] istvan at palocz dot hu
Ok, I missed the private keyword.
Agree
------------------------------------------------------------------------
[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