La classe WeakMap

(PECL weakref >= 0.2.0)

Introduction

Synopsis de la classe

WeakMap implements Countable , ArrayAccess , Iterator {
/* Méthodes */
public __construct ( void )
public count ( void ) : int
public current ( void ) : mixed
public key ( void ) : object
public next ( void ) : void
public offsetExists ( object $object ) : bool
public offsetGet ( object $object ) : mixed
public offsetSet ( object $object , mixed $value ) : void
public offsetUnset ( object $object ) : void
public rewind ( void ) : void
public valid ( void ) : bool
}

Exemples

Exemple #1 Exemple d'utilisation de Weakmap

<?php
$wm 
= new WeakMap();

$o = new StdClass;

class 
{
    public function 
__destruct() {
        echo 
"Mort !\n";
    }
}

$wm[$o] = new A;

var_dump(count($wm));
echo 
"Effacement..\n";
unset(
$o);
echo 
"Fait\n";
var_dump(count($wm));

L'exemple ci-dessus va afficher :

int(1)
Effacement..
Mort !
Fait
int(0)

Sommaire

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top