Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 12f9ef459d
Fetching contributors…

Cannot retrieve contributors at this time

file 81 lines (78 sloc) 2.662 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?xml version="1.0" encoding="UTF-8"?>
<package version="2.1" xmlns="http://pear.php.net/dtd/package-2.1" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.1 http://pear.php.net/dtd/package-2.1.xsd">
 <name>PEAR2_MultiErrors</name>
 <channel>pear2.php.net</channel>
 <summary>PEAR2_MultiErrors provides a simple and effective mechanism for aggregating many errors and organizing them by severity.
</summary>
 <description>
Errors are represented by PHP's built in exception object, and
severity levels are represented by PHP's pre-defined error levels
E_ERROR, E_WARNING, or E_NOTICE. Adding errors to the PEAR2_MultiErrors
object is simple, and done like adding to an array. Retrieving errors can
be done with iteration, and count() can be used to determine whether errors
were added.

&lt;?php
include '/path/to/PEAR2/Autoload.php';
$a = new PEAR2\MultiErrors;
$a-&gt;E_ERROR[] = new Exception('message one');
$a-&gt;E_WARNING[] = new PEAR2\Blah\Exception('message two');
// iterate over all errors
foreach ($a as $error) {...}
// iterate over E_ERROR severity
foreach ($a-&gt;E_ERROR as $error) {...}
count($a); // 2
count($a-&gt;E_ERROR); // 1
count($a-&gt;E_WARNING); // 1
count(E_NOTICE); // 0
?&gt;

Used in conjuction with PEAR2\Exception, it can also be used as a &quot;cause&quot;
of an Exception:

&lt;?php
include '/path/to/PEAR2/Autoload.php';
$a = new PEAR2\MultiErrors;
$a-&gt;E_ERROR[] = new Exception('message one');
$a-&gt;E_ERROR[] = new PEAR2\Blah\Exception('message two');
throw new PEAR2\My\Exception('task failed', $a);
?&gt;</description>
 <lead>
  <name>Gregory Beaver</name>
  <user>cellog</user>
  <email>cellog@php.net</email>
  <active>yes</active>
 </lead>
 <date>2011-09-14</date>
 <time>13:29:25</time>
 <version>
  <release>0.2.0</release>
  <api>0.1.0</api>
 </version>
 <stability>
  <release>alpha</release>
  <api>alpha</api>
 </stability>
 <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license>
 <notes>Convert namespace to PEAR2</notes>
 <contents>
  <dir name="/">
   <dir name="src" baseinstalldir="/">
    <dir name="PEAR2">
     <dir name="MultiErrors">
      <file role="php" name="Exception.php"/>
     </dir>
     <file role="php" name="MultiErrors.php"/>
    </dir>
   </dir>
  </dir>
 </contents>
 <dependencies>
  <required>
   <php>
    <min>5.2.0</min>
   </php>
   <pearinstaller>
    <min>2.0.0a1</min>
   </pearinstaller>
  </required>
 </dependencies>
 <phprelease/>
</package>
Something went wrong with that request. Please try again.