• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

tests/H03-May-2022-152146

README.rstH A D25-Mar-20192.1 KiB7355

config.m4H A D25-Mar-20192.2 KiB6452

config.w32H A D25-Mar-2019345 149

php_symfony_debug.hH A D25-Mar-20191.5 KiB5636

symfony_debug.cH A D25-Mar-20195.1 KiB225174

README.rst

1Symfony Debug Extension
2=======================
3
4This extension adds a ``symfony_zval_info($key, $array, $options = 0)`` function that:
5
6- exposes zval_hash/refcounts, allowing e.g. efficient exploration of arbitrary structures in PHP,
7- does work with references, preventing memory copying.
8
9Its behavior is about the same as:
10
11.. code-block:: php
12
13    <?php
14
15    function symfony_zval_info($key, $array, $options = 0)
16    {
17        // $options is currently not used, but could be in future version.
18
19        if (!array_key_exists($key, $array)) {
20            return null;
21        }
22
23        $info = array(
24            'type' => gettype($array[$key]),
25            'zval_hash' => /* hashed memory address of $array[$key] */,
26            'zval_refcount' => /* internal zval refcount of $array[$key] */,
27            'zval_isref' => /* is_ref status of $array[$key] */,
28        );
29
30        switch ($info['type']) {
31            case 'object':
32                $info += array(
33                    'object_class' => get_class($array[$key]),
34                    'object_refcount' => /* internal object refcount of $array[$key] */,
35                    'object_hash' => spl_object_hash($array[$key]),
36                    'object_handle' => /* internal object handle $array[$key] */,
37                );
38                break;
39
40            case 'resource':
41                $info += array(
42                    'resource_handle' => (int) $array[$key],
43                    'resource_type' => get_resource_type($array[$key]),
44                    'resource_refcount' => /* internal resource refcount of $array[$key] */,
45                );
46                break;
47
48            case 'array':
49                $info += array(
50                    'array_count' => count($array[$key]),
51                );
52                break;
53
54            case 'string':
55                $info += array(
56                    'strlen' => strlen($array[$key]),
57                );
58                break;
59        }
60
61        return $info;
62    }
63
64To enable the extension from source, run:
65
66.. code-block:: sh
67
68    phpize
69    ./configure
70    make
71    sudo make install
72
73