php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70181 Missing information which confuses readers
Submitted: 2015-08-01 16:32 UTC Modified: 2016-07-30 00:10 UTC
From: emilxp at abv dot bg Assigned: cmb (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: emilxp at abv dot bg
New email:
PHP Version: OS:

 

 [2015-08-01 16:32 UTC] emilxp at abv dot bg
Description:
------------
---
From manual page: http://php.net/manual/en/features.gc.refcounting-basics.php
---

I started reading the article at the page stated above and got confused by the sentence "The "refcount" gets decreased by one when any symbol linked to the variable container leaves the scope (e.g. when the function ends) or when unset() is called on a symbol.".

I believe there's at least one more way to reduce the refcount and that's by assignment.

I think that this missing information can confuse some people when they first read it. I think it should be stated that reducing the refcount can happen by making $a and/or $b reference to different zvals and possibly other ways that I couldn't come up with.

Test script:
---------------
<?php
$a = "bla";
$b = $a;

// now $a and $b reference "bla"
xdebug_debug_zval('a');
xdebug_debug_zval('b');
$a = "this";

// show that the refcount decreases
xdebug_debug_zval('a');
xdebug_debug_zval('b');

$b = "some";

// now both $a and $b point to different zvals.
// the first "bla" zval must be food for the garbadge collector
xdebug_debug_zval('a');
xdebug_debug_zval('b');


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-30 00:09 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339741
Log: Fix #70181: Missing information which confuses readers
 [2016-07-30 00:10 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-07-30 00:10 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=45542e6edc95219199d5f7603a6c880446e8b354
Log: Fix #70181: Missing information which confuses readers
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC