mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- updated PHP 5.3 namespace separator
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom output for Nette::Debug.
|
* Custom output for Nette\Debug.
|
||||||
*
|
*
|
||||||
* @author David Grudl
|
* @author David Grudl
|
||||||
* @copyright Copyright (c) 2004, 2009 David Grudl
|
* @copyright Copyright (c) 2004, 2009 David Grudl
|
||||||
|
@@ -54,8 +54,8 @@ class DibiConnection extends DibiObject
|
|||||||
*/
|
*/
|
||||||
public function __construct($config, $name = NULL)
|
public function __construct($config, $name = NULL)
|
||||||
{
|
{
|
||||||
if (class_exists(/*Nette::*/'Debug', FALSE)) {
|
if (class_exists(/*Nette\*/'Debug', FALSE)) {
|
||||||
/*Nette::*/Debug::addColophon(array('dibi', 'getColophon'));
|
/*Nette\*/Debug::addColophon(array('dibi', 'getColophon'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DSN string
|
// DSN string
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
* DibiObject is the ultimate ancestor of all instantiable classes.
|
* DibiObject is the ultimate ancestor of all instantiable classes.
|
||||||
*
|
*
|
||||||
* DibiObject is copy of Nette::Object from Nette Framework (http://nettephp.com).
|
* DibiObject is copy of Nette\Object from Nette Framework (http://nettephp.com).
|
||||||
*
|
*
|
||||||
* It defines some handful methods and enhances object core of PHP:
|
* It defines some handful methods and enhances object core of PHP:
|
||||||
* - access to undeclared members throws exceptions
|
* - access to undeclared members throws exceptions
|
||||||
@@ -82,11 +82,11 @@ abstract class DibiObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to reflection.
|
* Access to reflection.
|
||||||
* @return ReflectionObject
|
* @return \ReflectionObject
|
||||||
*/
|
*/
|
||||||
final public function getReflection()
|
final public function getReflection()
|
||||||
{
|
{
|
||||||
return new ReflectionObject($this);
|
return new /*\*/ReflectionObject($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,22 +96,22 @@ abstract class DibiObject
|
|||||||
* @param string method name
|
* @param string method name
|
||||||
* @param array arguments
|
* @param array arguments
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ::MemberAccessException
|
* @throws \MemberAccessException
|
||||||
*/
|
*/
|
||||||
public function __call($name, $args)
|
public function __call($name, $args)
|
||||||
{
|
{
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
|
|
||||||
if ($name === '') {
|
if ($name === '') {
|
||||||
throw new /*::*/MemberAccessException("Call to class '$class' method without name.");
|
throw new /*\*/MemberAccessException("Call to class '$class' method without name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// event functionality
|
// event functionality
|
||||||
if (preg_match('#^on[A-Z]#', $name)) {
|
if (preg_match('#^on[A-Z]#', $name)) {
|
||||||
$rp = new ReflectionProperty($class, $name);
|
$rp = new /*\*/ReflectionProperty($class, $name);
|
||||||
if ($rp->isPublic() && !$rp->isStatic()) {
|
if ($rp->isPublic() && !$rp->isStatic()) {
|
||||||
$list = $this->$name;
|
$list = $this->$name;
|
||||||
if (is_array($list) || $list instanceof Traversable) {
|
if (is_array($list) || $list instanceof /*\*/Traversable) {
|
||||||
foreach ($list as $handler) {
|
foreach ($list as $handler) {
|
||||||
/**/if (is_object($handler)) {
|
/**/if (is_object($handler)) {
|
||||||
call_user_func_array(array($handler, '__invoke'), $args);
|
call_user_func_array(array($handler, '__invoke'), $args);
|
||||||
@@ -131,7 +131,7 @@ abstract class DibiObject
|
|||||||
return call_user_func_array($cb, $args);
|
return call_user_func_array($cb, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new /*::*/MemberAccessException("Call to undefined method $class::$name().");
|
throw new /*\*/MemberAccessException("Call to undefined method $class::$name().");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,12 +141,12 @@ abstract class DibiObject
|
|||||||
* @param string method name (in lower case!)
|
* @param string method name (in lower case!)
|
||||||
* @param array arguments
|
* @param array arguments
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ::MemberAccessException
|
* @throws \MemberAccessException
|
||||||
*/
|
*/
|
||||||
public static function __callStatic($name, $args)
|
public static function __callStatic($name, $args)
|
||||||
{
|
{
|
||||||
$class = get_called_class();
|
$class = get_called_class();
|
||||||
throw new /*::*/MemberAccessException("Call to undefined static method $class::$name().");
|
throw new /*\*/MemberAccessException("Call to undefined static method $class::$name().");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,14 +217,14 @@ abstract class DibiObject
|
|||||||
* Returns property value. Do not call directly.
|
* Returns property value. Do not call directly.
|
||||||
* @param string property name
|
* @param string property name
|
||||||
* @return mixed property value
|
* @return mixed property value
|
||||||
* @throws ::MemberAccessException if the property is not defined.
|
* @throws \MemberAccessException if the property is not defined.
|
||||||
*/
|
*/
|
||||||
public function &__get($name)
|
public function &__get($name)
|
||||||
{
|
{
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
|
|
||||||
if ($name === '') {
|
if ($name === '') {
|
||||||
throw new /*::*/MemberAccessException("Cannot read an class '$class' property without name.");
|
throw new /*\*/MemberAccessException("Cannot read an class '$class' property without name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// property getter support
|
// property getter support
|
||||||
@@ -232,7 +232,7 @@ abstract class DibiObject
|
|||||||
$m = 'get' . $name;
|
$m = 'get' . $name;
|
||||||
if (self::hasAccessor($class, $m)) {
|
if (self::hasAccessor($class, $m)) {
|
||||||
// ampersands:
|
// ampersands:
|
||||||
// - uses &__get() because declaration should be forward compatible (e.g. with Nette::Web::Html)
|
// - uses &__get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
|
||||||
// - doesn't call &$this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
|
// - doesn't call &$this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
|
||||||
$val = $this->$m();
|
$val = $this->$m();
|
||||||
return $val;
|
return $val;
|
||||||
@@ -245,7 +245,7 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$name = func_get_arg(0);
|
$name = func_get_arg(0);
|
||||||
throw new /*::*/MemberAccessException("Cannot read an undeclared property $class::\$$name.");
|
throw new /*\*/MemberAccessException("Cannot read an undeclared property $class::\$$name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -255,14 +255,14 @@ abstract class DibiObject
|
|||||||
* @param string property name
|
* @param string property name
|
||||||
* @param mixed property value
|
* @param mixed property value
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ::MemberAccessException if the property is not defined or is read-only
|
* @throws \MemberAccessException if the property is not defined or is read-only
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
|
|
||||||
if ($name === '') {
|
if ($name === '') {
|
||||||
throw new /*::*/MemberAccessException("Cannot assign to an class '$class' property without name.");
|
throw new /*\*/MemberAccessException("Cannot assign to an class '$class' property without name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// property setter support
|
// property setter support
|
||||||
@@ -275,12 +275,12 @@ abstract class DibiObject
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$name = func_get_arg(0);
|
$name = func_get_arg(0);
|
||||||
throw new /*::*/MemberAccessException("Cannot assign to a read-only property $class::\$$name.");
|
throw new /*\*/MemberAccessException("Cannot assign to a read-only property $class::\$$name.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = func_get_arg(0);
|
$name = func_get_arg(0);
|
||||||
throw new /*::*/MemberAccessException("Cannot assign to an undeclared property $class::\$$name.");
|
throw new /*\*/MemberAccessException("Cannot assign to an undeclared property $class::\$$name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -302,12 +302,12 @@ abstract class DibiObject
|
|||||||
* Access to undeclared property.
|
* Access to undeclared property.
|
||||||
* @param string property name
|
* @param string property name
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ::MemberAccessException
|
* @throws \MemberAccessException
|
||||||
*/
|
*/
|
||||||
public function __unset($name)
|
public function __unset($name)
|
||||||
{
|
{
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
throw new /*::*/MemberAccessException("Cannot unset an property $class::\$$name.");
|
throw new /*\*/MemberAccessException("Cannot unset an property $class::\$$name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<h1>Nette::Debug & dibi example</h1>
|
<h1>Nette\Debug & dibi example</h1>
|
||||||
|
|
||||||
|
|
||||||
<p>Dibi can display and log exceptions via Nette::Debug, part of Nette Framework.</p>
|
<p>Dibi can display and log exceptions via Nette\Debug, part of Nette Framework.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Nette Framework: http://nettephp.com
|
<li>Nette Framework: http://nettephp.com
|
||||||
@@ -13,7 +13,7 @@ require_once 'Nette/Debug.php';
|
|||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
// enable Nette::Debug
|
// enable Nette\Debug
|
||||||
Debug::enable();
|
Debug::enable();
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user