Doc #76090 [Opn->Fbk]: Use self instead of class name in example
Edit report at https://bugs.php.net/bug.php?id=76090&edit=1
ID: 76090
Updated by: requinix@php.net
Reported by: istvan at palocz dot hu
Summary: Use self instead of class name in example
-Status: Open
+Status: Feedback
Type: Documentation Problem
-Package: Documentation problem
+Package: Scripting Engine problem
PHP Version: 7.2.3
Block user comment: N
Private report: N
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[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
Thread (4 messages)