8000 [Debug] Symfony debug extension by nicolas-grekas · Pull Request #10500 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Debug] Symfony debug extension #10500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Debug] a README for the debug extension
  • Loading branch information
nicolas-grekas committed Mar 26, 2014
commit 72d08c116eaae5b2a4cf93e312e49e40bb686595
71 changes: 71 additions & 0 deletions src/Symfony/Component/Debug/Resources/ext/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Symfony Debug Extension
=======================

This extension adds a ``symfony_zval_info($key, $array, $options = 0)`` function that:

- exposes zval_hash/refcounts, allowing e.g. efficient exploration of arbitrary structures in PHP,
- does work with references, preventing memory copying.

Its behavior is about the same as:

.. code-block:: php

<?php

function symfony_zval_info($key, $array, $options = 0)
{
// $options is currenlty not used, but could be in future version.

if (!array_key_exists($key, $array)) {
return null;
}

$info = array(
'type' => gettype($array[$key]),
'zval_hash' => /* hashed memory address of $array[$key] */,
'zval_refcount' => /* internal zval refcount of $array[$key] */,
'zval_isref' => /* is_ref status of $array[$key] */,
);

switch ($info['type']) {
case 'object':
$info += array(
'object_class' => get_class($array[$key]),
'object_refcount' => /* internal object refcount of $array[$key] */,
'object_hash' => spl_object_hash($array[$key]),
);
break;

case 'resource':
$info += array(
'resource_id' => (int) substr((string) $array[$key], 13),
'resource_type' => get_resource_type($array[$key]),
'resource_refcount' => /* internal resource refcount of $array[$key] */,
);
break;

case 'array':
$info += array(
'array_count' => count($array[$key]),
);
break;

case 'string':
$info += array(
'strlen' => strlen($array[$key]),
);
break;
}

return $info;
}

To enable the extension from source, run:

.. code-block:: sh

phpize
./configure
make
sudo make install

0