svn: /pear2/Exception/trunk/ RELEASE-0.2.0 src/Exception.php

From: Date: Sun, 21 Feb 2010 20:50:18 +0000
Subject: svn: /pear2/Exception/trunk/ RELEASE-0.2.0 src/Exception.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9184@lists.php.net to get a copy of this message
dufuz Sun, 21 Feb 2010 20:50:18 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295319 Log: Start work on 0.2.0: - Remove getCause as it just calls getPrevious and that's in PHP 5.3 by default - Remove getUniqueId as it not used anywhere nor what it produces Changed paths: A pear2/Exception/trunk/RELEASE-0.2.0 U pear2/Exception/trunk/src/Exception.php Added: pear2/Exception/trunk/RELEASE-0.2.0 =================================================================== --- pear2/Exception/trunk/RELEASE-0.2.0 (rev 0) +++ pear2/Exception/trunk/RELEASE-0.2.0 2010-02-21 20:50:18 UTC (rev 295319) @@ -0,0 +1,2 @@ +- Remove getCause() as it just uses the built in getPrevious() that was added in PHP 5.3 +- Remove getUniqueId as it's used anywhere \ No newline at end of file Modified: pear2/Exception/trunk/src/Exception.php =================================================================== --- pear2/Exception/trunk/src/Exception.php 2010-02-21 19:53:56 UTC (rev 295318) +++ pear2/Exception/trunk/src/Exception.php 2010-02-21 20:50:18 UTC (rev 295319) @@ -109,7 +109,6 @@ const OBSERVER_TRIGGER = -4; const OBSERVER_DIE = -8; private static $_observers = array(); - private static $_uniqueid = 0; private $_trace; /** @@ -139,9 +138,11 @@ $code = null; $cause = null; } + if (!is_string($message)) { throw new \Exception('exception message must be a string, was ' . gettype($message)); } + parent::__construct($message, $code, $cause); $this->signal(); } @@ -164,14 +165,6 @@ unset(self::$_observers[$label]); } - /** - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - private function signal() { foreach (self::$_observers as $func) { @@ -179,6 +172,7 @@ call_user_func($func, $this); continue; } + settype($func, 'array'); switch ($func[0]) { case self::OBSERVER_PRINT : @@ -200,16 +194,6 @@ } /** - * Returns the exception that caused this exception to be thrown - * @access public - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->getPrevious(); - } - - /** * Function must be public to call on caused exceptions * @param array */ @@ -220,12 +204,14 @@ 'message' => $this->message, 'file' => 'unknown', 'line' => 'unknown'); + if (isset($trace[0])) { if (isset($trace[0]['file'])) { $cause['file'] = $trace[0]['file']; $cause['line'] = $trace[0]['line']; } } + $causes[] = $cause; if ($this->getPrevious() instanceof self) { $this->getPrevious()->getCauseMessage($causes); @@ -249,7 +235,7 @@ } public function getTraceSafe() - { + { if (!isset($this->_trace)) { $this->_trace = $this->getTrace(); if (empty($this->_trace)) { @@ -304,6 +290,7 @@ if (!empty($v['class'])) { $html .= $v['class'] . $v['type']; } + $html .= $v['function']; $args = array(); if (!empty($v['args'])) { @@ -321,12 +308,14 @@ } } } + $html .= '(' . implode(', ',$args) . ')' . '</td>' . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') . ':' . (isset($v['line']) ? $v['line'] : 'unknown') . '</td></tr>' . "\n"; } + $html .= '<tr><td align="center">' . ($k+1) . '</td>' . '<td>{main}</td>' . '<td>&nbsp;</td></tr>' . "\n" @@ -344,7 +333,7 @@ . $cause['message'] . ' in ' . $cause['file'] . ' on line ' . $cause['line'] . "\n"; } + return $causeMsg . $this->getTraceAsString(); } -} -?> \ No newline at end of file +} \ No newline at end of file

« previous php.pear.core (#9184) next »