Skip to content
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

Phalcon\Registry #1935

Merged
merged 9 commits into from Jan 31, 2014
Merged
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
Next Next commit
Added comments
  • Loading branch information
sjinks committed Jan 30, 2014
commit 87fc89b737f1dfac2e0ece82084e3ce44f6be667
54 changes: 50 additions & 4 deletions ext/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,61 @@
#include <ext/standard/php_var.h>
#include <ext/standard/php_smart_str.h>

#if defined(PHALCON_USE_PHP_JSON) && PHP_VERSION_ID >= 50400
# include <ext/json/php_json.h>
#endif

#include "kernel/main.h"
#include "kernel/object.h"
#include "kernel/hash.h"
#include "kernel/fcall.h"

/**
* Phalcon\Registry
*
* A registry is a container for storing objects and values in the application space.
* By storing the value in a registry, the same object is always available throughout
* your application.
*
* <code>
* $registry = new \Phalcon\Registry();
*
* // Set value
* $registry->something = 'something';
* // or
* $registry['something'] = 'something';
*
* // Get value
* $value = $registry->something;
* // or
* $value = $registry['something'];
*
* // Check if the key exists
* $exists = isset($registry->something);
* // or
* $exists = isset($registry['something']);
*
* // Unset
* unset($registry->something);
* // or
* unset($registry['something']);
* </code>
*
* In addition to ArrayAccess, Phalcon\Registry also implements Countable
* (count($registry) will return the number of elements in the registry),
* Serializable and IteratorAggregate (you can iterate over the registry
* using a foreach loop) interfaces. For PHP 5.4 and higher, JsonSerializable
* interface is implemented.
*
* Phalcon\Registry is very fast (it is typically faster than any userspace
* implementation of the registry); however, this comes at a price:
* Phalcon\Registry is a final class and cannot be inherited from.
*
* Though Phalcon\Registry exposes methods like __get(), offsetGet(), count() etc,
* it is not recommended to invoke them manually (these method exists mainly to
* match the interfaces the registry implements): $registry->__get('property')
* is several times slower than $registry->property.
*
* Internally all the magic methods (and interfaces except JsonSerializable)
* are implemented using object handlers or similar techniques: this allows
* to bypass relatively slow method calls.
*/
zend_class_entry *phalcon_registry_ce;

static zend_object_handlers phalcon_registry_object_handlers;
Expand Down