+ */
+class HtmlFormatter extends NormalizerFormatter
+{
+ /**
+ * Translates Monolog log levels to html color priorities.
+ */
+ private $logLevels = array(
+ Logger::DEBUG => '#cccccc',
+ Logger::INFO => '#468847',
+ Logger::NOTICE => '#3a87ad',
+ Logger::WARNING => '#c09853',
+ Logger::ERROR => '#f0ad4e',
+ Logger::CRITICAL => '#FF7708',
+ Logger::ALERT => '#C12A19',
+ Logger::EMERGENCY => '#000000',
+ );
+
+ /**
+ * @param string $dateFormat The format of the timestamp: one supported by DateTime::format
+ */
+ public function __construct($dateFormat = null)
+ {
+ parent::__construct($dateFormat);
+ }
+
+ /**
+ * Creates an HTML table row
+ *
+ * @param string $th Row header content
+ * @param string $td Row standard cell content
+ * @return string
+ */
+ private function addRow($th, $td = ' ')
+ {
+ $th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8');
+ $td = ''.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
';
+
+ return "\n$th: | \n".$td." | \n
";
+ }
+
+ /**
+ * Create a HTML h1 tag
+ *
+ * @param string $title Text to be in the h1
+ * @param integer $level Error level
+ * @return string
+ */
+ private function addTitle($title, $level)
+ {
+ $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8');
+
+ return ''.$title.'
';
+ }
+ /**
+ * Formats a log record.
+ *
+ * @param array $record A record to format
+ * @return mixed The formatted record
+ */
+ public function format(array $record)
+ {
+ $output = $this->addTitle($record['level_name'], $record['level']);
+ $output .= '';
+
+ $output .= $this->addRow('Message', (string) $record['message']);
+ $output .= $this->addRow('Time', $record['datetime']->format('Y-m-d\TH:i:s.uO'));
+ $output .= $this->addRow('Channel', $record['channel']);
+ if ($record['context']) {
+ $output .= $this->addRow('Context', $this->convertToString($record['context']));
+ }
+ if ($record['extra']) {
+ $output .= $this->addRow('Extra', $this->convertToString($record['extra']));
+ }
+
+ return $output.'
';
+ }
+
+ /**
+ * Formats a set of log records.
+ *
+ * @param array $records A set of records to format
+ * @return mixed The formatted set of records
+ */
+ public function formatBatch(array $records)
+ {
+ $message = '';
+ foreach ($records as $record) {
+ $message .= $this->format($record);
+ }
+
+ return $message;
+ }
+
+ protected function convertToString($data)
+ {
+ if (null === $data || is_scalar($data)) {
+ return (string) $data;
+ }
+
+ $data = $this->normalize($data);
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ }
+
+ return str_replace('\\/', '/', json_encode($data));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
new file mode 100644
index 00000000..ac6f58c0
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
@@ -0,0 +1,116 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * Encodes whatever record data is passed to it as json
+ *
+ * This can be useful to log to databases or remote APIs
+ *
+ * @author Jordi Boggiano
+ */
+class JsonFormatter implements FormatterInterface
+{
+ protected $batchMode;
+ protected $appendNewline;
+
+ const BATCH_MODE_JSON = 1;
+ const BATCH_MODE_NEWLINES = 2;
+
+ /**
+ * @param int $batchMode
+ */
+ public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true)
+ {
+ $this->batchMode = $batchMode;
+ $this->appendNewline = $appendNewline;
+ }
+
+ /**
+ * The batch mode option configures the formatting style for
+ * multiple records. By default, multiple records will be
+ * formatted as a JSON-encoded array. However, for
+ * compatibility with some API endpoints, alternive styles
+ * are available.
+ *
+ * @return int
+ */
+ public function getBatchMode()
+ {
+ return $this->batchMode;
+ }
+
+ /**
+ * True if newlines are appended to every formatted record
+ *
+ * @return bool
+ */
+ public function isAppendingNewlines()
+ {
+ return $this->appendNewline;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ return json_encode($record) . ($this->appendNewline ? "\n" : '');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function formatBatch(array $records)
+ {
+ switch ($this->batchMode) {
+ case static::BATCH_MODE_NEWLINES:
+ return $this->formatBatchNewlines($records);
+
+ case static::BATCH_MODE_JSON:
+ default:
+ return $this->formatBatchJson($records);
+ }
+ }
+
+ /**
+ * Return a JSON-encoded array of records.
+ *
+ * @param array $records
+ * @return string
+ */
+ protected function formatBatchJson(array $records)
+ {
+ return json_encode($records);
+ }
+
+ /**
+ * Use new lines to separate records instead of a
+ * JSON-encoded array.
+ *
+ * @param array $records
+ * @return string
+ */
+ protected function formatBatchNewlines(array $records)
+ {
+ $instance = $this;
+
+ $oldNewline = $this->appendNewline;
+ $this->appendNewline = false;
+ array_walk($records, function (&$value, $key) use ($instance) {
+ $value = $instance->format($value);
+ });
+ $this->appendNewline = $oldNewline;
+
+ return implode("\n", $records);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
new file mode 100644
index 00000000..9ef0a645
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
@@ -0,0 +1,113 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Exception;
+
+/**
+ * Formats incoming records into a one-line string
+ *
+ * This is especially useful for logging to files
+ *
+ * @author Jordi Boggiano
+ * @author Christophe Coevoet
+ */
+class LineFormatter extends NormalizerFormatter
+{
+ const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
+
+ protected $format;
+ protected $allowInlineLineBreaks;
+
+ /**
+ * @param string $format The format of the message
+ * @param string $dateFormat The format of the timestamp: one supported by DateTime::format
+ * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
+ */
+ public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false)
+ {
+ $this->format = $format ?: static::SIMPLE_FORMAT;
+ $this->allowInlineLineBreaks = $allowInlineLineBreaks;
+ parent::__construct($dateFormat);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ $vars = parent::format($record);
+
+ $output = $this->format;
+ foreach ($vars['extra'] as $var => $val) {
+ if (false !== strpos($output, '%extra.'.$var.'%')) {
+ $output = str_replace('%extra.'.$var.'%', $this->replaceNewlines($this->convertToString($val)), $output);
+ unset($vars['extra'][$var]);
+ }
+ }
+ foreach ($vars as $var => $val) {
+ if (false !== strpos($output, '%'.$var.'%')) {
+ $output = str_replace('%'.$var.'%', $this->replaceNewlines($this->convertToString($val)), $output);
+ }
+ }
+
+ return $output;
+ }
+
+ public function formatBatch(array $records)
+ {
+ $message = '';
+ foreach ($records as $record) {
+ $message .= $this->format($record);
+ }
+
+ return $message;
+ }
+
+ protected function normalizeException(Exception $e)
+ {
+ $previousText = '';
+ if ($previous = $e->getPrevious()) {
+ do {
+ $previousText .= ', '.get_class($previous).': '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
+ } while ($previous = $previous->getPrevious());
+ }
+
+ return '[object] ('.get_class($e).': '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
+ }
+
+ protected function convertToString($data)
+ {
+ if (null === $data || is_bool($data)) {
+ return var_export($data, true);
+ }
+
+ if (is_scalar($data)) {
+ return (string) $data;
+ }
+
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return $this->toJson($data, true);
+ }
+
+ return str_replace('\\/', '/', @json_encode($data));
+ }
+
+ protected function replaceNewlines($str)
+ {
+ if ($this->allowInlineLineBreaks) {
+ return $str;
+ }
+
+ return preg_replace('{[\r\n]+}', ' ', $str);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
new file mode 100644
index 00000000..5ef0d9fa
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * Encodes message information into JSON in a format compatible with Loggly.
+ *
+ * @author Adam Pancutt
+ */
+class LogglyFormatter extends JsonFormatter
+{
+ /**
+ * Overrides the default batch mode to new lines for compatibility with the
+ * Loggly bulk API.
+ *
+ * @param integer $batchMode
+ */
+ public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false)
+ {
+ parent::__construct($batchMode, $appendNewline);
+ }
+
+ /**
+ * Appends the 'timestamp' parameter for indexing by Loggly.
+ *
+ * @see https://www.loggly.com/docs/automated-parsing/#json
+ * @see \Monolog\Formatter\JsonFormatter::format()
+ */
+ public function format(array $record)
+ {
+ if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) {
+ $record["timestamp"] = $record["datetime"]->format("c");
+ // TODO 2.0 unset the 'datetime' parameter, retained for BC
+ }
+
+ return parent::format($record);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
new file mode 100644
index 00000000..7a7b3b3c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
@@ -0,0 +1,165 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * Serializes a log message to Logstash Event Format
+ *
+ * @see http://logstash.net/
+ * @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb
+ *
+ * @author Tim Mower
+ */
+class LogstashFormatter extends NormalizerFormatter
+{
+ const V0 = 0;
+ const V1 = 1;
+
+ /**
+ * @var string the name of the system for the Logstash log message, used to fill the @source field
+ */
+ protected $systemName;
+
+ /**
+ * @var string an application name for the Logstash log message, used to fill the @type field
+ */
+ protected $applicationName;
+
+ /**
+ * @var string a prefix for 'extra' fields from the Monolog record (optional)
+ */
+ protected $extraPrefix;
+
+ /**
+ * @var string a prefix for 'context' fields from the Monolog record (optional)
+ */
+ protected $contextPrefix;
+
+ /**
+ * @var integer logstash format version to use
+ */
+ protected $version;
+
+ /**
+ * @param string $applicationName the application that sends the data, used as the "type" field of logstash
+ * @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
+ * @param string $extraPrefix prefix for extra keys inside logstash "fields"
+ * @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_
+ */
+ public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0)
+ {
+ // logstash requires a ISO 8601 format date with optional millisecond precision.
+ parent::__construct('Y-m-d\TH:i:s.uP');
+
+ $this->systemName = $systemName ?: gethostname();
+ $this->applicationName = $applicationName;
+ $this->extraPrefix = $extraPrefix;
+ $this->contextPrefix = $contextPrefix;
+ $this->version = $version;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ $record = parent::format($record);
+
+ if ($this->version === self::V1) {
+ $message = $this->formatV1($record);
+ } else {
+ $message = $this->formatV0($record);
+ }
+
+ return $this->toJson($message) . "\n";
+ }
+
+ protected function formatV0(array $record)
+ {
+ if (empty($record['datetime'])) {
+ $record['datetime'] = gmdate('c');
+ }
+ $message = array(
+ '@timestamp' => $record['datetime'],
+ '@source' => $this->systemName,
+ '@fields' => array()
+ );
+ if (isset($record['message'])) {
+ $message['@message'] = $record['message'];
+ }
+ if (isset($record['channel'])) {
+ $message['@tags'] = array($record['channel']);
+ $message['@fields']['channel'] = $record['channel'];
+ }
+ if (isset($record['level'])) {
+ $message['@fields']['level'] = $record['level'];
+ }
+ if ($this->applicationName) {
+ $message['@type'] = $this->applicationName;
+ }
+ if (isset($record['extra']['server'])) {
+ $message['@source_host'] = $record['extra']['server'];
+ }
+ if (isset($record['extra']['url'])) {
+ $message['@source_path'] = $record['extra']['url'];
+ }
+ if (!empty($record['extra'])) {
+ foreach ($record['extra'] as $key => $val) {
+ $message['@fields'][$this->extraPrefix . $key] = $val;
+ }
+ }
+ if (!empty($record['context'])) {
+ foreach ($record['context'] as $key => $val) {
+ $message['@fields'][$this->contextPrefix . $key] = $val;
+ }
+ }
+
+ return $message;
+ }
+
+ protected function formatV1(array $record)
+ {
+ if (empty($record['datetime'])) {
+ $record['datetime'] = gmdate('c');
+ }
+ $message = array(
+ '@timestamp' => $record['datetime'],
+ '@version' => 1,
+ 'host' => $this->systemName,
+ );
+ if (isset($record['message'])) {
+ $message['message'] = $record['message'];
+ }
+ if (isset($record['channel'])) {
+ $message['type'] = $record['channel'];
+ $message['channel'] = $record['channel'];
+ }
+ if (isset($record['level_name'])) {
+ $message['level'] = $record['level_name'];
+ }
+ if ($this->applicationName) {
+ $message['type'] = $this->applicationName;
+ }
+ if (!empty($record['extra'])) {
+ foreach ($record['extra'] as $key => $val) {
+ $message[$this->extraPrefix . $key] = $val;
+ }
+ }
+ if (!empty($record['context'])) {
+ foreach ($record['context'] as $key => $val) {
+ $message[$this->contextPrefix . $key] = $val;
+ }
+ }
+
+ return $message;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
new file mode 100644
index 00000000..dfa3cb91
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
@@ -0,0 +1,136 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Exception;
+
+/**
+ * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
+ *
+ * @author Jordi Boggiano
+ */
+class NormalizerFormatter implements FormatterInterface
+{
+ const SIMPLE_DATE = "Y-m-d H:i:s";
+
+ protected $dateFormat;
+
+ /**
+ * @param string $dateFormat The format of the timestamp: one supported by DateTime::format
+ */
+ public function __construct($dateFormat = null)
+ {
+ $this->dateFormat = $dateFormat ?: static::SIMPLE_DATE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ return $this->normalize($record);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function formatBatch(array $records)
+ {
+ foreach ($records as $key => $record) {
+ $records[$key] = $this->format($record);
+ }
+
+ return $records;
+ }
+
+ protected function normalize($data)
+ {
+ if (null === $data || is_scalar($data)) {
+ return $data;
+ }
+
+ if (is_array($data) || $data instanceof \Traversable) {
+ $normalized = array();
+
+ $count = 1;
+ foreach ($data as $key => $value) {
+ if ($count++ >= 1000) {
+ $normalized['...'] = 'Over 1000 items, aborting normalization';
+ break;
+ }
+ $normalized[$key] = $this->normalize($value);
+ }
+
+ return $normalized;
+ }
+
+ if ($data instanceof \DateTime) {
+ return $data->format($this->dateFormat);
+ }
+
+ if (is_object($data)) {
+ if ($data instanceof Exception) {
+ return $this->normalizeException($data);
+ }
+
+ return sprintf("[object] (%s: %s)", get_class($data), $this->toJson($data, true));
+ }
+
+ if (is_resource($data)) {
+ return '[resource]';
+ }
+
+ return '[unknown('.gettype($data).')]';
+ }
+
+ protected function normalizeException(Exception $e)
+ {
+ $data = array(
+ 'class' => get_class($e),
+ 'message' => $e->getMessage(),
+ 'file' => $e->getFile().':'.$e->getLine(),
+ );
+
+ $trace = $e->getTrace();
+ foreach ($trace as $frame) {
+ if (isset($frame['file'])) {
+ $data['trace'][] = $frame['file'].':'.$frame['line'];
+ } else {
+ $data['trace'][] = json_encode($frame);
+ }
+ }
+
+ if ($previous = $e->getPrevious()) {
+ $data['previous'] = $this->normalizeException($previous);
+ }
+
+ return $data;
+ }
+
+ protected function toJson($data, $ignoreErrors = false)
+ {
+ // suppress json_encode errors since it's twitchy with some inputs
+ if ($ignoreErrors) {
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return @json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ }
+
+ return @json_encode($data);
+ }
+
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ }
+
+ return json_encode($data);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php
new file mode 100644
index 00000000..5d345d53
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php
@@ -0,0 +1,48 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * Formats data into an associative array of scalar values.
+ * Objects and arrays will be JSON encoded.
+ *
+ * @author Andrew Lawson
+ */
+class ScalarFormatter extends NormalizerFormatter
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ foreach ($record as $key => $value) {
+ $record[$key] = $this->normalizeValue($value);
+ }
+
+ return $record;
+ }
+
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function normalizeValue($value)
+ {
+ $normalized = $this->normalize($value);
+
+ if (is_array($normalized) || is_object($normalized)) {
+ return $this->toJson($normalized, true);
+ }
+
+ return $normalized;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
new file mode 100644
index 00000000..654710a8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
@@ -0,0 +1,113 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+/**
+ * Serializes a log message according to Wildfire's header requirements
+ *
+ * @author Eric Clemmons (@ericclemmons)
+ * @author Christophe Coevoet
+ * @author Kirill chEbba Chebunin
+ */
+class WildfireFormatter extends NormalizerFormatter
+{
+ const TABLE = 'table';
+
+ /**
+ * Translates Monolog log levels to Wildfire levels.
+ */
+ private $logLevels = array(
+ Logger::DEBUG => 'LOG',
+ Logger::INFO => 'INFO',
+ Logger::NOTICE => 'INFO',
+ Logger::WARNING => 'WARN',
+ Logger::ERROR => 'ERROR',
+ Logger::CRITICAL => 'ERROR',
+ Logger::ALERT => 'ERROR',
+ Logger::EMERGENCY => 'ERROR',
+ );
+
+ /**
+ * {@inheritdoc}
+ */
+ public function format(array $record)
+ {
+ // Retrieve the line and file if set and remove them from the formatted extra
+ $file = $line = '';
+ if (isset($record['extra']['file'])) {
+ $file = $record['extra']['file'];
+ unset($record['extra']['file']);
+ }
+ if (isset($record['extra']['line'])) {
+ $line = $record['extra']['line'];
+ unset($record['extra']['line']);
+ }
+
+ $record = $this->normalize($record);
+ $message = array('message' => $record['message']);
+ $handleError = false;
+ if ($record['context']) {
+ $message['context'] = $record['context'];
+ $handleError = true;
+ }
+ if ($record['extra']) {
+ $message['extra'] = $record['extra'];
+ $handleError = true;
+ }
+ if (count($message) === 1) {
+ $message = reset($message);
+ }
+
+ if (isset($record['context'][self::TABLE])) {
+ $type = 'TABLE';
+ $label = $record['channel'] .': '. $record['message'];
+ $message = $record['context'][self::TABLE];
+ } else {
+ $type = $this->logLevels[$record['level']];
+ $label = $record['channel'];
+ }
+
+ // Create JSON object describing the appearance of the message in the console
+ $json = $this->toJson(array(
+ array(
+ 'Type' => $type,
+ 'File' => $file,
+ 'Line' => $line,
+ 'Label' => $label,
+ ),
+ $message,
+ ), $handleError);
+
+ // The message itself is a serialization of the above JSON object + it's length
+ return sprintf(
+ '%s|%s|',
+ strlen($json),
+ $json
+ );
+ }
+
+ public function formatBatch(array $records)
+ {
+ throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter');
+ }
+
+ protected function normalize($data)
+ {
+ if (is_object($data) && !$data instanceof \DateTime) {
+ return $data;
+ }
+
+ return parent::normalize($data);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
new file mode 100644
index 00000000..3bb21b71
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
@@ -0,0 +1,184 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Base Handler class providing the Handler structure
+ *
+ * @author Jordi Boggiano
+ */
+abstract class AbstractHandler implements HandlerInterface
+{
+ protected $level = Logger::DEBUG;
+ protected $bubble = true;
+
+ /**
+ * @var FormatterInterface
+ */
+ protected $formatter;
+ protected $processors = array();
+
+ /**
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($level = Logger::DEBUG, $bubble = true)
+ {
+ $this->level = $level;
+ $this->bubble = $bubble;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isHandling(array $record)
+ {
+ return $record['level'] >= $this->level;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ foreach ($records as $record) {
+ $this->handle($record);
+ }
+ }
+
+ /**
+ * Closes the handler.
+ *
+ * This will be called automatically when the object is destroyed
+ */
+ public function close()
+ {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function pushProcessor($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
+ }
+ array_unshift($this->processors, $callback);
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function popProcessor()
+ {
+ if (!$this->processors) {
+ throw new \LogicException('You tried to pop from an empty processor stack.');
+ }
+
+ return array_shift($this->processors);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ $this->formatter = $formatter;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormatter()
+ {
+ if (!$this->formatter) {
+ $this->formatter = $this->getDefaultFormatter();
+ }
+
+ return $this->formatter;
+ }
+
+ /**
+ * Sets minimum logging level at which this handler will be triggered.
+ *
+ * @param integer $level
+ * @return self
+ */
+ public function setLevel($level)
+ {
+ $this->level = $level;
+
+ return $this;
+ }
+
+ /**
+ * Gets minimum logging level at which this handler will be triggered.
+ *
+ * @return integer
+ */
+ public function getLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Sets the bubbling behavior.
+ *
+ * @param Boolean $bubble true means that this handler allows bubbling.
+ * false means that bubbling is not permitted.
+ * @return self
+ */
+ public function setBubble($bubble)
+ {
+ $this->bubble = $bubble;
+
+ return $this;
+ }
+
+ /**
+ * Gets the bubbling behavior.
+ *
+ * @return Boolean true means that this handler allows bubbling.
+ * false means that bubbling is not permitted.
+ */
+ public function getBubble()
+ {
+ return $this->bubble;
+ }
+
+ public function __destruct()
+ {
+ try {
+ $this->close();
+ } catch (\Exception $e) {
+ // do nothing
+ }
+ }
+
+ /**
+ * Gets the default formatter.
+ *
+ * @return FormatterInterface
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
new file mode 100644
index 00000000..6f18f72e
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
@@ -0,0 +1,66 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+/**
+ * Base Handler class providing the Handler structure
+ *
+ * Classes extending it should (in most cases) only implement write($record)
+ *
+ * @author Jordi Boggiano
+ * @author Christophe Coevoet
+ */
+abstract class AbstractProcessingHandler extends AbstractHandler
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if (!$this->isHandling($record)) {
+ return false;
+ }
+
+ $record = $this->processRecord($record);
+
+ $record['formatted'] = $this->getFormatter()->format($record);
+
+ $this->write($record);
+
+ return false === $this->bubble;
+ }
+
+ /**
+ * Writes the record down to the log of the implementing handler
+ *
+ * @param array $record
+ * @return void
+ */
+ abstract protected function write(array $record);
+
+ /**
+ * Processes a record.
+ *
+ * @param array $record
+ * @return array
+ */
+ protected function processRecord(array $record)
+ {
+ if ($this->processors) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ }
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
new file mode 100644
index 00000000..3eb83bd4
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
@@ -0,0 +1,92 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Common syslog functionality
+ */
+abstract class AbstractSyslogHandler extends AbstractProcessingHandler
+{
+ protected $facility;
+
+ /**
+ * Translates Monolog log levels to syslog log priorities.
+ */
+ protected $logLevels = array(
+ Logger::DEBUG => LOG_DEBUG,
+ Logger::INFO => LOG_INFO,
+ Logger::NOTICE => LOG_NOTICE,
+ Logger::WARNING => LOG_WARNING,
+ Logger::ERROR => LOG_ERR,
+ Logger::CRITICAL => LOG_CRIT,
+ Logger::ALERT => LOG_ALERT,
+ Logger::EMERGENCY => LOG_EMERG,
+ );
+
+ /**
+ * List of valid log facility names.
+ */
+ protected $facilities = array(
+ 'auth' => LOG_AUTH,
+ 'authpriv' => LOG_AUTHPRIV,
+ 'cron' => LOG_CRON,
+ 'daemon' => LOG_DAEMON,
+ 'kern' => LOG_KERN,
+ 'lpr' => LOG_LPR,
+ 'mail' => LOG_MAIL,
+ 'news' => LOG_NEWS,
+ 'syslog' => LOG_SYSLOG,
+ 'user' => LOG_USER,
+ 'uucp' => LOG_UUCP,
+ );
+
+ /**
+ * @param mixed $facility
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+
+ if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
+ $this->facilities['local0'] = LOG_LOCAL0;
+ $this->facilities['local1'] = LOG_LOCAL1;
+ $this->facilities['local2'] = LOG_LOCAL2;
+ $this->facilities['local3'] = LOG_LOCAL3;
+ $this->facilities['local4'] = LOG_LOCAL4;
+ $this->facilities['local5'] = LOG_LOCAL5;
+ $this->facilities['local6'] = LOG_LOCAL6;
+ $this->facilities['local7'] = LOG_LOCAL7;
+ }
+
+ // convert textual description of facility to syslog constant
+ if (array_key_exists(strtolower($facility), $this->facilities)) {
+ $facility = $this->facilities[strtolower($facility)];
+ } elseif (!in_array($facility, array_values($this->facilities), true)) {
+ throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
+ }
+
+ $this->facility = $facility;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
new file mode 100644
index 00000000..2db0d08d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
@@ -0,0 +1,69 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\JsonFormatter;
+
+class AmqpHandler extends AbstractProcessingHandler
+{
+ /**
+ * @var \AMQPExchange $exchange
+ */
+ protected $exchange;
+
+ /**
+ * @param \AMQPExchange $exchange AMQP exchange, ready for use
+ * @param string $exchangeName
+ * @param int $level
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true)
+ {
+ $this->exchange = $exchange;
+ $this->exchange->setName($exchangeName);
+
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ $data = $record["formatted"];
+
+ $routingKey = sprintf(
+ '%s.%s',
+ substr($record['level_name'], 0, 4),
+ $record['channel']
+ );
+
+ $this->exchange->publish(
+ $data,
+ strtolower($routingKey),
+ 0,
+ array(
+ 'delivery_mode' => 2,
+ 'Content-type' => 'application/json'
+ )
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
new file mode 100644
index 00000000..43190b92
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
@@ -0,0 +1,184 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Handler sending logs to browser's javascript console with no browser extension required
+ *
+ * @author Olivier Poitrey
+ */
+class BrowserConsoleHandler extends AbstractProcessingHandler
+{
+ protected static $initialized = false;
+ protected static $records = array();
+
+ /**
+ * {@inheritDoc}
+ *
+ * Formatted output may contain some formatting markers to be transfered to `console.log` using the %c format.
+ *
+ * Example of formatted string:
+ *
+ * You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white}
+ *
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter('[[%channel%]]{macro: autolabel} [[%level_name%]]{font-weight: bold} %message%');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ // Accumulate records
+ self::$records[] = $record;
+
+ // Register shutdown handler if not already done
+ if (PHP_SAPI !== 'cli' && !self::$initialized) {
+ self::$initialized = true;
+ register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send'));
+ }
+ }
+
+ /**
+ * Convert records to javascript console commands and send it to the browser.
+ * This method is automatically called on PHP shutdown if output is HTML.
+ */
+ public static function send()
+ {
+ // Check content type
+ foreach (headers_list() as $header) {
+ if (stripos($header, 'content-type:') === 0) {
+ if (stripos($header, 'text/html') === false) {
+ // This handler only works with HTML outputs
+ return;
+ }
+ break;
+ }
+ }
+
+ if (count(self::$records)) {
+ echo '';
+ self::reset();
+ }
+ }
+
+ /**
+ * Forget all logged records
+ */
+ public static function reset()
+ {
+ self::$records = array();
+ }
+
+ private static function generateScript()
+ {
+ $script = array();
+ foreach (self::$records as $record) {
+ $context = self::dump('Context', $record['context']);
+ $extra = self::dump('Extra', $record['extra']);
+
+ if (empty($context) && empty($extra)) {
+ $script[] = self::call_array('log', self::handleStyles($record['formatted']));
+ } else {
+ $script = array_merge($script,
+ array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))),
+ $context,
+ $extra,
+ array(self::call('groupEnd'))
+ );
+ }
+ }
+
+ return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);";
+ }
+
+ private static function handleStyles($formatted)
+ {
+ $args = array(self::quote('font-weight: normal'));
+ $format = '%c' . $formatted;
+ preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
+
+ foreach (array_reverse($matches) as $match) {
+ $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0]));
+ $args[] = '"font-weight: normal"';
+
+ $pos = $match[0][1];
+ $format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0]));
+ }
+
+ array_unshift($args, self::quote($format));
+
+ return $args;
+ }
+
+ private static function handleCustomStyles($style, $string)
+ {
+ static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey');
+ static $labels = array();
+
+ return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) {
+ if (trim($m[1]) === 'autolabel') {
+ // Format the string as a label with consistent auto assigned background color
+ if (!isset($labels[$string])) {
+ $labels[$string] = $colors[count($labels) % count($colors)];
+ }
+ $color = $labels[$string];
+
+ return "background-color: $color; color: white; border-radius: 3px; padding: 0 2px 0 2px";
+ }
+
+ return $m[1];
+ }, $style);
+ }
+
+ private static function dump($title, array $dict)
+ {
+ $script = array();
+ $dict = array_filter($dict);
+ if (empty($dict)) {
+ return $script;
+ }
+ $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title));
+ foreach ($dict as $key => $value) {
+ $value = json_encode($value);
+ if (empty($value)) {
+ $value = self::quote('');
+ }
+ $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value);
+ }
+
+ return $script;
+ }
+
+ private static function quote($arg)
+ {
+ return '"' . addcslashes($arg, "\"\n") . '"';
+ }
+
+ private static function call()
+ {
+ $args = func_get_args();
+ $method = array_shift($args);
+
+ return self::call_array($method, $args);
+ }
+
+ private static function call_array($method, array $args)
+ {
+ return 'c.' . $method . '(' . implode(', ', $args) . ');';
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
new file mode 100644
index 00000000..183d239a
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
@@ -0,0 +1,102 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Buffers all records until closing the handler and then pass them as batch.
+ *
+ * This is useful for a MailHandler to send only one mail per request instead of
+ * sending one per log message.
+ *
+ * @author Christophe Coevoet
+ */
+class BufferHandler extends AbstractHandler
+{
+ protected $handler;
+ protected $bufferSize = 0;
+ protected $bufferLimit;
+ protected $flushOnOverflow;
+ protected $buffer = array();
+ protected $initialized = false;
+
+ /**
+ * @param HandlerInterface $handler Handler.
+ * @param integer $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded
+ */
+ public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false)
+ {
+ parent::__construct($level, $bubble);
+ $this->handler = $handler;
+ $this->bufferLimit = (int) $bufferLimit;
+ $this->flushOnOverflow = $flushOnOverflow;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if ($record['level'] < $this->level) {
+ return false;
+ }
+
+ if (!$this->initialized) {
+ // __destructor() doesn't get called on Fatal errors
+ register_shutdown_function(array($this, 'close'));
+ $this->initialized = true;
+ }
+
+ if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) {
+ if ($this->flushOnOverflow) {
+ $this->flush();
+ } else {
+ array_shift($this->buffer);
+ $this->bufferSize--;
+ }
+ }
+
+ if ($this->processors) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ }
+
+ $this->buffer[] = $record;
+ $this->bufferSize++;
+
+ return false === $this->bubble;
+ }
+
+ public function flush()
+ {
+ if ($this->bufferSize === 0) {
+ return;
+ }
+
+ $this->handler->handleBatch($this->buffer);
+ $this->bufferSize = 0;
+ $this->buffer = array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $this->flush();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
new file mode 100644
index 00000000..ff7a7809
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
@@ -0,0 +1,192 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\ChromePHPFormatter;
+use Monolog\Logger;
+
+/**
+ * Handler sending logs to the ChromePHP extension (http://www.chromephp.com/)
+ *
+ * @author Christophe Coevoet
+ */
+class ChromePHPHandler extends AbstractProcessingHandler
+{
+ /**
+ * Version of the extension
+ */
+ const VERSION = '4.0';
+
+ /**
+ * Header name
+ */
+ const HEADER_NAME = 'X-ChromeLogger-Data';
+
+ protected static $initialized = false;
+
+ /**
+ * Tracks whether we sent too much data
+ *
+ * Chrome limits the headers to 256KB, so when we sent 240KB we stop sending
+ *
+ * @var Boolean
+ */
+ protected static $overflowed = false;
+
+ protected static $json = array(
+ 'version' => self::VERSION,
+ 'columns' => array('label', 'log', 'backtrace', 'type'),
+ 'rows' => array(),
+ );
+
+ protected static $sendHeaders = true;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ $messages = array();
+
+ foreach ($records as $record) {
+ if ($record['level'] < $this->level) {
+ continue;
+ }
+ $messages[] = $this->processRecord($record);
+ }
+
+ if (!empty($messages)) {
+ $messages = $this->getFormatter()->formatBatch($messages);
+ self::$json['rows'] = array_merge(self::$json['rows'], $messages);
+ $this->send();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new ChromePHPFormatter();
+ }
+
+ /**
+ * Creates & sends header for a record
+ *
+ * @see sendHeader()
+ * @see send()
+ * @param array $record
+ */
+ protected function write(array $record)
+ {
+ self::$json['rows'][] = $record['formatted'];
+
+ $this->send();
+ }
+
+ /**
+ * Sends the log header
+ *
+ * @see sendHeader()
+ */
+ protected function send()
+ {
+ if (self::$overflowed || !self::$sendHeaders) {
+ return;
+ }
+
+ if (!self::$initialized) {
+ self::$initialized = true;
+
+ self::$sendHeaders = $this->headersAccepted();
+ if (!self::$sendHeaders) {
+ return;
+ }
+
+ self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
+ }
+
+ $json = @json_encode(self::$json);
+ $data = base64_encode(utf8_encode($json));
+ if (strlen($data) > 240*1024) {
+ self::$overflowed = true;
+
+ $record = array(
+ 'message' => 'Incomplete logs, chrome header size limit reached',
+ 'context' => array(),
+ 'level' => Logger::WARNING,
+ 'level_name' => Logger::getLevelName(Logger::WARNING),
+ 'channel' => 'monolog',
+ 'datetime' => new \DateTime(),
+ 'extra' => array(),
+ );
+ self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
+ $json = @json_encode(self::$json);
+ $data = base64_encode(utf8_encode($json));
+ }
+
+ if (trim($data) !== '') {
+ $this->sendHeader(self::HEADER_NAME, $data);
+ }
+ }
+
+ /**
+ * Send header string to the client
+ *
+ * @param string $header
+ * @param string $content
+ */
+ protected function sendHeader($header, $content)
+ {
+ if (!headers_sent() && self::$sendHeaders) {
+ header(sprintf('%s: %s', $header, $content));
+ }
+ }
+
+ /**
+ * Verifies if the headers are accepted by the current user agent
+ *
+ * @return Boolean
+ */
+ protected function headersAccepted()
+ {
+ if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ return false;
+ }
+
+ return preg_match('{\bChrome/\d+[\.\d+]*\b}', $_SERVER['HTTP_USER_AGENT']);
+ }
+
+ /**
+ * BC getter for the sendHeaders property that has been made static
+ */
+ public function __get($property)
+ {
+ if ('sendHeaders' !== $property) {
+ throw new \InvalidArgumentException('Undefined property '.$property);
+ }
+
+ return static::$sendHeaders;
+ }
+
+ /**
+ * BC setter for the sendHeaders property that has been made static
+ */
+ public function __set($property, $value)
+ {
+ if ('sendHeaders' !== $property) {
+ throw new \InvalidArgumentException('Undefined property '.$property);
+ }
+
+ static::$sendHeaders = $value;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
new file mode 100644
index 00000000..b3687c3d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
@@ -0,0 +1,72 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\JsonFormatter;
+use Monolog\Logger;
+
+/**
+ * CouchDB handler
+ *
+ * @author Markus Bachmann
+ */
+class CouchDBHandler extends AbstractProcessingHandler
+{
+ private $options;
+
+ public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true)
+ {
+ $this->options = array_merge(array(
+ 'host' => 'localhost',
+ 'port' => 5984,
+ 'dbname' => 'logger',
+ 'username' => null,
+ 'password' => null,
+ ), $options);
+
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ $basicAuth = null;
+ if ($this->options['username']) {
+ $basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']);
+ }
+
+ $url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname'];
+ $context = stream_context_create(array(
+ 'http' => array(
+ 'method' => 'POST',
+ 'content' => $record['formatted'],
+ 'ignore_errors' => true,
+ 'max_redirects' => 0,
+ 'header' => 'Content-type: application/json',
+ )
+ ));
+
+ if (false === @file_get_contents($url, null, $context)) {
+ throw new \RuntimeException(sprintf('Could not connect to %s', $url));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
new file mode 100644
index 00000000..d968720c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
@@ -0,0 +1,145 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Logs to Cube.
+ *
+ * @link http://square.github.com/cube/
+ * @author Wan Chen
+ */
+class CubeHandler extends AbstractProcessingHandler
+{
+ private $udpConnection = null;
+ private $httpConnection = null;
+ private $scheme = null;
+ private $host = null;
+ private $port = null;
+ private $acceptedSchemes = array('http', 'udp');
+
+ /**
+ * Create a Cube handler
+ *
+ * @throws UnexpectedValueException when given url is not a valid url.
+ * A valid url must consists of three parts : protocol://host:port
+ * Only valid protocol used by Cube are http and udp
+ */
+ public function __construct($url, $level = Logger::DEBUG, $bubble = true)
+ {
+ $urlInfos = parse_url($url);
+
+ if (!isset($urlInfos['scheme']) || !isset($urlInfos['host']) || !isset($urlInfos['port'])) {
+ throw new \UnexpectedValueException('URL "'.$url.'" is not valid');
+ }
+
+ if (!in_array($urlInfos['scheme'], $this->acceptedSchemes)) {
+ throw new \UnexpectedValueException(
+ 'Invalid protocol (' . $urlInfos['scheme'] . ').'
+ . ' Valid options are ' . implode(', ', $this->acceptedSchemes));
+ }
+
+ $this->scheme = $urlInfos['scheme'];
+ $this->host = $urlInfos['host'];
+ $this->port = $urlInfos['port'];
+
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * Establish a connection to an UDP socket
+ *
+ * @throws LogicException when unable to connect to the socket
+ */
+ protected function connectUdp()
+ {
+ if (!extension_loaded('sockets')) {
+ throw new MissingExtensionException('The sockets extension is required to use udp URLs with the CubeHandler');
+ }
+
+ $this->udpConnection = socket_create(AF_INET, SOCK_DGRAM, 0);
+ if (!$this->udpConnection) {
+ throw new \LogicException('Unable to create a socket');
+ }
+
+ if (!socket_connect($this->udpConnection, $this->host, $this->port)) {
+ throw new \LogicException('Unable to connect to the socket at ' . $this->host . ':' . $this->port);
+ }
+ }
+
+ /**
+ * Establish a connection to a http server
+ */
+ protected function connectHttp()
+ {
+ if (!extension_loaded('curl')) {
+ throw new \LogicException('The curl extension is needed to use http URLs with the CubeHandler');
+ }
+
+ $this->httpConnection = curl_init('http://'.$this->host.':'.$this->port.'/1.0/event/put');
+
+ if (!$this->httpConnection) {
+ throw new \LogicException('Unable to connect to ' . $this->host . ':' . $this->port);
+ }
+
+ curl_setopt($this->httpConnection, CURLOPT_CUSTOMREQUEST, "POST");
+ curl_setopt($this->httpConnection, CURLOPT_RETURNTRANSFER, true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $date = $record['datetime'];
+
+ $data = array('time' => $date->format('Y-m-d\TH:i:s.uO'));
+ unset($record['datetime']);
+
+ if (isset($record['context']['type'])) {
+ $data['type'] = $record['context']['type'];
+ unset($record['context']['type']);
+ } else {
+ $data['type'] = $record['channel'];
+ }
+
+ $data['data'] = $record['context'];
+ $data['data']['level'] = $record['level'];
+
+ $this->{'write'.$this->scheme}(json_encode($data));
+ }
+
+ private function writeUdp($data)
+ {
+ if (!$this->udpConnection) {
+ $this->connectUdp();
+ }
+
+ socket_send($this->udpConnection, $data, strlen($data), 0);
+ }
+
+ private function writeHttp($data)
+ {
+ if (!$this->httpConnection) {
+ $this->connectHttp();
+ }
+
+ curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
+ curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: application/json',
+ 'Content-Length: ' . strlen('['.$data.']'))
+ );
+
+ return curl_exec($this->httpConnection);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php
new file mode 100644
index 00000000..b91ffec9
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php
@@ -0,0 +1,45 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\NormalizerFormatter;
+use Doctrine\CouchDB\CouchDBClient;
+
+/**
+ * CouchDB handler for Doctrine CouchDB ODM
+ *
+ * @author Markus Bachmann
+ */
+class DoctrineCouchDBHandler extends AbstractProcessingHandler
+{
+ private $client;
+
+ public function __construct(CouchDBClient $client, $level = Logger::DEBUG, $bubble = true)
+ {
+ $this->client = $client;
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ $this->client->postDocument($record['formatted']);
+ }
+
+ protected function getDefaultFormatter()
+ {
+ return new NormalizerFormatter;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
new file mode 100644
index 00000000..e7f843c8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
@@ -0,0 +1,89 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Aws\Common\Aws;
+use Aws\DynamoDb\DynamoDbClient;
+use Monolog\Formatter\ScalarFormatter;
+use Monolog\Logger;
+
+/**
+ * Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/)
+ *
+ * @link https://github.com/aws/aws-sdk-php/
+ * @author Andrew Lawson
+ */
+class DynamoDbHandler extends AbstractProcessingHandler
+{
+ const DATE_FORMAT = 'Y-m-d\TH:i:s.uO';
+
+ /**
+ * @var DynamoDbClient
+ */
+ protected $client;
+
+ /**
+ * @var string
+ */
+ protected $table;
+
+ /**
+ * @param DynamoDbClient $client
+ * @param string $table
+ * @param integer $level
+ * @param boolean $bubble
+ */
+ public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true)
+ {
+ if (!defined('Aws\Common\Aws::VERSION') || version_compare('3.0', Aws::VERSION, '<=')) {
+ throw new \RuntimeException('The DynamoDbHandler is only known to work with the AWS SDK 2.x releases');
+ }
+
+ $this->client = $client;
+ $this->table = $table;
+
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $filtered = $this->filterEmptyFields($record['formatted']);
+ $formatted = $this->client->formatAttributes($filtered);
+
+ $this->client->putItem(array(
+ 'TableName' => $this->table,
+ 'Item' => $formatted
+ ));
+ }
+
+ /**
+ * @param array $record
+ * @return array
+ */
+ protected function filterEmptyFields(array $record)
+ {
+ return array_filter($record, function ($value) {
+ return !empty($value) || false === $value || 0 === $value;
+ });
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new ScalarFormatter(self::DATE_FORMAT);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
new file mode 100644
index 00000000..96e5d57f
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
@@ -0,0 +1,128 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Formatter\ElasticaFormatter;
+use Monolog\Logger;
+use Elastica\Client;
+use Elastica\Exception\ExceptionInterface;
+
+/**
+ * Elastic Search handler
+ *
+ * Usage example:
+ *
+ * $client = new \Elastica\Client();
+ * $options = array(
+ * 'index' => 'elastic_index_name',
+ * 'type' => 'elastic_doc_type',
+ * );
+ * $handler = new ElasticSearchHandler($client, $options);
+ * $log = new Logger('application');
+ * $log->pushHandler($handler);
+ *
+ * @author Jelle Vink
+ */
+class ElasticSearchHandler extends AbstractProcessingHandler
+{
+ /**
+ * @var Client
+ */
+ protected $client;
+
+ /**
+ * @var array Handler config options
+ */
+ protected $options = array();
+
+ /**
+ * @param Client $client Elastica Client object
+ * @param array $options Handler configuration
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+ $this->client = $client;
+ $this->options = array_merge(
+ array(
+ 'index' => 'monolog', // Elastic index name
+ 'type' => 'record', // Elastic document type
+ 'ignore_error' => false, // Suppress Elastica exceptions
+ ),
+ $options
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ $this->bulkSend(array($record['formatted']));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(FormatterInterface $formatter)
+ {
+ if ($formatter instanceof ElasticaFormatter) {
+ return parent::setFormatter($formatter);
+ }
+ throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter');
+ }
+
+ /**
+ * Getter options
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new ElasticaFormatter($this->options['index'], $this->options['type']);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ $documents = $this->getFormatter()->formatBatch($records);
+ $this->bulkSend($documents);
+ }
+
+ /**
+ * Use Elasticsearch bulk API to send list of documents
+ * @param array $documents
+ * @throws \RuntimeException
+ */
+ protected function bulkSend(array $documents)
+ {
+ try {
+ $this->client->addDocuments($documents);
+ } catch (ExceptionInterface $e) {
+ if (!$this->options['ignore_error']) {
+ throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e);
+ }
+ }
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
new file mode 100644
index 00000000..d1e1ee60
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
@@ -0,0 +1,82 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\LineFormatter;
+use Monolog\Logger;
+
+/**
+ * Stores to PHP error_log() handler.
+ *
+ * @author Elan Ruusamäe
+ */
+class ErrorLogHandler extends AbstractProcessingHandler
+{
+ const OPERATING_SYSTEM = 0;
+ const SAPI = 4;
+
+ protected $messageType;
+ protected $expandNewlines;
+
+ /**
+ * @param integer $messageType Says where the error should go.
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Boolean $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries
+ */
+ public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false)
+ {
+ parent::__construct($level, $bubble);
+
+ if (false === in_array($messageType, self::getAvailableTypes())) {
+ $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));
+ throw new \InvalidArgumentException($message);
+ }
+
+ $this->messageType = $messageType;
+ $this->expandNewlines = $expandNewlines;
+ }
+
+ /**
+ * @return array With all available types
+ */
+ public static function getAvailableTypes()
+ {
+ return array(
+ self::OPERATING_SYSTEM,
+ self::SAPI,
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ if ($this->expandNewlines) {
+ $lines = preg_split('{[\r\n]+}', (string) $record['formatted']);
+ foreach ($lines as $line) {
+ error_log($line, $this->messageType);
+ }
+ } else {
+ error_log((string) $record['formatted'], $this->messageType);
+ }
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
new file mode 100644
index 00000000..597db732
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
@@ -0,0 +1,131 @@
+
+ */
+class FilterHandler extends AbstractHandler
+{
+ /**
+ * Handler or factory callable($record, $this)
+ *
+ * @var callable|\Monolog\Handler\HandlerInterface
+ */
+ protected $handler;
+
+ /**
+ * Minimum level for logs that are passes to handler
+ *
+ * @var int
+ */
+ protected $acceptedLevels;
+
+ /**
+ * Whether the messages that are handled can bubble up the stack or not
+ *
+ * @var Boolean
+ */
+ protected $bubble;
+
+ /**
+ * @param callable|HandlerInterface $handler Handler or factory callable($record, $this).
+ * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
+ * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true)
+ {
+ $this->handler = $handler;
+ $this->bubble = $bubble;
+ $this->setAcceptedLevels($minLevelOrList, $maxLevel);
+ }
+
+ /**
+ * @return array
+ */
+ public function getAcceptedLevels()
+ {
+ return array_flip($this->acceptedLevels);
+ }
+
+ /**
+ * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
+ * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array
+ */
+ public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY)
+ {
+ if (is_array($minLevelOrList)) {
+ $acceptedLevels = $minLevelOrList;
+ } else {
+ $acceptedLevels = array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) {
+ return $level >= $minLevelOrList && $level <= $maxLevel;
+ });
+ }
+ $this->acceptedLevels = array_flip($acceptedLevels);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isHandling(array $record)
+ {
+ return isset($this->acceptedLevels[$record['level']]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if (!$this->isHandling($record)) {
+ return false;
+ }
+
+ // The same logic as in FingersCrossedHandler
+ if (!$this->handler instanceof HandlerInterface) {
+ if (!is_callable($this->handler)) {
+ throw new \RuntimeException(
+ "The given handler (" . json_encode($this->handler)
+ . ") is not a callable nor a Monolog\\Handler\\HandlerInterface object"
+ );
+ }
+ $this->handler = call_user_func($this->handler, $record, $this);
+ if (!$this->handler instanceof HandlerInterface) {
+ throw new \RuntimeException("The factory callable should return a HandlerInterface");
+ }
+ }
+
+ if ($this->processors) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ }
+
+ $this->handler->handle($record);
+
+ return false === $this->bubble;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ $filtered = array();
+ foreach ($records as $record) {
+ if ($this->isHandling($record)) {
+ $filtered[] = $record;
+ }
+ }
+
+ $this->handler->handleBatch($filtered);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
new file mode 100644
index 00000000..c3e42efe
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
@@ -0,0 +1,28 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler\FingersCrossed;
+
+/**
+ * Interface for activation strategies for the FingersCrossedHandler.
+ *
+ * @author Johannes M. Schmitt
+ */
+interface ActivationStrategyInterface
+{
+ /**
+ * Returns whether the given record activates the handler.
+ *
+ * @param array $record
+ * @return Boolean
+ */
+ public function isHandlerActivated(array $record);
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
new file mode 100644
index 00000000..646d57a8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
@@ -0,0 +1,57 @@
+
+*
+* For the full copyright and license information, please view the LICENSE
+* file that was distributed with this source code.
+*/
+
+namespace Monolog\Handler\FingersCrossed;
+
+/**
+ * Channel and Error level based monolog activation strategy. Allows to trigger activation
+ * based on level per channel. e.g. trigger activation on level 'ERROR' by default, except
+ * for records of the 'sql' channel; those should trigger activation on level 'WARN'.
+ *
+ * Example:
+ *
+ *
+ * $activationStrategy = new ChannelLevelActivationStrategy(
+ * Logger::CRITICAL,
+ * array(
+ * 'request' => Logger::ALERT,
+ * 'sensitive' => Logger::ERROR,
+ * )
+ * );
+ * $handler = new FingersCrossedHandler(new StreamHandler('php://stderr'), $activationStrategy);
+ *
+ *
+ * @author Mike Meessen
+ */
+class ChannelLevelActivationStrategy implements ActivationStrategyInterface
+{
+ private $defaultActionLevel;
+ private $channelToActionLevel;
+
+ /**
+ * @param int $defaultActionLevel The default action level to be used if the record's category doesn't match any
+ * @param array $categoryToActionLevel An array that maps channel names to action levels.
+ */
+ public function __construct($defaultActionLevel, $channelToActionLevel = array())
+ {
+ $this->defaultActionLevel = $defaultActionLevel;
+ $this->channelToActionLevel = $channelToActionLevel;
+ }
+
+ public function isHandlerActivated(array $record)
+ {
+ if (isset($this->channelToActionLevel[$record['channel']])) {
+ return $record['level'] >= $this->channelToActionLevel[$record['channel']];
+ }
+
+ return $record['level'] >= $this->defaultActionLevel;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
new file mode 100644
index 00000000..7cd8ef1b
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler\FingersCrossed;
+
+/**
+ * Error level based activation strategy.
+ *
+ * @author Johannes M. Schmitt
+ */
+class ErrorLevelActivationStrategy implements ActivationStrategyInterface
+{
+ private $actionLevel;
+
+ public function __construct($actionLevel)
+ {
+ $this->actionLevel = $actionLevel;
+ }
+
+ public function isHandlerActivated(array $record)
+ {
+ return $record['level'] >= $this->actionLevel;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
new file mode 100644
index 00000000..9cf75edb
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
@@ -0,0 +1,138 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
+use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
+use Monolog\Logger;
+
+/**
+ * Buffers all records until a certain level is reached
+ *
+ * The advantage of this approach is that you don't get any clutter in your log files.
+ * Only requests which actually trigger an error (or whatever your actionLevel is) will be
+ * in the logs, but they will contain all records, not only those above the level threshold.
+ *
+ * You can find the various activation strategies in the
+ * Monolog\Handler\FingersCrossed\ namespace.
+ *
+ * @author Jordi Boggiano
+ */
+class FingersCrossedHandler extends AbstractHandler
+{
+ protected $handler;
+ protected $activationStrategy;
+ protected $buffering = true;
+ protected $bufferSize;
+ protected $buffer = array();
+ protected $stopBuffering;
+ protected $passthruLevel;
+
+ /**
+ * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler).
+ * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
+ * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true)
+ * @param int $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered
+ */
+ public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true, $passthruLevel = NULL)
+ {
+ if (null === $activationStrategy) {
+ $activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING);
+ }
+
+ // convert simple int activationStrategy to an object
+ if (!$activationStrategy instanceof ActivationStrategyInterface) {
+ $activationStrategy = new ErrorLevelActivationStrategy($activationStrategy);
+ }
+
+ $this->handler = $handler;
+ $this->activationStrategy = $activationStrategy;
+ $this->bufferSize = $bufferSize;
+ $this->bubble = $bubble;
+ $this->stopBuffering = $stopBuffering;
+ $this->passthruLevel = $passthruLevel;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isHandling(array $record)
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if ($this->processors) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ }
+
+ if ($this->buffering) {
+ $this->buffer[] = $record;
+ if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) {
+ array_shift($this->buffer);
+ }
+ if ($this->activationStrategy->isHandlerActivated($record)) {
+ if ($this->stopBuffering) {
+ $this->buffering = false;
+ }
+ if (!$this->handler instanceof HandlerInterface) {
+ if (!is_callable($this->handler)) {
+ throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
+ }
+ $this->handler = call_user_func($this->handler, $record, $this);
+ if (!$this->handler instanceof HandlerInterface) {
+ throw new \RuntimeException("The factory callable should return a HandlerInterface");
+ }
+ }
+ $this->handler->handleBatch($this->buffer);
+ $this->buffer = array();
+ }
+ } else {
+ $this->handler->handle($record);
+ }
+
+ return false === $this->bubble;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ if (NULL !== $this->passthruLevel) {
+ $level = $this->passthruLevel;
+ $this->buffer = array_filter($this->buffer, function ($record) use ($level) {
+ return $record['level'] >= $level;
+ });
+ if (count($this->buffer) > 0) {
+ $this->handler->handleBatch($this->buffer);
+ $this->buffer = array();
+ }
+ }
+ }
+
+ /**
+ * Resets the state of the handler. Stops forwarding records to the wrapped handler.
+ */
+ public function reset()
+ {
+ $this->buffering = true;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
new file mode 100644
index 00000000..fee47950
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
@@ -0,0 +1,195 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\WildfireFormatter;
+
+/**
+ * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol.
+ *
+ * @author Eric Clemmons (@ericclemmons)
+ */
+class FirePHPHandler extends AbstractProcessingHandler
+{
+ /**
+ * WildFire JSON header message format
+ */
+ const PROTOCOL_URI = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2';
+
+ /**
+ * FirePHP structure for parsing messages & their presentation
+ */
+ const STRUCTURE_URI = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1';
+
+ /**
+ * Must reference a "known" plugin, otherwise headers won't display in FirePHP
+ */
+ const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3';
+
+ /**
+ * Header prefix for Wildfire to recognize & parse headers
+ */
+ const HEADER_PREFIX = 'X-Wf';
+
+ /**
+ * Whether or not Wildfire vendor-specific headers have been generated & sent yet
+ */
+ protected static $initialized = false;
+
+ /**
+ * Shared static message index between potentially multiple handlers
+ * @var int
+ */
+ protected static $messageIndex = 1;
+
+ protected static $sendHeaders = true;
+
+ /**
+ * Base header creation function used by init headers & record headers
+ *
+ * @param array $meta Wildfire Plugin, Protocol & Structure Indexes
+ * @param string $message Log message
+ * @return array Complete header string ready for the client as key and message as value
+ */
+ protected function createHeader(array $meta, $message)
+ {
+ $header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta));
+
+ return array($header => $message);
+ }
+
+ /**
+ * Creates message header from record
+ *
+ * @see createHeader()
+ * @param array $record
+ * @return string
+ */
+ protected function createRecordHeader(array $record)
+ {
+ // Wildfire is extensible to support multiple protocols & plugins in a single request,
+ // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake.
+ return $this->createHeader(
+ array(1, 1, 1, self::$messageIndex++),
+ $record['formatted']
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new WildfireFormatter();
+ }
+
+ /**
+ * Wildfire initialization headers to enable message parsing
+ *
+ * @see createHeader()
+ * @see sendHeader()
+ * @return array
+ */
+ protected function getInitHeaders()
+ {
+ // Initial payload consists of required headers for Wildfire
+ return array_merge(
+ $this->createHeader(array('Protocol', 1), self::PROTOCOL_URI),
+ $this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI),
+ $this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI)
+ );
+ }
+
+ /**
+ * Send header string to the client
+ *
+ * @param string $header
+ * @param string $content
+ */
+ protected function sendHeader($header, $content)
+ {
+ if (!headers_sent() && self::$sendHeaders) {
+ header(sprintf('%s: %s', $header, $content));
+ }
+ }
+
+ /**
+ * Creates & sends header for a record, ensuring init headers have been sent prior
+ *
+ * @see sendHeader()
+ * @see sendInitHeaders()
+ * @param array $record
+ */
+ protected function write(array $record)
+ {
+ if (!self::$sendHeaders) {
+ return;
+ }
+
+ // WildFire-specific headers must be sent prior to any messages
+ if (!self::$initialized) {
+ self::$initialized = true;
+
+ self::$sendHeaders = $this->headersAccepted();
+ if (!self::$sendHeaders) {
+ return;
+ }
+
+ foreach ($this->getInitHeaders() as $header => $content) {
+ $this->sendHeader($header, $content);
+ }
+ }
+
+ $header = $this->createRecordHeader($record);
+ if (trim(current($header)) !== '') {
+ $this->sendHeader(key($header), current($header));
+ }
+ }
+
+ /**
+ * Verifies if the headers are accepted by the current user agent
+ *
+ * @return Boolean
+ */
+ protected function headersAccepted()
+ {
+ if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) {
+ return true;
+ }
+
+ return isset($_SERVER['HTTP_X_FIREPHP_VERSION']);
+ }
+
+ /**
+ * BC getter for the sendHeaders property that has been made static
+ */
+ public function __get($property)
+ {
+ if ('sendHeaders' !== $property) {
+ throw new \InvalidArgumentException('Undefined property '.$property);
+ }
+
+ return static::$sendHeaders;
+ }
+
+ /**
+ * BC setter for the sendHeaders property that has been made static
+ */
+ public function __set($property, $value)
+ {
+ if ('sendHeaders' !== $property) {
+ throw new \InvalidArgumentException('Undefined property '.$property);
+ }
+
+ static::$sendHeaders = $value;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php
new file mode 100644
index 00000000..0916343c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php
@@ -0,0 +1,103 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Sends notifications through the Flowdock push API
+ *
+ * This must be configured with a FlowdockFormatter instance via setFormatter()
+ *
+ * Notes:
+ * API token - Flowdock API token
+ *
+ * @author Dominik Liebler
+ * @see https://www.flowdock.com/api/push
+ */
+class FlowdockHandler extends SocketHandler
+{
+ /**
+ * @var string
+ */
+ protected $apiToken;
+
+ /**
+ * @param string $apiToken
+ * @param bool|int $level The minimum logging level at which this handler will be triggered
+ * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+ *
+ * @throws MissingExtensionException if OpenSSL is missing
+ */
+ public function __construct($apiToken, $level = Logger::DEBUG, $bubble = true)
+ {
+ if (!extension_loaded('openssl')) {
+ throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler');
+ }
+
+ parent::__construct('ssl://api.flowdock.com:443', $level, $bubble);
+ $this->apiToken = $apiToken;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ */
+ public function write(array $record)
+ {
+ parent::write($record);
+
+ $this->closeSocket();
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ * @return string
+ */
+ protected function generateDataStream($record)
+ {
+ $content = $this->buildContent($record);
+
+ return $this->buildHeader($content) . $content;
+ }
+
+ /**
+ * Builds the body of API call
+ *
+ * @param array $record
+ * @return string
+ */
+ private function buildContent($record)
+ {
+ return json_encode($record['formatted']['flowdock']);
+ }
+
+ /**
+ * Builds the header of the API Call
+ *
+ * @param string $content
+ * @return string
+ */
+ private function buildHeader($content)
+ {
+ $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n";
+ $header .= "Host: api.flowdock.com\r\n";
+ $header .= "Content-Type: application/json\r\n";
+ $header .= "Content-Length: " . strlen($content) . "\r\n";
+ $header .= "\r\n";
+
+ return $header;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
new file mode 100644
index 00000000..790f6364
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
@@ -0,0 +1,72 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Gelf\IMessagePublisher;
+use Gelf\PublisherInterface;
+use InvalidArgumentException;
+use Monolog\Logger;
+use Monolog\Formatter\GelfMessageFormatter;
+
+/**
+ * Handler to send messages to a Graylog2 (http://www.graylog2.org) server
+ *
+ * @author Matt Lehner
+ * @author Benjamin Zikarsky
+ */
+class GelfHandler extends AbstractProcessingHandler
+{
+ /**
+ * @var Publisher the publisher object that sends the message to the server
+ */
+ protected $publisher;
+
+ /**
+ * @param PublisherInterface|IMessagePublisher $publisher a publisher object
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($publisher, $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+
+ if (!$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) {
+ throw new InvalidArgumentException("Invalid publisher, expected a Gelf\IMessagePublisher or Gelf\PublisherInterface instance");
+ }
+
+ $this->publisher = $publisher;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $this->publisher = null;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $this->publisher->publish($record['formatted']);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new GelfMessageFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
new file mode 100644
index 00000000..99384d35
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
@@ -0,0 +1,80 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+/**
+ * Forwards records to multiple handlers
+ *
+ * @author Lenar Lõhmus
+ */
+class GroupHandler extends AbstractHandler
+{
+ protected $handlers;
+
+ /**
+ * @param array $handlers Array of Handlers.
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(array $handlers, $bubble = true)
+ {
+ foreach ($handlers as $handler) {
+ if (!$handler instanceof HandlerInterface) {
+ throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.');
+ }
+ }
+
+ $this->handlers = $handlers;
+ $this->bubble = $bubble;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isHandling(array $record)
+ {
+ foreach ($this->handlers as $handler) {
+ if ($handler->isHandling($record)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if ($this->processors) {
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ }
+
+ foreach ($this->handlers as $handler) {
+ $handler->handle($record);
+ }
+
+ return false === $this->bubble;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ foreach ($this->handlers as $handler) {
+ $handler->handleBatch($records);
+ }
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
new file mode 100644
index 00000000..accff037
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
@@ -0,0 +1,90 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FormatterInterface;
+
+/**
+ * Interface that all Monolog Handlers must implement
+ *
+ * @author Jordi Boggiano
+ */
+interface HandlerInterface
+{
+ /**
+ * Checks whether the given record will be handled by this handler.
+ *
+ * This is mostly done for performance reasons, to avoid calling processors for nothing.
+ *
+ * Handlers should still check the record levels within handle(), returning false in isHandling()
+ * is no guarantee that handle() will not be called, and isHandling() might not be called
+ * for a given record.
+ *
+ * @param array $record
+ *
+ * @return Boolean
+ */
+ public function isHandling(array $record);
+
+ /**
+ * Handles a record.
+ *
+ * All records may be passed to this method, and the handler should discard
+ * those that it does not want to handle.
+ *
+ * The return value of this function controls the bubbling process of the handler stack.
+ * Unless the bubbling is interrupted (by returning true), the Logger class will keep on
+ * calling further handlers in the stack with a given log record.
+ *
+ * @param array $record The record to handle
+ * @return Boolean true means that this handler handled the record, and that bubbling is not permitted.
+ * false means the record was either not processed or that this handler allows bubbling.
+ */
+ public function handle(array $record);
+
+ /**
+ * Handles a set of records at once.
+ *
+ * @param array $records The records to handle (an array of record arrays)
+ */
+ public function handleBatch(array $records);
+
+ /**
+ * Adds a processor in the stack.
+ *
+ * @param callable $callback
+ * @return self
+ */
+ public function pushProcessor($callback);
+
+ /**
+ * Removes the processor on top of the stack and returns it.
+ *
+ * @return callable
+ */
+ public function popProcessor();
+
+ /**
+ * Sets the formatter.
+ *
+ * @param FormatterInterface $formatter
+ * @return self
+ */
+ public function setFormatter(FormatterInterface $formatter);
+
+ /**
+ * Gets the formatter.
+ *
+ * @return FormatterInterface
+ */
+ public function getFormatter();
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
new file mode 100644
index 00000000..38ce931c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
@@ -0,0 +1,300 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Sends notifications through the hipchat api to a hipchat room
+ *
+ * Notes:
+ * API token - HipChat API token
+ * Room - HipChat Room Id or name, where messages are sent
+ * Name - Name used to send the message (from)
+ * notify - Should the message trigger a notification in the clients
+ *
+ * @author Rafael Dohms
+ * @see https://www.hipchat.com/docs/api
+ */
+class HipChatHandler extends SocketHandler
+{
+ /**
+ * The maximum allowed length for the name used in the "from" field.
+ */
+ const MAXIMUM_NAME_LENGTH = 15;
+
+ /**
+ * The maximum allowed length for the message.
+ */
+ const MAXIMUM_MESSAGE_LENGTH = 9500;
+
+ /**
+ * @var string
+ */
+ private $token;
+
+ /**
+ * @var array
+ */
+ private $room;
+
+ /**
+ * @var string
+ */
+ private $name;
+
+ /**
+ * @var boolean
+ */
+ private $notify;
+
+ /**
+ * @var string
+ */
+ private $format;
+
+ /**
+ * @param string $token HipChat API Token
+ * @param string $room The room that should be alerted of the message (Id or Name)
+ * @param string $name Name used in the "from" field
+ * @param bool $notify Trigger a notification in clients or not
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Boolean $useSSL Whether to connect via SSL.
+ * @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
+ */
+ public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text')
+ {
+ if (!$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) {
+ throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.');
+ }
+
+ $connectionString = $useSSL ? 'ssl://api.hipchat.com:443' : 'api.hipchat.com:80';
+ parent::__construct($connectionString, $level, $bubble);
+
+ $this->token = $token;
+ $this->name = $name;
+ $this->notify = $notify;
+ $this->room = $room;
+ $this->format = $format;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ * @return string
+ */
+ protected function generateDataStream($record)
+ {
+ $content = $this->buildContent($record);
+
+ return $this->buildHeader($content) . $content;
+ }
+
+ /**
+ * Builds the body of API call
+ *
+ * @param array $record
+ * @return string
+ */
+ private function buildContent($record)
+ {
+ $dataArray = array(
+ 'from' => $this->name,
+ 'room_id' => $this->room,
+ 'notify' => $this->notify,
+ 'message' => $record['formatted'],
+ 'message_format' => $this->format,
+ 'color' => $this->getAlertColor($record['level']),
+ );
+
+ return http_build_query($dataArray);
+ }
+
+ /**
+ * Builds the header of the API Call
+ *
+ * @param string $content
+ * @return string
+ */
+ private function buildHeader($content)
+ {
+ $header = "POST /v1/rooms/message?format=json&auth_token=".$this->token." HTTP/1.1\r\n";
+ $header .= "Host: api.hipchat.com\r\n";
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
+ $header .= "Content-Length: " . strlen($content) . "\r\n";
+ $header .= "\r\n";
+
+ return $header;
+ }
+
+ /**
+ * Assigns a color to each level of log records.
+ *
+ * @param integer $level
+ * @return string
+ */
+ protected function getAlertColor($level)
+ {
+ switch (true) {
+ case $level >= Logger::ERROR:
+ return 'red';
+ case $level >= Logger::WARNING:
+ return 'yellow';
+ case $level >= Logger::INFO:
+ return 'green';
+ case $level == Logger::DEBUG:
+ return 'gray';
+ default:
+ return 'yellow';
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ */
+ public function write(array $record)
+ {
+ parent::write($record);
+ $this->closeSocket();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ if (count($records) == 0) {
+ return true;
+ }
+
+ $batchRecords = $this->combineRecords($records);
+
+ $handled = false;
+ foreach ($batchRecords as $batchRecord) {
+ if ($this->isHandling($batchRecord)) {
+ $this->write($batchRecord);
+ $handled = true;
+ }
+ }
+
+ if (!$handled) {
+ return false;
+ }
+
+ return false === $this->bubble;
+ }
+
+ /**
+ * Combines multiple records into one. Error level of the combined record
+ * will be the highest level from the given records. Datetime will be taken
+ * from the first record.
+ *
+ * @param $records
+ * @return array
+ */
+ private function combineRecords($records)
+ {
+ $batchRecord = null;
+ $batchRecords = array();
+ $batchedMessages = array();
+ $messages = array();
+ $formattedMessages = array();
+ $level = 0;
+ $levelName = null;
+ $datetime = null;
+
+ foreach ($records as $record) {
+ $record = $this->processRecord($record);
+
+ if ($record['level'] > $level) {
+ $level = $record['level'];
+ $levelName = $record['level_name'];
+ }
+
+ if (null === $datetime) {
+ $datetime = $record['datetime'];
+ }
+
+ $messages[] = $record['message'];
+ $messgeStr = implode(PHP_EOL, $messages);
+ $formattedMessages[] = $this->getFormatter()->format($record);
+ $formattedMessageStr = implode('', $formattedMessages);
+
+ $batchRecord = array(
+ 'message' => $messgeStr,
+ 'formatted' => $formattedMessageStr,
+ 'context' => array(),
+ 'extra' => array(),
+ );
+
+ if (!$this->validateStringLength($batchRecord['formatted'], static::MAXIMUM_MESSAGE_LENGTH)) {
+ // Pop the last message and implode the remainging messages
+ $lastMessage = array_pop($messages);
+ $lastFormattedMessage = array_pop($formattedMessages);
+ $batchRecord['message'] = implode(PHP_EOL, $messages);
+ $batchRecord['formatted'] = implode('', $formattedMessages);
+
+ $batchRecords[] = $batchRecord;
+ $messages = array($lastMessage);
+ $formattedMessages = array($lastFormattedMessage);
+
+ $batchRecord = null;
+ }
+ }
+
+ if (null !== $batchRecord) {
+ $batchRecords[] = $batchRecord;
+ }
+
+ // Set the max level and datetime for all records
+ foreach ($batchRecords as &$batchRecord) {
+ $batchRecord = array_merge(
+ $batchRecord,
+ array(
+ 'level' => $level,
+ 'level_name' => $levelName,
+ 'datetime' => $datetime
+ )
+ );
+ }
+
+ return $batchRecords;
+ }
+
+ /**
+ * Validates the length of a string.
+ *
+ * If the `mb_strlen()` function is available, it will use that, as HipChat
+ * allows UTF-8 characters. Otherwise, it will fall back to `strlen()`.
+ *
+ * Note that this might cause false failures in the specific case of using
+ * a valid name with less than 16 characters, but 16 or more bytes, on a
+ * system where `mb_strlen()` is unavailable.
+ *
+ * @param string $str
+ * @param int $length
+ *
+ * @return bool
+ */
+ private function validateStringLength($str, $length)
+ {
+ if (function_exists('mb_strlen')) {
+ return (mb_strlen($str) <= $length);
+ }
+
+ return (strlen($str) <= $length);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
new file mode 100644
index 00000000..18b3fa4f
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
@@ -0,0 +1,57 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * @author Robert Kaufmann III
+ */
+class LogEntriesHandler extends SocketHandler
+{
+
+ /**
+ * @var string
+ */
+ protected $logToken;
+
+ /**
+ * @param string $token Log token supplied by LogEntries
+ * @param boolean $useSSL Whether or not SSL encryption should be used.
+ * @param int $level The minimum logging level to trigger this handler
+ * @param boolean $bubble Whether or not messages that are handled should bubble up the stack.
+ *
+ * @throws MissingExtensionExcpetion If SSL encryption is set to true and OpenSSL is missing
+ */
+ public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true)
+ {
+ if ($useSSL && !extension_loaded('openssl')) {
+ throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
+ }
+
+ $endpoint = $useSSL ? 'ssl://api.logentries.com:20000' : 'data.logentries.com:80';
+ parent::__construct($endpoint, $level, $bubble);
+ $this->logToken = $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param array $record
+ * @return string
+ */
+ protected function generateDataStream($record)
+ {
+ return $this->logToken . ' ' . $record['formatted'];
+ }
+
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php
new file mode 100644
index 00000000..9a3de6e6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php
@@ -0,0 +1,93 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\LogglyFormatter;
+
+/**
+ * Sends errors to Loggly.
+ *
+ * @author Przemek Sobstel
+ * @author Adam Pancutt
+ */
+class LogglyHandler extends AbstractProcessingHandler
+{
+ const HOST = 'logs-01.loggly.com';
+ const ENDPOINT_SINGLE = 'inputs';
+ const ENDPOINT_BATCH = 'bulk';
+
+ protected $token;
+
+ protected $tag;
+
+ public function __construct($token, $level = Logger::DEBUG, $bubble = true)
+ {
+ if (!extension_loaded('curl')) {
+ throw new \LogicException('The curl extension is needed to use the LogglyHandler');
+ }
+
+ $this->token = $token;
+
+ parent::__construct($level, $bubble);
+ }
+
+ public function setTag($tag)
+ {
+ $this->tag = $tag;
+ }
+
+ protected function write(array $record)
+ {
+ $this->send($record["formatted"], self::ENDPOINT_SINGLE);
+ }
+
+ public function handleBatch(array $records)
+ {
+ $level = $this->level;
+
+ $records = array_filter($records, function ($record) use ($level) {
+ return ($record['level'] >= $level);
+ });
+
+ if ($records) {
+ $this->send($this->getFormatter()->formatBatch($records), self::ENDPOINT_BATCH);
+ }
+ }
+
+ protected function send($data, $endpoint)
+ {
+ $url = sprintf("https://%s/%s/%s/", self::HOST, $endpoint, $this->token);
+
+ $headers = array('Content-Type: application/json');
+
+ if ($this->tag) {
+ $headers[] = "X-LOGGLY-TAG: {$this->tag}";
+ }
+
+ $ch = curl_init();
+
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ curl_exec($ch);
+ curl_close($ch);
+ }
+
+ protected function getDefaultFormatter()
+ {
+ return new LogglyFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
new file mode 100644
index 00000000..86292727
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
@@ -0,0 +1,55 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+/**
+ * Base class for all mail handlers
+ *
+ * @author Gyula Sallai
+ */
+abstract class MailHandler extends AbstractProcessingHandler
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ $messages = array();
+
+ foreach ($records as $record) {
+ if ($record['level'] < $this->level) {
+ continue;
+ }
+ $messages[] = $this->processRecord($record);
+ }
+
+ if (!empty($messages)) {
+ $this->send((string) $this->getFormatter()->formatBatch($messages), $messages);
+ }
+ }
+
+ /**
+ * Send a mail with the given content
+ *
+ * @param string $content
+ * @param array $records the array of log records that formed this content
+ */
+ abstract protected function send($content, array $records);
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $this->send((string) $record['formatted'], array($record));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php
new file mode 100644
index 00000000..0cb21cd2
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+/**
+ * Exception can be thrown if an extension for an handler is missing
+ *
+ * @author Christian Bergau
+ */
+class MissingExtensionException extends \Exception
+{
+
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
new file mode 100644
index 00000000..6c431f2b
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
@@ -0,0 +1,55 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\NormalizerFormatter;
+
+/**
+ * Logs to a MongoDB database.
+ *
+ * usage example:
+ *
+ * $log = new Logger('application');
+ * $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod");
+ * $log->pushHandler($mongodb);
+ *
+ * @author Thomas Tourlourat
+ */
+class MongoDBHandler extends AbstractProcessingHandler
+{
+ protected $mongoCollection;
+
+ public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
+ {
+ if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
+ throw new \InvalidArgumentException('MongoClient or Mongo instance required');
+ }
+
+ $this->mongoCollection = $mongo->selectCollection($database, $collection);
+
+ parent::__construct($level, $bubble);
+ }
+
+ protected function write(array $record)
+ {
+ $this->mongoCollection->save($record["formatted"]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new NormalizerFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
new file mode 100644
index 00000000..f97df482
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
@@ -0,0 +1,147 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * NativeMailerHandler uses the mail() function to send the emails
+ *
+ * @author Christophe Coevoet
+ * @author Mark Garrett
+ */
+class NativeMailerHandler extends MailHandler
+{
+ /**
+ * The email address to which the message is delivered
+ * @var string
+ */
+ protected $to;
+
+ /**
+ * The subject of the email
+ * @var string
+ */
+ protected $subject;
+
+ /**
+ * Optional headers for the message
+ * @var array
+ */
+ protected $headers = array();
+
+ /**
+ * The wordwrap length for the message
+ * @var integer
+ */
+ protected $maxColumnWidth;
+
+ /**
+ * The Content-type for the message
+ * @var string
+ */
+ protected $contentType = 'text/plain';
+
+ /**
+ * The encoding for the message
+ * @var string
+ */
+ protected $encoding = 'utf-8';
+
+ /**
+ * @param string|array $to The receiver of the mail
+ * @param string $subject The subject of the mail
+ * @param string $from The sender of the mail
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $maxColumnWidth The maximum column width that the message lines will have
+ */
+ public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
+ {
+ parent::__construct($level, $bubble);
+ $this->to = is_array($to) ? $to : array($to);
+ $this->subject = $subject;
+ $this->addHeader(sprintf('From: %s', $from));
+ $this->maxColumnWidth = $maxColumnWidth;
+ }
+
+ /**
+ * Add headers to the message
+ *
+ * @param string|array $headers Custom added headers
+ * @return null
+ */
+ public function addHeader($headers)
+ {
+ foreach ((array) $headers as $header) {
+ if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) {
+ throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons');
+ }
+ $this->headers[] = $header;
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function send($content, array $records)
+ {
+ $content = wordwrap($content, $this->maxColumnWidth);
+ $headers = ltrim(implode("\r\n", $this->headers) . "\r\n", "\r\n");
+ $headers .= 'Content-type: ' . $this->getContentType() . '; charset=' . $this->getEncoding() . "\r\n";
+ if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) {
+ $headers .= 'MIME-Version: 1.0' . "\r\n";
+ }
+ foreach ($this->to as $to) {
+ mail($to, $this->subject, $content, $headers);
+ }
+ }
+
+ /**
+ * @return string $contentType
+ */
+ public function getContentType()
+ {
+ return $this->contentType;
+ }
+
+ /**
+ * @return string $encoding
+ */
+ public function getEncoding()
+ {
+ return $this->encoding;
+ }
+
+ /**
+ * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML
+ * messages.
+ * @return self
+ */
+ public function setContentType($contentType)
+ {
+ $this->contentType = $contentType;
+
+ return $this;
+ }
+
+ /**
+ * @param string $encoding
+ * @return self
+ */
+ public function setEncoding($encoding)
+ {
+ $this->encoding = $encoding;
+
+ return $this;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
new file mode 100644
index 00000000..f7055cc1
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
@@ -0,0 +1,106 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Class to record a log on a NewRelic application
+ *
+ * @see https://newrelic.com/docs/php/new-relic-for-php
+ */
+class NewRelicHandler extends AbstractProcessingHandler
+{
+ /**
+ * Name of the New Relic application that will receive logs from this handler.
+ *
+ * @var string
+ */
+ protected $appName;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @param string $appName
+ */
+ public function __construct($level = Logger::ERROR, $bubble = true, $appName = null)
+ {
+ parent::__construct($level, $bubble);
+
+ $this->appName = $appName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record)
+ {
+ if (!$this->isNewRelicEnabled()) {
+ throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
+ }
+
+ if ($appName = $this->getAppName($record['context'])) {
+ $this->setNewRelicAppName($appName);
+ }
+
+ if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
+ newrelic_notice_error($record['message'], $record['context']['exception']);
+ unset($record['context']['exception']);
+ } else {
+ newrelic_notice_error($record['message']);
+ }
+
+ foreach ($record['context'] as $key => $parameter) {
+ newrelic_add_custom_parameter($key, $parameter);
+ }
+
+ foreach ($record['extra'] as $key => $parameter) {
+ newrelic_add_custom_parameter($key, $parameter);
+ }
+ }
+
+ /**
+ * Checks whether the NewRelic extension is enabled in the system.
+ *
+ * @return bool
+ */
+ protected function isNewRelicEnabled()
+ {
+ return extension_loaded('newrelic');
+ }
+
+ /**
+ * Returns the appname where this log should be sent. Each log can override the default appname, set in this
+ * handler's constructor, by providing the appname in its context.
+ *
+ * @param array $context
+ * @return null|string
+ */
+ protected function getAppName(array $context)
+ {
+ if (isset($context['appname'])) {
+ return $context['appname'];
+ }
+
+ return $this->appName;
+ }
+
+ /**
+ * Sets the NewRelic application that should receive this log.
+ *
+ * @param string $appName
+ */
+ protected function setNewRelicAppName($appName)
+ {
+ newrelic_set_appname($appName);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
new file mode 100644
index 00000000..3754e45d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
@@ -0,0 +1,45 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Blackhole
+ *
+ * Any record it can handle will be thrown away. This can be used
+ * to put on top of an existing stack to override it temporarily.
+ *
+ * @author Jordi Boggiano
+ */
+class NullHandler extends AbstractHandler
+{
+ /**
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ */
+ public function __construct($level = Logger::DEBUG)
+ {
+ parent::__construct($level, false);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handle(array $record)
+ {
+ if ($record['level'] < $this->level) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
new file mode 100644
index 00000000..2c80afe7
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
@@ -0,0 +1,145 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Sends notifications through the pushover api to mobile phones
+ *
+ * @author Sebastian Göttschkes
+ * @see https://www.pushover.net/api
+ */
+class PushoverHandler extends SocketHandler
+{
+ private $token;
+ private $users;
+ private $title;
+ private $user;
+ private $retry;
+ private $expire;
+
+ private $highPriorityLevel;
+ private $emergencyLevel;
+
+ /**
+ * Sounds the api supports by default
+ * @see https://pushover.net/api#sounds
+ * @var array
+ */
+ private $sounds = array(
+ 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming',
+ 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb',
+ 'persistent', 'echo', 'updown', 'none',
+ );
+
+ /**
+ * @param string $token Pushover api token
+ * @param string|array $users Pushover user id or array of ids the message will be sent to
+ * @param string $title Title sent to the Pushover API
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not
+ * the pushover.net app owner. OpenSSL is required for this option.
+ * @param integer $highPriorityLevel The minimum logging level at which this handler will start
+ * sending "high priority" requests to the Pushover API
+ * @param integer $emergencyLevel The minimum logging level at which this handler will start
+ * sending "emergency" requests to the Pushover API
+ * @param integer $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user.
+ * @param integer $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds).
+ */
+ public function __construct($token, $users, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $highPriorityLevel = Logger::CRITICAL, $emergencyLevel = Logger::EMERGENCY, $retry = 30, $expire = 25200)
+ {
+ $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80';
+ parent::__construct($connectionString, $level, $bubble);
+
+ $this->token = $token;
+ $this->users = (array) $users;
+ $this->title = $title ?: gethostname();
+ $this->highPriorityLevel = $highPriorityLevel;
+ $this->emergencyLevel = $emergencyLevel;
+ $this->retry = $retry;
+ $this->expire = $expire;
+ }
+
+ protected function generateDataStream($record)
+ {
+ $content = $this->buildContent($record);
+
+ return $this->buildHeader($content) . $content;
+ }
+
+ private function buildContent($record)
+ {
+ // Pushover has a limit of 512 characters on title and message combined.
+ $maxMessageLength = 512 - strlen($this->title);
+ $message = substr($record['message'], 0, $maxMessageLength);
+ $timestamp = $record['datetime']->getTimestamp();
+
+ $dataArray = array(
+ 'token' => $this->token,
+ 'user' => $this->user,
+ 'message' => $message,
+ 'title' => $this->title,
+ 'timestamp' => $timestamp
+ );
+
+ if ($record['level'] >= $this->emergencyLevel) {
+ $dataArray['priority'] = 2;
+ $dataArray['retry'] = $this->retry;
+ $dataArray['expire'] = $this->expire;
+ } elseif ($record['level'] >= $this->highPriorityLevel) {
+ $dataArray['priority'] = 1;
+ }
+
+ if (isset($record['context']['sound']) && in_array($record['context']['sound'], $this->sounds)) {
+ $dataArray['sound'] = $record['context']['sound'];
+ } elseif (isset($record['extra']['sound']) && in_array($record['extra']['sound'], $this->sounds)) {
+ $dataArray['sound'] = $record['extra']['sound'];
+ }
+
+ return http_build_query($dataArray);
+ }
+
+ private function buildHeader($content)
+ {
+ $header = "POST /1/messages.json HTTP/1.1\r\n";
+ $header .= "Host: api.pushover.net\r\n";
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
+ $header .= "Content-Length: " . strlen($content) . "\r\n";
+ $header .= "\r\n";
+
+ return $header;
+ }
+
+ public function write(array $record)
+ {
+ foreach ($this->users as $user) {
+ $this->user = $user;
+
+ parent::write($record);
+ $this->closeSocket();
+ }
+
+ $this->user = null;
+ }
+
+ public function setHighPriorityLevel($value)
+ {
+ $this->highPriorityLevel = $value;
+ }
+
+ public function setEmergencyLevel($value)
+ {
+ $this->emergencyLevel = $value;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
new file mode 100644
index 00000000..2b32c321
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
@@ -0,0 +1,175 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\LineFormatter;
+use Monolog\Formatter\FormatterInterface;
+use Monolog\Logger;
+use Raven_Client;
+
+/**
+ * Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server
+ * using raven-php (https://github.com/getsentry/raven-php)
+ *
+ * @author Marc Abramowitz
+ */
+class RavenHandler extends AbstractProcessingHandler
+{
+ /**
+ * Translates Monolog log levels to Raven log levels.
+ */
+ private $logLevels = array(
+ Logger::DEBUG => Raven_Client::DEBUG,
+ Logger::INFO => Raven_Client::INFO,
+ Logger::NOTICE => Raven_Client::INFO,
+ Logger::WARNING => Raven_Client::WARNING,
+ Logger::ERROR => Raven_Client::ERROR,
+ Logger::CRITICAL => Raven_Client::FATAL,
+ Logger::ALERT => Raven_Client::FATAL,
+ Logger::EMERGENCY => Raven_Client::FATAL,
+ );
+
+ /**
+ * @var Raven_Client the client object that sends the message to the server
+ */
+ protected $ravenClient;
+
+ /**
+ * @var LineFormatter The formatter to use for the logs generated via handleBatch()
+ */
+ protected $batchFormatter;
+
+ /**
+ * @param Raven_Client $ravenClient
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+
+ $this->ravenClient = $ravenClient;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function handleBatch(array $records)
+ {
+ $level = $this->level;
+
+ // filter records based on their level
+ $records = array_filter($records, function ($record) use ($level) {
+ return $record['level'] >= $level;
+ });
+
+ if (!$records) {
+ return;
+ }
+
+ // the record with the highest severity is the "main" one
+ $record = array_reduce($records, function ($highest, $record) {
+ if ($record['level'] >= $highest['level']) {
+ return $record;
+ }
+
+ return $highest;
+ });
+
+ // the other ones are added as a context item
+ $logs = array();
+ foreach ($records as $r) {
+ $logs[] = $this->processRecord($r);
+ }
+
+ if ($logs) {
+ $record['context']['logs'] = (string) $this->getBatchFormatter()->formatBatch($logs);
+ }
+
+ $this->handle($record);
+ }
+
+ /**
+ * Sets the formatter for the logs generated by handleBatch().
+ *
+ * @param FormatterInterface $formatter
+ */
+ public function setBatchFormatter(FormatterInterface $formatter)
+ {
+ $this->batchFormatter = $formatter;
+ }
+
+ /**
+ * Gets the formatter for the logs generated by handleBatch().
+ *
+ * @return FormatterInterface
+ */
+ public function getBatchFormatter()
+ {
+ if (!$this->batchFormatter) {
+ $this->batchFormatter = $this->getDefaultBatchFormatter();
+ }
+
+ return $this->batchFormatter;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $options = array();
+ $options['level'] = $this->logLevels[$record['level']];
+ $options['tags'] = array();
+ if (!empty($record['extra']['tags'])) {
+ $options['tags'] = array_merge($options['tags'], $record['extra']['tags']);
+ unset($record['extra']['tags']);
+ }
+ if (!empty($record['context']['tags'])) {
+ $options['tags'] = array_merge($options['tags'], $record['context']['tags']);
+ unset($record['context']['tags']);
+ }
+ if (!empty($record['context'])) {
+ $options['extra']['context'] = $record['context'];
+ }
+ if (!empty($record['extra'])) {
+ $options['extra']['extra'] = $record['extra'];
+ }
+
+ if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
+ $options['extra']['message'] = $record['formatted'];
+ $this->ravenClient->captureException($record['context']['exception'], $options);
+
+ return;
+ }
+
+ $this->ravenClient->captureMessage($record['formatted'], array(), $options);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter('[%channel%] %message%');
+ }
+
+ /**
+ * Gets the default formatter for the logs generated by handleBatch().
+ *
+ * @return FormatterInterface
+ */
+ protected function getDefaultBatchFormatter()
+ {
+ return new LineFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
new file mode 100644
index 00000000..3fc7f34b
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Logs to a Redis key using rpush
+ *
+ * usage example:
+ *
+ * $log = new Logger('application');
+ * $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs", "prod");
+ * $log->pushHandler($redis);
+ *
+ * @author Thomas Tourlourat
+ */
+class RedisHandler extends AbstractProcessingHandler
+{
+ private $redisClient;
+ private $redisKey;
+
+ # redis instance, key to use
+ public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true)
+ {
+ if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) {
+ throw new \InvalidArgumentException('Predis\Client or Redis instance required');
+ }
+
+ $this->redisClient = $redis;
+ $this->redisKey = $key;
+
+ parent::__construct($level, $bubble);
+ }
+
+ protected function write(array $record)
+ {
+ $this->redisClient->rpush($this->redisKey, $record["formatted"]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getDefaultFormatter()
+ {
+ return new LineFormatter();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
new file mode 100644
index 00000000..fb02ad60
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
@@ -0,0 +1,64 @@
+
+ */
+class RollbarHandler extends AbstractProcessingHandler
+{
+ /**
+ * Rollbar notifier
+ *
+ * @var RollbarNotifier
+ */
+ protected $rollbarNotifier;
+
+ /**
+ * @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
+ {
+ $this->rollbarNotifier = $rollbarNotifier;
+
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
+ $this->rollbarNotifier->report_exception($record['context']['exception']);
+ } else {
+ $extraData = array(
+ 'level' => $record['level'],
+ 'channel' => $record['channel'],
+ 'datetime' => $record['datetime']->format('U'),
+ );
+
+ $this->rollbarNotifier->report_message(
+ $record['message'],
+ $record['level_name'],
+ array_merge($record['context'], $record['extra'], $extraData)
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $this->rollbarNotifier->flush();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
new file mode 100644
index 00000000..f8800bc8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
@@ -0,0 +1,152 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Stores logs to files that are rotated every day and a limited number of files are kept.
+ *
+ * This rotation is only intended to be used as a workaround. Using logrotate to
+ * handle the rotation is strongly encouraged when you can use it.
+ *
+ * @author Christophe Coevoet
+ * @author Jordi Boggiano
+ */
+class RotatingFileHandler extends StreamHandler
+{
+ protected $filename;
+ protected $maxFiles;
+ protected $mustRotate;
+ protected $nextRotation;
+ protected $filenameFormat;
+ protected $dateFormat;
+
+ /**
+ * @param string $filename
+ * @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $filePermission Optional file permissions (default (0644) are only for owner read/write)
+ */
+ public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null)
+ {
+ $this->filename = $filename;
+ $this->maxFiles = (int) $maxFiles;
+ $this->nextRotation = new \DateTime('tomorrow');
+ $this->filenameFormat = '{filename}-{date}';
+ $this->dateFormat = 'Y-m-d';
+
+ parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ parent::close();
+
+ if (true === $this->mustRotate) {
+ $this->rotate();
+ }
+ }
+
+ public function setFilenameFormat($filenameFormat, $dateFormat)
+ {
+ $this->filenameFormat = $filenameFormat;
+ $this->dateFormat = $dateFormat;
+ $this->url = $this->getTimedFilename();
+ $this->close();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ // on the first record written, if the log is new, we should rotate (once per day)
+ if (null === $this->mustRotate) {
+ $this->mustRotate = !file_exists($this->url);
+ }
+
+ if ($this->nextRotation < $record['datetime']) {
+ $this->mustRotate = true;
+ $this->close();
+ }
+
+ parent::write($record);
+ }
+
+ /**
+ * Rotates the files.
+ */
+ protected function rotate()
+ {
+ // update filename
+ $this->url = $this->getTimedFilename();
+ $this->nextRotation = new \DateTime('tomorrow');
+
+ // skip GC of old logs if files are unlimited
+ if (0 === $this->maxFiles) {
+ return;
+ }
+
+ $logFiles = glob($this->getGlobPattern());
+ if ($this->maxFiles >= count($logFiles)) {
+ // no files to remove
+ return;
+ }
+
+ // Sorting the files by name to remove the older ones
+ usort($logFiles, function ($a, $b) {
+ return strcmp($b, $a);
+ });
+
+ foreach (array_slice($logFiles, $this->maxFiles) as $file) {
+ if (is_writable($file)) {
+ unlink($file);
+ }
+ }
+ }
+
+ protected function getTimedFilename()
+ {
+ $fileInfo = pathinfo($this->filename);
+ $timedFilename = str_replace(
+ array('{filename}', '{date}'),
+ array($fileInfo['filename'], date($this->dateFormat)),
+ $fileInfo['dirname'] . '/' . $this->filenameFormat
+ );
+
+ if (!empty($fileInfo['extension'])) {
+ $timedFilename .= '.'.$fileInfo['extension'];
+ }
+
+ return $timedFilename;
+ }
+
+ protected function getGlobPattern()
+ {
+ $fileInfo = pathinfo($this->filename);
+ $glob = str_replace(
+ array('{filename}', '{date}'),
+ array($fileInfo['filename'], '*'),
+ $fileInfo['dirname'] . '/' . $this->filenameFormat
+ );
+ if (!empty($fileInfo['extension'])) {
+ $glob .= '.'.$fileInfo['extension'];
+ }
+
+ return $glob;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
new file mode 100644
index 00000000..4faa327d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
@@ -0,0 +1,285 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Stores to any socket - uses fsockopen() or pfsockopen().
+ *
+ * @author Pablo de Leon Belloc
+ * @see http://php.net/manual/en/function.fsockopen.php
+ */
+class SocketHandler extends AbstractProcessingHandler
+{
+ private $connectionString;
+ private $connectionTimeout;
+ private $resource;
+ private $timeout = 0;
+ private $persistent = false;
+ private $errno;
+ private $errstr;
+
+ /**
+ * @param string $connectionString Socket connection string
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+ $this->connectionString = $connectionString;
+ $this->connectionTimeout = (float) ini_get('default_socket_timeout');
+ }
+
+ /**
+ * Connect (if necessary) and write to the socket
+ *
+ * @param array $record
+ *
+ * @throws \UnexpectedValueException
+ * @throws \RuntimeException
+ */
+ public function write(array $record)
+ {
+ $this->connectIfNotConnected();
+ $data = $this->generateDataStream($record);
+ $this->writeToSocket($data);
+ }
+
+ /**
+ * We will not close a PersistentSocket instance so it can be reused in other requests.
+ */
+ public function close()
+ {
+ if (!$this->isPersistent()) {
+ $this->closeSocket();
+ }
+ }
+
+ /**
+ * Close socket, if open
+ */
+ public function closeSocket()
+ {
+ if (is_resource($this->resource)) {
+ fclose($this->resource);
+ $this->resource = null;
+ }
+ }
+
+ /**
+ * Set socket connection to nbe persistent. It only has effect before the connection is initiated.
+ *
+ * @param type $boolean
+ */
+ public function setPersistent($boolean)
+ {
+ $this->persistent = (boolean) $boolean;
+ }
+
+ /**
+ * Set connection timeout. Only has effect before we connect.
+ *
+ * @param float $seconds
+ *
+ * @see http://php.net/manual/en/function.fsockopen.php
+ */
+ public function setConnectionTimeout($seconds)
+ {
+ $this->validateTimeout($seconds);
+ $this->connectionTimeout = (float) $seconds;
+ }
+
+ /**
+ * Set write timeout. Only has effect before we connect.
+ *
+ * @param float $seconds
+ *
+ * @see http://php.net/manual/en/function.stream-set-timeout.php
+ */
+ public function setTimeout($seconds)
+ {
+ $this->validateTimeout($seconds);
+ $this->timeout = (float) $seconds;
+ }
+
+ /**
+ * Get current connection string
+ *
+ * @return string
+ */
+ public function getConnectionString()
+ {
+ return $this->connectionString;
+ }
+
+ /**
+ * Get persistent setting
+ *
+ * @return boolean
+ */
+ public function isPersistent()
+ {
+ return $this->persistent;
+ }
+
+ /**
+ * Get current connection timeout setting
+ *
+ * @return float
+ */
+ public function getConnectionTimeout()
+ {
+ return $this->connectionTimeout;
+ }
+
+ /**
+ * Get current in-transfer timeout
+ *
+ * @return float
+ */
+ public function getTimeout()
+ {
+ return $this->timeout;
+ }
+
+ /**
+ * Check to see if the socket is currently available.
+ *
+ * UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details.
+ *
+ * @return boolean
+ */
+ public function isConnected()
+ {
+ return is_resource($this->resource)
+ && !feof($this->resource); // on TCP - other party can close connection.
+ }
+
+ /**
+ * Wrapper to allow mocking
+ */
+ protected function pfsockopen()
+ {
+ return @pfsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout);
+ }
+
+ /**
+ * Wrapper to allow mocking
+ */
+ protected function fsockopen()
+ {
+ return @fsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout);
+ }
+
+ /**
+ * Wrapper to allow mocking
+ *
+ * @see http://php.net/manual/en/function.stream-set-timeout.php
+ */
+ protected function streamSetTimeout()
+ {
+ $seconds = floor($this->timeout);
+ $microseconds = round(($this->timeout - $seconds)*1e6);
+
+ return stream_set_timeout($this->resource, $seconds, $microseconds);
+ }
+
+ /**
+ * Wrapper to allow mocking
+ */
+ protected function fwrite($data)
+ {
+ return @fwrite($this->resource, $data);
+ }
+
+ /**
+ * Wrapper to allow mocking
+ */
+ protected function streamGetMetadata()
+ {
+ return stream_get_meta_data($this->resource);
+ }
+
+ private function validateTimeout($value)
+ {
+ $ok = filter_var($value, FILTER_VALIDATE_FLOAT);
+ if ($ok === false || $value < 0) {
+ throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)");
+ }
+ }
+
+ private function connectIfNotConnected()
+ {
+ if ($this->isConnected()) {
+ return;
+ }
+ $this->connect();
+ }
+
+ protected function generateDataStream($record)
+ {
+ return (string) $record['formatted'];
+ }
+
+ private function connect()
+ {
+ $this->createSocketResource();
+ $this->setSocketTimeout();
+ }
+
+ private function createSocketResource()
+ {
+ if ($this->isPersistent()) {
+ $resource = $this->pfsockopen();
+ } else {
+ $resource = $this->fsockopen();
+ }
+ if (!$resource) {
+ throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)");
+ }
+ $this->resource = $resource;
+ }
+
+ private function setSocketTimeout()
+ {
+ if (!$this->streamSetTimeout()) {
+ throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()");
+ }
+ }
+
+ private function writeToSocket($data)
+ {
+ $length = strlen($data);
+ $sent = 0;
+ while ($this->isConnected() && $sent < $length) {
+ if (0 == $sent) {
+ $chunk = $this->fwrite($data);
+ } else {
+ $chunk = $this->fwrite(substr($data, $sent));
+ }
+ if ($chunk === false) {
+ throw new \RuntimeException("Could not write to socket");
+ }
+ $sent += $chunk;
+ $socketInfo = $this->streamGetMetadata();
+ if ($socketInfo['timed_out']) {
+ throw new \RuntimeException("Write timed-out");
+ }
+ }
+ if (!$this->isConnected() && $sent < $length) {
+ throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)");
+ }
+ }
+
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
new file mode 100644
index 00000000..5c8fc1fc
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
@@ -0,0 +1,87 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Stores to any stream resource
+ *
+ * Can be used to store into php://stderr, remote and local files, etc.
+ *
+ * @author Jordi Boggiano
+ */
+class StreamHandler extends AbstractProcessingHandler
+{
+ protected $stream;
+ protected $url;
+ private $errorMessage;
+ protected $filePermission;
+
+ /**
+ * @param string $stream
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $filePermissions Optional file permissions (default (0644) are only for owner read/write)
+ */
+ public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $filePermission = null)
+ {
+ parent::__construct($level, $bubble);
+ if (is_resource($stream)) {
+ $this->stream = $stream;
+ } else {
+ $this->url = $stream;
+ }
+
+ $this->filePermission = $filePermission;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ if (is_resource($this->stream)) {
+ fclose($this->stream);
+ }
+ $this->stream = null;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ if (!is_resource($this->stream)) {
+ if (!$this->url) {
+ throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
+ }
+ $this->errorMessage = null;
+ set_error_handler(array($this, 'customErrorHandler'));
+ $this->stream = fopen($this->url, 'a');
+ if ($this->filePermission !== null) {
+ @chmod($this->url, $this->filePermission);
+ }
+ restore_error_handler();
+ if (!is_resource($this->stream)) {
+ $this->stream = null;
+ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
+ }
+ }
+ fwrite($this->stream, (string) $record['formatted']);
+ }
+
+ private function customErrorHandler($code, $msg)
+ {
+ $this->errorMessage = preg_replace('{^fopen\(.*?\): }', '', $msg);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
new file mode 100644
index 00000000..ca03ccaa
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
@@ -0,0 +1,55 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * SwiftMailerHandler uses Swift_Mailer to send the emails
+ *
+ * @author Gyula Sallai
+ */
+class SwiftMailerHandler extends MailHandler
+{
+ protected $mailer;
+ protected $message;
+
+ /**
+ * @param \Swift_Mailer $mailer The mailer to use
+ * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true)
+ {
+ parent::__construct($level, $bubble);
+ $this->mailer = $mailer;
+ if (!$message instanceof \Swift_Message && is_callable($message)) {
+ $message = call_user_func($message);
+ }
+ if (!$message instanceof \Swift_Message) {
+ throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
+ }
+ $this->message = $message;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function send($content, array $records)
+ {
+ $message = clone $this->message;
+ $message->setBody($content);
+
+ $this->mailer->send($message);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
new file mode 100644
index 00000000..47c73e12
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Logs to syslog service.
+ *
+ * usage example:
+ *
+ * $log = new Logger('application');
+ * $syslog = new SyslogHandler('myfacility', 'local6');
+ * $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%");
+ * $syslog->setFormatter($formatter);
+ * $log->pushHandler($syslog);
+ *
+ * @author Sven Paulus
+ */
+class SyslogHandler extends AbstractSyslogHandler
+{
+ protected $ident;
+ protected $logopts;
+
+ /**
+ * @param string $ident
+ * @param mixed $facility
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID
+ */
+ public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID)
+ {
+ parent::__construct($facility, $level, $bubble);
+
+ $this->ident = $ident;
+ $this->logopts = $logopts;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ closelog();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ if (!openlog($this->ident, $this->logopts, $this->facility)) {
+ throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"');
+ }
+ syslog($this->logLevels[$record['level']], (string) $record['formatted']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php
new file mode 100644
index 00000000..d87ab9d3
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php
@@ -0,0 +1,62 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler\SyslogUdp;
+
+class UdpSocket
+{
+ const DATAGRAM_MAX_LENGTH = 2048;
+
+ public function __construct($ip, $port = 514)
+ {
+ $this->ip = $ip;
+ $this->port = $port;
+ $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+ }
+
+ public function write($line, $header = "")
+ {
+ $remaining = $line;
+ while (!is_null($remaining)) {
+ list($chunk, $remaining) = $this->splitLineIfNessesary($remaining, $header);
+ $this->send($chunk);
+ }
+ }
+
+ public function close()
+ {
+ socket_close($this->socket);
+ }
+
+ protected function send($chunk)
+ {
+ socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
+ }
+
+ protected function splitLineIfNessesary($line, $header)
+ {
+ if ($this->shouldSplitLine($line, $header)) {
+ $chunkSize = self::DATAGRAM_MAX_LENGTH - strlen($header);
+ $chunk = $header . substr($line, 0, $chunkSize);
+ $remaining = substr($line, $chunkSize);
+ } else {
+ $chunk = $header . $line;
+ $remaining = null;
+ }
+
+ return array($chunk, $remaining);
+ }
+
+ protected function shouldSplitLine($remaining, $header)
+ {
+ return strlen($header.$remaining) > self::DATAGRAM_MAX_LENGTH;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
new file mode 100644
index 00000000..4aadffc5
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
@@ -0,0 +1,80 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\Handler\SyslogUdp\UdpSocket;
+
+/**
+ * A Handler for logging to a remote syslogd server.
+ *
+ * @author Jesper Skovgaard Nielsen
+ */
+class SyslogUdpHandler extends AbstractSyslogHandler
+{
+ /**
+ * @param string $host
+ * @param int $port
+ * @param mixed $facility
+ * @param integer $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
+ {
+ parent::__construct($facility, $level, $bubble);
+
+ $this->socket = new UdpSocket($host, $port ?: 514);
+ }
+
+ protected function write(array $record)
+ {
+ $lines = $this->splitMessageIntoLines($record['formatted']);
+
+ $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]);
+
+ foreach ($lines as $line) {
+ $this->socket->write($line, $header);
+ }
+ }
+
+ public function close()
+ {
+ $this->socket->close();
+ }
+
+ private function splitMessageIntoLines($message)
+ {
+ if (is_array($message)) {
+ $message = implode("\n", $message);
+ }
+
+ return preg_split('/$\R?^/m', $message);
+ }
+
+ /**
+ * Make common syslog header (see rfc5424)
+ */
+ private function makeCommonSyslogHeader($severity)
+ {
+ $priority = $severity + $this->facility;
+
+ return "<$priority>: ";
+ }
+
+ /**
+ * Inject your own socket, mainly used for testing
+ */
+ public function setSocket($socket)
+ {
+ $this->socket = $socket;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
new file mode 100644
index 00000000..085d9e17
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
@@ -0,0 +1,140 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+
+/**
+ * Used for testing purposes.
+ *
+ * It records all records and gives you access to them for verification.
+ *
+ * @author Jordi Boggiano
+ */
+class TestHandler extends AbstractProcessingHandler
+{
+ protected $records = array();
+ protected $recordsByLevel = array();
+
+ public function getRecords()
+ {
+ return $this->records;
+ }
+
+ public function hasEmergency($record)
+ {
+ return $this->hasRecord($record, Logger::EMERGENCY);
+ }
+
+ public function hasAlert($record)
+ {
+ return $this->hasRecord($record, Logger::ALERT);
+ }
+
+ public function hasCritical($record)
+ {
+ return $this->hasRecord($record, Logger::CRITICAL);
+ }
+
+ public function hasError($record)
+ {
+ return $this->hasRecord($record, Logger::ERROR);
+ }
+
+ public function hasWarning($record)
+ {
+ return $this->hasRecord($record, Logger::WARNING);
+ }
+
+ public function hasNotice($record)
+ {
+ return $this->hasRecord($record, Logger::NOTICE);
+ }
+
+ public function hasInfo($record)
+ {
+ return $this->hasRecord($record, Logger::INFO);
+ }
+
+ public function hasDebug($record)
+ {
+ return $this->hasRecord($record, Logger::DEBUG);
+ }
+
+ public function hasEmergencyRecords()
+ {
+ return isset($this->recordsByLevel[Logger::EMERGENCY]);
+ }
+
+ public function hasAlertRecords()
+ {
+ return isset($this->recordsByLevel[Logger::ALERT]);
+ }
+
+ public function hasCriticalRecords()
+ {
+ return isset($this->recordsByLevel[Logger::CRITICAL]);
+ }
+
+ public function hasErrorRecords()
+ {
+ return isset($this->recordsByLevel[Logger::ERROR]);
+ }
+
+ public function hasWarningRecords()
+ {
+ return isset($this->recordsByLevel[Logger::WARNING]);
+ }
+
+ public function hasNoticeRecords()
+ {
+ return isset($this->recordsByLevel[Logger::NOTICE]);
+ }
+
+ public function hasInfoRecords()
+ {
+ return isset($this->recordsByLevel[Logger::INFO]);
+ }
+
+ public function hasDebugRecords()
+ {
+ return isset($this->recordsByLevel[Logger::DEBUG]);
+ }
+
+ protected function hasRecord($record, $level)
+ {
+ if (!isset($this->recordsByLevel[$level])) {
+ return false;
+ }
+
+ if (is_array($record)) {
+ $record = $record['message'];
+ }
+
+ foreach ($this->recordsByLevel[$level] as $rec) {
+ if ($rec['message'] === $record) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $this->recordsByLevel[$record['level']][] = $record;
+ $this->records[] = $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
new file mode 100644
index 00000000..f22cf218
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
@@ -0,0 +1,95 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\NormalizerFormatter;
+use Monolog\Logger;
+
+/**
+ * Handler sending logs to Zend Monitor
+ *
+ * @author Christian Bergau
+ */
+class ZendMonitorHandler extends AbstractProcessingHandler
+{
+ /**
+ * Monolog level / ZendMonitor Custom Event priority map
+ *
+ * @var array
+ */
+ protected $levelMap = array(
+ Logger::DEBUG => 1,
+ Logger::INFO => 2,
+ Logger::NOTICE => 3,
+ Logger::WARNING => 4,
+ Logger::ERROR => 5,
+ Logger::CRITICAL => 6,
+ Logger::ALERT => 7,
+ Logger::EMERGENCY => 0,
+ );
+
+ /**
+ * Construct
+ *
+ * @param int $level
+ * @param bool $bubble
+ * @throws MissingExtensionException
+ */
+ public function __construct($level = Logger::DEBUG, $bubble = true)
+ {
+ if (!function_exists('zend_monitor_custom_event')) {
+ throw new MissingExtensionException('You must have Zend Server installed in order to use this handler');
+ }
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function write(array $record)
+ {
+ $this->writeZendMonitorCustomEvent(
+ $this->levelMap[$record['level']],
+ $record['message'],
+ $record['formatted']
+ );
+ }
+
+ /**
+ * Write a record to Zend Monitor
+ *
+ * @param int $level
+ * @param string $message
+ * @param array $formatted
+ */
+ protected function writeZendMonitorCustomEvent($level, $message, $formatted)
+ {
+ zend_monitor_custom_event($level, $message, $formatted);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDefaultFormatter()
+ {
+ return new NormalizerFormatter();
+ }
+
+ /**
+ * Get the level map
+ *
+ * @return array
+ */
+ public function getLevelMap()
+ {
+ return $this->levelMap;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Logger.php b/src/lib/vendor/monolog/monolog/src/Monolog/Logger.php
new file mode 100644
index 00000000..3e3f95ce
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Logger.php
@@ -0,0 +1,598 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use Monolog\Handler\HandlerInterface;
+use Monolog\Handler\StreamHandler;
+use Psr\Log\LoggerInterface;
+use Psr\Log\InvalidArgumentException;
+
+/**
+ * Monolog log channel
+ *
+ * It contains a stack of Handlers and a stack of Processors,
+ * and uses them to store records that are added to it.
+ *
+ * @author Jordi Boggiano
+ */
+class Logger implements LoggerInterface
+{
+ /**
+ * Detailed debug information
+ */
+ const DEBUG = 100;
+
+ /**
+ * Interesting events
+ *
+ * Examples: User logs in, SQL logs.
+ */
+ const INFO = 200;
+
+ /**
+ * Uncommon events
+ */
+ const NOTICE = 250;
+
+ /**
+ * Exceptional occurrences that are not errors
+ *
+ * Examples: Use of deprecated APIs, poor use of an API,
+ * undesirable things that are not necessarily wrong.
+ */
+ const WARNING = 300;
+
+ /**
+ * Runtime errors
+ */
+ const ERROR = 400;
+
+ /**
+ * Critical conditions
+ *
+ * Example: Application component unavailable, unexpected exception.
+ */
+ const CRITICAL = 500;
+
+ /**
+ * Action must be taken immediately
+ *
+ * Example: Entire website down, database unavailable, etc.
+ * This should trigger the SMS alerts and wake you up.
+ */
+ const ALERT = 550;
+
+ /**
+ * Urgent alert.
+ */
+ const EMERGENCY = 600;
+
+ /**
+ * Monolog API version
+ *
+ * This is only bumped when API breaks are done and should
+ * follow the major version of the library
+ *
+ * @var int
+ */
+ const API = 1;
+
+ /**
+ * Logging levels from syslog protocol defined in RFC 5424
+ *
+ * @var array $levels Logging levels
+ */
+ protected static $levels = array(
+ 100 => 'DEBUG',
+ 200 => 'INFO',
+ 250 => 'NOTICE',
+ 300 => 'WARNING',
+ 400 => 'ERROR',
+ 500 => 'CRITICAL',
+ 550 => 'ALERT',
+ 600 => 'EMERGENCY',
+ );
+
+ /**
+ * @var \DateTimeZone
+ */
+ protected static $timezone;
+
+ /**
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * The handler stack
+ *
+ * @var HandlerInterface[]
+ */
+ protected $handlers;
+
+ /**
+ * Processors that will process all log records
+ *
+ * To process records of a single handler instead, add the processor on that specific handler
+ *
+ * @var callable[]
+ */
+ protected $processors;
+
+ /**
+ * @param string $name The logging channel
+ * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
+ * @param callable[] $processors Optional array of processors
+ */
+ public function __construct($name, array $handlers = array(), array $processors = array())
+ {
+ $this->name = $name;
+ $this->handlers = $handlers;
+ $this->processors = $processors;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Pushes a handler on to the stack.
+ *
+ * @param HandlerInterface $handler
+ */
+ public function pushHandler(HandlerInterface $handler)
+ {
+ array_unshift($this->handlers, $handler);
+ }
+
+ /**
+ * Pops a handler from the stack
+ *
+ * @return HandlerInterface
+ */
+ public function popHandler()
+ {
+ if (!$this->handlers) {
+ throw new \LogicException('You tried to pop from an empty handler stack.');
+ }
+
+ return array_shift($this->handlers);
+ }
+
+ /**
+ * @return HandlerInterface[]
+ */
+ public function getHandlers()
+ {
+ return $this->handlers;
+ }
+
+ /**
+ * Adds a processor on to the stack.
+ *
+ * @param callable $callback
+ */
+ public function pushProcessor($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
+ }
+ array_unshift($this->processors, $callback);
+ }
+
+ /**
+ * Removes the processor on top of the stack and returns it.
+ *
+ * @return callable
+ */
+ public function popProcessor()
+ {
+ if (!$this->processors) {
+ throw new \LogicException('You tried to pop from an empty processor stack.');
+ }
+
+ return array_shift($this->processors);
+ }
+
+ /**
+ * @return callable[]
+ */
+ public function getProcessors()
+ {
+ return $this->processors;
+ }
+
+ /**
+ * Adds a log record.
+ *
+ * @param integer $level The logging level
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addRecord($level, $message, array $context = array())
+ {
+ if (!$this->handlers) {
+ $this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
+ }
+
+ if (!static::$timezone) {
+ static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
+ }
+
+ $record = array(
+ 'message' => (string) $message,
+ 'context' => $context,
+ 'level' => $level,
+ 'level_name' => static::getLevelName($level),
+ 'channel' => $this->name,
+ 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
+ 'extra' => array(),
+ );
+ // check if any handler will handle this message
+ $handlerKey = null;
+ foreach ($this->handlers as $key => $handler) {
+ if ($handler->isHandling($record)) {
+ $handlerKey = $key;
+ break;
+ }
+ }
+ // none found
+ if (null === $handlerKey) {
+ return false;
+ }
+
+ // found at least one, process message and dispatch it
+ foreach ($this->processors as $processor) {
+ $record = call_user_func($processor, $record);
+ }
+ while (isset($this->handlers[$handlerKey]) &&
+ false === $this->handlers[$handlerKey]->handle($record)) {
+ $handlerKey++;
+ }
+
+ return true;
+ }
+
+ /**
+ * Adds a log record at the DEBUG level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addDebug($message, array $context = array())
+ {
+ return $this->addRecord(static::DEBUG, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the INFO level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addInfo($message, array $context = array())
+ {
+ return $this->addRecord(static::INFO, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the NOTICE level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addNotice($message, array $context = array())
+ {
+ return $this->addRecord(static::NOTICE, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the WARNING level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addWarning($message, array $context = array())
+ {
+ return $this->addRecord(static::WARNING, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the ERROR level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addError($message, array $context = array())
+ {
+ return $this->addRecord(static::ERROR, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the CRITICAL level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addCritical($message, array $context = array())
+ {
+ return $this->addRecord(static::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the ALERT level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addAlert($message, array $context = array())
+ {
+ return $this->addRecord(static::ALERT, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the EMERGENCY level.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function addEmergency($message, array $context = array())
+ {
+ return $this->addRecord(static::EMERGENCY, $message, $context);
+ }
+
+ /**
+ * Gets all supported logging levels.
+ *
+ * @return array Assoc array with human-readable level names => level codes.
+ */
+ public static function getLevels()
+ {
+ return array_flip(static::$levels);
+ }
+
+ /**
+ * Gets the name of the logging level.
+ *
+ * @param integer $level
+ * @return string
+ */
+ public static function getLevelName($level)
+ {
+ if (!isset(static::$levels[$level])) {
+ throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
+ }
+
+ return static::$levels[$level];
+ }
+
+ /**
+ * Checks whether the Logger has a handler that listens on the given level
+ *
+ * @param integer $level
+ * @return Boolean
+ */
+ public function isHandling($level)
+ {
+ $record = array(
+ 'level' => $level,
+ );
+
+ foreach ($this->handlers as $handler) {
+ if ($handler->isHandling($record)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Adds a log record at an arbitrary level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param mixed $level The log level
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function log($level, $message, array $context = array())
+ {
+ if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
+ $level = constant(__CLASS__.'::'.strtoupper($level));
+ }
+
+ return $this->addRecord($level, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the DEBUG level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function debug($message, array $context = array())
+ {
+ return $this->addRecord(static::DEBUG, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the INFO level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function info($message, array $context = array())
+ {
+ return $this->addRecord(static::INFO, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the INFO level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function notice($message, array $context = array())
+ {
+ return $this->addRecord(static::NOTICE, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the WARNING level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function warn($message, array $context = array())
+ {
+ return $this->addRecord(static::WARNING, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the WARNING level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function warning($message, array $context = array())
+ {
+ return $this->addRecord(static::WARNING, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the ERROR level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function err($message, array $context = array())
+ {
+ return $this->addRecord(static::ERROR, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the ERROR level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function error($message, array $context = array())
+ {
+ return $this->addRecord(static::ERROR, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the CRITICAL level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function crit($message, array $context = array())
+ {
+ return $this->addRecord(static::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the CRITICAL level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function critical($message, array $context = array())
+ {
+ return $this->addRecord(static::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the ALERT level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function alert($message, array $context = array())
+ {
+ return $this->addRecord(static::ALERT, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the EMERGENCY level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function emerg($message, array $context = array())
+ {
+ return $this->addRecord(static::EMERGENCY, $message, $context);
+ }
+
+ /**
+ * Adds a log record at the EMERGENCY level.
+ *
+ * This method allows for compatibility with common interfaces.
+ *
+ * @param string $message The log message
+ * @param array $context The log context
+ * @return Boolean Whether the record has been processed
+ */
+ public function emergency($message, array $context = array())
+ {
+ return $this->addRecord(static::EMERGENCY, $message, $context);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
new file mode 100644
index 00000000..96c2abfe
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
@@ -0,0 +1,64 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\Logger;
+
+/**
+ * Injects Git branch and Git commit SHA in all records
+ *
+ * @author Nick Otter
+ * @author Jordi Boggiano
+ */
+class GitProcessor
+{
+ private $level;
+ private static $cache;
+
+ public function __construct($level = Logger::DEBUG)
+ {
+ $this->level = $level;
+ }
+
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ // return if the level is not high enough
+ if ($record['level'] < $this->level) {
+ return $record;
+ }
+
+ $record['extra']['git'] = self::getGitInfo();
+
+ return $record;
+ }
+
+ private static function getGitInfo()
+ {
+ if (self::$cache) {
+ return self::$cache;
+ }
+
+ $branches = `git branch -v --no-abbrev`;
+ if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) {
+ return self::$cache = array(
+ 'branch' => $matches[1],
+ 'commit' => $matches[2],
+ );
+ }
+
+ return self::$cache = array();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
new file mode 100644
index 00000000..a2c48ce6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
@@ -0,0 +1,82 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\Logger;
+
+/**
+ * Injects line/file:class/function where the log message came from
+ *
+ * Warning: This only works if the handler processes the logs directly.
+ * If you put the processor on a handler that is behind a FingersCrossedHandler
+ * for example, the processor will only be called once the trigger level is reached,
+ * and all the log records will have the same file/line/.. data from the call that
+ * triggered the FingersCrossedHandler.
+ *
+ * @author Jordi Boggiano
+ */
+class IntrospectionProcessor
+{
+ private $level;
+
+ private $skipClassesPartials;
+
+ public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array('Monolog\\'))
+ {
+ $this->level = $level;
+ $this->skipClassesPartials = $skipClassesPartials;
+ }
+
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ // return if the level is not high enough
+ if ($record['level'] < $this->level) {
+ return $record;
+ }
+
+ $trace = debug_backtrace();
+
+ // skip first since it's always the current method
+ array_shift($trace);
+ // the call_user_func call is also skipped
+ array_shift($trace);
+
+ $i = 0;
+
+ while (isset($trace[$i]['class'])) {
+ foreach ($this->skipClassesPartials as $part) {
+ if (strpos($trace[$i]['class'], $part) !== false) {
+ $i++;
+ continue 2;
+ }
+ }
+ break;
+ }
+
+ // we should have the call source now
+ $record['extra'] = array_merge(
+ $record['extra'],
+ array(
+ 'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null,
+ 'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null,
+ 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
+ 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
+ )
+ );
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php
new file mode 100644
index 00000000..552fd709
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Injects memory_get_peak_usage in all records
+ *
+ * @see Monolog\Processor\MemoryProcessor::__construct() for options
+ * @author Rob Jensen
+ */
+class MemoryPeakUsageProcessor extends MemoryProcessor
+{
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ $bytes = memory_get_peak_usage($this->realUsage);
+ $formatted = $this->formatBytes($bytes);
+
+ $record['extra'] = array_merge(
+ $record['extra'],
+ array(
+ 'memory_peak_usage' => $formatted,
+ )
+ );
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
new file mode 100644
index 00000000..7e53f470
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
@@ -0,0 +1,64 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Some methods that are common for all memory processors
+ *
+ * @author Rob Jensen
+ */
+abstract class MemoryProcessor
+{
+ /**
+ * @var boolean If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported.
+ */
+ protected $realUsage;
+
+ /**
+ * @var boolean If true, then format memory size to human readable string (MB, KB, B depending on size)
+ */
+ protected $useFormatting;
+
+ /**
+ * @param boolean $realUsage Set this to true to get the real size of memory allocated from system.
+ * @param boolean $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size)
+ */
+ public function __construct($realUsage = true, $useFormatting = true)
+ {
+ $this->realUsage = (boolean) $realUsage;
+ $this->useFormatting = (boolean) $useFormatting;
+ }
+
+ /**
+ * Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is
+ *
+ * @param int $bytes
+ * @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is
+ */
+ protected function formatBytes($bytes)
+ {
+ $bytes = (int) $bytes;
+
+ if (!$this->useFormatting) {
+ return $bytes;
+ }
+
+ if ($bytes > 1024*1024) {
+ return round($bytes/1024/1024, 2).' MB';
+ } elseif ($bytes > 1024) {
+ return round($bytes/1024, 2).' KB';
+ }
+
+ return $bytes . ' B';
+ }
+
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php
new file mode 100644
index 00000000..0c4dd9ab
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Injects memory_get_usage in all records
+ *
+ * @see Monolog\Processor\MemoryProcessor::__construct() for options
+ * @author Rob Jensen
+ */
+class MemoryUsageProcessor extends MemoryProcessor
+{
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ $bytes = memory_get_usage($this->realUsage);
+ $formatted = $this->formatBytes($bytes);
+
+ $record['extra'] = array_merge(
+ $record['extra'],
+ array(
+ 'memory_usage' => $formatted,
+ )
+ );
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
new file mode 100644
index 00000000..9d3f5590
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Adds value of getmypid into records
+ *
+ * @author Andreas Hörnicke
+ */
+class ProcessIdProcessor
+{
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ $record['extra']['process_id'] = getmypid();
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
new file mode 100644
index 00000000..b63fcccc
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
@@ -0,0 +1,42 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Processes a record's message according to PSR-3 rules
+ *
+ * It replaces {foo} with the value from $context['foo']
+ *
+ * @author Jordi Boggiano
+ */
+class PsrLogMessageProcessor
+{
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ if (false === strpos($record['message'], '{')) {
+ return $record;
+ }
+
+ $replacements = array();
+ foreach ($record['context'] as $key => $val) {
+ $replacements['{'.$key.'}'] = $val;
+ }
+
+ $record['message'] = strtr($record['message'], $replacements);
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
new file mode 100644
index 00000000..2784cef4
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
@@ -0,0 +1,34 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Adds a tags array into record
+ *
+ * @author Martijn Riemers
+ */
+class TagProcessor
+{
+ private $tags;
+
+ public function __construct(array $tags = array())
+ {
+ $this->tags = $tags;
+ }
+
+ public function __invoke(array $record)
+ {
+ $record['extra']['tags'] = $this->tags;
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
new file mode 100644
index 00000000..80270d08
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
@@ -0,0 +1,38 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Adds a unique identifier into records
+ *
+ * @author Simon Mönch
+ */
+class UidProcessor
+{
+ private $uid;
+
+ public function __construct($length = 7)
+ {
+ if (!is_int($length) || $length > 32 || $length < 1) {
+ throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
+ }
+
+ $this->uid = substr(hash('md5', uniqid('', true)), 0, $length);
+ }
+
+ public function __invoke(array $record)
+ {
+ $record['extra']['uid'] = $this->uid;
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
new file mode 100644
index 00000000..4c2bc191
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
@@ -0,0 +1,66 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+/**
+ * Injects url/method and remote IP of the current web request in all records
+ *
+ * @author Jordi Boggiano
+ */
+class WebProcessor
+{
+ protected $serverData;
+
+ /**
+ * @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data
+ */
+ public function __construct($serverData = null)
+ {
+ if (null === $serverData) {
+ $this->serverData =& $_SERVER;
+ } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) {
+ $this->serverData = $serverData;
+ } else {
+ throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
+ }
+ }
+
+ /**
+ * @param array $record
+ * @return array
+ */
+ public function __invoke(array $record)
+ {
+ // skip processing if for some reason request data
+ // is not present (CLI or wonky SAPIs)
+ if (!isset($this->serverData['REQUEST_URI'])) {
+ return $record;
+ }
+
+ $record['extra'] = array_merge(
+ $record['extra'],
+ array(
+ 'url' => $this->serverData['REQUEST_URI'],
+ 'ip' => isset($this->serverData['REMOTE_ADDR']) ? $this->serverData['REMOTE_ADDR'] : null,
+ 'http_method' => isset($this->serverData['REQUEST_METHOD']) ? $this->serverData['REQUEST_METHOD'] : null,
+ 'server' => isset($this->serverData['SERVER_NAME']) ? $this->serverData['SERVER_NAME'] : null,
+ 'referrer' => isset($this->serverData['HTTP_REFERER']) ? $this->serverData['HTTP_REFERER'] : null,
+ )
+ );
+
+ if (isset($this->serverData['UNIQUE_ID'])) {
+ $record['extra']['unique_id'] = $this->serverData['UNIQUE_ID'];
+ }
+
+ return $record;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/src/Monolog/Registry.php b/src/lib/vendor/monolog/monolog/src/Monolog/Registry.php
new file mode 100644
index 00000000..a3eba079
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/src/Monolog/Registry.php
@@ -0,0 +1,118 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use InvalidArgumentException;
+
+/**
+ * Monolog log registry
+ *
+ * Allows to get `Logger` instances in the global scope
+ * via static method calls on this class.
+ *
+ *
+ * $application = new Monolog\Logger('application');
+ * $api = new Monolog\Logger('api');
+ *
+ * Monolog\Registry::addLogger($application);
+ * Monolog\Registry::addLogger($api);
+ *
+ * function testLogger()
+ * {
+ * Monolog\Registry::api()->addError('Sent to $api Logger instance');
+ * Monolog\Registry::application()->addError('Sent to $application Logger instance');
+ * }
+ *
+ *
+ * @author Tomas Tatarko
+ */
+class Registry
+{
+ /**
+ * List of all loggers in the registry (ba named indexes)
+ *
+ * @var Logger[]
+ */
+ private static $loggers = array();
+
+ /**
+ * Adds new logging channel to the registry
+ *
+ * @param Logger $logger Instance of the logging channel
+ * @param string|null $name Name of the logging channel ($logger->getName() by default)
+ * @param boolean $overwrite Overwrite instance in the registry if the given name already exists?
+ * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
+ */
+ public static function addLogger(Logger $logger, $name = null, $overwrite = false)
+ {
+ $name = $name ?: $logger->getName();
+
+ if (isset(self::$loggers[$name]) && !$overwrite) {
+ throw new InvalidArgumentException('Logger with the given name already exists');
+ }
+
+ self::$loggers[$name] = $logger;
+ }
+
+ /**
+ * Removes instance from registry by name or instance
+ *
+ * @param string|Logger $logger Name or logger instance
+ */
+ public static function removeLogger($logger)
+ {
+ if ($logger instanceof Logger) {
+ if (false !== ($idx = array_search($logger, self::$loggers, true))) {
+ unset(self::$loggers[$idx]);
+ }
+ } else {
+ unset(self::$loggers[$logger]);
+ }
+ }
+
+ /**
+ * Clears the registry
+ */
+ public static function clear()
+ {
+ self::$loggers = array();
+ }
+
+ /**
+ * Gets Logger instance from the registry
+ *
+ * @param string $name Name of the requested Logger instance
+ * @return Logger Requested instance of Logger
+ * @throws \InvalidArgumentException If named Logger instance is not in the registry
+ */
+ public static function getInstance($name)
+ {
+ if (!isset(self::$loggers[$name])) {
+ throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name));
+ }
+
+ return self::$loggers[$name];
+ }
+
+ /**
+ * Gets Logger instance from the registry via static method call
+ *
+ * @param string $name Name of the requested Logger instance
+ * @param array $arguments Arguments passed to static method call
+ * @return Logger Requested instance of Logger
+ * @throws \InvalidArgumentException If named Logger instance is not in the registry
+ */
+ public static function __callStatic($name, $arguments)
+ {
+ return self::getInstance($name);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php
new file mode 100644
index 00000000..a9a3f301
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php
@@ -0,0 +1,31 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use Monolog\Handler\TestHandler;
+
+class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ public function testHandleError()
+ {
+ $logger = new Logger('test', array($handler = new TestHandler));
+ $errHandler = new ErrorHandler($logger);
+
+ $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
+ trigger_error('Foo', E_USER_ERROR);
+ $this->assertCount(1, $handler->getRecords());
+ $this->assertTrue($handler->hasErrorRecords());
+ trigger_error('Foo', E_USER_NOTICE);
+ $this->assertCount(2, $handler->getRecords());
+ $this->assertTrue($handler->hasEmergencyRecords());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
new file mode 100644
index 00000000..e7f7334e
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php
@@ -0,0 +1,158 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers Monolog\Formatter\ChromePHPFormatter::format
+ */
+ public function testDefaultFormat()
+ {
+ $formatter = new ChromePHPFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('ip' => '127.0.0.1'),
+ 'message' => 'log',
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertEquals(
+ array(
+ 'meh',
+ array(
+ 'message' => 'log',
+ 'context' => array('from' => 'logger'),
+ 'extra' => array('ip' => '127.0.0.1'),
+ ),
+ 'unknown',
+ 'error'
+ ),
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\ChromePHPFormatter::format
+ */
+ public function testFormatWithFileAndLine()
+ {
+ $formatter = new ChromePHPFormatter();
+ $record = array(
+ 'level' => Logger::CRITICAL,
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
+ 'message' => 'log',
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertEquals(
+ array(
+ 'meh',
+ array(
+ 'message' => 'log',
+ 'context' => array('from' => 'logger'),
+ 'extra' => array('ip' => '127.0.0.1'),
+ ),
+ 'test : 14',
+ 'error'
+ ),
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\ChromePHPFormatter::format
+ */
+ public function testFormatWithoutContext()
+ {
+ $formatter = new ChromePHPFormatter();
+ $record = array(
+ 'level' => Logger::DEBUG,
+ 'level_name' => 'DEBUG',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertEquals(
+ array(
+ 'meh',
+ 'log',
+ 'unknown',
+ 'log'
+ ),
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch
+ */
+ public function testBatchFormatThrowException()
+ {
+ $formatter = new ChromePHPFormatter();
+ $records = array(
+ array(
+ 'level' => Logger::INFO,
+ 'level_name' => 'INFO',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ ),
+ array(
+ 'level' => Logger::WARNING,
+ 'level_name' => 'WARNING',
+ 'channel' => 'foo',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log2',
+ ),
+ );
+
+ $this->assertEquals(
+ array(
+ array(
+ 'meh',
+ 'log',
+ 'unknown',
+ 'info'
+ ),
+ array(
+ 'foo',
+ 'log2',
+ 'unknown',
+ 'warn'
+ ),
+ ),
+ $formatter->formatBatch($records)
+ );
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php
new file mode 100644
index 00000000..546e5c26
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php
@@ -0,0 +1,79 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists("Elastica\Document")) {
+ $this->markTestSkipped("ruflin/elastica not installed");
+ }
+ }
+
+ /**
+ * @covers Monolog\Formatter\ElasticaFormatter::__construct
+ * @covers Monolog\Formatter\ElasticaFormatter::format
+ * @covers Monolog\Formatter\ElasticaFormatter::getDocument
+ */
+ public function testFormat()
+ {
+ // test log message
+ $msg = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ // expected values
+ $expected = $msg;
+ $expected['datetime'] = '1970-01-01T00:00:00+0000';
+ $expected['context'] = array(
+ 'class' => '[object] (stdClass: {})',
+ 'foo' => 7,
+ 0 => 'bar',
+ );
+
+ // format log message
+ $formatter = new ElasticaFormatter('my_index', 'doc_type');
+ $doc = $formatter->format($msg);
+ $this->assertInstanceOf('Elastica\Document', $doc);
+
+ // Document parameters
+ $params = $doc->getParams();
+ $this->assertEquals('my_index', $params['_index']);
+ $this->assertEquals('doc_type', $params['_type']);
+
+ // Document data values
+ $data = $doc->getData();
+ foreach (array_keys($expected) as $key) {
+ $this->assertEquals($expected[$key], $data[$key]);
+ }
+ }
+
+ /**
+ * @covers Monolog\Formatter\ElasticaFormatter::getIndex
+ * @covers Monolog\Formatter\ElasticaFormatter::getType
+ */
+ public function testGetters()
+ {
+ $formatter = new ElasticaFormatter('my_index', 'doc_type');
+ $this->assertEquals('my_index', $formatter->getIndex());
+ $this->assertEquals('doc_type', $formatter->getType());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php
new file mode 100644
index 00000000..1b2fd97a
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php
@@ -0,0 +1,55 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+use Monolog\TestCase;
+
+class FlowdockFormatterTest extends TestCase
+{
+ /**
+ * @covers Monolog\Formatter\FlowdockFormatter::format
+ */
+ public function testFormat()
+ {
+ $formatter = new FlowdockFormatter('test_source', 'source@test.com');
+ $record = $this->getRecord();
+
+ $expected = array(
+ 'source' => 'test_source',
+ 'from_address' => 'source@test.com',
+ 'subject' => 'in test_source: WARNING - test',
+ 'content' => 'test',
+ 'tags' => array('#logs', '#warning', '#test'),
+ 'project' => 'test_source',
+ );
+ $formatted = $formatter->format($record);
+
+ $this->assertEquals($expected, $formatted['flowdock']);
+ }
+
+ /**
+ * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch
+ */
+ public function testFormatBatch()
+ {
+ $formatter = new FlowdockFormatter('test_source', 'source@test.com');
+ $records = array(
+ $this->getRecord(Logger::WARNING),
+ $this->getRecord(Logger::DEBUG),
+ );
+ $formatted = $formatter->formatBatch($records);
+
+ $this->assertArrayHasKey('flowdock', $formatted[0]);
+ $this->assertArrayHasKey('flowdock', $formatted[1]);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
new file mode 100644
index 00000000..d47ba91c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php
@@ -0,0 +1,191 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('\Gelf\Message')) {
+ $this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed");
+ }
+ }
+
+ /**
+ * @covers Monolog\Formatter\GelfMessageFormatter::format
+ */
+ public function testDefaultFormatter()
+ {
+ $formatter = new GelfMessageFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+ $this->assertEquals(0, $message->getTimestamp());
+ $this->assertEquals('log', $message->getShortMessage());
+ $this->assertEquals('meh', $message->getFacility());
+ $this->assertEquals(null, $message->getLine());
+ $this->assertEquals(null, $message->getFile());
+ $this->assertEquals($this->isLegacy() ? 3 : 'error', $message->getLevel());
+ $this->assertNotEmpty($message->getHost());
+
+ $formatter = new GelfMessageFormatter('mysystem');
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+ $this->assertEquals('mysystem', $message->getHost());
+ }
+
+ /**
+ * @covers Monolog\Formatter\GelfMessageFormatter::format
+ */
+ public function testFormatWithFileAndLine()
+ {
+ $formatter = new GelfMessageFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('file' => 'test', 'line' => 14),
+ 'message' => 'log',
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+ $this->assertEquals('test', $message->getFile());
+ $this->assertEquals(14, $message->getLine());
+ }
+
+ /**
+ * @covers Monolog\Formatter\GelfMessageFormatter::format
+ */
+ public function testFormatWithContext()
+ {
+ $formatter = new GelfMessageFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+
+ $message_array = $message->toArray();
+
+ $this->assertArrayHasKey('_ctxt_from', $message_array);
+ $this->assertEquals('logger', $message_array['_ctxt_from']);
+
+ // Test with extraPrefix
+ $formatter = new GelfMessageFormatter(null, null, 'CTX');
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+
+ $message_array = $message->toArray();
+
+ $this->assertArrayHasKey('_CTXfrom', $message_array);
+ $this->assertEquals('logger', $message_array['_CTXfrom']);
+
+ }
+
+ /**
+ * @covers Monolog\Formatter\GelfMessageFormatter::format
+ */
+ public function testFormatWithContextContainingException()
+ {
+ $formatter = new GelfMessageFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger', 'exception' => array(
+ 'class' => '\Exception',
+ 'file' => '/some/file/in/dir.php:56',
+ 'trace' => array('/some/file/1.php:23', '/some/file/2.php:3')
+ )),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log'
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+
+ $this->assertEquals("/some/file/in/dir.php", $message->getFile());
+ $this->assertEquals("56", $message->getLine());
+
+ }
+
+ /**
+ * @covers Monolog\Formatter\GelfMessageFormatter::format
+ */
+ public function testFormatWithExtra()
+ {
+ $formatter = new GelfMessageFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+
+ $message_array = $message->toArray();
+
+ $this->assertArrayHasKey('_key', $message_array);
+ $this->assertEquals('pair', $message_array['_key']);
+
+ // Test with extraPrefix
+ $formatter = new GelfMessageFormatter(null, 'EXT');
+ $message = $formatter->format($record);
+
+ $this->assertInstanceOf('Gelf\Message', $message);
+
+ $message_array = $message->toArray();
+
+ $this->assertArrayHasKey('_EXTkey', $message_array);
+ $this->assertEquals('pair', $message_array['_EXTkey']);
+ }
+
+ private function isLegacy()
+ {
+ return interface_exists('\Gelf\IMessagePublisher');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
new file mode 100644
index 00000000..d18c4763
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php
@@ -0,0 +1,79 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+use Monolog\TestCase;
+
+class JsonFormatterTest extends TestCase
+{
+ /**
+ * @covers Monolog\Formatter\JsonFormatter::__construct
+ * @covers Monolog\Formatter\JsonFormatter::getBatchMode
+ * @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines
+ */
+ public function testConstruct()
+ {
+ $formatter = new JsonFormatter();
+ $this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
+ $this->assertEquals(true, $formatter->isAppendingNewlines());
+ $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false);
+ $this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
+ $this->assertEquals(false, $formatter->isAppendingNewlines());
+ }
+
+ /**
+ * @covers Monolog\Formatter\JsonFormatter::format
+ */
+ public function testFormat()
+ {
+ $formatter = new JsonFormatter();
+ $record = $this->getRecord();
+ $this->assertEquals(json_encode($record)."\n", $formatter->format($record));
+
+ $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false);
+ $record = $this->getRecord();
+ $this->assertEquals(json_encode($record), $formatter->format($record));
+ }
+
+ /**
+ * @covers Monolog\Formatter\JsonFormatter::formatBatch
+ * @covers Monolog\Formatter\JsonFormatter::formatBatchJson
+ */
+ public function testFormatBatch()
+ {
+ $formatter = new JsonFormatter();
+ $records = array(
+ $this->getRecord(Logger::WARNING),
+ $this->getRecord(Logger::DEBUG),
+ );
+ $this->assertEquals(json_encode($records), $formatter->formatBatch($records));
+ }
+
+ /**
+ * @covers Monolog\Formatter\JsonFormatter::formatBatch
+ * @covers Monolog\Formatter\JsonFormatter::formatBatchNewlines
+ */
+ public function testFormatBatchNewlines()
+ {
+
+ $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES);
+ $records = $expected = array(
+ $this->getRecord(Logger::WARNING),
+ $this->getRecord(Logger::DEBUG),
+ );
+ array_walk($expected, function (&$value, $key) {
+ $value = json_encode($value);
+ });
+ $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
new file mode 100644
index 00000000..096e5644
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php
@@ -0,0 +1,194 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * @covers Monolog\Formatter\LineFormatter
+ */
+class LineFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDefFormatWithString()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'context' => array(),
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ));
+ $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
+ }
+
+ public function testDefFormatWithArrayContext()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ 'bool' => false,
+ 'null' => null,
+ )
+ ));
+ $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux","bool":false,"null":null} []'."\n", $message);
+ }
+
+ public function testDefFormatExtras()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array('ip' => '127.0.0.1'),
+ 'message' => 'log',
+ ));
+ $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message);
+ }
+
+ public function testFormatExtras()
+ {
+ $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array('ip' => '127.0.0.1', 'file' => 'test'),
+ 'message' => 'log',
+ ));
+ $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message);
+ }
+
+ public function testDefFormatWithObject()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
+ 'message' => 'foobar',
+ ));
+
+ $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
+ }
+
+ public function testDefFormatWithException()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'core',
+ 'context' => array('exception' => new \RuntimeException('Foo')),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'message' => 'foobar',
+ ));
+
+ $path = str_replace('\\/', '/', json_encode(__FILE__));
+
+ $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).')"} []'."\n", $message);
+ }
+
+ public function testDefFormatWithPreviousException()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $previous = new \LogicException('Wut?');
+ $message = $formatter->format(array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'core',
+ 'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'message' => 'foobar',
+ ));
+
+ $path = str_replace('\\/', '/', json_encode(__FILE__));
+
+ $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).', LogicException: Wut? at '.substr($path, 1, -1).':'.(__LINE__-12).')"} []'."\n", $message);
+ }
+
+ public function testBatchFormat()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->formatBatch(array(
+ array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'test',
+ 'message' => 'bar',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'message' => 'foo',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ ));
+ $this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
+ }
+
+ public function testFormatShouldStripInlineLineBreaks()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d');
+ $message = $formatter->format(
+ array(
+ 'message' => "foo\nbar",
+ 'context' => array(),
+ 'extra' => array(),
+ )
+ );
+
+ $this->assertRegExp('/foo bar/', $message);
+ }
+
+ public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
+ {
+ $formatter = new LineFormatter(null, 'Y-m-d', true);
+ $message = $formatter->format(
+ array(
+ 'message' => "foo\nbar",
+ 'context' => array(),
+ 'extra' => array(),
+ )
+ );
+
+ $this->assertRegExp('/foo\nbar/', $message);
+ }
+}
+
+class TestFoo
+{
+ public $foo = 'foo';
+}
+
+class TestBar
+{
+ public function __toString()
+ {
+ return 'bar';
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php
new file mode 100644
index 00000000..6d59b3f3
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php
@@ -0,0 +1,40 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\TestCase;
+
+class LogglyFormatterTest extends TestCase
+{
+ /**
+ * @covers Monolog\Formatter\LogglyFormatter::__construct
+ */
+ public function testConstruct()
+ {
+ $formatter = new LogglyFormatter();
+ $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode());
+ $formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON);
+ $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode());
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogglyFormatter::format
+ */
+ public function testFormat()
+ {
+ $formatter = new LogglyFormatter();
+ $record = $this->getRecord();
+ $formatted_decoded = json_decode($formatter->format($record), true);
+ $this->assertArrayHasKey("timestamp", $formatted_decoded);
+ $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
new file mode 100644
index 00000000..5776ab72
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php
@@ -0,0 +1,292 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testDefaultFormatter()
+ {
+ $formatter = new LogstashFormatter('test', 'hostname');
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
+ $this->assertEquals('log', $message['@message']);
+ $this->assertEquals('meh', $message['@fields']['channel']);
+ $this->assertContains('meh', $message['@tags']);
+ $this->assertEquals(Logger::ERROR, $message['@fields']['level']);
+ $this->assertEquals('test', $message['@type']);
+ $this->assertEquals('hostname', $message['@source']);
+
+ $formatter = new LogstashFormatter('mysystem');
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals('mysystem', $message['@type']);
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithFileAndLine()
+ {
+ $formatter = new LogstashFormatter('test');
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('file' => 'test', 'line' => 14),
+ 'message' => 'log',
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals('test', $message['@fields']['file']);
+ $this->assertEquals(14, $message['@fields']['line']);
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithContext()
+ {
+ $formatter = new LogstashFormatter('test');
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $message_array = $message['@fields'];
+
+ $this->assertArrayHasKey('ctxt_from', $message_array);
+ $this->assertEquals('logger', $message_array['ctxt_from']);
+
+ // Test with extraPrefix
+ $formatter = new LogstashFormatter('test', null, null, 'CTX');
+ $message = json_decode($formatter->format($record), true);
+
+ $message_array = $message['@fields'];
+
+ $this->assertArrayHasKey('CTXfrom', $message_array);
+ $this->assertEquals('logger', $message_array['CTXfrom']);
+
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithExtra()
+ {
+ $formatter = new LogstashFormatter('test');
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $message_array = $message['@fields'];
+
+ $this->assertArrayHasKey('key', $message_array);
+ $this->assertEquals('pair', $message_array['key']);
+
+ // Test with extraPrefix
+ $formatter = new LogstashFormatter('test', null, 'EXT');
+ $message = json_decode($formatter->format($record), true);
+
+ $message_array = $message['@fields'];
+
+ $this->assertArrayHasKey('EXTkey', $message_array);
+ $this->assertEquals('pair', $message_array['EXTkey']);
+ }
+
+ public function testFormatWithApplicationName()
+ {
+ $formatter = new LogstashFormatter('app', 'test');
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('@type', $message);
+ $this->assertEquals('app', $message['@type']);
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testDefaultFormatterV1()
+ {
+ $formatter = new LogstashFormatter('test', 'hostname', null, 'ctxt_', LogstashFormatter::V1);
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']);
+ $this->assertEquals("1", $message['@version']);
+ $this->assertEquals('log', $message['message']);
+ $this->assertEquals('meh', $message['channel']);
+ $this->assertEquals('ERROR', $message['level']);
+ $this->assertEquals('test', $message['type']);
+ $this->assertEquals('hostname', $message['host']);
+
+ $formatter = new LogstashFormatter('mysystem', null, null, 'ctxt_', LogstashFormatter::V1);
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals('mysystem', $message['type']);
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithFileAndLineV1()
+ {
+ $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('file' => 'test', 'line' => 14),
+ 'message' => 'log',
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertEquals('test', $message['file']);
+ $this->assertEquals(14, $message['line']);
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithContextV1()
+ {
+ $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('ctxt_from', $message);
+ $this->assertEquals('logger', $message['ctxt_from']);
+
+ // Test with extraPrefix
+ $formatter = new LogstashFormatter('test', null, null, 'CTX', LogstashFormatter::V1);
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('CTXfrom', $message);
+ $this->assertEquals('logger', $message['CTXfrom']);
+
+ }
+
+ /**
+ * @covers Monolog\Formatter\LogstashFormatter::format
+ */
+ public function testFormatWithExtraV1()
+ {
+ $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1);
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('key', $message);
+ $this->assertEquals('pair', $message['key']);
+
+ // Test with extraPrefix
+ $formatter = new LogstashFormatter('test', null, 'EXT', 'ctxt_', LogstashFormatter::V1);
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('EXTkey', $message);
+ $this->assertEquals('pair', $message['EXTkey']);
+ }
+
+ public function testFormatWithApplicationNameV1()
+ {
+ $formatter = new LogstashFormatter('app', 'test', null, 'ctxt_', LogstashFormatter::V1);
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('key' => 'pair'),
+ 'message' => 'log'
+ );
+
+ $message = json_decode($formatter->format($record), true);
+
+ $this->assertArrayHasKey('type', $message);
+ $this->assertEquals('app', $message['type']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
new file mode 100644
index 00000000..74778712
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php
@@ -0,0 +1,182 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+/**
+ * @covers Monolog\Formatter\NormalizerFormatter
+ */
+class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFormat()
+ {
+ $formatter = new NormalizerFormatter('Y-m-d');
+ $formatted = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ ),
+ ));
+
+ $this->assertEquals(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'message' => 'foo',
+ 'datetime' => date('Y-m-d'),
+ 'extra' => array(
+ 'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
+ 'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: {})',
+ 'baz' => array(),
+ 'res' => '[resource]',
+ ),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ), $formatted);
+ }
+
+ public function testFormatExceptions()
+ {
+ $formatter = new NormalizerFormatter('Y-m-d');
+ $e = new \LogicException('bar');
+ $e2 = new \RuntimeException('foo', 0, $e);
+ $formatted = $formatter->format(array(
+ 'exception' => $e2,
+ ));
+
+ $this->assertGreaterThan(5, count($formatted['exception']['trace']));
+ $this->assertTrue(isset($formatted['exception']['previous']));
+ unset($formatted['exception']['trace'], $formatted['exception']['previous']);
+
+ $this->assertEquals(array(
+ 'exception' => array(
+ 'class' => get_class($e2),
+ 'message' => $e2->getMessage(),
+ 'file' => $e2->getFile().':'.$e2->getLine(),
+ )
+ ), $formatted);
+ }
+
+ public function testBatchFormat()
+ {
+ $formatter = new NormalizerFormatter('Y-m-d');
+ $formatted = $formatter->formatBatch(array(
+ array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'test',
+ 'message' => 'bar',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'message' => 'foo',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ ));
+ $this->assertEquals(array(
+ array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'test',
+ 'message' => 'bar',
+ 'context' => array(),
+ 'datetime' => date('Y-m-d'),
+ 'extra' => array(),
+ ),
+ array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'message' => 'foo',
+ 'context' => array(),
+ 'datetime' => date('Y-m-d'),
+ 'extra' => array(),
+ ),
+ ), $formatted);
+ }
+
+ /**
+ * Test issue #137
+ */
+ public function testIgnoresRecursiveObjectReferences()
+ {
+ // set up the recursion
+ $foo = new \stdClass();
+ $bar = new \stdClass();
+
+ $foo->bar = $bar;
+ $bar->foo = $foo;
+
+ // set an error handler to assert that the error is not raised anymore
+ $that = $this;
+ set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
+ if (error_reporting() & $level) {
+ restore_error_handler();
+ $that->fail("$message should not be raised");
+ }
+ });
+
+ $formatter = new NormalizerFormatter();
+ $reflMethod = new \ReflectionMethod($formatter, 'toJson');
+ $reflMethod->setAccessible(true);
+ $res = $reflMethod->invoke($formatter, array($foo, $bar), true);
+
+ restore_error_handler();
+
+ $this->assertEquals(@json_encode(array($foo, $bar)), $res);
+ }
+
+ public function testIgnoresInvalidTypes()
+ {
+ // set up the recursion
+ $resource = fopen(__FILE__, 'r');
+
+ // set an error handler to assert that the error is not raised anymore
+ $that = $this;
+ set_error_handler(function ($level, $message, $file, $line, $context) use ($that) {
+ if (error_reporting() & $level) {
+ restore_error_handler();
+ $that->fail("$message should not be raised");
+ }
+ });
+
+ $formatter = new NormalizerFormatter();
+ $reflMethod = new \ReflectionMethod($formatter, 'toJson');
+ $reflMethod->setAccessible(true);
+ $res = $reflMethod->invoke($formatter, array($resource), true);
+
+ restore_error_handler();
+
+ $this->assertEquals(@json_encode(array($resource)), $res);
+ }
+}
+
+class TestFooNorm
+{
+ public $foo = 'foo';
+}
+
+class TestBarNorm
+{
+ public function __toString()
+ {
+ return 'bar';
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php
new file mode 100644
index 00000000..b8cbb132
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php
@@ -0,0 +1,96 @@
+formatter = new ScalarFormatter();
+ }
+
+ public function buildTrace(\Exception $e)
+ {
+ $data = array();
+ $trace = $e->getTrace();
+ foreach ($trace as $frame) {
+ if (isset($frame['file'])) {
+ $data[] = $frame['file'].':'.$frame['line'];
+ } else {
+ $data[] = json_encode($frame);
+ }
+ }
+
+ return $data;
+ }
+
+ public function encodeJson($data)
+ {
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+ }
+
+ return json_encode($data);
+ }
+
+ public function testFormat()
+ {
+ $exception = new \Exception('foo');
+ $formatted = $this->formatter->format(array(
+ 'foo' => 'string',
+ 'bar' => 1,
+ 'baz' => false,
+ 'bam' => array(1,2,3),
+ 'bat' => array('foo' => 'bar'),
+ 'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
+ 'ban' => $exception
+ ));
+
+ $this->assertSame(array(
+ 'foo' => 'string',
+ 'bar' => 1,
+ 'baz' => false,
+ 'bam' => $this->encodeJson(array(1,2,3)),
+ 'bat' => $this->encodeJson(array('foo' => 'bar')),
+ 'bap' => '1970-01-01 00:00:00',
+ 'ban' => $this->encodeJson(array(
+ 'class' => get_class($exception),
+ 'message' => $exception->getMessage(),
+ 'file' => $exception->getFile() . ':' . $exception->getLine(),
+ 'trace' => $this->buildTrace($exception)
+ ))
+ ), $formatted);
+ }
+
+ public function testFormatWithErrorContext()
+ {
+ $context = array('file' => 'foo', 'line' => 1);
+ $formatted = $this->formatter->format(array(
+ 'context' => $context
+ ));
+
+ $this->assertSame(array(
+ 'context' => $this->encodeJson($context)
+ ), $formatted);
+ }
+
+ public function testFormatWithExceptionContext()
+ {
+ $exception = new \Exception('foo');
+ $formatted = $this->formatter->format(array(
+ 'context' => array(
+ 'exception' => $exception
+ )
+ ));
+
+ $this->assertSame(array(
+ 'context' => $this->encodeJson(array(
+ 'exception' => array(
+ 'class' => get_class($exception),
+ 'message' => $exception->getMessage(),
+ 'file' => $exception->getFile() . ':' . $exception->getLine(),
+ 'trace' => $this->buildTrace($exception)
+ )
+ ))
+ ), $formatted);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
new file mode 100644
index 00000000..52f15a36
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php
@@ -0,0 +1,142 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Formatter;
+
+use Monolog\Logger;
+
+class WildfireFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers Monolog\Formatter\WildfireFormatter::format
+ */
+ public function testDefaultFormat()
+ {
+ $wildfire = new WildfireFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('ip' => '127.0.0.1'),
+ 'message' => 'log',
+ );
+
+ $message = $wildfire->format($record);
+
+ $this->assertEquals(
+ '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},'
+ .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\WildfireFormatter::format
+ */
+ public function testFormatWithFileAndLine()
+ {
+ $wildfire = new WildfireFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('from' => 'logger'),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14),
+ 'message' => 'log',
+ );
+
+ $message = $wildfire->format($record);
+
+ $this->assertEquals(
+ '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},'
+ .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|',
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\WildfireFormatter::format
+ */
+ public function testFormatWithoutContext()
+ {
+ $wildfire = new WildfireFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $message = $wildfire->format($record);
+
+ $this->assertEquals(
+ '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|',
+ $message
+ );
+ }
+
+ /**
+ * @covers Monolog\Formatter\WildfireFormatter::formatBatch
+ * @expectedException BadMethodCallException
+ */
+ public function testBatchFormatThrowException()
+ {
+ $wildfire = new WildfireFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array(),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $wildfire->formatBatch(array($record));
+ }
+
+ /**
+ * @covers Monolog\Formatter\WildfireFormatter::format
+ */
+ public function testTableFormat()
+ {
+ $wildfire = new WildfireFormatter();
+ $record = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'table-channel',
+ 'context' => array(
+ WildfireFormatter::TABLE => array(
+ array('col1', 'col2', 'col3'),
+ array('val1', 'val2', 'val3'),
+ array('foo1', 'foo2', 'foo3'),
+ array('bar1', 'bar2', 'bar3'),
+ ),
+ ),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'table-message',
+ );
+
+ $message = $wildfire->format($record);
+
+ $this->assertEquals(
+ '171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|',
+ $message
+ );
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php
new file mode 100644
index 00000000..7e4e7eb5
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php
@@ -0,0 +1,32 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+spl_autoload_register(function ($class) {
+ $file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php';
+ if (file_exists($file)) {
+ require $file;
+
+ return true;
+ }
+});
+
+use Monolog\Logger;
+use Monolog\Handler\FirePHPHandler;
+use Monolog\Handler\ChromePHPHandler;
+
+$logger = new Logger('firephp');
+$logger->pushHandler(new FirePHPHandler);
+$logger->pushHandler(new ChromePHPHandler());
+
+$logger->addDebug('Debug');
+$logger->addInfo('Info');
+$logger->addWarning('Warning');
+$logger->addError('Error');
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
new file mode 100644
index 00000000..01d522fa
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php
@@ -0,0 +1,104 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
+use Monolog\Processor\WebProcessor;
+
+class AbstractHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\AbstractHandler::__construct
+ * @covers Monolog\Handler\AbstractHandler::getLevel
+ * @covers Monolog\Handler\AbstractHandler::setLevel
+ * @covers Monolog\Handler\AbstractHandler::getBubble
+ * @covers Monolog\Handler\AbstractHandler::setBubble
+ * @covers Monolog\Handler\AbstractHandler::getFormatter
+ * @covers Monolog\Handler\AbstractHandler::setFormatter
+ */
+ public function testConstructAndGetSet()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
+ $this->assertEquals(Logger::WARNING, $handler->getLevel());
+ $this->assertEquals(false, $handler->getBubble());
+
+ $handler->setLevel(Logger::ERROR);
+ $handler->setBubble(true);
+ $handler->setFormatter($formatter = new LineFormatter);
+ $this->assertEquals(Logger::ERROR, $handler->getLevel());
+ $this->assertEquals(true, $handler->getBubble());
+ $this->assertSame($formatter, $handler->getFormatter());
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractHandler::handleBatch
+ */
+ public function testHandleBatch()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
+ $handler->expects($this->exactly(2))
+ ->method('handle');
+ $handler->handleBatch(array($this->getRecord(), $this->getRecord()));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractHandler::isHandling
+ */
+ public function testIsHandling()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
+ $this->assertTrue($handler->isHandling($this->getRecord()));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractHandler::getFormatter
+ * @covers Monolog\Handler\AbstractHandler::getDefaultFormatter
+ */
+ public function testGetFormatterInitializesDefault()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
+ $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter());
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractHandler::pushProcessor
+ * @covers Monolog\Handler\AbstractHandler::popProcessor
+ * @expectedException LogicException
+ */
+ public function testPushPopProcessor()
+ {
+ $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
+ $processor1 = new WebProcessor;
+ $processor2 = new WebProcessor;
+
+ $logger->pushProcessor($processor1);
+ $logger->pushProcessor($processor2);
+
+ $this->assertEquals($processor2, $logger->popProcessor());
+ $this->assertEquals($processor1, $logger->popProcessor());
+ $logger->popProcessor();
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractHandler::pushProcessor
+ * @expectedException InvalidArgumentException
+ */
+ public function testPushProcessorWithNonCallable()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
+
+ $handler->pushProcessor(new \stdClass());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
new file mode 100644
index 00000000..24d4f63c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
@@ -0,0 +1,80 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Processor\WebProcessor;
+
+class AbstractProcessingHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\AbstractProcessingHandler::handle
+ */
+ public function testHandleLowerLevelMessage()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
+ $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractProcessingHandler::handle
+ */
+ public function testHandleBubbling()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
+ $this->assertFalse($handler->handle($this->getRecord()));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractProcessingHandler::handle
+ */
+ public function testHandleNotBubbling()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
+ $this->assertTrue($handler->handle($this->getRecord()));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractProcessingHandler::handle
+ */
+ public function testHandleIsFalseWhenNotHandled()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
+ $this->assertTrue($handler->handle($this->getRecord()));
+ $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
+ }
+
+ /**
+ * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
+ */
+ public function testProcessRecord()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
+ $handler->pushProcessor(new WebProcessor(array(
+ 'REQUEST_URI' => '',
+ 'REQUEST_METHOD' => '',
+ 'REMOTE_ADDR' => '',
+ 'SERVER_NAME' => '',
+ 'UNIQUE_ID' => '',
+ )));
+ $handledRecord = null;
+ $handler->expects($this->once())
+ ->method('write')
+ ->will($this->returnCallback(function ($record) use (&$handledRecord) {
+ $handledRecord = $record;
+ }))
+ ;
+ $handler->handle($this->getRecord());
+ $this->assertEquals(6, count($handledRecord['extra']));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
new file mode 100644
index 00000000..249f2b72
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php
@@ -0,0 +1,80 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\RotatingFileHandler
+ */
+class AmqpHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) {
+ $this->markTestSkipped("amqp-php not installed");
+ }
+
+ if (!class_exists('AMQPChannel')) {
+ $this->markTestSkipped("Please update AMQP to version >= 1.0");
+ }
+ }
+
+ public function testHandle()
+ {
+ $messages = array();
+
+ $exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
+ $exchange->expects($this->once())
+ ->method('setName')
+ ->with('log')
+ ;
+ $exchange->expects($this->any())
+ ->method('publish')
+ ->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) {
+ $messages[] = array($message, $routing_key, $flags, $attributes);
+ }))
+ ;
+
+ $handler = new AmqpHandler($exchange, 'log');
+
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $expected = array(
+ array(
+ 'message' => 'test',
+ 'context' => array(
+ 'data' => array(),
+ 'foo' => 34,
+ ),
+ 'level' => 300,
+ 'level_name' => 'WARNING',
+ 'channel' => 'test',
+ 'extra' => array(),
+ ),
+ 'warn.test',
+ 0,
+ array(
+ 'delivery_mode' => 2,
+ 'Content-type' => 'application/json'
+ )
+ );
+
+ $handler->handle($record);
+
+ $this->assertCount(1, $messages);
+ $messages[0][0] = json_decode($messages[0][0], true);
+ unset($messages[0][0]['datetime']);
+ $this->assertEquals($expected, $messages[0]);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
new file mode 100644
index 00000000..f3d8038c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php
@@ -0,0 +1,131 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\BrowserConsoleHandlerTest
+ */
+class BrowserConsoleHandlerTest extends TestCase
+{
+ protected function setUp()
+ {
+ BrowserConsoleHandler::reset();
+ }
+
+ protected function generateScript()
+ {
+ $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript');
+ $reflMethod->setAccessible(true);
+
+ return $reflMethod->invoke(null);
+ }
+
+ public function testStyling()
+ {
+ $handler = new BrowserConsoleHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+
+ $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
+
+ $expected = <<assertEquals($expected, $this->generateScript());
+ }
+
+ public function testEscaping()
+ {
+ $handler = new BrowserConsoleHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+
+ $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
+
+ $expected = <<assertEquals($expected, $this->generateScript());
+ }
+
+
+ public function testAutolabel()
+ {
+ $handler = new BrowserConsoleHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+
+ $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
+ $handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}'));
+ $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
+
+ $expected = <<assertEquals($expected, $this->generateScript());
+ }
+
+ public function testContext()
+ {
+ $handler = new BrowserConsoleHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+
+ $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
+
+ $expected = <<assertEquals($expected, $this->generateScript());
+ }
+
+ public function testConcurrentHandlers()
+ {
+ $handler1 = new BrowserConsoleHandler();
+ $handler1->setFormatter($this->getIdentityFormatter());
+
+ $handler2 = new BrowserConsoleHandler();
+ $handler2->setFormatter($this->getIdentityFormatter());
+
+ $handler1->handle($this->getRecord(Logger::DEBUG, 'test1'));
+ $handler2->handle($this->getRecord(Logger::DEBUG, 'test2'));
+ $handler1->handle($this->getRecord(Logger::DEBUG, 'test3'));
+ $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
+
+ $expected = <<assertEquals($expected, $this->generateScript());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
new file mode 100644
index 00000000..beb08cf8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php
@@ -0,0 +1,149 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class BufferHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\BufferHandler::__construct
+ * @covers Monolog\Handler\BufferHandler::handle
+ * @covers Monolog\Handler\BufferHandler::close
+ */
+ public function testHandleBuffers()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertFalse($test->hasInfoRecords());
+ $handler->close();
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue(count($test->getRecords()) === 2);
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::close
+ * @covers Monolog\Handler\BufferHandler::flush
+ */
+ public function testDestructPropagatesRecords()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test);
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->__destruct();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasDebugRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::handle
+ */
+ public function testHandleBufferLimit()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test, 2);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->close();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertFalse($test->hasDebugRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::handle
+ */
+ public function testHandleBufferLimitWithFlushOnOverflow()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test, 3, Logger::DEBUG, true, true);
+
+ // send two records
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertCount(0, $test->getRecords());
+
+ // overflow
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertCount(3, $test->getRecords());
+
+ // should buffer again
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertCount(3, $test->getRecords());
+
+ $handler->close();
+ $this->assertCount(5, $test->getRecords());
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::handle
+ */
+ public function testHandleLevel()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test, 0, Logger::INFO);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->close();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertFalse($test->hasDebugRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::flush
+ */
+ public function testFlush()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test, 0);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->flush();
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertFalse($test->hasWarningRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\BufferHandler::handle
+ */
+ public function testHandleUsesProcessors()
+ {
+ $test = new TestHandler();
+ $handler = new BufferHandler($test);
+ $handler->pushProcessor(function ($record) {
+ $record['extra']['foo'] = true;
+
+ return $record;
+ });
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->flush();
+ $this->assertTrue($test->hasWarningRecords());
+ $records = $test->getRecords();
+ $this->assertTrue($records[0]['extra']['foo']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
new file mode 100644
index 00000000..2f55faf8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php
@@ -0,0 +1,141 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\ChromePHPHandler
+ */
+class ChromePHPHandlerTest extends TestCase
+{
+ protected function setUp()
+ {
+ TestChromePHPHandler::reset();
+ $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
+ }
+
+ public function testHeaders()
+ {
+ $handler = new TestChromePHPHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING));
+
+ $expected = array(
+ 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
+ 'version' => ChromePHPHandler::VERSION,
+ 'columns' => array('label', 'log', 'backtrace', 'type'),
+ 'rows' => array(
+ 'test',
+ 'test',
+ ),
+ 'request_uri' => '',
+ ))))
+ );
+
+ $this->assertEquals($expected, $handler->getHeaders());
+ }
+
+ public function testHeadersOverflow()
+ {
+ $handler = new TestChromePHPHandler();
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150*1024)));
+
+ // overflow chrome headers limit
+ $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100*1024)));
+
+ $expected = array(
+ 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
+ 'version' => ChromePHPHandler::VERSION,
+ 'columns' => array('label', 'log', 'backtrace', 'type'),
+ 'rows' => array(
+ array(
+ 'test',
+ 'test',
+ 'unknown',
+ 'log',
+ ),
+ array(
+ 'test',
+ str_repeat('a', 150*1024),
+ 'unknown',
+ 'warn',
+ ),
+ array(
+ 'monolog',
+ 'Incomplete logs, chrome header size limit reached',
+ 'unknown',
+ 'warn',
+ ),
+ ),
+ 'request_uri' => '',
+ ))))
+ );
+
+ $this->assertEquals($expected, $handler->getHeaders());
+ }
+
+ public function testConcurrentHandlers()
+ {
+ $handler = new TestChromePHPHandler();
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING));
+
+ $handler2 = new TestChromePHPHandler();
+ $handler2->setFormatter($this->getIdentityFormatter());
+ $handler2->handle($this->getRecord(Logger::DEBUG));
+ $handler2->handle($this->getRecord(Logger::WARNING));
+
+ $expected = array(
+ 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
+ 'version' => ChromePHPHandler::VERSION,
+ 'columns' => array('label', 'log', 'backtrace', 'type'),
+ 'rows' => array(
+ 'test',
+ 'test',
+ 'test',
+ 'test',
+ ),
+ 'request_uri' => '',
+ ))))
+ );
+
+ $this->assertEquals($expected, $handler2->getHeaders());
+ }
+}
+
+class TestChromePHPHandler extends ChromePHPHandler
+{
+ protected $headers = array();
+
+ public static function reset()
+ {
+ self::$initialized = false;
+ self::$overflowed = false;
+ self::$sendHeaders = true;
+ self::$json['rows'] = array();
+ }
+
+ protected function sendHeader($header, $content)
+ {
+ $this->headers[$header] = $content;
+ }
+
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
new file mode 100644
index 00000000..78a1d15c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class CouchDBHandlerTest extends TestCase
+{
+ public function testHandle()
+ {
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $expected = array(
+ 'message' => 'test',
+ 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
+ 'level' => Logger::WARNING,
+ 'level_name' => 'WARNING',
+ 'channel' => 'test',
+ 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
+ 'extra' => array(),
+ );
+
+ $handler = new CouchDBHandler();
+
+ try {
+ $handler->handle($record);
+ } catch (\RuntimeException $e) {
+ $this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984');
+ }
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
new file mode 100644
index 00000000..d67da90a
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php
@@ -0,0 +1,52 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class DoctrineCouchDBHandlerTest extends TestCase
+{
+ protected function setup()
+ {
+ if (!class_exists('Doctrine\CouchDB\CouchDBClient')) {
+ $this->markTestSkipped('The "doctrine/couchdb" package is not installed');
+ }
+ }
+
+ public function testHandle()
+ {
+ $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
+ ->setMethods(array('postDocument'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $expected = array(
+ 'message' => 'test',
+ 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
+ 'level' => Logger::WARNING,
+ 'level_name' => 'WARNING',
+ 'channel' => 'test',
+ 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
+ 'extra' => array(),
+ );
+
+ $client->expects($this->once())
+ ->method('postDocument')
+ ->with($expected);
+
+ $handler = new DoctrineCouchDBHandler($client);
+ $handler->handle($record);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php
new file mode 100644
index 00000000..a38a8cb7
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php
@@ -0,0 +1,73 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+
+class DynamoDbHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
+ $this->markTestSkipped('aws/aws-sdk-php not installed');
+ }
+
+ $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
+ ->setMethods(array('formatAttributes', '__call'))
+ ->disableOriginalConstructor()->getMock();
+ }
+
+ public function testConstruct()
+ {
+ $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
+ }
+
+ public function testInterface()
+ {
+ $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
+ }
+
+ public function testGetFormatter()
+ {
+ $handler = new DynamoDbHandler($this->client, 'foo');
+ $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
+ }
+
+ public function testHandle()
+ {
+ $record = $this->getRecord();
+ $formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
+ $formatted = array('foo' => 1, 'bar' => 2);
+ $handler = new DynamoDbHandler($this->client, 'foo');
+ $handler->setFormatter($formatter);
+
+ $formatter
+ ->expects($this->once())
+ ->method('format')
+ ->with($record)
+ ->will($this->returnValue($formatted));
+ $this->client
+ ->expects($this->once())
+ ->method('formatAttributes')
+ ->with($this->isType('array'))
+ ->will($this->returnValue($formatted));
+ $this->client
+ ->expects($this->once())
+ ->method('__call')
+ ->with('putItem', array(array(
+ 'TableName' => 'foo',
+ 'Item' => $formatted
+ )));
+
+ $handler->handle($record);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php
new file mode 100644
index 00000000..1687074b
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php
@@ -0,0 +1,239 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\ElasticaFormatter;
+use Monolog\Formatter\NormalizerFormatter;
+use Monolog\TestCase;
+use Monolog\Logger;
+use Elastica\Client;
+use Elastica\Request;
+use Elastica\Response;
+
+class ElasticSearchHandlerTest extends TestCase
+{
+ /**
+ * @var Client mock
+ */
+ protected $client;
+
+ /**
+ * @var array Default handler options
+ */
+ protected $options = array(
+ 'index' => 'my_index',
+ 'type' => 'doc_type',
+ );
+
+ public function setUp()
+ {
+ // Elastica lib required
+ if (!class_exists("Elastica\Client")) {
+ $this->markTestSkipped("ruflin/elastica not installed");
+ }
+
+ // base mock Elastica Client object
+ $this->client = $this->getMockBuilder('Elastica\Client')
+ ->setMethods(array('addDocuments'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ /**
+ * @covers Monolog\Handler\ElasticSearchHandler::write
+ * @covers Monolog\Handler\ElasticSearchHandler::handleBatch
+ * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
+ * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
+ */
+ public function testHandle()
+ {
+ // log message
+ $msg = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ // format expected result
+ $formatter = new ElasticaFormatter($this->options['index'], $this->options['type']);
+ $expected = array($formatter->format($msg));
+
+ // setup ES client mock
+ $this->client->expects($this->any())
+ ->method('addDocuments')
+ ->with($expected);
+
+ // perform tests
+ $handler = new ElasticSearchHandler($this->client, $this->options);
+ $handler->handle($msg);
+ $handler->handleBatch(array($msg));
+ }
+
+ /**
+ * @covers Monolog\Handler\ElasticSearchHandler::setFormatter
+ */
+ public function testSetFormatter()
+ {
+ $handler = new ElasticSearchHandler($this->client);
+ $formatter = new ElasticaFormatter('index_new', 'type_new');
+ $handler->setFormatter($formatter);
+ $this->assertInstanceOf('Monolog\Formatter\ElasticaFormatter', $handler->getFormatter());
+ $this->assertEquals('index_new', $handler->getFormatter()->getIndex());
+ $this->assertEquals('type_new', $handler->getFormatter()->getType());
+ }
+
+ /**
+ * @covers Monolog\Handler\ElasticSearchHandler::setFormatter
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter
+ */
+ public function testSetFormatterInvalid()
+ {
+ $handler = new ElasticSearchHandler($this->client);
+ $formatter = new NormalizerFormatter();
+ $handler->setFormatter($formatter);
+ }
+
+ /**
+ * @covers Monolog\Handler\ElasticSearchHandler::__construct
+ * @covers Monolog\Handler\ElasticSearchHandler::getOptions
+ */
+ public function testOptions()
+ {
+ $expected = array(
+ 'index' => $this->options['index'],
+ 'type' => $this->options['type'],
+ 'ignore_error' => false,
+ );
+ $handler = new ElasticSearchHandler($this->client, $this->options);
+ $this->assertEquals($expected, $handler->getOptions());
+ }
+
+ /**
+ * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
+ * @dataProvider providerTestConnectionErrors
+ */
+ public function testConnectionErrors($ignore, $expectedError)
+ {
+ $clientOpts = array('host' => '127.0.0.1', 'port' => 1);
+ $client = new Client($clientOpts);
+ $handlerOpts = array('ignore_error' => $ignore);
+ $handler = new ElasticSearchHandler($client, $handlerOpts);
+
+ if ($expectedError) {
+ $this->setExpectedException($expectedError[0], $expectedError[1]);
+ $handler->handle($this->getRecord());
+ } else {
+ $this->assertFalse($handler->handle($this->getRecord()));
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function providerTestConnectionErrors()
+ {
+ return array(
+ array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')),
+ array(true, false),
+ );
+ }
+
+ /**
+ * Integration test using localhost Elastic Search server
+ *
+ * @covers Monolog\Handler\ElasticSearchHandler::__construct
+ * @covers Monolog\Handler\ElasticSearchHandler::handleBatch
+ * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
+ * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
+ */
+ public function testHandleIntegration()
+ {
+ $msg = array(
+ 'level' => Logger::ERROR,
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
+ 'datetime' => new \DateTime("@0"),
+ 'extra' => array(),
+ 'message' => 'log',
+ );
+
+ $expected = $msg;
+ $expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601);
+ $expected['context'] = array(
+ 'class' => '[object] (stdClass: {})',
+ 'foo' => 7,
+ 0 => 'bar',
+ );
+
+ $client = new Client();
+ $handler = new ElasticSearchHandler($client, $this->options);
+ try {
+ $handler->handleBatch(array($msg));
+ } catch (\RuntimeException $e) {
+ $this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
+ }
+
+ // check document id from ES server response
+ $documentId = $this->getCreatedDocId($client->getLastResponse());
+ $this->assertNotEmpty($documentId, 'No elastic document id received');
+
+ // retrieve document source from ES and validate
+ $document = $this->getDocSourceFromElastic(
+ $client,
+ $this->options['index'],
+ $this->options['type'],
+ $documentId
+ );
+ $this->assertEquals($expected, $document);
+
+ // remove test index from ES
+ $client->request("/{$this->options['index']}", Request::DELETE);
+ }
+
+ /**
+ * Return last created document id from ES response
+ * @param Response $response Elastica Response object
+ * @return string|null
+ */
+ protected function getCreatedDocId(Response $response)
+ {
+ $data = $response->getData();
+ if (!empty($data['items'][0]['create']['_id'])) {
+ return $data['items'][0]['create']['_id'];
+ }
+ }
+
+ /**
+ * Retrieve document by id from Elasticsearch
+ * @param Client $client Elastica client
+ * @param string $index
+ * @param string $type
+ * @param string $documentId
+ * @return array
+ */
+ protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
+ {
+ $resp = $client->request("/{$index}/{$type}/{$documentId}", Request::GET);
+ $data = $resp->getData();
+ if (!empty($data['_source'])) {
+ return $data['_source'];
+ }
+
+ return array();
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php
new file mode 100644
index 00000000..626f5f9f
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php
@@ -0,0 +1,58 @@
+setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
+ $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
+
+ $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
+ $this->assertSame($GLOBALS['error_log'][0][1], $type);
+
+ $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
+ $handler->setFormatter(new LineFormatter(null, null, true));
+ $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
+
+ $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
+ $this->assertSame($GLOBALS['error_log'][1][1], $type);
+
+ $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
+ $this->assertSame($GLOBALS['error_log'][2][1], $type);
+
+ $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
+ $this->assertSame($GLOBALS['error_log'][3][1], $type);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php
new file mode 100644
index 00000000..1f86c8ec
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php
@@ -0,0 +1,151 @@
+assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
+ $this->assertTrue($handler->isHandling($this->getRecord(Logger::INFO)));
+ $this->assertTrue($handler->isHandling($this->getRecord(Logger::NOTICE)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::WARNING)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::ERROR)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::CRITICAL)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::ALERT)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::EMERGENCY)));
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::handle
+ * @covers Monolog\Handler\FilterHandler::setAcceptedLevels
+ * @covers Monolog\Handler\FilterHandler::isHandling
+ */
+ public function testHandleProcessOnlyNeededLevels()
+ {
+ $test = new TestHandler();
+ $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE);
+
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $this->assertFalse($test->hasDebugRecords());
+
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertTrue($test->hasInfoRecords());
+ $handler->handle($this->getRecord(Logger::NOTICE));
+ $this->assertTrue($test->hasNoticeRecords());
+
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertFalse($test->hasWarningRecords());
+ $handler->handle($this->getRecord(Logger::ERROR));
+ $this->assertFalse($test->hasErrorRecords());
+ $handler->handle($this->getRecord(Logger::CRITICAL));
+ $this->assertFalse($test->hasCriticalRecords());
+ $handler->handle($this->getRecord(Logger::ALERT));
+ $this->assertFalse($test->hasAlertRecords());
+ $handler->handle($this->getRecord(Logger::EMERGENCY));
+ $this->assertFalse($test->hasEmergencyRecords());
+
+ $test = new TestHandler();
+ $handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR));
+
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $this->assertFalse($test->hasDebugRecords());
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertTrue($test->hasInfoRecords());
+ $handler->handle($this->getRecord(Logger::NOTICE));
+ $this->assertFalse($test->hasNoticeRecords());
+ $handler->handle($this->getRecord(Logger::ERROR));
+ $this->assertTrue($test->hasErrorRecords());
+ $handler->handle($this->getRecord(Logger::CRITICAL));
+ $this->assertFalse($test->hasCriticalRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::setAcceptedLevels
+ * @covers Monolog\Handler\FilterHandler::getAcceptedLevels
+ */
+ public function testAcceptedLevelApi()
+ {
+ $test = new TestHandler();
+ $handler = new FilterHandler($test);
+
+ $levels = array(Logger::INFO, Logger::ERROR);
+ $handler->setAcceptedLevels($levels);
+ $this->assertSame($levels, $handler->getAcceptedLevels());
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::handle
+ */
+ public function testHandleUsesProcessors()
+ {
+ $test = new TestHandler();
+ $handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY);
+ $handler->pushProcessor(
+ function ($record) {
+ $record['extra']['foo'] = true;
+
+ return $record;
+ }
+ );
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasWarningRecords());
+ $records = $test->getRecords();
+ $this->assertTrue($records[0]['extra']['foo']);
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::handle
+ */
+ public function testHandleRespectsBubble()
+ {
+ $test = new TestHandler();
+
+ $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, false);
+ $this->assertTrue($handler->handle($this->getRecord(Logger::INFO)));
+ $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
+
+ $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, true);
+ $this->assertFalse($handler->handle($this->getRecord(Logger::INFO)));
+ $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::handle
+ */
+ public function testHandleWithCallback()
+ {
+ $test = new TestHandler();
+ $handler = new FilterHandler(
+ function ($record, $handler) use ($test) {
+ return $test;
+ }, Logger::INFO, Logger::NOTICE, false
+ );
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FilterHandler::handle
+ * @expectedException \RuntimeException
+ */
+ public function testHandleWithBadCallbackThrowsException()
+ {
+ $handler = new FilterHandler(
+ function ($record, $handler) {
+ return 'foo';
+ }
+ );
+ $handler->handle($this->getRecord(Logger::WARNING));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
new file mode 100644
index 00000000..d02fef99
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php
@@ -0,0 +1,207 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
+use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
+
+class FingersCrossedHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::__construct
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleBuffers()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertFalse($test->hasInfoRecords());
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->close();
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue(count($test->getRecords()) === 3);
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleStopsBufferingAfterTrigger()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test);
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->close();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasDebugRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ * @covers Monolog\Handler\FingersCrossedHandler::reset
+ */
+ public function testHandleRestartBufferingAfterReset()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test);
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->reset();
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->close();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertFalse($test->hasInfoRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->close();
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertFalse($test->hasInfoRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleBufferLimit()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasWarningRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertFalse($test->hasDebugRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleWithCallback()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler(function ($record, $handler) use ($test) {
+ return $test;
+ });
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertFalse($test->hasInfoRecords());
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue(count($test->getRecords()) === 3);
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ * @expectedException RuntimeException
+ */
+ public function testHandleWithBadCallbackThrowsException()
+ {
+ $handler = new FingersCrossedHandler(function ($record, $handler) {
+ return 'foo';
+ });
+ $handler->handle($this->getRecord(Logger::WARNING));
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::isHandling
+ */
+ public function testIsHandlingAlways()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, Logger::ERROR);
+ $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::__construct
+ * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct
+ * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated
+ */
+ public function testErrorLevelActivationStrategy()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING));
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $this->assertFalse($test->hasDebugRecords());
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertTrue($test->hasWarningRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct
+ * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated
+ */
+ public function testChannelLevelActivationStrategy()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG)));
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertFalse($test->hasWarningRecords());
+ $record = $this->getRecord(Logger::DEBUG);
+ $record['channel'] = 'othertest';
+ $handler->handle($record);
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertTrue($test->hasWarningRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::handle
+ */
+ public function testHandleUsesProcessors()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, Logger::INFO);
+ $handler->pushProcessor(function ($record) {
+ $record['extra']['foo'] = true;
+
+ return $record;
+ });
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasWarningRecords());
+ $records = $test->getRecords();
+ $this->assertTrue($records[0]['extra']['foo']);
+ }
+
+ /**
+ * @covers Monolog\Handler\FingersCrossedHandler::close
+ */
+ public function testPassthruOnClose()
+ {
+ $test = new TestHandler();
+ $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, Logger::INFO);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ $handler->close();
+ $this->assertFalse($test->hasDebugRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
new file mode 100644
index 00000000..0eb10a63
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php
@@ -0,0 +1,96 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\FirePHPHandler
+ */
+class FirePHPHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ TestFirePHPHandler::reset();
+ $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0';
+ }
+
+ public function testHeaders()
+ {
+ $handler = new TestFirePHPHandler;
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING));
+
+ $expected = array(
+ 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
+ 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
+ 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
+ 'X-Wf-1-1-1-1' => 'test',
+ 'X-Wf-1-1-1-2' => 'test',
+ );
+
+ $this->assertEquals($expected, $handler->getHeaders());
+ }
+
+ public function testConcurrentHandlers()
+ {
+ $handler = new TestFirePHPHandler;
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::WARNING));
+
+ $handler2 = new TestFirePHPHandler;
+ $handler2->setFormatter($this->getIdentityFormatter());
+ $handler2->handle($this->getRecord(Logger::DEBUG));
+ $handler2->handle($this->getRecord(Logger::WARNING));
+
+ $expected = array(
+ 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
+ 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
+ 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
+ 'X-Wf-1-1-1-1' => 'test',
+ 'X-Wf-1-1-1-2' => 'test',
+ );
+
+ $expected2 = array(
+ 'X-Wf-1-1-1-3' => 'test',
+ 'X-Wf-1-1-1-4' => 'test',
+ );
+
+ $this->assertEquals($expected, $handler->getHeaders());
+ $this->assertEquals($expected2, $handler2->getHeaders());
+ }
+}
+
+class TestFirePHPHandler extends FirePHPHandler
+{
+ protected $headers = array();
+
+ public static function reset()
+ {
+ self::$initialized = false;
+ self::$sendHeaders = true;
+ self::$messageIndex = 1;
+ }
+
+ protected function sendHeader($header, $content)
+ {
+ $this->headers[$header] = $content;
+ }
+
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php
new file mode 100644
index 00000000..4b120d51
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php
@@ -0,0 +1,88 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Formatter\FlowdockFormatter;
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @author Dominik Liebler
+ * @see https://www.hipchat.com/docs/api
+ */
+class FlowdockHandlerTest extends TestCase
+{
+ /**
+ * @var resource
+ */
+ private $res;
+
+ /**
+ * @var FlowdockHandler
+ */
+ private $handler;
+
+ public function setUp()
+ {
+ if (!extension_loaded('openssl')) {
+ $this->markTestSkipped('This test requires openssl to run');
+ }
+ }
+
+ public function testWriteHeader()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
+
+ return $content;
+ }
+
+ /**
+ * @depends testWriteHeader
+ */
+ public function testWriteContent($content)
+ {
+ $this->assertRegexp('/"source":"test_source"/', $content);
+ $this->assertRegexp('/"from_address":"source@test\.com"/', $content);
+ }
+
+ private function createHandler($token = 'myToken')
+ {
+ $constructorArgs = array($token, Logger::DEBUG);
+ $this->res = fopen('php://memory', 'a');
+ $this->handler = $this->getMock(
+ '\Monolog\Handler\FlowdockHandler',
+ array('fsockopen', 'streamSetTimeout', 'closeSocket'),
+ $constructorArgs
+ );
+
+ $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
+ $reflectionProperty->setAccessible(true);
+ $reflectionProperty->setValue($this->handler, 'localhost:1234');
+
+ $this->handler->expects($this->any())
+ ->method('fsockopen')
+ ->will($this->returnValue($this->res));
+ $this->handler->expects($this->any())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(true));
+ $this->handler->expects($this->any())
+ ->method('closeSocket')
+ ->will($this->returnValue(true));
+
+ $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php
new file mode 100644
index 00000000..d60a6db3
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php
@@ -0,0 +1,93 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Gelf\Message;
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Formatter\GelfMessageFormatter;
+
+class GelfHandlerLegacyTest extends TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
+ $this->markTestSkipped("mlehner/gelf-php not installed");
+ }
+ }
+
+ /**
+ * @covers Monolog\Handler\GelfHandler::__construct
+ */
+ public function testConstruct()
+ {
+ $handler = new GelfHandler($this->getMessagePublisher());
+ $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
+ }
+
+ protected function getHandler($messagePublisher)
+ {
+ $handler = new GelfHandler($messagePublisher);
+
+ return $handler;
+ }
+
+ protected function getMessagePublisher()
+ {
+ return new MockMessagePublisher('localhost');
+ }
+
+ public function testDebug()
+ {
+ $messagePublisher = $this->getMessagePublisher();
+ $handler = $this->getHandler($messagePublisher);
+
+ $record = $this->getRecord(Logger::DEBUG, "A test debug message");
+ $handler->handle($record);
+
+ $this->assertEquals(7, $messagePublisher->lastMessage->getLevel());
+ $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
+ $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
+ $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
+ }
+
+ public function testWarning()
+ {
+ $messagePublisher = $this->getMessagePublisher();
+ $handler = $this->getHandler($messagePublisher);
+
+ $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $handler->handle($record);
+
+ $this->assertEquals(4, $messagePublisher->lastMessage->getLevel());
+ $this->assertEquals('test', $messagePublisher->lastMessage->getFacility());
+ $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage());
+ $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage());
+ }
+
+ public function testInjectedGelfMessageFormatter()
+ {
+ $messagePublisher = $this->getMessagePublisher();
+ $handler = $this->getHandler($messagePublisher);
+
+ $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
+
+ $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $record['extra']['blarg'] = 'yep';
+ $record['context']['from'] = 'logger';
+ $handler->handle($record);
+
+ $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost());
+ $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray());
+ $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
new file mode 100644
index 00000000..83136875
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php
@@ -0,0 +1,119 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Gelf\Message;
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Formatter\GelfMessageFormatter;
+
+class GelfHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) {
+ $this->markTestSkipped("graylog2/gelf-php not installed");
+ }
+ }
+
+ /**
+ * @covers Monolog\Handler\GelfHandler::__construct
+ */
+ public function testConstruct()
+ {
+ $handler = new GelfHandler($this->getMessagePublisher());
+ $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
+ }
+
+ protected function getHandler($messagePublisher)
+ {
+ $handler = new GelfHandler($messagePublisher);
+
+ return $handler;
+ }
+
+ protected function getMessagePublisher()
+ {
+ return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false);
+ }
+
+ public function testDebug()
+ {
+ $record = $this->getRecord(Logger::DEBUG, "A test debug message");
+ $expectedMessage = new Message();
+ $expectedMessage
+ ->setLevel(7)
+ ->setFacility("test")
+ ->setShortMessage($record['message'])
+ ->setTimestamp($record['datetime'])
+ ;
+
+ $messagePublisher = $this->getMessagePublisher();
+ $messagePublisher->expects($this->once())
+ ->method('publish')
+ ->with($expectedMessage);
+
+ $handler = $this->getHandler($messagePublisher);
+
+ $handler->handle($record);
+
+ }
+
+ public function testWarning()
+ {
+ $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $expectedMessage = new Message();
+ $expectedMessage
+ ->setLevel(4)
+ ->setFacility("test")
+ ->setShortMessage($record['message'])
+ ->setTimestamp($record['datetime'])
+ ;
+
+ $messagePublisher = $this->getMessagePublisher();
+ $messagePublisher->expects($this->once())
+ ->method('publish')
+ ->with($expectedMessage);
+
+ $handler = $this->getHandler($messagePublisher);
+
+ $handler->handle($record);
+ }
+
+ public function testInjectedGelfMessageFormatter()
+ {
+ $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $record['extra']['blarg'] = 'yep';
+ $record['context']['from'] = 'logger';
+
+ $expectedMessage = new Message();
+ $expectedMessage
+ ->setLevel(4)
+ ->setFacility("test")
+ ->setHost("mysystem")
+ ->setShortMessage($record['message'])
+ ->setTimestamp($record['datetime'])
+ ->setAdditional("EXTblarg", 'yep')
+ ->setAdditional("CTXfrom", 'logger')
+ ;
+
+ $messagePublisher = $this->getMessagePublisher();
+ $messagePublisher->expects($this->once())
+ ->method('publish')
+ ->with($expectedMessage);
+
+ $handler = $this->getHandler($messagePublisher);
+ $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX'));
+ $handler->handle($record);
+
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
new file mode 100644
index 00000000..c6298a6e
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php
@@ -0,0 +1,89 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class GroupHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\GroupHandler::__construct
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorOnlyTakesHandler()
+ {
+ new GroupHandler(array(new TestHandler(), "foo"));
+ }
+
+ /**
+ * @covers Monolog\Handler\GroupHandler::__construct
+ * @covers Monolog\Handler\GroupHandler::handle
+ */
+ public function testHandle()
+ {
+ $testHandlers = array(new TestHandler(), new TestHandler());
+ $handler = new GroupHandler($testHandlers);
+ $handler->handle($this->getRecord(Logger::DEBUG));
+ $handler->handle($this->getRecord(Logger::INFO));
+ foreach ($testHandlers as $test) {
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue(count($test->getRecords()) === 2);
+ }
+ }
+
+ /**
+ * @covers Monolog\Handler\GroupHandler::handleBatch
+ */
+ public function testHandleBatch()
+ {
+ $testHandlers = array(new TestHandler(), new TestHandler());
+ $handler = new GroupHandler($testHandlers);
+ $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
+ foreach ($testHandlers as $test) {
+ $this->assertTrue($test->hasDebugRecords());
+ $this->assertTrue($test->hasInfoRecords());
+ $this->assertTrue(count($test->getRecords()) === 2);
+ }
+ }
+
+ /**
+ * @covers Monolog\Handler\GroupHandler::isHandling
+ */
+ public function testIsHandling()
+ {
+ $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
+ $handler = new GroupHandler($testHandlers);
+ $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
+ $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
+ $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
+ }
+
+ /**
+ * @covers Monolog\Handler\GroupHandler::handle
+ */
+ public function testHandleUsesProcessors()
+ {
+ $test = new TestHandler();
+ $handler = new GroupHandler(array($test));
+ $handler->pushProcessor(function ($record) {
+ $record['extra']['foo'] = true;
+
+ return $record;
+ });
+ $handler->handle($this->getRecord(Logger::WARNING));
+ $this->assertTrue($test->hasWarningRecords());
+ $records = $test->getRecords();
+ $this->assertTrue($records[0]['extra']['foo']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php
new file mode 100644
index 00000000..8b9e4d44
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php
@@ -0,0 +1,167 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @author Rafael Dohms
+ * @see https://www.hipchat.com/docs/api
+ */
+class HipChatHandlerTest extends TestCase
+{
+
+ private $res;
+ private $handler;
+
+ public function testWriteHeader()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
+
+ return $content;
+ }
+
+ /**
+ * @depends testWriteHeader
+ */
+ public function testWriteContent($content)
+ {
+ $this->assertRegexp('/from=Monolog&room_id=room1¬ify=0&message=test1&message_format=text&color=red$/', $content);
+ }
+
+ public function testWriteWithComplexMessage()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
+ }
+
+ /**
+ * @dataProvider provideLevelColors
+ */
+ public function testWriteWithErrorLevelsAndColors($level, $expectedColor)
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord($level, 'Backup of database "example" finished in 16 minutes.'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/color='.$expectedColor.'/', $content);
+ }
+
+ public function provideLevelColors()
+ {
+ return array(
+ array(Logger::DEBUG, 'gray'),
+ array(Logger::INFO, 'green'),
+ array(Logger::WARNING, 'yellow'),
+ array(Logger::ERROR, 'red'),
+ array(Logger::CRITICAL, 'red'),
+ array(Logger::ALERT, 'red'),
+ array(Logger::EMERGENCY,'red'),
+ array(Logger::NOTICE, 'green'),
+ );
+ }
+
+ /**
+ * @dataProvider provideBatchRecords
+ */
+ public function testHandleBatch($records, $expectedColor)
+ {
+ $this->createHandler();
+
+ $this->handler->handleBatch($records);
+
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/color='.$expectedColor.'/', $content);
+ }
+
+ public function provideBatchRecords()
+ {
+ return array(
+ array(
+ array(
+ array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
+ array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
+ array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime())
+ ),
+ 'red',
+ ),
+ array(
+ array(
+ array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()),
+ array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
+ ),
+ 'yellow',
+ ),
+ array(
+ array(
+ array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
+ array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()),
+ ),
+ 'green',
+ ),
+ array(
+ array(
+ array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()),
+ ),
+ 'gray',
+ ),
+ );
+ }
+
+ private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false)
+ {
+ $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG);
+ $this->res = fopen('php://memory', 'a');
+ $this->handler = $this->getMock(
+ '\Monolog\Handler\HipChatHandler',
+ array('fsockopen', 'streamSetTimeout', 'closeSocket'),
+ $constructorArgs
+ );
+
+ $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
+ $reflectionProperty->setAccessible(true);
+ $reflectionProperty->setValue($this->handler, 'localhost:1234');
+
+ $this->handler->expects($this->any())
+ ->method('fsockopen')
+ ->will($this->returnValue($this->res));
+ $this->handler->expects($this->any())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(true));
+ $this->handler->expects($this->any())
+ ->method('closeSocket')
+ ->will($this->returnValue(true));
+
+ $this->handler->setFormatter($this->getIdentityFormatter());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCreateWithTooLongName()
+ {
+ $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php
new file mode 100644
index 00000000..7af60be8
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php
@@ -0,0 +1,84 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @author Robert Kaufmann III
+ */
+class LogEntriesHandlerTest extends TestCase
+{
+ /**
+ * @var resource
+ */
+ private $res;
+
+ /**
+ * @var LogEntriesHandler
+ */
+ private $handler;
+
+ public function testWriteContent()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test'));
+
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content);
+ }
+
+ public function testWriteBatchContent()
+ {
+ $records = array(
+ $this->getRecord(),
+ $this->getRecord(),
+ $this->getRecord()
+ );
+ $this->createHandler();
+ $this->handler->handleBatch($records);
+
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content);
+ }
+
+ private function createHandler()
+ {
+ $useSSL = extension_loaded('openssl');
+ $args = array('testToken', $useSSL, Logger::DEBUG, true);
+ $this->res = fopen('php://memory', 'a');
+ $this->handler = $this->getMock(
+ '\Monolog\Handler\LogEntriesHandler',
+ array('fsockopen', 'streamSetTimeout', 'closeSocket'),
+ $args
+ );
+
+ $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
+ $reflectionProperty->setAccessible(true);
+ $reflectionProperty->setValue($this->handler, 'localhost:1234');
+
+ $this->handler->expects($this->any())
+ ->method('fsockopen')
+ ->will($this->returnValue($this->res));
+ $this->handler->expects($this->any())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(true));
+ $this->handler->expects($this->any())
+ ->method('closeSocket')
+ ->will($this->returnValue(true));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
new file mode 100644
index 00000000..6754f3d6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php
@@ -0,0 +1,75 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\Logger;
+use Monolog\TestCase;
+
+class MailHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\MailHandler::handleBatch
+ */
+ public function testHandleBatch()
+ {
+ $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
+ $formatter->expects($this->once())
+ ->method('formatBatch'); // Each record is formatted
+
+ $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
+ $handler->expects($this->once())
+ ->method('send');
+ $handler->expects($this->never())
+ ->method('write'); // write is for individual records
+
+ $handler->setFormatter($formatter);
+
+ $handler->handleBatch($this->getMultipleRecords());
+ }
+
+ /**
+ * @covers Monolog\Handler\MailHandler::handleBatch
+ */
+ public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
+ {
+ $records = array(
+ $this->getRecord(Logger::DEBUG, 'debug message 1'),
+ $this->getRecord(Logger::DEBUG, 'debug message 2'),
+ $this->getRecord(Logger::INFO, 'information'),
+ );
+
+ $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
+ $handler->expects($this->never())
+ ->method('send');
+ $handler->setLevel(Logger::ERROR);
+
+ $handler->handleBatch($records);
+ }
+
+ /**
+ * @covers Monolog\Handler\MailHandler::write
+ */
+ public function testHandle()
+ {
+ $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
+
+ $record = $this->getRecord();
+ $records = array($record);
+ $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n";
+
+ $handler->expects($this->once())
+ ->method('send')
+ ->with($records[0]['formatted'], $records);
+
+ $handler->handle($record);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
new file mode 100644
index 00000000..fbaab9bc
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php
@@ -0,0 +1,26 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Raven_Client;
+
+class MockRavenClient extends Raven_Client
+{
+ public function capture($data, $stack, $vars = null)
+ {
+ $this->lastData = $data;
+ $this->lastStack = $stack;
+ }
+
+ public $lastData;
+ public $lastStack;
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
new file mode 100644
index 00000000..7f06d666
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php
@@ -0,0 +1,63 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class MongoDBHandlerTest extends TestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorShouldThrowExceptionForInvalidMongo()
+ {
+ new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
+ }
+
+ public function testHandle()
+ {
+ $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
+ $collection = $this->getMock('stdClass', array('save'));
+
+ $mongo->expects($this->once())
+ ->method('selectCollection')
+ ->with('DB', 'Collection')
+ ->will($this->returnValue($collection));
+
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $expected = array(
+ 'message' => 'test',
+ 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
+ 'level' => Logger::WARNING,
+ 'level_name' => 'WARNING',
+ 'channel' => 'test',
+ 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
+ 'extra' => array(),
+ );
+
+ $collection->expects($this->once())
+ ->method('save')
+ ->with($expected);
+
+ $handler = new MongoDBHandler($mongo, 'DB', 'Collection');
+ $handler->handle($record);
+ }
+}
+
+if (!class_exists('Mongo')) {
+ class Mongo
+ {
+ public function selectCollection() {}
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
new file mode 100644
index 00000000..50ceace0
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php
@@ -0,0 +1,43 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+
+class NativeMailerHandlerTest extends TestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorHeaderInjection()
+ {
+ $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testSetterHeaderInjection()
+ {
+ $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
+ $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testSetterArrayHeaderInjection()
+ {
+ $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
+ $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php
new file mode 100644
index 00000000..2e059684
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php
@@ -0,0 +1,134 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Psr\Log\LogLevel;
+
+class NewRelicHandlerTest extends TestCase
+{
+ public static $appname;
+ public static $customParameters;
+
+ public function setUp()
+ {
+ self::$appname = null;
+ self::$customParameters = array();
+ }
+
+ /**
+ * @expectedException Monolog\Handler\MissingExtensionException
+ */
+ public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded()
+ {
+ $handler = new StubNewRelicHandlerWithoutExtension();
+ $handler->handle($this->getRecord(Logger::ERROR));
+ }
+
+ public function testThehandlerCanHandleTheRecord()
+ {
+ $handler = new StubNewRelicHandler();
+ $handler->handle($this->getRecord(Logger::ERROR));
+ }
+
+ public function testThehandlerCanAddContextParamsToTheNewRelicTrace()
+ {
+ $handler = new StubNewRelicHandler();
+ $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
+ $this->assertEquals(array('a' => 'b'), self::$customParameters);
+ }
+
+ public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
+ {
+ $record = $this->getRecord(Logger::ERROR, 'log message');
+ $record['extra'] = array('c' => 'd');
+
+ $handler = new StubNewRelicHandler();
+ $handler->handle($record);
+
+ $this->assertEquals(array('c' => 'd'), self::$customParameters);
+ }
+
+ public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
+ {
+ $record = $this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'));
+ $record['extra'] = array('c' => 'd');
+
+ $handler = new StubNewRelicHandler();
+ $handler->handle($record);
+
+ $expected = array(
+ 'a' => 'b',
+ 'c' => 'd',
+ );
+
+ $this->assertEquals($expected, self::$customParameters);
+ }
+
+ public function testTheAppNameIsNullByDefault()
+ {
+ $handler = new StubNewRelicHandler();
+ $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
+
+ $this->assertEquals(null, self::$appname);
+ }
+
+ public function testTheAppNameCanBeInjectedFromtheConstructor()
+ {
+ $handler = new StubNewRelicHandler(LogLevel::ALERT, false, 'myAppName');
+ $handler->handle($this->getRecord(Logger::ERROR, 'log message'));
+
+ $this->assertEquals('myAppName', self::$appname);
+ }
+
+ public function testTheAppNameCanBeOverriddenFromEachLog()
+ {
+ $handler = new StubNewRelicHandler(LogLevel::ALERT, false, 'myAppName');
+ $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName')));
+
+ $this->assertEquals('logAppName', self::$appname);
+ }
+}
+
+class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
+{
+ protected function isNewRelicEnabled()
+ {
+ return false;
+ }
+}
+
+class StubNewRelicHandler extends NewRelicHandler
+{
+ protected function isNewRelicEnabled()
+ {
+ return true;
+ }
+}
+
+function newrelic_notice_error()
+{
+ return true;
+}
+
+function newrelic_set_appname($appname)
+{
+ return NewRelicHandlerTest::$appname = $appname;
+}
+
+function newrelic_add_custom_parameter($key, $value)
+{
+ NewRelicHandlerTest::$customParameters[$key] = $value;
+
+ return true;
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
new file mode 100644
index 00000000..292df78c
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php
@@ -0,0 +1,33 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\NullHandler::handle
+ */
+class NullHandlerTest extends TestCase
+{
+ public function testHandle()
+ {
+ $handler = new NullHandler();
+ $this->assertTrue($handler->handle($this->getRecord()));
+ }
+
+ public function testHandleLowerLevelRecord()
+ {
+ $handler = new NullHandler(Logger::WARNING);
+ $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
new file mode 100644
index 00000000..e048a02a
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php
@@ -0,0 +1,142 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * Almost all examples (expected header, titles, messages) taken from
+ * https://www.pushover.net/api
+ * @author Sebastian Göttschkes
+ * @see https://www.pushover.net/api
+ */
+class PushoverHandlerTest extends TestCase
+{
+
+ private $res;
+ private $handler;
+
+ public function testWriteHeader()
+ {
+ $this->createHandler();
+ $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
+
+ return $content;
+ }
+
+ /**
+ * @depends testWriteHeader
+ */
+ public function testWriteContent($content)
+ {
+ $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content);
+ }
+
+ public function testWriteWithComplexTitle()
+ {
+ $this->createHandler('myToken', 'myUser', 'Backup finished - SQL1', Logger::EMERGENCY);
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content);
+ }
+
+ public function testWriteWithComplexMessage()
+ {
+ $this->createHandler();
+ $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
+ }
+
+ public function testWriteWithTooLongMessage()
+ {
+ $message = str_pad('test', 520, 'a');
+ $this->createHandler();
+ $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, $message));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $expectedMessage = substr($message, 0, 505);
+
+ $this->assertRegexp('/message=' . $expectedMessage . '&title/', $content);
+ }
+
+ public function testWriteWithHighPriority()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content);
+ }
+
+ public function testWriteWithEmergencyPriority()
+ {
+ $this->createHandler();
+ $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
+ }
+
+ public function testWriteToMultipleUsers()
+ {
+ $this->createHandler('myToken', array('userA', 'userB'));
+ $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
+ fseek($this->res, 0);
+ $content = fread($this->res, 1024);
+
+ $this->assertRegexp('/token=myToken&user=userA&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200POST/', $content);
+ $this->assertRegexp('/token=myToken&user=userB&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content);
+ }
+
+ private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
+ {
+ $constructorArgs = array($token, $user, $title);
+ $this->res = fopen('php://memory', 'a');
+ $this->handler = $this->getMock(
+ '\Monolog\Handler\PushoverHandler',
+ array('fsockopen', 'streamSetTimeout', 'closeSocket'),
+ $constructorArgs
+ );
+
+ $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
+ $reflectionProperty->setAccessible(true);
+ $reflectionProperty->setValue($this->handler, 'localhost:1234');
+
+ $this->handler->expects($this->any())
+ ->method('fsockopen')
+ ->will($this->returnValue($this->res));
+ $this->handler->expects($this->any())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(true));
+ $this->handler->expects($this->any())
+ ->method('closeSocket')
+ ->will($this->returnValue(true));
+
+ $this->handler->setFormatter($this->getIdentityFormatter());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
new file mode 100644
index 00000000..8fe86961
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
@@ -0,0 +1,150 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
+
+class RavenHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists("Raven_Client")) {
+ $this->markTestSkipped("raven/raven not installed");
+ }
+
+ require_once __DIR__ . '/MockRavenClient.php';
+ }
+
+ /**
+ * @covers Monolog\Handler\RavenHandler::__construct
+ */
+ public function testConstruct()
+ {
+ $handler = new RavenHandler($this->getRavenClient());
+ $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler);
+ }
+
+ protected function getHandler($ravenClient)
+ {
+ $handler = new RavenHandler($ravenClient);
+
+ return $handler;
+ }
+
+ protected function getRavenClient()
+ {
+ $dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
+
+ return new MockRavenClient($dsn);
+ }
+
+ public function testDebug()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ $record = $this->getRecord(Logger::DEBUG, "A test debug message");
+ $handler->handle($record);
+
+ $this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
+ $this->assertContains($record['message'], $ravenClient->lastData['message']);
+ }
+
+ public function testWarning()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $handler->handle($record);
+
+ $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
+ $this->assertContains($record['message'], $ravenClient->lastData['message']);
+ }
+
+ public function testTag()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ $tags = array(1, 2, 'foo');
+ $record = $this->getRecord(Logger::INFO, "test", array('tags' => $tags));
+ $handler->handle($record);
+
+ $this->assertEquals($tags, $ravenClient->lastData['tags']);
+ }
+
+ public function testException()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ try {
+ $this->methodThatThrowsAnException();
+ } catch (\Exception $e) {
+ $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
+ $handler->handle($record);
+ }
+
+ $this->assertEquals($record['message'], $ravenClient->lastData['message']);
+ }
+
+ public function testHandleBatch()
+ {
+ $records = $this->getMultipleRecords();
+ $records[] = $this->getRecord(Logger::WARNING, 'warning');
+ $records[] = $this->getRecord(Logger::WARNING, 'warning');
+
+ $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
+ $logFormatter->expects($this->once())->method('formatBatch');
+
+ $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
+ $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
+ return $record['level'] == 400;
+ }));
+
+ $handler = $this->getHandler($this->getRavenClient());
+ $handler->setBatchFormatter($logFormatter);
+ $handler->setFormatter($formatter);
+ $handler->handleBatch($records);
+ }
+
+ public function testHandleBatchDoNothingIfRecordsAreBelowLevel()
+ {
+ $records = array(
+ $this->getRecord(Logger::DEBUG, 'debug message 1'),
+ $this->getRecord(Logger::DEBUG, 'debug message 2'),
+ $this->getRecord(Logger::INFO, 'information'),
+ );
+
+ $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
+ $handler->expects($this->never())->method('handle');
+ $handler->setLevel(Logger::ERROR);
+ $handler->handleBatch($records);
+ }
+
+ public function testGetSetBatchFormatter()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ $handler->setBatchFormatter($formatter = new LineFormatter());
+ $this->assertSame($formatter, $handler->getBatchFormatter());
+ }
+
+ private function methodThatThrowsAnException()
+ {
+ throw new \Exception('This is an exception');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
new file mode 100644
index 00000000..3629f8a2
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php
@@ -0,0 +1,71 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+use Monolog\Formatter\LineFormatter;
+
+class RedisHandlerTest extends TestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorShouldThrowExceptionForInvalidRedis()
+ {
+ new RedisHandler(new \stdClass(), 'key');
+ }
+
+ public function testConstructorShouldWorkWithPredis()
+ {
+ $redis = $this->getMock('Predis\Client');
+ $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
+ }
+
+ public function testConstructorShouldWorkWithRedis()
+ {
+ $redis = $this->getMock('Redis');
+ $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
+ }
+
+ public function testPredisHandle()
+ {
+ $redis = $this->getMock('Predis\Client', array('rpush'));
+
+ // Predis\Client uses rpush
+ $redis->expects($this->once())
+ ->method('rpush')
+ ->with('key', 'test');
+
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $handler = new RedisHandler($redis, 'key');
+ $handler->setFormatter(new LineFormatter("%message%"));
+ $handler->handle($record);
+ }
+
+ public function testRedisHandle()
+ {
+ $redis = $this->getMock('Redis', array('rpush'));
+
+ // Redis uses rPush
+ $redis->expects($this->once())
+ ->method('rPush')
+ ->with('key', 'test');
+
+ $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
+
+ $handler = new RedisHandler($redis, 'key');
+ $handler->setFormatter(new LineFormatter("%message%"));
+ $handler->handle($record);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
new file mode 100644
index 00000000..f4cefda1
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php
@@ -0,0 +1,99 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+
+/**
+ * @covers Monolog\Handler\RotatingFileHandler
+ */
+class RotatingFileHandlerTest extends TestCase
+{
+ public function setUp()
+ {
+ $dir = __DIR__.'/Fixtures';
+ chmod($dir, 0777);
+ if (!is_writable($dir)) {
+ $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.');
+ }
+ }
+
+ public function testRotationCreatesNewFile()
+ {
+ touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
+
+ $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord());
+
+ $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
+ $this->assertTrue(file_exists($log));
+ $this->assertEquals('test', file_get_contents($log));
+ }
+
+ /**
+ * @dataProvider rotationTests
+ */
+ public function testRotation($createFile)
+ {
+ touch($old1 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot');
+ touch($old2 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 2).'.rot');
+ touch($old3 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 3).'.rot');
+ touch($old4 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 4).'.rot');
+
+ $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
+
+ if ($createFile) {
+ touch($log);
+ }
+
+ $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2);
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord());
+
+ $handler->close();
+
+ $this->assertTrue(file_exists($log));
+ $this->assertTrue(file_exists($old1));
+ $this->assertEquals($createFile, file_exists($old2));
+ $this->assertEquals($createFile, file_exists($old3));
+ $this->assertEquals($createFile, file_exists($old4));
+ $this->assertEquals('test', file_get_contents($log));
+ }
+
+ public function rotationTests()
+ {
+ return array(
+ 'Rotation is triggered when the file of the current day is not present'
+ => array(true),
+ 'Rotation is not triggered when the file is already present'
+ => array(false),
+ );
+ }
+
+ public function testReuseCurrentFile()
+ {
+ $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot';
+ file_put_contents($log, "foo");
+ $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot');
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord());
+ $this->assertEquals('footest', file_get_contents($log));
+ }
+
+ public function tearDown()
+ {
+ foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) {
+ unlink($file);
+ }
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
new file mode 100644
index 00000000..3a925eb5
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php
@@ -0,0 +1,283 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @author Pablo de Leon Belloc
+ */
+class SocketHandlerTest extends TestCase
+{
+ /**
+ * @var Monolog\Handler\SocketHandler
+ */
+ private $handler;
+
+ /**
+ * @var resource
+ */
+ private $res;
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testInvalidHostname()
+ {
+ $this->createHandler('garbage://here');
+ $this->writeRecord('data');
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testBadConnectionTimeout()
+ {
+ $this->createHandler('localhost:1234');
+ $this->handler->setConnectionTimeout(-1);
+ }
+
+ public function testSetConnectionTimeout()
+ {
+ $this->createHandler('localhost:1234');
+ $this->handler->setConnectionTimeout(10.1);
+ $this->assertEquals(10.1, $this->handler->getConnectionTimeout());
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testBadTimeout()
+ {
+ $this->createHandler('localhost:1234');
+ $this->handler->setTimeout(-1);
+ }
+
+ public function testSetTimeout()
+ {
+ $this->createHandler('localhost:1234');
+ $this->handler->setTimeout(10.25);
+ $this->assertEquals(10.25, $this->handler->getTimeout());
+ }
+
+ public function testSetConnectionString()
+ {
+ $this->createHandler('tcp://localhost:9090');
+ $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testExceptionIsThrownOnFsockopenError()
+ {
+ $this->setMockHandler(array('fsockopen'));
+ $this->handler->expects($this->once())
+ ->method('fsockopen')
+ ->will($this->returnValue(false));
+ $this->writeRecord('Hello world');
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testExceptionIsThrownOnPfsockopenError()
+ {
+ $this->setMockHandler(array('pfsockopen'));
+ $this->handler->expects($this->once())
+ ->method('pfsockopen')
+ ->will($this->returnValue(false));
+ $this->handler->setPersistent(true);
+ $this->writeRecord('Hello world');
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testExceptionIsThrownIfCannotSetTimeout()
+ {
+ $this->setMockHandler(array('streamSetTimeout'));
+ $this->handler->expects($this->once())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(false));
+ $this->writeRecord('Hello world');
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testWriteFailsOnIfFwriteReturnsFalse()
+ {
+ $this->setMockHandler(array('fwrite'));
+
+ $callback = function ($arg) {
+ $map = array(
+ 'Hello world' => 6,
+ 'world' => false,
+ );
+
+ return $map[$arg];
+ };
+
+ $this->handler->expects($this->exactly(2))
+ ->method('fwrite')
+ ->will($this->returnCallback($callback));
+
+ $this->writeRecord('Hello world');
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testWriteFailsIfStreamTimesOut()
+ {
+ $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
+
+ $callback = function ($arg) {
+ $map = array(
+ 'Hello world' => 6,
+ 'world' => 5,
+ );
+
+ return $map[$arg];
+ };
+
+ $this->handler->expects($this->exactly(1))
+ ->method('fwrite')
+ ->will($this->returnCallback($callback));
+ $this->handler->expects($this->exactly(1))
+ ->method('streamGetMetadata')
+ ->will($this->returnValue(array('timed_out' => true)));
+
+ $this->writeRecord('Hello world');
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testWriteFailsOnIncompleteWrite()
+ {
+ $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
+
+ $res = $this->res;
+ $callback = function ($string) use ($res) {
+ fclose($res);
+
+ return strlen('Hello');
+ };
+
+ $this->handler->expects($this->exactly(1))
+ ->method('fwrite')
+ ->will($this->returnCallback($callback));
+ $this->handler->expects($this->exactly(1))
+ ->method('streamGetMetadata')
+ ->will($this->returnValue(array('timed_out' => false)));
+
+ $this->writeRecord('Hello world');
+ }
+
+ public function testWriteWithMemoryFile()
+ {
+ $this->setMockHandler();
+ $this->writeRecord('test1');
+ $this->writeRecord('test2');
+ $this->writeRecord('test3');
+ fseek($this->res, 0);
+ $this->assertEquals('test1test2test3', fread($this->res, 1024));
+ }
+
+ public function testWriteWithMock()
+ {
+ $this->setMockHandler(array('fwrite'));
+
+ $callback = function ($arg) {
+ $map = array(
+ 'Hello world' => 6,
+ 'world' => 5,
+ );
+
+ return $map[$arg];
+ };
+
+ $this->handler->expects($this->exactly(2))
+ ->method('fwrite')
+ ->will($this->returnCallback($callback));
+
+ $this->writeRecord('Hello world');
+ }
+
+ public function testClose()
+ {
+ $this->setMockHandler();
+ $this->writeRecord('Hello world');
+ $this->assertInternalType('resource', $this->res);
+ $this->handler->close();
+ $this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler");
+ }
+
+ public function testCloseDoesNotClosePersistentSocket()
+ {
+ $this->setMockHandler();
+ $this->handler->setPersistent(true);
+ $this->writeRecord('Hello world');
+ $this->assertTrue(is_resource($this->res));
+ $this->handler->close();
+ $this->assertTrue(is_resource($this->res));
+ }
+
+ private function createHandler($connectionString)
+ {
+ $this->handler = new SocketHandler($connectionString);
+ $this->handler->setFormatter($this->getIdentityFormatter());
+ }
+
+ private function writeRecord($string)
+ {
+ $this->handler->handle($this->getRecord(Logger::WARNING, $string));
+ }
+
+ private function setMockHandler(array $methods = array())
+ {
+ $this->res = fopen('php://memory', 'a');
+
+ $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
+ $newMethods = array_diff($methods, $defaultMethods);
+
+ $finalMethods = array_merge($defaultMethods, $newMethods);
+
+ $this->handler = $this->getMock(
+ '\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234')
+ );
+
+ if (!in_array('fsockopen', $methods)) {
+ $this->handler->expects($this->any())
+ ->method('fsockopen')
+ ->will($this->returnValue($this->res));
+ }
+
+ if (!in_array('pfsockopen', $methods)) {
+ $this->handler->expects($this->any())
+ ->method('pfsockopen')
+ ->will($this->returnValue($this->res));
+ }
+
+ if (!in_array('streamSetTimeout', $methods)) {
+ $this->handler->expects($this->any())
+ ->method('streamSetTimeout')
+ ->will($this->returnValue(true));
+ }
+
+ $this->handler->setFormatter($this->getIdentityFormatter());
+ }
+
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
new file mode 100644
index 00000000..63d4fef6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php
@@ -0,0 +1,88 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+class StreamHandlerTest extends TestCase
+{
+ /**
+ * @covers Monolog\Handler\StreamHandler::__construct
+ * @covers Monolog\Handler\StreamHandler::write
+ */
+ public function testWrite()
+ {
+ $handle = fopen('php://memory', 'a+');
+ $handler = new StreamHandler($handle);
+ $handler->setFormatter($this->getIdentityFormatter());
+ $handler->handle($this->getRecord(Logger::WARNING, 'test'));
+ $handler->handle($this->getRecord(Logger::WARNING, 'test2'));
+ $handler->handle($this->getRecord(Logger::WARNING, 'test3'));
+ fseek($handle, 0);
+ $this->assertEquals('testtest2test3', fread($handle, 100));
+ }
+
+ /**
+ * @covers Monolog\Handler\StreamHandler::close
+ */
+ public function testClose()
+ {
+ $handle = fopen('php://memory', 'a+');
+ $handler = new StreamHandler($handle);
+ $this->assertTrue(is_resource($handle));
+ $handler->close();
+ $this->assertFalse(is_resource($handle));
+ }
+
+ /**
+ * @covers Monolog\Handler\StreamHandler::write
+ */
+ public function testWriteCreatesTheStreamResource()
+ {
+ $handler = new StreamHandler('php://memory');
+ $handler->handle($this->getRecord());
+ }
+
+ /**
+ * @expectedException LogicException
+ * @covers Monolog\Handler\StreamHandler::__construct
+ * @covers Monolog\Handler\StreamHandler::write
+ */
+ public function testWriteMissingResource()
+ {
+ $handler = new StreamHandler(null);
+ $handler->handle($this->getRecord());
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ * @covers Monolog\Handler\StreamHandler::__construct
+ * @covers Monolog\Handler\StreamHandler::write
+ */
+ public function testWriteInvalidResource()
+ {
+ $handler = new StreamHandler('bogus://url');
+ $handler->handle($this->getRecord());
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ * @covers Monolog\Handler\StreamHandler::__construct
+ * @covers Monolog\Handler\StreamHandler::write
+ */
+ public function testWriteNonExistingResource()
+ {
+ $handler = new StreamHandler('/foo/bar/baz/'.rand(0, 10000));
+ $handler->handle($this->getRecord());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php
new file mode 100644
index 00000000..98219ac1
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php
@@ -0,0 +1,43 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+use Monolog\Logger;
+
+class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers Monolog\Handler\SyslogHandler::__construct
+ */
+ public function testConstruct()
+ {
+ $handler = new SyslogHandler('test');
+ $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
+
+ $handler = new SyslogHandler('test', LOG_USER);
+ $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
+
+ $handler = new SyslogHandler('test', 'user');
+ $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
+
+ $handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
+ $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
+ }
+
+ /**
+ * @covers Monolog\Handler\SyslogHandler::__construct
+ */
+ public function testConstructInvalidFacility()
+ {
+ $this->setExpectedException('UnexpectedValueException');
+ $handler = new SyslogHandler('test', 'unknown');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php
new file mode 100644
index 00000000..269a296e
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php
@@ -0,0 +1,37 @@
+setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
+
+ $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
+ $socket->expects($this->at(0))
+ ->method('write')
+ ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">: ");
+ $socket->expects($this->at(1))
+ ->method('write')
+ ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">: ");
+
+ $handler->setSocket($socket);
+
+ $handler->handle($this->getRecordWithMessage("hej\nlol"));
+ }
+
+ protected function getRecordWithMessage($msg)
+ {
+ return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php
new file mode 100644
index 00000000..801d80a9
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php
@@ -0,0 +1,56 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+use Monolog\Logger;
+
+/**
+ * @covers Monolog\Handler\TestHandler
+ */
+class TestHandlerTest extends TestCase
+{
+ /**
+ * @dataProvider methodProvider
+ */
+ public function testHandler($method, $level)
+ {
+ $handler = new TestHandler;
+ $record = $this->getRecord($level, 'test'.$method);
+ $this->assertFalse($handler->{'has'.$method}($record));
+ $this->assertFalse($handler->{'has'.$method.'Records'}());
+ $handler->handle($record);
+
+ $this->assertFalse($handler->{'has'.$method}('bar'));
+ $this->assertTrue($handler->{'has'.$method}($record));
+ $this->assertTrue($handler->{'has'.$method}('test'.$method));
+ $this->assertTrue($handler->{'has'.$method.'Records'}());
+
+ $records = $handler->getRecords();
+ unset($records[0]['formatted']);
+ $this->assertEquals(array($record), $records);
+ }
+
+ public function methodProvider()
+ {
+ return array(
+ array('Emergency', Logger::EMERGENCY),
+ array('Alert' , Logger::ALERT),
+ array('Critical' , Logger::CRITICAL),
+ array('Error' , Logger::ERROR),
+ array('Warning' , Logger::WARNING),
+ array('Info' , Logger::INFO),
+ array('Notice' , Logger::NOTICE),
+ array('Debug' , Logger::DEBUG),
+ );
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php
new file mode 100644
index 00000000..d16b0a3d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php
@@ -0,0 +1,45 @@
+getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
+
+ $socket->expects($this->at(0))
+ ->method('send')
+ ->with("HEADER: The quick brown fox jumps over the lazy dog");
+
+ $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
+ }
+
+ public function testWeSplitLongMessages()
+ {
+ $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
+
+ $socket->expects($this->at(1))
+ ->method('send')
+ ->with("The quick brown fox jumps over the lazy dog");
+
+ $aStringOfLength2048 = str_repeat("derp", 2048/4);
+
+ $socket->write($aStringOfLength2048."The quick brown fox jumps over the lazy dog");
+ }
+
+ public function testAllSplitMessagesHasAHeader()
+ {
+ $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
+
+ $socket->expects($this->exactly(5))
+ ->method('send')
+ ->with($this->stringStartsWith("HEADER"));
+
+ $aStringOfLength8192 = str_repeat("derp", 2048);
+
+ $socket->write($aStringOfLength8192, "HEADER");
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php
new file mode 100644
index 00000000..416039e6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php
@@ -0,0 +1,69 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Handler;
+
+use Monolog\TestCase;
+
+class ZendMonitorHandlerTest extends TestCase
+{
+ protected $zendMonitorHandler;
+
+ public function setUp()
+ {
+ if (!function_exists('zend_monitor_custom_event')) {
+ $this->markTestSkipped('ZendServer is not installed');
+ }
+ }
+
+ /**
+ * @covers Monolog\Handler\ZendMonitorHandler::write
+ */
+ public function testWrite()
+ {
+ $record = $this->getRecord();
+ $formatterResult = array(
+ 'message' => $record['message']
+ );
+
+ $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
+ ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
+ ->getMock();
+
+ $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $formatterMock->expects($this->once())
+ ->method('format')
+ ->will($this->returnValue($formatterResult));
+
+ $zendMonitor->expects($this->once())
+ ->method('getDefaultFormatter')
+ ->will($this->returnValue($formatterMock));
+
+ $levelMap = $zendMonitor->getLevelMap();
+
+ $zendMonitor->expects($this->once())
+ ->method('writeZendMonitorCustomEvent')
+ ->with($levelMap[$record['level']], $record['message'], $formatterResult);
+
+ $zendMonitor->handle($record);
+ }
+
+ /**
+ * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
+ */
+ public function testGetDefaultFormatterReturnsNormalizerFormatter()
+ {
+ $zendMonitor = new ZendMonitorHandler();
+ $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/LoggerTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/LoggerTest.php
new file mode 100644
index 00000000..7a19c0b4
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/LoggerTest.php
@@ -0,0 +1,409 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use Monolog\Processor\WebProcessor;
+use Monolog\Handler\TestHandler;
+
+class LoggerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @covers Monolog\Logger::getName
+ */
+ public function testGetName()
+ {
+ $logger = new Logger('foo');
+ $this->assertEquals('foo', $logger->getName());
+ }
+
+ /**
+ * @covers Monolog\Logger::getLevelName
+ */
+ public function testGetLevelName()
+ {
+ $this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
+ }
+
+ /**
+ * @covers Monolog\Logger::getLevelName
+ * @expectedException InvalidArgumentException
+ */
+ public function testGetLevelNameThrows()
+ {
+ Logger::getLevelName(5);
+ }
+
+ /**
+ * @covers Monolog\Logger::__construct
+ */
+ public function testChannel()
+ {
+ $logger = new Logger('foo');
+ $handler = new TestHandler;
+ $logger->pushHandler($handler);
+ $logger->addWarning('test');
+ list($record) = $handler->getRecords();
+ $this->assertEquals('foo', $record['channel']);
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testLog()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'));
+ $handler->expects($this->once())
+ ->method('handle');
+ $logger->pushHandler($handler);
+
+ $this->assertTrue($logger->addWarning('test'));
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testLogNotHandled()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR));
+ $handler->expects($this->never())
+ ->method('handle');
+ $logger->pushHandler($handler);
+
+ $this->assertFalse($logger->addWarning('test'));
+ }
+
+ public function testHandlersInCtor()
+ {
+ $handler1 = new TestHandler;
+ $handler2 = new TestHandler;
+ $logger = new Logger(__METHOD__, array($handler1, $handler2));
+
+ $this->assertEquals($handler1, $logger->popHandler());
+ $this->assertEquals($handler2, $logger->popHandler());
+ }
+
+ public function testProcessorsInCtor()
+ {
+ $processor1 = new WebProcessor;
+ $processor2 = new WebProcessor;
+ $logger = new Logger(__METHOD__, array(), array($processor1, $processor2));
+
+ $this->assertEquals($processor1, $logger->popProcessor());
+ $this->assertEquals($processor2, $logger->popProcessor());
+ }
+
+ /**
+ * @covers Monolog\Logger::pushHandler
+ * @covers Monolog\Logger::popHandler
+ * @expectedException LogicException
+ */
+ public function testPushPopHandler()
+ {
+ $logger = new Logger(__METHOD__);
+ $handler1 = new TestHandler;
+ $handler2 = new TestHandler;
+
+ $logger->pushHandler($handler1);
+ $logger->pushHandler($handler2);
+
+ $this->assertEquals($handler2, $logger->popHandler());
+ $this->assertEquals($handler1, $logger->popHandler());
+ $logger->popHandler();
+ }
+
+ /**
+ * @covers Monolog\Logger::pushProcessor
+ * @covers Monolog\Logger::popProcessor
+ * @expectedException LogicException
+ */
+ public function testPushPopProcessor()
+ {
+ $logger = new Logger(__METHOD__);
+ $processor1 = new WebProcessor;
+ $processor2 = new WebProcessor;
+
+ $logger->pushProcessor($processor1);
+ $logger->pushProcessor($processor2);
+
+ $this->assertEquals($processor2, $logger->popProcessor());
+ $this->assertEquals($processor1, $logger->popProcessor());
+ $logger->popProcessor();
+ }
+
+ /**
+ * @covers Monolog\Logger::pushProcessor
+ * @expectedException InvalidArgumentException
+ */
+ public function testPushProcessorWithNonCallable()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $logger->pushProcessor(new \stdClass());
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testProcessorsAreExecuted()
+ {
+ $logger = new Logger(__METHOD__);
+ $handler = new TestHandler;
+ $logger->pushHandler($handler);
+ $logger->pushProcessor(function ($record) {
+ $record['extra']['win'] = true;
+
+ return $record;
+ });
+ $logger->addError('test');
+ list($record) = $handler->getRecords();
+ $this->assertTrue($record['extra']['win']);
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testProcessorsAreCalledOnlyOnce()
+ {
+ $logger = new Logger(__METHOD__);
+ $handler = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler->expects($this->any())
+ ->method('handle')
+ ->will($this->returnValue(true))
+ ;
+ $logger->pushHandler($handler);
+
+ $processor = $this->getMockBuilder('Monolog\Processor\WebProcessor')
+ ->disableOriginalConstructor()
+ ->setMethods(array('__invoke'))
+ ->getMock()
+ ;
+ $processor->expects($this->once())
+ ->method('__invoke')
+ ->will($this->returnArgument(0))
+ ;
+ $logger->pushProcessor($processor);
+
+ $logger->addError('test');
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testProcessorsNotCalledWhenNotHandled()
+ {
+ $logger = new Logger(__METHOD__);
+ $handler = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler->expects($this->once())
+ ->method('isHandling')
+ ->will($this->returnValue(false))
+ ;
+ $logger->pushHandler($handler);
+ $that = $this;
+ $logger->pushProcessor(function ($record) use ($that) {
+ $that->fail('The processor should not be called');
+ });
+ $logger->addAlert('test');
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testHandlersNotCalledBeforeFirstHandling()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler1->expects($this->never())
+ ->method('isHandling')
+ ->will($this->returnValue(false))
+ ;
+ $handler1->expects($this->once())
+ ->method('handle')
+ ->will($this->returnValue(false))
+ ;
+ $logger->pushHandler($handler1);
+
+ $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler2->expects($this->once())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler2->expects($this->once())
+ ->method('handle')
+ ->will($this->returnValue(false))
+ ;
+ $logger->pushHandler($handler2);
+
+ $handler3 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler3->expects($this->once())
+ ->method('isHandling')
+ ->will($this->returnValue(false))
+ ;
+ $handler3->expects($this->never())
+ ->method('handle')
+ ;
+ $logger->pushHandler($handler3);
+
+ $logger->debug('test');
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testBubblingWhenTheHandlerReturnsFalse()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler1->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler1->expects($this->once())
+ ->method('handle')
+ ->will($this->returnValue(false))
+ ;
+ $logger->pushHandler($handler1);
+
+ $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler2->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler2->expects($this->once())
+ ->method('handle')
+ ->will($this->returnValue(false))
+ ;
+ $logger->pushHandler($handler2);
+
+ $logger->debug('test');
+ }
+
+ /**
+ * @covers Monolog\Logger::addRecord
+ */
+ public function testNotBubblingWhenTheHandlerReturnsTrue()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler1->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler1->expects($this->never())
+ ->method('handle')
+ ;
+ $logger->pushHandler($handler1);
+
+ $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler2->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+ $handler2->expects($this->once())
+ ->method('handle')
+ ->will($this->returnValue(true))
+ ;
+ $logger->pushHandler($handler2);
+
+ $logger->debug('test');
+ }
+
+ /**
+ * @covers Monolog\Logger::isHandling
+ */
+ public function testIsHandling()
+ {
+ $logger = new Logger(__METHOD__);
+
+ $handler1 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler1->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(false))
+ ;
+
+ $logger->pushHandler($handler1);
+ $this->assertFalse($logger->isHandling(Logger::DEBUG));
+
+ $handler2 = $this->getMock('Monolog\Handler\HandlerInterface');
+ $handler2->expects($this->any())
+ ->method('isHandling')
+ ->will($this->returnValue(true))
+ ;
+
+ $logger->pushHandler($handler2);
+ $this->assertTrue($logger->isHandling(Logger::DEBUG));
+ }
+
+ /**
+ * @dataProvider logMethodProvider
+ * @covers Monolog\Logger::addDebug
+ * @covers Monolog\Logger::addInfo
+ * @covers Monolog\Logger::addNotice
+ * @covers Monolog\Logger::addWarning
+ * @covers Monolog\Logger::addError
+ * @covers Monolog\Logger::addCritical
+ * @covers Monolog\Logger::addAlert
+ * @covers Monolog\Logger::addEmergency
+ * @covers Monolog\Logger::debug
+ * @covers Monolog\Logger::info
+ * @covers Monolog\Logger::notice
+ * @covers Monolog\Logger::warn
+ * @covers Monolog\Logger::err
+ * @covers Monolog\Logger::crit
+ * @covers Monolog\Logger::alert
+ * @covers Monolog\Logger::emerg
+ */
+ public function testLogMethods($method, $expectedLevel)
+ {
+ $logger = new Logger('foo');
+ $handler = new TestHandler;
+ $logger->pushHandler($handler);
+ $logger->{$method}('test');
+ list($record) = $handler->getRecords();
+ $this->assertEquals($expectedLevel, $record['level']);
+ }
+
+ public function logMethodProvider()
+ {
+ return array(
+ // monolog methods
+ array('addDebug', Logger::DEBUG),
+ array('addInfo', Logger::INFO),
+ array('addNotice', Logger::NOTICE),
+ array('addWarning', Logger::WARNING),
+ array('addError', Logger::ERROR),
+ array('addCritical', Logger::CRITICAL),
+ array('addAlert', Logger::ALERT),
+ array('addEmergency', Logger::EMERGENCY),
+
+ // ZF/Sf2 compat methods
+ array('debug', Logger::DEBUG),
+ array('info', Logger::INFO),
+ array('notice', Logger::NOTICE),
+ array('warn', Logger::WARNING),
+ array('err', Logger::ERROR),
+ array('crit', Logger::CRITICAL),
+ array('alert', Logger::ALERT),
+ array('emerg', Logger::EMERGENCY),
+ );
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php
new file mode 100644
index 00000000..5adb505d
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class GitProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\GitProcessor::__invoke
+ */
+ public function testProcessor()
+ {
+ $processor = new GitProcessor();
+ $record = $processor($this->getRecord());
+
+ $this->assertArrayHasKey('git', $record['extra']);
+ $this->assertTrue(!is_array($record['extra']['git']['branch']));
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php
new file mode 100644
index 00000000..0dd411d7
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php
@@ -0,0 +1,123 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Acme;
+
+class Tester
+{
+ public function test($handler, $record)
+ {
+ $handler->handle($record);
+ }
+}
+
+function tester($handler, $record)
+{
+ $handler->handle($record);
+}
+
+namespace Monolog\Processor;
+
+use Monolog\Logger;
+use Monolog\TestCase;
+use Monolog\Handler\TestHandler;
+
+class IntrospectionProcessorTest extends TestCase
+{
+ public function getHandler()
+ {
+ $processor = new IntrospectionProcessor();
+ $handler = new TestHandler();
+ $handler->pushProcessor($processor);
+
+ return $handler;
+ }
+
+ public function testProcessorFromClass()
+ {
+ $handler = $this->getHandler();
+ $tester = new \Acme\Tester;
+ $tester->test($handler, $this->getRecord());
+ list($record) = $handler->getRecords();
+ $this->assertEquals(__FILE__, $record['extra']['file']);
+ $this->assertEquals(18, $record['extra']['line']);
+ $this->assertEquals('Acme\Tester', $record['extra']['class']);
+ $this->assertEquals('test', $record['extra']['function']);
+ }
+
+ public function testProcessorFromFunc()
+ {
+ $handler = $this->getHandler();
+ \Acme\tester($handler, $this->getRecord());
+ list($record) = $handler->getRecords();
+ $this->assertEquals(__FILE__, $record['extra']['file']);
+ $this->assertEquals(24, $record['extra']['line']);
+ $this->assertEquals(null, $record['extra']['class']);
+ $this->assertEquals('Acme\tester', $record['extra']['function']);
+ }
+
+ public function testLevelTooLow()
+ {
+ $input = array(
+ 'level' => Logger::DEBUG,
+ 'extra' => array(),
+ );
+
+ $expected = $input;
+
+ $processor = new IntrospectionProcessor(Logger::CRITICAL);
+ $actual = $processor($input);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function testLevelEqual()
+ {
+ $input = array(
+ 'level' => Logger::CRITICAL,
+ 'extra' => array(),
+ );
+
+ $expected = $input;
+ $expected['extra'] = array(
+ 'file' => null,
+ 'line' => null,
+ 'class' => 'ReflectionMethod',
+ 'function' => 'invokeArgs',
+ );
+
+ $processor = new IntrospectionProcessor(Logger::CRITICAL);
+ $actual = $processor($input);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function testLevelHigher()
+ {
+ $input = array(
+ 'level' => Logger::EMERGENCY,
+ 'extra' => array(),
+ );
+
+ $expected = $input;
+ $expected['extra'] = array(
+ 'file' => null,
+ 'line' => null,
+ 'class' => 'ReflectionMethod',
+ 'function' => 'invokeArgs',
+ );
+
+ $processor = new IntrospectionProcessor(Logger::CRITICAL);
+ $actual = $processor($input);
+
+ $this->assertEquals($expected, $actual);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
new file mode 100644
index 00000000..eb666144
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
@@ -0,0 +1,42 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class MemoryPeakUsageProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
+ * @covers Monolog\Processor\MemoryProcessor::formatBytes
+ */
+ public function testProcessor()
+ {
+ $processor = new MemoryPeakUsageProcessor();
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
+ $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']);
+ }
+
+ /**
+ * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
+ * @covers Monolog\Processor\MemoryProcessor::formatBytes
+ */
+ public function testProcessorWithoutFormatting()
+ {
+ $processor = new MemoryPeakUsageProcessor(true, false);
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
+ $this->assertInternalType('int', $record['extra']['memory_peak_usage']);
+ $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php
new file mode 100644
index 00000000..4692dbfc
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php
@@ -0,0 +1,42 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class MemoryUsageProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
+ * @covers Monolog\Processor\MemoryProcessor::formatBytes
+ */
+ public function testProcessor()
+ {
+ $processor = new MemoryUsageProcessor();
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('memory_usage', $record['extra']);
+ $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']);
+ }
+
+ /**
+ * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
+ * @covers Monolog\Processor\MemoryProcessor::formatBytes
+ */
+ public function testProcessorWithoutFormatting()
+ {
+ $processor = new MemoryUsageProcessor(true, false);
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('memory_usage', $record['extra']);
+ $this->assertInternalType('int', $record['extra']['memory_usage']);
+ $this->assertGreaterThan(0, $record['extra']['memory_usage']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php
new file mode 100644
index 00000000..458d2a33
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class ProcessIdProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\ProcessIdProcessor::__invoke
+ */
+ public function testProcessor()
+ {
+ $processor = new ProcessIdProcessor();
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('process_id', $record['extra']);
+ $this->assertInternalType('int', $record['extra']['process_id']);
+ $this->assertGreaterThan(0, $record['extra']['process_id']);
+ $this->assertEquals(getmypid(), $record['extra']['process_id']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php
new file mode 100644
index 00000000..851a9dc2
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php
@@ -0,0 +1,29 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class TagProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\TagProcessor::__invoke
+ */
+ public function testProcessor()
+ {
+ $tags = array(1, 2, 3);
+ $processor = new TagProcessor($tags);
+ $record = $processor($this->getRecord());
+
+ $this->assertEquals($tags, $record['extra']['tags']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php
new file mode 100644
index 00000000..7ced62ca
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php
@@ -0,0 +1,27 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class UidProcessorTest extends TestCase
+{
+ /**
+ * @covers Monolog\Processor\UidProcessor::__invoke
+ */
+ public function testProcessor()
+ {
+ $processor = new UidProcessor();
+ $record = $processor($this->getRecord());
+ $this->assertArrayHasKey('uid', $record['extra']);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php
new file mode 100644
index 00000000..df29fdd6
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php
@@ -0,0 +1,83 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog\Processor;
+
+use Monolog\TestCase;
+
+class WebProcessorTest extends TestCase
+{
+ public function testProcessor()
+ {
+ $server = array(
+ 'REQUEST_URI' => 'A',
+ 'REMOTE_ADDR' => 'B',
+ 'REQUEST_METHOD' => 'C',
+ 'HTTP_REFERER' => 'D',
+ 'SERVER_NAME' => 'F',
+ 'UNIQUE_ID' => 'G',
+ );
+
+ $processor = new WebProcessor($server);
+ $record = $processor($this->getRecord());
+ $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
+ $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
+ $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
+ $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
+ $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
+ $this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']);
+ }
+
+ public function testProcessorDoNothingIfNoRequestUri()
+ {
+ $server = array(
+ 'REMOTE_ADDR' => 'B',
+ 'REQUEST_METHOD' => 'C',
+ );
+ $processor = new WebProcessor($server);
+ $record = $processor($this->getRecord());
+ $this->assertEmpty($record['extra']);
+ }
+
+ public function testProcessorReturnNullIfNoHttpReferer()
+ {
+ $server = array(
+ 'REQUEST_URI' => 'A',
+ 'REMOTE_ADDR' => 'B',
+ 'REQUEST_METHOD' => 'C',
+ 'SERVER_NAME' => 'F',
+ );
+ $processor = new WebProcessor($server);
+ $record = $processor($this->getRecord());
+ $this->assertNull($record['extra']['referrer']);
+ }
+
+ public function testProcessorDoesNotAddUniqueIdIfNotPresent()
+ {
+ $server = array(
+ 'REQUEST_URI' => 'A',
+ 'REMOTE_ADDR' => 'B',
+ 'REQUEST_METHOD' => 'C',
+ 'SERVER_NAME' => 'F',
+ );
+ $processor = new WebProcessor($server);
+ $record = $processor($this->getRecord());
+ $this->assertFalse(isset($record['extra']['unique_id']));
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testInvalidData()
+ {
+ new WebProcessor(new \stdClass);
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php b/src/lib/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
new file mode 100644
index 00000000..ab899449
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php
@@ -0,0 +1,47 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+use Monolog\Handler\TestHandler;
+use Monolog\Formatter\LineFormatter;
+use Monolog\Processor\PsrLogMessageProcessor;
+use Psr\Log\Test\LoggerInterfaceTest;
+
+class PsrLogCompatTest extends LoggerInterfaceTest
+{
+ private $handler;
+
+ public function getLogger()
+ {
+ $logger = new Logger('foo');
+ $logger->pushHandler($handler = new TestHandler);
+ $logger->pushProcessor(new PsrLogMessageProcessor);
+ $handler->setFormatter(new LineFormatter('%level_name% %message%'));
+
+ $this->handler = $handler;
+
+ return $logger;
+ }
+
+ public function getLogs()
+ {
+ $convert = function ($record) {
+ $lower = function ($match) {
+ return strtolower($match[0]);
+ };
+
+ return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']);
+ };
+
+ return array_map($convert, $this->handler->getRecords());
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/Monolog/TestCase.php b/src/lib/vendor/monolog/monolog/tests/Monolog/TestCase.php
new file mode 100644
index 00000000..cae79340
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/Monolog/TestCase.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Monolog;
+
+class TestCase extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @return array Record
+ */
+ protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
+ {
+ return array(
+ 'message' => $message,
+ 'context' => $context,
+ 'level' => $level,
+ 'level_name' => Logger::getLevelName($level),
+ 'channel' => 'test',
+ 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
+ 'extra' => array(),
+ );
+ }
+
+ /**
+ * @return array
+ */
+ protected function getMultipleRecords()
+ {
+ return array(
+ $this->getRecord(Logger::DEBUG, 'debug message 1'),
+ $this->getRecord(Logger::DEBUG, 'debug message 2'),
+ $this->getRecord(Logger::INFO, 'information'),
+ $this->getRecord(Logger::WARNING, 'warning'),
+ $this->getRecord(Logger::ERROR, 'error')
+ );
+ }
+
+ /**
+ * @return Monolog\Formatter\FormatterInterface
+ */
+ protected function getIdentityFormatter()
+ {
+ $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
+ $formatter->expects($this->any())
+ ->method('format')
+ ->will($this->returnCallback(function ($record) { return $record['message']; }));
+
+ return $formatter;
+ }
+}
diff --git a/src/lib/vendor/monolog/monolog/tests/bootstrap.php b/src/lib/vendor/monolog/monolog/tests/bootstrap.php
new file mode 100644
index 00000000..b78740e2
--- /dev/null
+++ b/src/lib/vendor/monolog/monolog/tests/bootstrap.php
@@ -0,0 +1,15 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+$loader = require __DIR__ . "/../vendor/autoload.php";
+$loader->addPsr4('Monolog\\', __DIR__.'/Monolog');
+
+date_default_timezone_set('UTC');
diff --git a/src/lib/vendor/pimple/pimple/.gitignore b/src/lib/vendor/pimple/pimple/.gitignore
new file mode 100644
index 00000000..c089b095
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/.gitignore
@@ -0,0 +1,3 @@
+phpunit.xml
+composer.lock
+/vendor/
diff --git a/src/lib/vendor/pimple/pimple/.travis.yml b/src/lib/vendor/pimple/pimple/.travis.yml
new file mode 100644
index 00000000..5f8bb7c9
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/.travis.yml
@@ -0,0 +1,32 @@
+language: php
+
+env:
+ matrix:
+ - PIMPLE_EXT=no
+ - PIMPLE_EXT=yes
+ global:
+ - REPORT_EXIT_STATUS=1
+
+php:
+ - 5.3
+ - 5.4
+ - 5.5
+ - 5.6
+ - hhvm
+
+before_script:
+ - composer self-update
+ - COMPOSER_ROOT_VERSION=dev-master composer dump-autoload
+ - if [ "$PIMPLE_EXT" == "yes" ]; then sh -c "cd ext/pimple && phpize && ./configure && make && sudo make install"; fi
+ - if [ "$PIMPLE_EXT" == "yes" ]; then echo "extension=pimple.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
+
+script:
+ - cd ext/pimple
+ - if [ "$PIMPLE_EXT" == "yes" ]; then yes n | make test | tee output ; grep -E 'Tests failed +. +0' output; fi
+ - cd ../..
+ - phpunit
+
+matrix:
+ exclude:
+ - php: hhvm
+ env: PIMPLE_EXT=yes
diff --git a/src/lib/vendor/pimple/pimple/CHANGELOG b/src/lib/vendor/pimple/pimple/CHANGELOG
new file mode 100644
index 00000000..084ec80a
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/CHANGELOG
@@ -0,0 +1,21 @@
+* 2.1.1 (2014-07-24)
+
+ * fixed compiler warnings for the C extension
+ * fixed code when dealing with circular references
+
+* 2.1.0 (2014-06-24)
+
+ * moved the Pimple to Pimple\Container (with a BC layer -- Pimple is now a
+ deprecated alias which will be removed in Pimple 3.0)
+ * added Pimple\ServiceProviderInterface (and Pimple::register())
+
+* 2.0.0 (2014-02-10)
+
+ * changed extend to automatically re-assign the extended service and keep it as shared or factory
+ (to keep BC, extend still returns the extended service)
+ * changed services to be shared by default (use factory() for factory
+ services)
+
+* 1.0.0
+
+ * initial version
diff --git a/src/lib/vendor/pimple/pimple/LICENSE b/src/lib/vendor/pimple/pimple/LICENSE
new file mode 100644
index 00000000..86b4721b
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2009-2014 Fabien Potencier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/lib/vendor/pimple/pimple/README.rst b/src/lib/vendor/pimple/pimple/README.rst
new file mode 100644
index 00000000..217885d8
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/README.rst
@@ -0,0 +1,210 @@
+Pimple
+======
+
+.. caution::
+
+ This is the documentation for Pimple 2.x. If you are using Pimple 1.x, read
+ the `Pimple 1.x documentation`_. Reading the Pimple 1.x code is also a good
+ way to learn more about how to create a simple Dependency Injection
+ Container (Pimple 2.x implementation being more focused on performance).
+
+Pimple is a small Dependency Injection Container for PHP.
+
+Installation
+------------
+
+Before using Pimple in your project, add it to your ``composer.json`` file:
+
+.. code-block:: bash
+
+ $ ./composer.phar require pimple/pimple ~2.1
+
+Alternatively, Pimple is also available as a PHP C extension:
+
+.. code-block:: bash
+
+ $ cd ext/pimple
+ $ phpize
+ $ ./configure
+ $ make
+ $ make install
+
+Usage
+-----
+
+Creating a container is a matter of creating a ``Container`` instance:
+
+.. code-block:: php
+
+ use Pimple\Container;
+
+ $container = new Container();
+
+.. note::
+
+ In Pimple 2.0, the class ``Pimple\Container`` was named ``Pimple`` (a class
+ alias is automatically registered to keep backward compatibility, but you
+ should upgrade your code.)
+
+As many other dependency injection containers, Pimple manages two different
+kind of data: **services** and **parameters**.
+
+Defining Services
+~~~~~~~~~~~~~~~~~
+
+A service is an object that does something as part of a larger system. Examples
+of services: a database connection, a templating engine, or a mailer. Almost
+any **global** object can be a service.
+
+Services are defined by **anonymous functions** that return an instance of an
+object:
+
+.. code-block:: php
+
+ // define some services
+ $container['session_storage'] = function ($c) {
+ return new SessionStorage('SESSION_ID');
+ };
+
+ $container['session'] = function ($c) {
+ return new Session($c['session_storage']);
+ };
+
+Notice that the anonymous function has access to the current container
+instance, allowing references to other services or parameters.
+
+As objects are only created when you get them, the order of the definitions
+does not matter.
+
+Using the defined services is also very easy:
+
+.. code-block:: php
+
+ // get the session object
+ $session = $container['session'];
+
+ // the above call is roughly equivalent to the following code:
+ // $storage = new SessionStorage('SESSION_ID');
+ // $session = new Session($storage);
+
+Defining Factory Services
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+By default, each time you get a service, Pimple returns the **same instance**
+of it. If you want a different instance to be returned for all calls, wrap your
+anonymous function with the ``factory()`` method
+
+.. code-block:: php
+
+ $container['session'] = $container->factory(function ($c) {
+ return new Session($c['session_storage']);
+ });
+
+Now, each call to ``$container['session']`` returns a new instance of the
+session.
+
+Defining Parameters
+~~~~~~~~~~~~~~~~~~~
+
+Defining a parameter allows to ease the configuration of your container from
+the outside and to store global values:
+
+.. code-block:: php
+
+ // define some parameters
+ $container['cookie_name'] = 'SESSION_ID';
+ $container['session_storage_class'] = 'SessionStorage';
+
+If you change the ``session_storage`` service definition like below:
+
+.. code-block:: php
+
+ $container['session_storage'] = function ($c) {
+ return new $c['session_storage_class']($c['cookie_name']);
+ };
+
+You can now easily change the cookie name by overriding the
+``session_storage_class`` parameter instead of redefining the service
+definition.
+
+Protecting Parameters
+~~~~~~~~~~~~~~~~~~~~~
+
+Because Pimple sees anonymous functions as service definitions, you need to
+wrap anonymous functions with the ``protect()`` method to store them as
+parameters:
+
+.. code-block:: php
+
+ $container['random_func'] = $container->protect(function () {
+ return rand();
+ });
+
+Modifying Services after Definition
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In some cases you may want to modify a service definition after it has been
+defined. You can use the ``extend()`` method to define additional code to be
+run on your service just after it is created:
+
+.. code-block:: php
+
+ $container['session_storage'] = function ($c) {
+ return new $c['session_storage_class']($c['cookie_name']);
+ };
+
+ $container->extend('session_storage', function ($storage, $c) {
+ $storage->...();
+
+ return $storage;
+ };
+
+The first argument is the name of the service to extend, the second a function
+that gets access to the object instance and the container.
+
+Extending a Container
+~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 2.1
+
+ Support for extending a container was introduced in Pimple 2.1.
+
+If you use the same libraries over and over, you might want to reuse some
+services from one project to the next one; package your services into a
+**provider** by implementing ``Pimple\ServiceProviderInterface``:
+
+.. code-block:: php
+
+ use Pimple\Container;
+
+ class FooProvider implements Pimple\ServiceProviderInterface
+ {
+ public function register(Container $pimple)
+ {
+ // register some services and parameters
+ // on $pimple
+ }
+ }
+
+Then, register the provider on a Container:
+
+.. code-block:: php
+
+ $pimple->register(new FooProvider());
+
+Fetching the Service Creation Function
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When you access an object, Pimple automatically calls the anonymous function
+that you defined, which creates the service object for you. If you want to get
+raw access to this function, you can use the ``raw()`` method:
+
+.. code-block:: php
+
+ $container['session'] = function ($c) {
+ return new Session($c['session_storage']);
+ };
+
+ $sessionFunction = $container->raw('session');
+
+.. _Pimple 1.x documentation: https://github.com/fabpot/Pimple/tree/1.1
diff --git a/src/lib/vendor/pimple/pimple/composer.json b/src/lib/vendor/pimple/pimple/composer.json
new file mode 100644
index 00000000..1a14653e
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "pimple/pimple",
+ "type": "library",
+ "description": "Pimple is a simple Dependency Injection Container for PHP 5.3",
+ "keywords": ["dependency injection", "container"],
+ "homepage": "http://pimple.sensiolabs.org",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "autoload": {
+ "psr-0": { "Pimple": "src/" }
+ },
+ "autoload-dev": {
+ "psr-4": { "Pimple\\Tests\\": "tests/" }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1.x-dev"
+ }
+ }
+}
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/.gitignore b/src/lib/vendor/pimple/pimple/ext/pimple/.gitignore
new file mode 100644
index 00000000..1861088a
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/.gitignore
@@ -0,0 +1,30 @@
+*.sw*
+.deps
+Makefile
+Makefile.fragments
+Makefile.global
+Makefile.objects
+acinclude.m4
+aclocal.m4
+build/
+config.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.nice
+config.status
+config.sub
+configure
+configure.in
+install-sh
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+run-tests.php
+*.loT
+.libs/
+modules/
+*.la
+*.lo
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/README.md b/src/lib/vendor/pimple/pimple/ext/pimple/README.md
new file mode 100644
index 00000000..7b39eb29
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/README.md
@@ -0,0 +1,12 @@
+This is Pimple 2 implemented in C
+
+* PHP >= 5.3
+* Not tested under Windows, might work
+
+Install
+=======
+
+ > phpize
+ > ./configure
+ > make
+ > make install
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/config.m4 b/src/lib/vendor/pimple/pimple/ext/pimple/config.m4
new file mode 100644
index 00000000..c9ba17dd
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/config.m4
@@ -0,0 +1,63 @@
+dnl $Id$
+dnl config.m4 for extension pimple
+
+dnl Comments in this file start with the string 'dnl'.
+dnl Remove where necessary. This file will not work
+dnl without editing.
+
+dnl If your extension references something external, use with:
+
+dnl PHP_ARG_WITH(pimple, for pimple support,
+dnl Make sure that the comment is aligned:
+dnl [ --with-pimple Include pimple support])
+
+dnl Otherwise use enable:
+
+PHP_ARG_ENABLE(pimple, whether to enable pimple support,
+dnl Make sure that the comment is aligned:
+[ --enable-pimple Enable pimple support])
+
+if test "$PHP_PIMPLE" != "no"; then
+ dnl Write more examples of tests here...
+
+ dnl # --with-pimple -> check with-path
+ dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
+ dnl SEARCH_FOR="/include/pimple.h" # you most likely want to change this
+ dnl if test -r $PHP_PIMPLE/$SEARCH_FOR; then # path given as parameter
+ dnl PIMPLE_DIR=$PHP_PIMPLE
+ dnl else # search default path list
+ dnl AC_MSG_CHECKING([for pimple files in default path])
+ dnl for i in $SEARCH_PATH ; do
+ dnl if test -r $i/$SEARCH_FOR; then
+ dnl PIMPLE_DIR=$i
+ dnl AC_MSG_RESULT(found in $i)
+ dnl fi
+ dnl done
+ dnl fi
+ dnl
+ dnl if test -z "$PIMPLE_DIR"; then
+ dnl AC_MSG_RESULT([not found])
+ dnl AC_MSG_ERROR([Please reinstall the pimple distribution])
+ dnl fi
+
+ dnl # --with-pimple -> add include path
+ dnl PHP_ADD_INCLUDE($PIMPLE_DIR/include)
+
+ dnl # --with-pimple -> check for lib and symbol presence
+ dnl LIBNAME=pimple # you may want to change this
+ dnl LIBSYMBOL=pimple # you most likely want to change this
+
+ dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
+ dnl [
+ dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PIMPLE_DIR/lib, PIMPLE_SHARED_LIBADD)
+ dnl AC_DEFINE(HAVE_PIMPLELIB,1,[ ])
+ dnl ],[
+ dnl AC_MSG_ERROR([wrong pimple lib version or lib not found])
+ dnl ],[
+ dnl -L$PIMPLE_DIR/lib -lm
+ dnl ])
+ dnl
+ dnl PHP_SUBST(PIMPLE_SHARED_LIBADD)
+
+ PHP_NEW_EXTENSION(pimple, pimple.c, $ext_shared)
+fi
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/config.w32 b/src/lib/vendor/pimple/pimple/ext/pimple/config.w32
new file mode 100644
index 00000000..39857b32
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/config.w32
@@ -0,0 +1,13 @@
+// $Id$
+// vim:ft=javascript
+
+// If your extension references something external, use ARG_WITH
+// ARG_WITH("pimple", "for pimple support", "no");
+
+// Otherwise, use ARG_ENABLE
+// ARG_ENABLE("pimple", "enable pimple support", "no");
+
+if (PHP_PIMPLE != "no") {
+ EXTENSION("pimple", "pimple.c");
+}
+
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/php_pimple.h b/src/lib/vendor/pimple/pimple/ext/pimple/php_pimple.h
new file mode 100644
index 00000000..619ccb6d
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/php_pimple.h
@@ -0,0 +1,122 @@
+
+/*
+ * This file is part of Pimple.
+ *
+ * Copyright (c) 2014 Fabien Potencier
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef PHP_PIMPLE_H
+#define PHP_PIMPLE_H
+
+extern zend_module_entry pimple_module_entry;
+#define phpext_pimple_ptr &pimple_module_entry
+
+#ifdef PHP_WIN32
+# define PHP_PIMPLE_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_PIMPLE_API __attribute__ ((visibility("default")))
+#else
+# define PHP_PIMPLE_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+#define PIMPLE_VERSION "2.1.1"
+#define PIMPLE_NS "Pimple"
+
+#define PIMPLE_DEFAULT_ZVAL_CACHE_NUM 5
+#define PIMPLE_DEFAULT_ZVAL_VALUES_NUM 10
+
+PHP_MINIT_FUNCTION(pimple);
+PHP_MSHUTDOWN_FUNCTION(pimple);
+PHP_RINIT_FUNCTION(pimple);
+PHP_RSHUTDOWN_FUNCTION(pimple);
+PHP_MINFO_FUNCTION(pimple);
+
+PHP_METHOD(Pimple, __construct);
+PHP_METHOD(Pimple, factory);
+PHP_METHOD(Pimple, protect);
+PHP_METHOD(Pimple, raw);
+PHP_METHOD(Pimple, extend);
+PHP_METHOD(Pimple, keys);
+PHP_METHOD(Pimple, register);
+PHP_METHOD(Pimple, offsetSet);
+PHP_METHOD(Pimple, offsetUnset);
+PHP_METHOD(Pimple, offsetGet);
+PHP_METHOD(Pimple, offsetExists);
+
+PHP_METHOD(PimpleClosure, __invoke);
+
+typedef struct _pimple_bucket_value {
+ zval *value; /* Must be the first element */
+ zval *raw;
+ zend_fcall_info_cache *fcc;
+ zend_object_handle handle_num;
+ enum {
+ PIMPLE_IS_PARAM = 0,
+ PIMPLE_IS_SERVICE = 2
+ } type;
+ zend_bool initialized;
+} pimple_bucket_value;
+
+typedef struct _pimple_object {
+ zend_object zobj;
+ HashTable values;
+ HashTable factories;
+ HashTable protected;
+} pimple_object;
+
+typedef struct _pimple_closure_object {
+ zend_object zobj;
+ zval *callable;
+ zval *factory;
+} pimple_closure_object;
+
+static const char sensiolabs_logo[] = "
";
+
+static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC);
+static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC);
+
+static void pimple_init_bucket(pimple_bucket_value *bucket);
+static void pimple_bucket_dtor(pimple_bucket_value *bucket);
+static void pimple_free_bucket(pimple_bucket_value *bucket);
+
+static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC);
+static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC);
+static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC);
+static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC);
+static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC);
+static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC);
+
+static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC);
+static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC);
+static zend_function *pimple_closure_get_constructor(zval * TSRMLS_DC);
+
+#ifdef ZTS
+#define PIMPLE_G(v) TSRMG(pimple_globals_id, zend_pimple_globals *, v)
+#else
+#define PIMPLE_G(v) (pimple_globals.v)
+#endif
+
+#endif /* PHP_PIMPLE_H */
+
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/pimple.c b/src/lib/vendor/pimple/pimple/ext/pimple/pimple.c
new file mode 100644
index 00000000..44eb8da7
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/pimple.c
@@ -0,0 +1,940 @@
+
+/*
+ * This file is part of Pimple.
+ *
+ * Copyright (c) 2014 Fabien Potencier
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_pimple.h"
+#include "pimple_compat.h"
+#include "zend_interfaces.h"
+#include "zend.h"
+#include "ext/spl/spl_exceptions.h"
+#include "Zend/zend_exceptions.h"
+#include "main/php_output.h"
+#include "SAPI.h"
+
+static zend_class_entry *pimple_ce;
+static zend_object_handlers pimple_object_handlers;
+static zend_class_entry *pimple_closure_ce;
+static zend_class_entry *pimple_serviceprovider_ce;
+static zend_object_handlers pimple_closure_object_handlers;
+
+#define FETCH_DIM_HANDLERS_VARS pimple_object *pimple_obj = NULL; \
+ ulong index; \
+ pimple_obj = (pimple_object *)zend_object_store_get_object(object TSRMLS_CC); \
+
+#define PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS do { \
+ if (ce != pimple_ce) { \
+ zend_hash_find(&ce->function_table, ZEND_STRS("offsetget"), (void **)&function); \
+ if (function->common.scope != ce) { /* if the function is not defined in this actual class */ \
+ pimple_object_handlers.read_dimension = pimple_object_read_dimension; /* then overwrite the handler to use custom one */ \
+ } \
+ zend_hash_find(&ce->function_table, ZEND_STRS("offsetset"), (void **)&function); \
+ if (function->common.scope != ce) { \
+ pimple_object_handlers.write_dimension = pimple_object_write_dimension; \
+ } \
+ zend_hash_find(&ce->function_table, ZEND_STRS("offsetexists"), (void **)&function); \
+ if (function->common.scope != ce) { \
+ pimple_object_handlers.has_dimension = pimple_object_has_dimension; \
+ } \
+ zend_hash_find(&ce->function_table, ZEND_STRS("offsetunset"), (void **)&function); \
+ if (function->common.scope != ce) { \
+ pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \
+ } \
+ } else { \
+ pimple_object_handlers.read_dimension = pimple_object_read_dimension; \
+ pimple_object_handlers.write_dimension = pimple_object_write_dimension; \
+ pimple_object_handlers.has_dimension = pimple_object_has_dimension; \
+ pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \
+ }\
+ } while(0);
+
+#define PIMPLE_CALL_CB do { \
+ zend_fcall_info_argn(&fci TSRMLS_CC, 1, &object); \
+ fci.size = sizeof(fci); \
+ fci.object_ptr = retval->fcc->object_ptr; \
+ fci.function_name = retval->value; \
+ fci.no_separation = 1; \
+ fci.retval_ptr_ptr = &retval_ptr_ptr; \
+\
+ zend_call_function(&fci, retval->fcc TSRMLS_CC); \
+ efree(fci.params); \
+ if (EG(exception)) { \
+ return EG(uninitialized_zval_ptr); \
+ } \
+ } while(0);
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 0)
+ZEND_ARG_ARRAY_INFO(0, value, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetset, 0, 0, 2)
+ZEND_ARG_INFO(0, offset)
+ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetget, 0, 0, 1)
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetexists, 0, 0, 1)
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetunset, 0, 0, 1)
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_factory, 0, 0, 1)
+ZEND_ARG_INFO(0, callable)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_protect, 0, 0, 1)
+ZEND_ARG_INFO(0, callable)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_raw, 0, 0, 1)
+ZEND_ARG_INFO(0, id)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_extend, 0, 0, 2)
+ZEND_ARG_INFO(0, id)
+ZEND_ARG_INFO(0, callable)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_keys, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_register, 0, 0, 1)
+ZEND_ARG_OBJ_INFO(0, provider, Pimple\\ServiceProviderInterface, 0)
+ZEND_ARG_ARRAY_INFO(0, values, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pimpleclosure___invoke, 0, 0, 1)
+ZEND_ARG_INFO(0, callarg)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_serviceprovider_register, 0, 0, 1)
+ZEND_ARG_OBJ_INFO(0, pimple, Pimple\\Container, 0)
+ZEND_END_ARG_INFO()
+
+static const zend_function_entry pimple_ce_functions[] = {
+ PHP_ME(Pimple, __construct, arginfo___construct, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, factory, arginfo_factory, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, protect, arginfo_protect, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, raw, arginfo_raw, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, extend, arginfo_extend, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, keys, arginfo_keys, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, register, arginfo_register, ZEND_ACC_PUBLIC)
+
+ PHP_ME(Pimple, offsetSet, arginfo_offsetset, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, offsetGet, arginfo_offsetget, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, offsetExists, arginfo_offsetexists, ZEND_ACC_PUBLIC)
+ PHP_ME(Pimple, offsetUnset, arginfo_offsetunset, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
+
+static const zend_function_entry pimple_closure_ce_functions[] = {
+ PHP_ME(PimpleClosure, __invoke, arginfo_pimpleclosure___invoke, ZEND_ACC_PRIVATE)
+ PHP_FE_END
+};
+
+static const zend_function_entry pimple_serviceprovider_iface_ce_functions[] = {
+ PHP_ABSTRACT_ME(ServiceProviderInterface, register, arginfo_serviceprovider_register)
+ PHP_FE_END
+};
+
+static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC)
+{
+ zend_object_std_dtor(&obj->zobj TSRMLS_CC);
+ if (obj->factory) {
+ zval_ptr_dtor(&obj->factory);
+ }
+ if (obj->callable) {
+ zval_ptr_dtor(&obj->callable);
+ }
+ efree(obj);
+}
+
+static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC)
+{
+ zend_hash_destroy(&obj->factories);
+ zend_hash_destroy(&obj->protected);
+ zend_hash_destroy(&obj->values);
+ zend_object_std_dtor(&obj->zobj TSRMLS_CC);
+ efree(obj);
+}
+
+static void pimple_free_bucket(pimple_bucket_value *bucket)
+{
+ if (bucket->fcc) {
+ efree(bucket->fcc);
+ bucket->fcc = NULL;
+ }
+ if (bucket->raw) {
+ zval_ptr_dtor(&bucket->raw);
+ }
+}
+
+static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value retval;
+ pimple_closure_object *pimple_closure_obj = NULL;
+
+ pimple_closure_obj = ecalloc(1, sizeof(pimple_closure_object));
+ ZEND_OBJ_INIT(&pimple_closure_obj->zobj, ce);
+
+ pimple_closure_object_handlers.get_constructor = pimple_closure_get_constructor;
+ retval.handlers = &pimple_closure_object_handlers;
+ retval.handle = zend_objects_store_put(pimple_closure_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_closure_free_object_storage, NULL TSRMLS_CC);
+
+ return retval;
+}
+
+static zend_function *pimple_closure_get_constructor(zval *obj TSRMLS_DC)
+{
+ zend_error(E_ERROR, "Pimple\\ContainerClosure is an internal class and cannot be instantiated");
+
+ return NULL;
+}
+
+static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value retval;
+ pimple_object *pimple_obj = NULL;
+ zend_function *function = NULL;
+
+ pimple_obj = emalloc(sizeof(pimple_object));
+ ZEND_OBJ_INIT(&pimple_obj->zobj, ce);
+
+ PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS
+
+ retval.handlers = &pimple_object_handlers;
+ retval.handle = zend_objects_store_put(pimple_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_free_object_storage, NULL TSRMLS_CC);
+
+ zend_hash_init(&pimple_obj->factories, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0);
+ zend_hash_init(&pimple_obj->protected, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0);
+ zend_hash_init(&pimple_obj->values, PIMPLE_DEFAULT_ZVAL_VALUES_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0);
+
+ return retval;
+}
+
+static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC)
+{
+ FETCH_DIM_HANDLERS_VARS
+
+ pimple_bucket_value pimple_value = {0}, *found_value = NULL;
+ ulong hash;
+
+ pimple_init_bucket(&pimple_value);
+ pimple_zval_to_pimpleval(value, &pimple_value TSRMLS_CC);
+
+ if (!offset) {/* $p[] = 'foo' when not overloaded */
+ zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL);
+ Z_ADDREF_P(value);
+ return;
+ }
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ hash = zend_hash_func(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ zend_hash_quick_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void **)&found_value);
+ if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) {
+ pimple_free_bucket(&pimple_value);
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot override frozen service \"%s\".", Z_STRVAL_P(offset));
+ return;
+ }
+ if (zend_hash_quick_update(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) {
+ pimple_free_bucket(&pimple_value);
+ return;
+ }
+ Z_ADDREF_P(value);
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ zend_hash_index_find(&pimple_obj->values, index, (void **)&found_value);
+ if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) {
+ pimple_free_bucket(&pimple_value);
+ zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot override frozen service \"%ld\".", index);
+ return;
+ }
+ if (zend_hash_index_update(&pimple_obj->values, index, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) {
+ pimple_free_bucket(&pimple_value);
+ return;
+ }
+ Z_ADDREF_P(value);
+ break;
+ case IS_NULL: /* $p[] = 'foo' when overloaded */
+ zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL);
+ Z_ADDREF_P(value);
+ break;
+ default:
+ pimple_free_bucket(&pimple_value);
+ zend_error(E_WARNING, "Unsupported offset type");
+ }
+}
+
+static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC)
+{
+ FETCH_DIM_HANDLERS_VARS
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ zend_symtable_del(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ zend_symtable_del(&pimple_obj->factories, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ zend_symtable_del(&pimple_obj->protected, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ zend_hash_index_del(&pimple_obj->values, index);
+ zend_hash_index_del(&pimple_obj->factories, index);
+ zend_hash_index_del(&pimple_obj->protected, index);
+ break;
+ default:
+ zend_error(E_WARNING, "Unsupported offset type");
+ }
+}
+
+static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC)
+{
+ FETCH_DIM_HANDLERS_VARS
+
+ pimple_bucket_value *retval = NULL;
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == SUCCESS) {
+ switch (check_empty) {
+ case 0: /* isset */
+ return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;) */
+ case 1: /* empty */
+ default:
+ return zend_is_true(retval->value);
+ }
+ }
+ return 0;
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == SUCCESS) {
+ switch (check_empty) {
+ case 0: /* isset */
+ return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;)*/
+ case 1: /* empty */
+ default:
+ return zend_is_true(retval->value);
+ }
+ }
+ return 0;
+ break;
+ default:
+ zend_error(E_WARNING, "Unsupported offset type");
+ return 0;
+ }
+}
+
+static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
+{
+ FETCH_DIM_HANDLERS_VARS
+
+ pimple_bucket_value *retval = NULL;
+ zend_fcall_info fci = {0};
+ zval *retval_ptr_ptr = NULL;
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset));
+ return EG(uninitialized_zval_ptr);
+ }
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == FAILURE) {
+ return EG(uninitialized_zval_ptr);
+ }
+ break;
+ case IS_NULL: /* $p[][3] = 'foo' first dim access */
+ return EG(uninitialized_zval_ptr);
+ break;
+ default:
+ zend_error(E_WARNING, "Unsupported offset type");
+ return EG(uninitialized_zval_ptr);
+ }
+
+ if(retval->type == PIMPLE_IS_PARAM) {
+ return retval->value;
+ }
+
+ if (zend_hash_index_exists(&pimple_obj->protected, retval->handle_num)) {
+ /* Service is protected, return the value every time */
+ return retval->value;
+ }
+
+ if (zend_hash_index_exists(&pimple_obj->factories, retval->handle_num)) {
+ /* Service is a factory, call it everytime and never cache its result */
+ PIMPLE_CALL_CB
+ Z_DELREF_P(retval_ptr_ptr); /* fetch dim addr will increment refcount */
+ return retval_ptr_ptr;
+ }
+
+ if (retval->initialized == 1) {
+ /* Service has already been called, return its cached value */
+ return retval->value;
+ }
+
+ ALLOC_INIT_ZVAL(retval->raw);
+ MAKE_COPY_ZVAL(&retval->value, retval->raw);
+
+ PIMPLE_CALL_CB
+
+ retval->initialized = 1;
+ zval_ptr_dtor(&retval->value);
+ retval->value = retval_ptr_ptr;
+
+ return retval->value;
+}
+
+static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC)
+{
+ if (Z_TYPE_P(_zval) != IS_OBJECT) {
+ return FAILURE;
+ }
+
+ if (_pimple_bucket_value->fcc->called_scope) {
+ return SUCCESS;
+ }
+
+ if (Z_OBJ_HANDLER_P(_zval, get_closure) && Z_OBJ_HANDLER_P(_zval, get_closure)(_zval, &_pimple_bucket_value->fcc->calling_scope, &_pimple_bucket_value->fcc->function_handler, &_pimple_bucket_value->fcc->object_ptr TSRMLS_CC) == SUCCESS) {
+ _pimple_bucket_value->fcc->called_scope = _pimple_bucket_value->fcc->calling_scope;
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
+}
+
+static void pimple_init_bucket(pimple_bucket_value *bucket)
+{
+ memset(bucket, 0, sizeof(pimple_bucket_value));
+ bucket->fcc = ecalloc(1, sizeof(zend_fcall_info_cache));
+}
+
+static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC)
+{
+ _pimple_bucket_value->value = _zval;
+
+ if (Z_TYPE_P(_zval) != IS_OBJECT) {
+ return PIMPLE_IS_PARAM;
+ }
+
+ if (pimple_zval_is_valid_callback(_zval, _pimple_bucket_value TSRMLS_CC) == SUCCESS) {
+ _pimple_bucket_value->type = PIMPLE_IS_SERVICE;
+ _pimple_bucket_value->handle_num = Z_OBJ_HANDLE_P(_zval);
+ }
+
+ return PIMPLE_IS_SERVICE;
+}
+
+static void pimple_bucket_dtor(pimple_bucket_value *bucket)
+{
+ zval_ptr_dtor(&bucket->value);
+ pimple_free_bucket(bucket);
+}
+
+PHP_METHOD(Pimple, protect)
+{
+ zval *protected = NULL;
+ pimple_object *pobj = NULL;
+ pimple_bucket_value bucket = {0};
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &protected) == FAILURE) {
+ return;
+ }
+
+ pimple_init_bucket(&bucket);
+
+ if (pimple_zval_is_valid_callback(protected, &bucket TSRMLS_CC) == FAILURE) {
+ pimple_free_bucket(&bucket);
+ zend_throw_exception(spl_ce_InvalidArgumentException, "Callable is not a Closure or invokable object.", 0 TSRMLS_CC);
+ return;
+ }
+
+ pimple_zval_to_pimpleval(protected, &bucket TSRMLS_CC);
+ pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (zend_hash_index_update(&pobj->protected, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) {
+ RETURN_ZVAL(protected, 1 , 0);
+ } else {
+ pimple_free_bucket(&bucket);
+ }
+ RETURN_FALSE;
+}
+
+PHP_METHOD(Pimple, raw)
+{
+ zval *offset = NULL;
+ pimple_object *pobj = NULL;
+ pimple_bucket_value *value = NULL;
+ ulong index;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
+ return;
+ }
+
+ pobj = zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset));
+ RETURN_NULL();
+ }
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) {
+ RETURN_NULL();
+ }
+ break;
+ case IS_NULL:
+ default:
+ zend_error(E_WARNING, "Unsupported offset type");
+ }
+
+ if (value->raw) {
+ RETVAL_ZVAL(value->raw, 1, 0);
+ } else {
+ RETVAL_ZVAL(value->value, 1, 0);
+ }
+}
+
+PHP_METHOD(Pimple, extend)
+{
+ zval *offset = NULL, *callable = NULL, *pimple_closure_obj = NULL;
+ pimple_bucket_value bucket = {0}, *value = NULL;
+ pimple_object *pobj = NULL;
+ pimple_closure_object *pcobj = NULL;
+ ulong index;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &callable) == FAILURE) {
+ return;
+ }
+
+ pobj = zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ switch (Z_TYPE_P(offset)) {
+ case IS_STRING:
+ if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset));
+ RETURN_NULL();
+ }
+ if (value->type != PIMPLE_IS_SERVICE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" does not contain an object definition.", Z_STRVAL_P(offset));
+ RETURN_NULL();
+ }
+ break;
+ case IS_DOUBLE:
+ case IS_BOOL:
+ case IS_LONG:
+ if (Z_TYPE_P(offset) == IS_DOUBLE) {
+ index = (ulong)Z_DVAL_P(offset);
+ } else {
+ index = Z_LVAL_P(offset);
+ }
+ if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%ld\" is not defined.", index);
+ RETURN_NULL();
+ }
+ if (value->type != PIMPLE_IS_SERVICE) {
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%ld\" does not contain an object definition.", index);
+ RETURN_NULL();
+ }
+ break;
+ case IS_NULL:
+ default:
+ zend_error(E_WARNING, "Unsupported offset type");
+ }
+
+ pimple_init_bucket(&bucket);
+
+ if (pimple_zval_is_valid_callback(callable, &bucket TSRMLS_CC) == FAILURE) {
+ pimple_free_bucket(&bucket);
+ zend_throw_exception(spl_ce_InvalidArgumentException, "Extension service definition is not a Closure or invokable object.", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+ pimple_free_bucket(&bucket);
+
+ ALLOC_INIT_ZVAL(pimple_closure_obj);
+ object_init_ex(pimple_closure_obj, pimple_closure_ce);
+
+ pcobj = zend_object_store_get_object(pimple_closure_obj TSRMLS_CC);
+ pcobj->callable = callable;
+ pcobj->factory = value->value;
+ Z_ADDREF_P(callable);
+ Z_ADDREF_P(value->value);
+
+ if (zend_hash_index_exists(&pobj->factories, value->handle_num)) {
+ pimple_init_bucket(&bucket);
+ pimple_zval_to_pimpleval(pimple_closure_obj, &bucket TSRMLS_CC);
+ zend_hash_index_del(&pobj->factories, value->handle_num);
+ zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL);
+ Z_ADDREF_P(pimple_closure_obj);
+ }
+
+ pimple_object_write_dimension(getThis(), offset, pimple_closure_obj TSRMLS_CC);
+
+ RETVAL_ZVAL(pimple_closure_obj, 1, 1);
+}
+
+PHP_METHOD(Pimple, keys)
+{
+ HashPosition pos;
+ pimple_object *pobj = NULL;
+ zval **value = NULL;
+ zval *endval = NULL;
+ char *str_index = NULL;
+ int str_len;
+ ulong num_index;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ pobj = zend_object_store_get_object(getThis() TSRMLS_CC);
+ array_init_size(return_value, zend_hash_num_elements(&pobj->values));
+
+ zend_hash_internal_pointer_reset_ex(&pobj->values, &pos);
+
+ while(zend_hash_get_current_data_ex(&pobj->values, (void **)&value, &pos) == SUCCESS) {
+ MAKE_STD_ZVAL(endval);
+ switch (zend_hash_get_current_key_ex(&pobj->values, &str_index, (uint *)&str_len, &num_index, 0, &pos)) {
+ case HASH_KEY_IS_STRING:
+ ZVAL_STRINGL(endval, str_index, str_len - 1, 1);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL);
+ break;
+ case HASH_KEY_IS_LONG:
+ ZVAL_LONG(endval, num_index);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL);
+ break;
+ }
+ zend_hash_move_forward_ex(&pobj->values, &pos);
+ }
+}
+
+PHP_METHOD(Pimple, factory)
+{
+ zval *factory = NULL;
+ pimple_object *pobj = NULL;
+ pimple_bucket_value bucket = {0};
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &factory) == FAILURE) {
+ return;
+ }
+
+ pimple_init_bucket(&bucket);
+
+ if (pimple_zval_is_valid_callback(factory, &bucket TSRMLS_CC) == FAILURE) {
+ pimple_free_bucket(&bucket);
+ zend_throw_exception(spl_ce_InvalidArgumentException, "Service definition is not a Closure or invokable object.", 0 TSRMLS_CC);
+ return;
+ }
+
+ pimple_zval_to_pimpleval(factory, &bucket TSRMLS_CC);
+ pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ if (zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) {
+ Z_ADDREF_P(factory);
+ RETURN_ZVAL(factory, 1 , 0);
+ } else {
+ pimple_free_bucket(&bucket);
+ }
+
+ RETURN_FALSE;
+}
+
+PHP_METHOD(Pimple, offsetSet)
+{
+ zval *offset = NULL, *value = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &value) == FAILURE) {
+ return;
+ }
+
+ pimple_object_write_dimension(getThis(), offset, value TSRMLS_CC);
+}
+
+PHP_METHOD(Pimple, offsetGet)
+{
+ zval *offset = NULL, *retval = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
+ return;
+ }
+
+ retval = pimple_object_read_dimension(getThis(), offset, 0 TSRMLS_CC);
+
+ RETVAL_ZVAL(retval, 1, 0);
+}
+
+PHP_METHOD(Pimple, offsetUnset)
+{
+ zval *offset = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
+ return;
+ }
+
+ pimple_object_unset_dimension(getThis(), offset TSRMLS_CC);
+}
+
+PHP_METHOD(Pimple, offsetExists)
+{
+ zval *offset = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
+ return;
+ }
+
+ RETVAL_BOOL(pimple_object_has_dimension(getThis(), offset, 1 TSRMLS_CC));
+}
+
+PHP_METHOD(Pimple, register)
+{
+ zval *provider;
+ zval **data;
+ zval *retval = NULL;
+ zval key;
+
+ HashTable *array = NULL;
+ HashPosition pos;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|h", &provider, pimple_serviceprovider_ce, &array) == FAILURE) {
+ return;
+ }
+
+ zend_call_method_with_1_params(&provider, Z_OBJCE_P(provider), NULL, "register", &retval, getThis());
+
+ if (retval) {
+ zval_ptr_dtor(&retval);
+ }
+
+ if (!array) {
+ return;
+ }
+
+ zend_hash_internal_pointer_reset_ex(array, &pos);
+
+ while(zend_hash_get_current_data_ex(array, (void **)&data, &pos) == SUCCESS) {
+ zend_hash_get_current_key_zval_ex(array, &key, &pos);
+ pimple_object_write_dimension(getThis(), &key, *data TSRMLS_CC);
+ zend_hash_move_forward_ex(array, &pos);
+ }
+
+ RETVAL_ZVAL(getThis(), 1, 0);
+}
+
+PHP_METHOD(Pimple, __construct)
+{
+ zval *values = NULL, **pData = NULL, offset = {0};
+ HashPosition pos;
+ char *str_index = NULL;
+ zend_uint str_length;
+ ulong num_index;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &values) == FAILURE || !values) {
+ return;
+ }
+
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos);
+ while (zend_hash_has_more_elements_ex(Z_ARRVAL_P(values), &pos) == SUCCESS) {
+ zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&pData, &pos);
+ zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &str_index, &str_length, &num_index, 0, &pos);
+ if (zend_hash_get_current_key_type_ex(Z_ARRVAL_P(values), &pos) == HASH_KEY_IS_LONG) {
+ ZVAL_LONG(&offset, num_index);
+ } else {
+ ZVAL_STRINGL(&offset, str_index, (str_length - 1), 0);
+ }
+ pimple_object_write_dimension(getThis(), &offset, *pData TSRMLS_CC);
+ zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos);
+ }
+}
+
+/*
+ * This is PHP code snippet handling extend()s calls :
+
+ $extended = function ($c) use ($callable, $factory) {
+ return $callable($factory($c), $c);
+ };
+
+ */
+PHP_METHOD(PimpleClosure, __invoke)
+{
+ pimple_closure_object *pcobj = NULL;
+ zval *arg = NULL, *retval = NULL, *newretval = NULL;
+ zend_fcall_info fci = {0};
+ zval **args[2];
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
+ return;
+ }
+
+ pcobj = zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ fci.function_name = pcobj->factory;
+ args[0] = &arg;
+ zend_fcall_info_argp(&fci TSRMLS_CC, 1, args);
+ fci.retval_ptr_ptr = &retval;
+ fci.size = sizeof(fci);
+
+ if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) {
+ efree(fci.params);
+ return; /* Should here return default zval */
+ }
+
+ efree(fci.params);
+ memset(&fci, 0, sizeof(fci));
+ fci.size = sizeof(fci);
+
+ fci.function_name = pcobj->callable;
+ args[0] = &retval;
+ args[1] = &arg;
+ zend_fcall_info_argp(&fci TSRMLS_CC, 2, args);
+ fci.retval_ptr_ptr = &newretval;
+
+ if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) {
+ efree(fci.params);
+ zval_ptr_dtor(&retval);
+ return;
+ }
+
+ efree(fci.params);
+ zval_ptr_dtor(&retval);
+ RETVAL_ZVAL(newretval, 1 ,1);
+}
+
+PHP_MINIT_FUNCTION(pimple)
+{
+ zend_class_entry tmp_pimple_ce, tmp_pimple_closure_ce, tmp_pimple_serviceprovider_iface_ce;
+ INIT_NS_CLASS_ENTRY(tmp_pimple_ce, PIMPLE_NS, "Container", pimple_ce_functions);
+ INIT_NS_CLASS_ENTRY(tmp_pimple_closure_ce, PIMPLE_NS, "ContainerClosure", pimple_closure_ce_functions);
+ INIT_NS_CLASS_ENTRY(tmp_pimple_serviceprovider_iface_ce, PIMPLE_NS, "ServiceProviderInterface", pimple_serviceprovider_iface_ce_functions);
+
+ tmp_pimple_ce.create_object = pimple_object_create;
+ tmp_pimple_closure_ce.create_object = pimple_closure_object_create;
+
+ pimple_ce = zend_register_internal_class(&tmp_pimple_ce TSRMLS_CC);
+ zend_class_implements(pimple_ce TSRMLS_CC, 1, zend_ce_arrayaccess);
+
+ pimple_closure_ce = zend_register_internal_class(&tmp_pimple_closure_ce TSRMLS_CC);
+ pimple_closure_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
+
+ pimple_serviceprovider_ce = zend_register_internal_interface(&tmp_pimple_serviceprovider_iface_ce TSRMLS_CC);
+
+ pimple_closure_object_handlers = std_object_handlers;
+ pimple_object_handlers = std_object_handlers;
+
+ return SUCCESS;
+}
+
+PHP_MSHUTDOWN_FUNCTION(pimple)
+{
+ return SUCCESS;
+}
+
+PHP_RINIT_FUNCTION(pimple)
+{
+ return SUCCESS;
+}
+
+PHP_RSHUTDOWN_FUNCTION(pimple)
+{
+ return SUCCESS;
+}
+
+PHP_MINFO_FUNCTION(pimple)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "SensioLabs Pimple C support", "enabled");
+ php_info_print_table_row(2, "Pimple supported version", PIMPLE_VERSION);
+ php_info_print_table_end();
+
+ php_info_print_box_start(0);
+ php_write((void *)ZEND_STRL("SensioLabs Pimple C support developed by Julien Pauli") TSRMLS_CC);
+ if (!sapi_module.phpinfo_as_text) {
+ php_write((void *)ZEND_STRL(sensiolabs_logo) TSRMLS_CC);
+ }
+ php_info_print_box_end();
+}
+
+zend_module_entry pimple_module_entry = {
+ STANDARD_MODULE_HEADER,
+ "pimple",
+ NULL,
+ PHP_MINIT(pimple),
+ PHP_MSHUTDOWN(pimple),
+ PHP_RINIT(pimple),
+ PHP_RSHUTDOWN(pimple),
+ PHP_MINFO(pimple),
+ PIMPLE_VERSION,
+ STANDARD_MODULE_PROPERTIES
+};
+
+#ifdef COMPILE_DL_PIMPLE
+ZEND_GET_MODULE(pimple)
+#endif
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/pimple_compat.h b/src/lib/vendor/pimple/pimple/ext/pimple/pimple_compat.h
new file mode 100644
index 00000000..d234e174
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/pimple_compat.h
@@ -0,0 +1,81 @@
+
+/*
+ * This file is part of Pimple.
+ *
+ * Copyright (c) 2014 Fabien Potencier
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished
+ * to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef PIMPLE_COMPAT_H_
+#define PIMPLE_COMPAT_H_
+
+#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */
+
+#define PHP_5_0_X_API_NO 220040412
+#define PHP_5_1_X_API_NO 220051025
+#define PHP_5_2_X_API_NO 220060519
+#define PHP_5_3_X_API_NO 220090626
+#define PHP_5_4_X_API_NO 220100525
+#define PHP_5_5_X_API_NO 220121212
+#define PHP_5_6_X_API_NO 220131226
+
+#define IS_PHP_56 ZEND_EXTENSION_API_NO == PHP_5_6_X_API_NO
+#define IS_AT_LEAST_PHP_56 ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO
+
+#define IS_PHP_55 ZEND_EXTENSION_API_NO == PHP_5_5_X_API_NO
+#define IS_AT_LEAST_PHP_55 ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO
+
+#define IS_PHP_54 ZEND_EXTENSION_API_NO == PHP_5_4_X_API_NO
+#define IS_AT_LEAST_PHP_54 ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO
+
+#define IS_PHP_53 ZEND_EXTENSION_API_NO == PHP_5_3_X_API_NO
+#define IS_AT_LEAST_PHP_53 ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
+
+#if IS_PHP_53
+#define object_properties_init(obj, ce) do { \
+ zend_hash_copy(obj->properties, &ce->default_properties, zval_copy_property_ctor(ce), NULL, sizeof(zval *)); \
+ } while (0);
+#endif
+
+#define ZEND_OBJ_INIT(obj, ce) do { \
+ zend_object_std_init(obj, ce TSRMLS_CC); \
+ object_properties_init((obj), (ce)); \
+ } while(0);
+
+#if IS_PHP_53 || IS_PHP_54
+static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
+ Bucket *p;
+
+ p = pos ? (*pos) : ht->pInternalPointer;
+
+ if (!p) {
+ Z_TYPE_P(key) = IS_NULL;
+ } else if (p->nKeyLength) {
+ Z_TYPE_P(key) = IS_STRING;
+ Z_STRVAL_P(key) = estrndup(p->arKey, p->nKeyLength - 1);
+ Z_STRLEN_P(key) = p->nKeyLength - 1;
+ } else {
+ Z_TYPE_P(key) = IS_LONG;
+ Z_LVAL_P(key) = p->h;
+ }
+}
+#endif
+
+#endif /* PIMPLE_COMPAT_H_ */
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/001.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/001.phpt
new file mode 100644
index 00000000..0809ea23
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/001.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test for read_dim/write_dim handlers
+--SKIPIF--
+
+--FILE--
+
+
+--EXPECTF--
+foo
+42
+foo2
+foo99
+baz
+strstr
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/002.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/002.phpt
new file mode 100644
index 00000000..7b56d2c1
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/002.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Test for constructor
+--SKIPIF--
+
+--FILE--
+'foo'));
+var_dump($p[42]);
+?>
+--EXPECT--
+NULL
+string(3) "foo"
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/003.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/003.phpt
new file mode 100644
index 00000000..a22cfa35
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/003.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test empty dimensions
+--SKIPIF--
+
+--FILE--
+
+--EXPECT--
+int(42)
+string(3) "bar"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/004.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/004.phpt
new file mode 100644
index 00000000..1e1d2513
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/004.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test has/unset dim handlers
+--SKIPIF--
+
+--FILE--
+
+--EXPECT--
+int(42)
+NULL
+bool(true)
+bool(false)
+bool(true)
+bool(true)
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/005.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/005.phpt
new file mode 100644
index 00000000..0479ee05
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/005.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test simple class inheritance
+--SKIPIF--
+
+--FILE--
+someAttr;
+?>
+--EXPECT--
+string(3) "hit"
+foo
+fooAttr
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/006.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/006.phpt
new file mode 100644
index 00000000..cfe8a119
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/006.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test complex class inheritance
+--SKIPIF--
+
+--FILE--
+ 'bar', 88 => 'baz');
+
+$p = new TestPimple($defaultValues);
+$p[42] = 'foo';
+var_dump($p[42]);
+var_dump($p[0]);
+?>
+--EXPECT--
+string(13) "hit offsetset"
+string(27) "hit offsetget in TestPimple"
+string(25) "hit offsetget in MyPimple"
+string(3) "foo"
+string(27) "hit offsetget in TestPimple"
+string(25) "hit offsetget in MyPimple"
+string(3) "baz"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/007.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/007.phpt
new file mode 100644
index 00000000..5aac6838
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/007.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test for read_dim/write_dim handlers
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+foo
+42
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/008.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/008.phpt
new file mode 100644
index 00000000..db7eeec4
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/008.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test frozen services
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/009.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/009.phpt
new file mode 100644
index 00000000..bb05ea29
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/009.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Test service is called as callback, and only once
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+bool(true)
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/010.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/010.phpt
new file mode 100644
index 00000000..badce014
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/010.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test service is called as callback for every callback type
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+callme
+called
+Foo::bar
+array(2) {
+ [0]=>
+ string(3) "Foo"
+ [1]=>
+ string(3) "bar"
+}
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/011.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/011.phpt
new file mode 100644
index 00000000..6682ab8e
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/011.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test service callback throwing an exception
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+all right!
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/012.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/012.phpt
new file mode 100644
index 00000000..4c6ac486
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/012.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Test service factory
+--SKIPIF--
+
+--FILE--
+factory($f = function() { var_dump('called-1'); return 'ret-1';});
+
+$p[] = $f;
+
+$p[] = function () { var_dump('called-2'); return 'ret-2'; };
+
+var_dump($p[0]);
+var_dump($p[0]);
+var_dump($p[1]);
+var_dump($p[1]);
+?>
+--EXPECTF--
+string(8) "called-1"
+string(5) "ret-1"
+string(8) "called-1"
+string(5) "ret-1"
+string(8) "called-2"
+string(5) "ret-2"
+string(5) "ret-2"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/013.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/013.phpt
new file mode 100644
index 00000000..f419958c
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/013.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test keys()
+--SKIPIF--
+
+--FILE--
+keys());
+
+$p['foo'] = 'bar';
+$p[] = 'foo';
+
+var_dump($p->keys());
+
+unset($p['foo']);
+
+var_dump($p->keys());
+?>
+--EXPECTF--
+array(0) {
+}
+array(2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/014.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/014.phpt
new file mode 100644
index 00000000..ac937213
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/014.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test raw()
+--SKIPIF--
+
+--FILE--
+raw('foo'));
+var_dump($p[42]);
+
+unset($p['foo']);
+
+try {
+ $p->raw('foo');
+ echo "expected exception";
+} catch (InvalidArgumentException $e) { }
+--EXPECTF--
+string(8) "called-2"
+string(5) "ret-2"
+object(Closure)#%i (0) {
+}
+string(8) "called-2"
+string(5) "ret-2"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/015.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/015.phpt
new file mode 100644
index 00000000..314f008a
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/015.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test protect()
+--SKIPIF--
+
+--FILE--
+protect($f);
+
+var_dump($p['foo']);
+--EXPECTF--
+object(Closure)#%i (0) {
+}
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/016.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/016.phpt
new file mode 100644
index 00000000..e55edb0a
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/016.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test extend()
+--SKIPIF--
+
+--FILE--
+extend(12, function ($w) { var_dump($w); return 'bar'; }); /* $callable in code above */
+
+var_dump($c('param'));
+--EXPECTF--
+string(5) "param"
+string(3) "foo"
+string(3) "bar"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/017.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/017.phpt
new file mode 100644
index 00000000..bac23ce0
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/017.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test extend() with exception in service extension
+--SKIPIF--
+
+--FILE--
+extend(12, function ($w) { throw new BadMethodCallException; });
+
+try {
+ $p[12];
+ echo "Exception expected";
+} catch (BadMethodCallException $e) { }
+--EXPECTF--
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt
new file mode 100644
index 00000000..8f881d6e
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test extend() with exception in service factory
+--SKIPIF--
+
+--FILE--
+extend(12, function ($w) { return 'foobar'; });
+
+try {
+ $p[12];
+ echo "Exception expected";
+} catch (BadMethodCallException $e) { }
+--EXPECTF--
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/018.phpt b/src/lib/vendor/pimple/pimple/ext/pimple/tests/018.phpt
new file mode 100644
index 00000000..27c12a14
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/018.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test register()
+--SKIPIF--
+
+--FILE--
+register(new Foo, array(42 => 'bar'));
+
+var_dump($p[42]);
+--EXPECTF--
+object(Pimple\Container)#1 (0) {
+}
+string(3) "bar"
\ No newline at end of file
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench.phpb b/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench.phpb
new file mode 100644
index 00000000..8ddd6e3b
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench.phpb
@@ -0,0 +1,51 @@
+factory($factory);
+
+$p['factory'] = $factory;
+
+echo $p['factory'];
+echo $p['factory'];
+echo $p['factory'];
+
+}
+
+echo microtime(true) - $time;
diff --git a/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb b/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb
new file mode 100644
index 00000000..0fbc8391
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb
@@ -0,0 +1,25 @@
+
diff --git a/src/lib/vendor/pimple/pimple/phpunit.xml.dist b/src/lib/vendor/pimple/pimple/phpunit.xml.dist
new file mode 100644
index 00000000..550fe8dc
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/phpunit.xml.dist
@@ -0,0 +1,19 @@
+
+
+
+
+
+ ./tests/
+
+
+
diff --git a/src/lib/vendor/pimple/pimple/src/Pimple.php b/src/lib/vendor/pimple/pimple/src/Pimple.php
new file mode 100644
index 00000000..2a45cadf
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/src/Pimple.php
@@ -0,0 +1,27 @@
+factories = new \SplObjectStorage();
+ $this->protected = new \SplObjectStorage();
+
+ foreach ($values as $key => $value) {
+ $this->offsetSet($key, $value);
+ }
+ }
+
+ /**
+ * Sets a parameter or an object.
+ *
+ * Objects must be defined as Closures.
+ *
+ * Allowing any PHP callable leads to difficult to debug problems
+ * as function names (strings) are callable (creating a function with
+ * the same name as an existing parameter would break your container).
+ *
+ * @param string $id The unique identifier for the parameter or object
+ * @param mixed $value The value of the parameter or a closure to define an object
+ * @throws \RuntimeException Prevent override of a frozen service
+ */
+ public function offsetSet($id, $value)
+ {
+ if (isset($this->frozen[$id])) {
+ throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id));
+ }
+
+ $this->values[$id] = $value;
+ $this->keys[$id] = true;
+ }
+
+ /**
+ * Gets a parameter or an object.
+ *
+ * @param string $id The unique identifier for the parameter or object
+ *
+ * @return mixed The value of the parameter or an object
+ *
+ * @throws \InvalidArgumentException if the identifier is not defined
+ */
+ public function offsetGet($id)
+ {
+ if (!isset($this->keys[$id])) {
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
+ }
+
+ if (
+ isset($this->raw[$id])
+ || !is_object($this->values[$id])
+ || isset($this->protected[$this->values[$id]])
+ || !method_exists($this->values[$id], '__invoke')
+ ) {
+ return $this->values[$id];
+ }
+
+ if (isset($this->factories[$this->values[$id]])) {
+ return $this->values[$id]($this);
+ }
+
+ $raw = $this->values[$id];
+ $val = $this->values[$id] = $raw($this);
+ $this->raw[$id] = $raw;
+
+ $this->frozen[$id] = true;
+
+ return $val;
+ }
+
+ /**
+ * Checks if a parameter or an object is set.
+ *
+ * @param string $id The unique identifier for the parameter or object
+ *
+ * @return bool
+ */
+ public function offsetExists($id)
+ {
+ return isset($this->keys[$id]);
+ }
+
+ /**
+ * Unsets a parameter or an object.
+ *
+ * @param string $id The unique identifier for the parameter or object
+ */
+ public function offsetUnset($id)
+ {
+ if (isset($this->keys[$id])) {
+ if (is_object($this->values[$id])) {
+ unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]);
+ }
+
+ unset($this->values[$id], $this->frozen[$id], $this->raw[$id], $this->keys[$id]);
+ }
+ }
+
+ /**
+ * Marks a callable as being a factory service.
+ *
+ * @param callable $callable A service definition to be used as a factory
+ *
+ * @return callable The passed callable
+ *
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
+ */
+ public function factory($callable)
+ {
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
+ throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.');
+ }
+
+ $this->factories->attach($callable);
+
+ return $callable;
+ }
+
+ /**
+ * Protects a callable from being interpreted as a service.
+ *
+ * This is useful when you want to store a callable as a parameter.
+ *
+ * @param callable $callable A callable to protect from being evaluated
+ *
+ * @return callable The passed callable
+ *
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
+ */
+ public function protect($callable)
+ {
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
+ throw new \InvalidArgumentException('Callable is not a Closure or invokable object.');
+ }
+
+ $this->protected->attach($callable);
+
+ return $callable;
+ }
+
+ /**
+ * Gets a parameter or the closure defining an object.
+ *
+ * @param string $id The unique identifier for the parameter or object
+ *
+ * @return mixed The value of the parameter or the closure defining an object
+ *
+ * @throws \InvalidArgumentException if the identifier is not defined
+ */
+ public function raw($id)
+ {
+ if (!isset($this->keys[$id])) {
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
+ }
+
+ if (isset($this->raw[$id])) {
+ return $this->raw[$id];
+ }
+
+ return $this->values[$id];
+ }
+
+ /**
+ * Extends an object definition.
+ *
+ * Useful when you want to extend an existing object definition,
+ * without necessarily loading that object.
+ *
+ * @param string $id The unique identifier for the object
+ * @param callable $callable A service definition to extend the original
+ *
+ * @return callable The wrapped callable
+ *
+ * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
+ */
+ public function extend($id, $callable)
+ {
+ if (!isset($this->keys[$id])) {
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
+ }
+
+ if (!is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) {
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" does not contain an object definition.', $id));
+ }
+
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
+ throw new \InvalidArgumentException('Extension service definition is not a Closure or invokable object.');
+ }
+
+ $factory = $this->values[$id];
+
+ $extended = function ($c) use ($callable, $factory) {
+ return $callable($factory($c), $c);
+ };
+
+ if (isset($this->factories[$factory])) {
+ $this->factories->detach($factory);
+ $this->factories->attach($extended);
+ }
+
+ return $this[$id] = $extended;
+ }
+
+ /**
+ * Returns all defined value names.
+ *
+ * @return array An array of value names
+ */
+ public function keys()
+ {
+ return array_keys($this->values);
+ }
+
+ /**
+ * Registers a service provider.
+ *
+ * @param ServiceProviderInterface $provider A ServiceProviderInterface instance
+ * @param array $values An array of values that customizes the provider
+ *
+ * @return static
+ */
+ public function register(ServiceProviderInterface $provider, array $values = array())
+ {
+ $provider->register($this);
+
+ foreach ($values as $key => $value) {
+ $this[$key] = $value;
+ }
+
+ return $this;
+ }
+}
diff --git a/src/lib/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php b/src/lib/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php
new file mode 100644
index 00000000..9b122bd4
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php
@@ -0,0 +1,46 @@
+value = $value;
+
+ return $service;
+ }
+}
diff --git a/src/lib/vendor/pimple/pimple/tests/Fixtures/NonInvokable.php b/src/lib/vendor/pimple/pimple/tests/Fixtures/NonInvokable.php
new file mode 100644
index 00000000..33cd4e54
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/tests/Fixtures/NonInvokable.php
@@ -0,0 +1,34 @@
+factory(function () {
+ return new Service();
+ });
+ }
+}
diff --git a/src/lib/vendor/pimple/pimple/tests/Fixtures/Service.php b/src/lib/vendor/pimple/pimple/tests/Fixtures/Service.php
new file mode 100644
index 00000000..d71b184d
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/tests/Fixtures/Service.php
@@ -0,0 +1,35 @@
+
+ */
+class Service
+{
+ public $value;
+}
diff --git a/src/lib/vendor/pimple/pimple/tests/PimpleServiceProviderInterfaceTest.php b/src/lib/vendor/pimple/pimple/tests/PimpleServiceProviderInterfaceTest.php
new file mode 100644
index 00000000..69f76f84
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/tests/PimpleServiceProviderInterfaceTest.php
@@ -0,0 +1,76 @@
+
+ */
+class PimpleServiceProviderInterfaceTest extends \PHPUnit_Framework_TestCase
+{
+ public function testProvider()
+ {
+ $pimple = new Container();
+
+ $pimpleServiceProvider = new Fixtures\PimpleServiceProvider();
+ $pimpleServiceProvider->register($pimple);
+
+ $this->assertEquals('value', $pimple['param']);
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']);
+
+ $serviceOne = $pimple['factory'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+
+ $serviceTwo = $pimple['factory'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+
+ $this->assertNotSame($serviceOne, $serviceTwo);
+ }
+
+ public function testProviderWithRegisterMethod()
+ {
+ $pimple = new Container();
+
+ $pimple->register(new Fixtures\PimpleServiceProvider(), array(
+ 'anotherParameter' => 'anotherValue'
+ ));
+
+ $this->assertEquals('value', $pimple['param']);
+ $this->assertEquals('anotherValue', $pimple['anotherParameter']);
+
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']);
+
+ $serviceOne = $pimple['factory'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+
+ $serviceTwo = $pimple['factory'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+
+ $this->assertNotSame($serviceOne, $serviceTwo);
+ }
+}
diff --git a/src/lib/vendor/pimple/pimple/tests/PimpleTest.php b/src/lib/vendor/pimple/pimple/tests/PimpleTest.php
new file mode 100644
index 00000000..30ca3912
--- /dev/null
+++ b/src/lib/vendor/pimple/pimple/tests/PimpleTest.php
@@ -0,0 +1,434 @@
+
+ */
+class PimpleTest extends \PHPUnit_Framework_TestCase
+{
+ public function testWithString()
+ {
+ $pimple = new Container();
+ $pimple['param'] = 'value';
+
+ $this->assertEquals('value', $pimple['param']);
+ }
+
+ public function testWithClosure()
+ {
+ $pimple = new Container();
+ $pimple['service'] = function () {
+ return new Fixtures\Service();
+ };
+
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['service']);
+ }
+
+ public function testServicesShouldBeDifferent()
+ {
+ $pimple = new Container();
+ $pimple['service'] = $pimple->factory(function () {
+ return new Fixtures\Service();
+ });
+
+ $serviceOne = $pimple['service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+
+ $serviceTwo = $pimple['service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+
+ $this->assertNotSame($serviceOne, $serviceTwo);
+ }
+
+ public function testShouldPassContainerAsParameter()
+ {
+ $pimple = new Container();
+ $pimple['service'] = function () {
+ return new Fixtures\Service();
+ };
+ $pimple['container'] = function ($container) {
+ return $container;
+ };
+
+ $this->assertNotSame($pimple, $pimple['service']);
+ $this->assertSame($pimple, $pimple['container']);
+ }
+
+ public function testIsset()
+ {
+ $pimple = new Container();
+ $pimple['param'] = 'value';
+ $pimple['service'] = function () {
+ return new Fixtures\Service();
+ };
+
+ $pimple['null'] = null;
+
+ $this->assertTrue(isset($pimple['param']));
+ $this->assertTrue(isset($pimple['service']));
+ $this->assertTrue(isset($pimple['null']));
+ $this->assertFalse(isset($pimple['non_existent']));
+ }
+
+ public function testConstructorInjection()
+ {
+ $params = array("param" => "value");
+ $pimple = new Container($params);
+
+ $this->assertSame($params['param'], $pimple['param']);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" is not defined.
+ */
+ public function testOffsetGetValidatesKeyIsPresent()
+ {
+ $pimple = new Container();
+ echo $pimple['foo'];
+ }
+
+ public function testOffsetGetHonorsNullValues()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = null;
+ $this->assertNull($pimple['foo']);
+ }
+
+ public function testUnset()
+ {
+ $pimple = new Container();
+ $pimple['param'] = 'value';
+ $pimple['service'] = function () {
+ return new Fixtures\Service();
+ };
+
+ unset($pimple['param'], $pimple['service']);
+ $this->assertFalse(isset($pimple['param']));
+ $this->assertFalse(isset($pimple['service']));
+ }
+
+ /**
+ * @dataProvider serviceDefinitionProvider
+ */
+ public function testShare($service)
+ {
+ $pimple = new Container();
+ $pimple['shared_service'] = $service;
+
+ $serviceOne = $pimple['shared_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+
+ $serviceTwo = $pimple['shared_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+
+ $this->assertSame($serviceOne, $serviceTwo);
+ }
+
+ /**
+ * @dataProvider serviceDefinitionProvider
+ */
+ public function testProtect($service)
+ {
+ $pimple = new Container();
+ $pimple['protected'] = $pimple->protect($service);
+
+ $this->assertSame($service, $pimple['protected']);
+ }
+
+ public function testGlobalFunctionNameAsParameterValue()
+ {
+ $pimple = new Container();
+ $pimple['global_function'] = 'strlen';
+ $this->assertSame('strlen', $pimple['global_function']);
+ }
+
+ public function testRaw()
+ {
+ $pimple = new Container();
+ $pimple['service'] = $definition = $pimple->factory(function () { return 'foo'; });
+ $this->assertSame($definition, $pimple->raw('service'));
+ }
+
+ public function testRawHonorsNullValues()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = null;
+ $this->assertNull($pimple->raw('foo'));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" is not defined.
+ */
+ public function testRawValidatesKeyIsPresent()
+ {
+ $pimple = new Container();
+ $pimple->raw('foo');
+ }
+
+ /**
+ * @dataProvider serviceDefinitionProvider
+ */
+ public function testExtend($service)
+ {
+ $pimple = new Container();
+ $pimple['shared_service'] = function () {
+ return new Fixtures\Service();
+ };
+ $pimple['factory_service'] = $pimple->factory(function () {
+ return new Fixtures\Service();
+ });
+
+ $pimple->extend('shared_service', $service);
+ $serviceOne = $pimple['shared_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+ $serviceTwo = $pimple['shared_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+ $this->assertSame($serviceOne, $serviceTwo);
+ $this->assertSame($serviceOne->value, $serviceTwo->value);
+
+ $pimple->extend('factory_service', $service);
+ $serviceOne = $pimple['factory_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceOne);
+ $serviceTwo = $pimple['factory_service'];
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $serviceTwo);
+ $this->assertNotSame($serviceOne, $serviceTwo);
+ $this->assertNotSame($serviceOne->value, $serviceTwo->value);
+ }
+
+ public function testExtendDoesNotLeakWithFactories()
+ {
+ if (extension_loaded('pimple')) {
+ $this->markTestSkipped('Pimple extension does not support this test');
+ }
+ $pimple = new Container();
+
+ $pimple['foo'] = $pimple->factory(function () { return; });
+ $pimple['foo'] = $pimple->extend('foo', function ($foo, $pimple) { return; });
+ unset($pimple['foo']);
+
+ $p = new \ReflectionProperty($pimple, 'values');
+ $p->setAccessible(true);
+ $this->assertEmpty($p->getValue($pimple));
+
+ $p = new \ReflectionProperty($pimple, 'factories');
+ $p->setAccessible(true);
+ $this->assertCount(0, $p->getValue($pimple));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" is not defined.
+ */
+ public function testExtendValidatesKeyIsPresent()
+ {
+ $pimple = new Container();
+ $pimple->extend('foo', function () {});
+ }
+
+ public function testKeys()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = 123;
+ $pimple['bar'] = 123;
+
+ $this->assertEquals(array('foo', 'bar'), $pimple->keys());
+ }
+
+ /** @test */
+ public function settingAnInvokableObjectShouldTreatItAsFactory()
+ {
+ $pimple = new Container();
+ $pimple['invokable'] = new Fixtures\Invokable();
+
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\Service', $pimple['invokable']);
+ }
+
+ /** @test */
+ public function settingNonInvokableObjectShouldTreatItAsParameter()
+ {
+ $pimple = new Container();
+ $pimple['non_invokable'] = new Fixtures\NonInvokable();
+
+ $this->assertInstanceOf('Pimple\Tests\Fixtures\NonInvokable', $pimple['non_invokable']);
+ }
+
+ /**
+ * @dataProvider badServiceDefinitionProvider
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Service definition is not a Closure or invokable object.
+ */
+ public function testFactoryFailsForInvalidServiceDefinitions($service)
+ {
+ $pimple = new Container();
+ $pimple->factory($service);
+ }
+
+ /**
+ * @dataProvider badServiceDefinitionProvider
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Callable is not a Closure or invokable object.
+ */
+ public function testProtectFailsForInvalidServiceDefinitions($service)
+ {
+ $pimple = new Container();
+ $pimple->protect($service);
+ }
+
+ /**
+ * @dataProvider badServiceDefinitionProvider
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" does not contain an object definition.
+ */
+ public function testExtendFailsForKeysNotContainingServiceDefinitions($service)
+ {
+ $pimple = new Container();
+ $pimple['foo'] = $service;
+ $pimple->extend('foo', function () {});
+ }
+
+ /**
+ * @dataProvider badServiceDefinitionProvider
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Extension service definition is not a Closure or invokable object.
+ */
+ public function testExtendFailsForInvalidServiceDefinitions($service)
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {};
+ $pimple->extend('foo', $service);
+ }
+
+ /**
+ * Provider for invalid service definitions
+ */
+ public function badServiceDefinitionProvider()
+ {
+ return array(
+ array(123),
+ array(new Fixtures\NonInvokable())
+ );
+ }
+
+ /**
+ * Provider for service definitions
+ */
+ public function serviceDefinitionProvider()
+ {
+ return array(
+ array(function ($value) {
+ $service = new Fixtures\Service();
+ $service->value = $value;
+
+ return $service;
+ }),
+ array(new Fixtures\Invokable())
+ );
+ }
+
+ public function testDefiningNewServiceAfterFreeze()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {
+ return 'foo';
+ };
+ $foo = $pimple['foo'];
+
+ $pimple['bar'] = function () {
+ return 'bar';
+ };
+ $this->assertSame('bar', $pimple['bar']);
+ }
+
+ /**
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage Cannot override frozen service "foo".
+ */
+ public function testOverridingServiceAfterFreeze()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {
+ return 'foo';
+ };
+ $foo = $pimple['foo'];
+
+ $pimple['foo'] = function () {
+ return 'bar';
+ };
+ }
+
+ public function testRemovingServiceAfterFreeze()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {
+ return 'foo';
+ };
+ $foo = $pimple['foo'];
+
+ unset($pimple['foo']);
+ $pimple['foo'] = function () {
+ return 'bar';
+ };
+ $this->assertSame('bar', $pimple['foo']);
+ }
+
+ public function testExtendingService()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {
+ return 'foo';
+ };
+ $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) {
+ return "$foo.bar";
+ });
+ $pimple['foo'] = $pimple->extend('foo', function ($foo, $app) {
+ return "$foo.baz";
+ });
+ $this->assertSame('foo.bar.baz', $pimple['foo']);
+ }
+
+ public function testExtendingServiceAfterOtherServiceFreeze()
+ {
+ $pimple = new Container();
+ $pimple['foo'] = function () {
+ return 'foo';
+ };
+ $pimple['bar'] = function () {
+ return 'bar';
+ };
+ $foo = $pimple['foo'];
+
+ $pimple['bar'] = $pimple->extend('bar', function ($bar, $app) {
+ return "$bar.baz";
+ });
+ $this->assertSame('bar.baz', $pimple['bar']);
+ }
+}
diff --git a/src/lib/vendor/psr/log/.gitignore b/src/lib/vendor/psr/log/.gitignore
new file mode 100644
index 00000000..22d0d82f
--- /dev/null
+++ b/src/lib/vendor/psr/log/.gitignore
@@ -0,0 +1 @@
+vendor
diff --git a/src/lib/vendor/psr/log/LICENSE b/src/lib/vendor/psr/log/LICENSE
new file mode 100644
index 00000000..474c952b
--- /dev/null
+++ b/src/lib/vendor/psr/log/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2012 PHP Framework Interoperability Group
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/lib/vendor/psr/log/Psr/Log/AbstractLogger.php b/src/lib/vendor/psr/log/Psr/Log/AbstractLogger.php
new file mode 100644
index 00000000..00f90345
--- /dev/null
+++ b/src/lib/vendor/psr/log/Psr/Log/AbstractLogger.php
@@ -0,0 +1,120 @@
+log(LogLevel::EMERGENCY, $message, $context);
+ }
+
+ /**
+ * Action must be taken immediately.
+ *
+ * Example: Entire website down, database unavailable, etc. This should
+ * trigger the SMS alerts and wake you up.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function alert($message, array $context = array())
+ {
+ $this->log(LogLevel::ALERT, $message, $context);
+ }
+
+ /**
+ * Critical conditions.
+ *
+ * Example: Application component unavailable, unexpected exception.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function critical($message, array $context = array())
+ {
+ $this->log(LogLevel::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Runtime errors that do not require immediate action but should typically
+ * be logged and monitored.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function error($message, array $context = array())
+ {
+ $this->log(LogLevel::ERROR, $message, $context);
+ }
+
+ /**
+ * Exceptional occurrences that are not errors.
+ *
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
+ * that are not necessarily wrong.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function warning($message, array $context = array())
+ {
+ $this->log(LogLevel::WARNING, $message, $context);
+ }
+
+ /**
+ * Normal but significant events.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function notice($message, array $context = array())
+ {
+ $this->log(LogLevel::NOTICE, $message, $context);
+ }
+
+ /**
+ * Interesting events.
+ *
+ * Example: User logs in, SQL logs.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function info($message, array $context = array())
+ {
+ $this->log(LogLevel::INFO, $message, $context);
+ }
+
+ /**
+ * Detailed debug information.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function debug($message, array $context = array())
+ {
+ $this->log(LogLevel::DEBUG, $message, $context);
+ }
+}
diff --git a/src/lib/vendor/psr/log/Psr/Log/InvalidArgumentException.php b/src/lib/vendor/psr/log/Psr/Log/InvalidArgumentException.php
new file mode 100644
index 00000000..67f852d1
--- /dev/null
+++ b/src/lib/vendor/psr/log/Psr/Log/InvalidArgumentException.php
@@ -0,0 +1,7 @@
+logger = $logger;
+ }
+}
diff --git a/src/lib/vendor/psr/log/Psr/Log/LoggerInterface.php b/src/lib/vendor/psr/log/Psr/Log/LoggerInterface.php
new file mode 100644
index 00000000..476bb962
--- /dev/null
+++ b/src/lib/vendor/psr/log/Psr/Log/LoggerInterface.php
@@ -0,0 +1,114 @@
+log(LogLevel::EMERGENCY, $message, $context);
+ }
+
+ /**
+ * Action must be taken immediately.
+ *
+ * Example: Entire website down, database unavailable, etc. This should
+ * trigger the SMS alerts and wake you up.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function alert($message, array $context = array())
+ {
+ $this->log(LogLevel::ALERT, $message, $context);
+ }
+
+ /**
+ * Critical conditions.
+ *
+ * Example: Application component unavailable, unexpected exception.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function critical($message, array $context = array())
+ {
+ $this->log(LogLevel::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Runtime errors that do not require immediate action but should typically
+ * be logged and monitored.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function error($message, array $context = array())
+ {
+ $this->log(LogLevel::ERROR, $message, $context);
+ }
+
+ /**
+ * Exceptional occurrences that are not errors.
+ *
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
+ * that are not necessarily wrong.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function warning($message, array $context = array())
+ {
+ $this->log(LogLevel::WARNING, $message, $context);
+ }
+
+ /**
+ * Normal but significant events.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function notice($message, array $context = array())
+ {
+ $this->log(LogLevel::NOTICE, $message, $context);
+ }
+
+ /**
+ * Interesting events.
+ *
+ * Example: User logs in, SQL logs.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function info($message, array $context = array())
+ {
+ $this->log(LogLevel::INFO, $message, $context);
+ }
+
+ /**
+ * Detailed debug information.
+ *
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function debug($message, array $context = array())
+ {
+ $this->log(LogLevel::DEBUG, $message, $context);
+ }
+
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @param mixed $level
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ abstract public function log($level, $message, array $context = array());
+}
diff --git a/src/lib/vendor/psr/log/Psr/Log/NullLogger.php b/src/lib/vendor/psr/log/Psr/Log/NullLogger.php
new file mode 100644
index 00000000..553a3c59
--- /dev/null
+++ b/src/lib/vendor/psr/log/Psr/Log/NullLogger.php
@@ -0,0 +1,27 @@
+logger) { }`
+ * blocks.
+ */
+class NullLogger extends AbstractLogger
+{
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @param mixed $level
+ * @param string $message
+ * @param array $context
+ * @return null
+ */
+ public function log($level, $message, array $context = array())
+ {
+ // noop
+ }
+}
diff --git a/src/lib/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/src/lib/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php
new file mode 100644
index 00000000..a9328151
--- /dev/null
+++ b/src/lib/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php
@@ -0,0 +1,116 @@
+ "
+ *
+ * Example ->error('Foo') would yield "error Foo"
+ *
+ * @return string[]
+ */
+ abstract function getLogs();
+
+ public function testImplements()
+ {
+ $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
+ }
+
+ /**
+ * @dataProvider provideLevelsAndMessages
+ */
+ public function testLogsAtAllLevels($level, $message)
+ {
+ $logger = $this->getLogger();
+ $logger->{$level}($message, array('user' => 'Bob'));
+ $logger->log($level, $message, array('user' => 'Bob'));
+
+ $expected = array(
+ $level.' message of level '.$level.' with context: Bob',
+ $level.' message of level '.$level.' with context: Bob',
+ );
+ $this->assertEquals($expected, $this->getLogs());
+ }
+
+ public function provideLevelsAndMessages()
+ {
+ return array(
+ LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
+ LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
+ LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
+ LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
+ LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
+ LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
+ LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
+ LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
+ );
+ }
+
+ /**
+ * @expectedException Psr\Log\InvalidArgumentException
+ */
+ public function testThrowsOnInvalidLevel()
+ {
+ $logger = $this->getLogger();
+ $logger->log('invalid level', 'Foo');
+ }
+
+ public function testContextReplacement()
+ {
+ $logger = $this->getLogger();
+ $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
+
+ $expected = array('info {Message {nothing} Bob Bar a}');
+ $this->assertEquals($expected, $this->getLogs());
+ }
+
+ public function testObjectCastToString()
+ {
+ $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
+ $dummy->expects($this->once())
+ ->method('__toString')
+ ->will($this->returnValue('DUMMY'));
+
+ $this->getLogger()->warning($dummy);
+ }
+
+ public function testContextCanContainAnything()
+ {
+ $context = array(
+ 'bool' => true,
+ 'null' => null,
+ 'string' => 'Foo',
+ 'int' => 0,
+ 'float' => 0.5,
+ 'nested' => array('with object' => new DummyTest),
+ 'object' => new \DateTime,
+ 'resource' => fopen('php://memory', 'r'),
+ );
+
+ $this->getLogger()->warning('Crazy context data', $context);
+ }
+
+ public function testContextExceptionKeyCanBeExceptionOrOtherValues()
+ {
+ $this->getLogger()->warning('Random message', array('exception' => 'oops'));
+ $this->getLogger()->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
+ }
+}
+
+class DummyTest
+{
+}
\ No newline at end of file
diff --git a/src/lib/vendor/psr/log/README.md b/src/lib/vendor/psr/log/README.md
new file mode 100644
index 00000000..574bc1cb
--- /dev/null
+++ b/src/lib/vendor/psr/log/README.md
@@ -0,0 +1,45 @@
+PSR Log
+=======
+
+This repository holds all interfaces/classes/traits related to
+[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
+
+Note that this is not a logger of its own. It is merely an interface that
+describes a logger. See the specification for more details.
+
+Usage
+-----
+
+If you need a logger, you can use the interface like this:
+
+```php
+logger = $logger;
+ }
+
+ public function doSomething()
+ {
+ if ($this->logger) {
+ $this->logger->info('Doing work');
+ }
+
+ // do something useful
+ }
+}
+```
+
+You can then pick one of the implementations of the interface to get a logger.
+
+If you want to implement the interface, you can require this package and
+implement `Psr\Log\LoggerInterface` in your code. Please read the
+[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
+for details.
diff --git a/src/lib/vendor/psr/log/composer.json b/src/lib/vendor/psr/log/composer.json
new file mode 100644
index 00000000..6bdcc219
--- /dev/null
+++ b/src/lib/vendor/psr/log/composer.json
@@ -0,0 +1,17 @@
+{
+ "name": "psr/log",
+ "description": "Common interface for logging libraries",
+ "keywords": ["psr", "psr-3", "log"],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "autoload": {
+ "psr-0": {
+ "Psr\\Log\\": ""
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore
new file mode 100644
index 00000000..c49a5d8d
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore
@@ -0,0 +1,3 @@
+vendor/
+composer.lock
+phpunit.xml
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md
new file mode 100644
index 00000000..bb42ee19
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md
@@ -0,0 +1,23 @@
+CHANGELOG
+=========
+
+2.5.0
+-----
+
+ * added Debug\TraceableEventDispatcher (originally in HttpKernel)
+ * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface
+ * added RegisterListenersPass (originally in HttpKernel)
+
+2.1.0
+-----
+
+ * added TraceableEventDispatcherInterface
+ * added ContainerAwareEventDispatcher
+ * added a reference to the EventDispatcher on the Event
+ * added a reference to the Event name on the event
+ * added fluid interface to the dispatch() method which now returns the Event
+ object
+ * added GenericEvent event class
+ * added the possibility for subscribers to subscribe several times for the
+ same event
+ * added ImmutableEventDispatcher
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
new file mode 100644
index 00000000..e97d427e
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
@@ -0,0 +1,202 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Lazily loads listeners and subscribers from the dependency injection
+ * container
+ *
+ * @author Fabien Potencier
+ * @author Bernhard Schussek
+ * @author Jordan Alliot
+ */
+class ContainerAwareEventDispatcher extends EventDispatcher
+{
+ /**
+ * The container from where services are loaded
+ * @var ContainerInterface
+ */
+ private $container;
+
+ /**
+ * The service IDs of the event listeners and subscribers
+ * @var array
+ */
+ private $listenerIds = array();
+
+ /**
+ * The services registered as listeners
+ * @var array
+ */
+ private $listeners = array();
+
+ /**
+ * Constructor.
+ *
+ * @param ContainerInterface $container A ContainerInterface instance
+ */
+ public function __construct(ContainerInterface $container)
+ {
+ $this->container = $container;
+ }
+
+ /**
+ * Adds a service as event listener
+ *
+ * @param string $eventName Event for which the listener is added
+ * @param array $callback The service ID of the listener service & the method
+ * name that has to be called
+ * @param int $priority The higher this value, the earlier an event listener
+ * will be triggered in the chain.
+ * Defaults to 0.
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function addListenerService($eventName, $callback, $priority = 0)
+ {
+ if (!is_array($callback) || 2 !== count($callback)) {
+ throw new \InvalidArgumentException('Expected an array("service", "method") argument');
+ }
+
+ $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority);
+ }
+
+ public function removeListener($eventName, $listener)
+ {
+ $this->lazyLoad($eventName);
+
+ if (isset($this->listeners[$eventName])) {
+ foreach ($this->listeners[$eventName] as $key => $l) {
+ foreach ($this->listenerIds[$eventName] as $i => $args) {
+ list($serviceId, $method, $priority) = $args;
+ if ($key === $serviceId.'.'.$method) {
+ if ($listener === array($l, $method)) {
+ unset($this->listeners[$eventName][$key]);
+ if (empty($this->listeners[$eventName])) {
+ unset($this->listeners[$eventName]);
+ }
+ unset($this->listenerIds[$eventName][$i]);
+ if (empty($this->listenerIds[$eventName])) {
+ unset($this->listenerIds[$eventName]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ parent::removeListener($eventName, $listener);
+ }
+
+ /**
+ * @see EventDispatcherInterface::hasListeners
+ */
+ public function hasListeners($eventName = null)
+ {
+ if (null === $eventName) {
+ return (bool) count($this->listenerIds) || (bool) count($this->listeners);
+ }
+
+ if (isset($this->listenerIds[$eventName])) {
+ return true;
+ }
+
+ return parent::hasListeners($eventName);
+ }
+
+ /**
+ * @see EventDispatcherInterface::getListeners
+ */
+ public function getListeners($eventName = null)
+ {
+ if (null === $eventName) {
+ foreach (array_keys($this->listenerIds) as $serviceEventName) {
+ $this->lazyLoad($serviceEventName);
+ }
+ } else {
+ $this->lazyLoad($eventName);
+ }
+
+ return parent::getListeners($eventName);
+ }
+
+ /**
+ * Adds a service as event subscriber
+ *
+ * @param string $serviceId The service ID of the subscriber service
+ * @param string $class The service's class name (which must implement EventSubscriberInterface)
+ */
+ public function addSubscriberService($serviceId, $class)
+ {
+ foreach ($class::getSubscribedEvents() as $eventName => $params) {
+ if (is_string($params)) {
+ $this->listenerIds[$eventName][] = array($serviceId, $params, 0);
+ } elseif (is_string($params[0])) {
+ $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0);
+ } else {
+ foreach ($params as $listener) {
+ $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * Lazily loads listeners for this event from the dependency injection
+ * container.
+ *
+ * @throws \InvalidArgumentException if the service is not defined
+ */
+ public function dispatch($eventName, Event $event = null)
+ {
+ $this->lazyLoad($eventName);
+
+ return parent::dispatch($eventName, $event);
+ }
+
+ public function getContainer()
+ {
+ return $this->container;
+ }
+
+ /**
+ * Lazily loads listeners for this event from the dependency injection
+ * container.
+ *
+ * @param string $eventName The name of the event to dispatch. The name of
+ * the event is the name of the method that is
+ * invoked on listeners.
+ */
+ protected function lazyLoad($eventName)
+ {
+ if (isset($this->listenerIds[$eventName])) {
+ foreach ($this->listenerIds[$eventName] as $args) {
+ list($serviceId, $method, $priority) = $args;
+ $listener = $this->container->get($serviceId);
+
+ $key = $serviceId.'.'.$method;
+ if (!isset($this->listeners[$eventName][$key])) {
+ $this->addListener($eventName, array($listener, $method), $priority);
+ } elseif ($listener !== $this->listeners[$eventName][$key]) {
+ parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method));
+ $this->addListener($eventName, array($listener, $method), $priority);
+ }
+
+ $this->listeners[$eventName][$key] = $listener;
+ }
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
new file mode 100644
index 00000000..410226bb
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
@@ -0,0 +1,317 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Debug;
+
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\Stopwatch\Stopwatch;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Collects some data about event listeners.
+ *
+ * This event dispatcher delegates the dispatching to another one.
+ *
+ * @author Fabien Potencier
+ */
+class TraceableEventDispatcher implements TraceableEventDispatcherInterface
+{
+ protected $logger;
+ protected $stopwatch;
+
+ private $called;
+ private $dispatcher;
+
+ /**
+ * Constructor.
+ *
+ * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
+ * @param Stopwatch $stopwatch A Stopwatch instance
+ * @param LoggerInterface $logger A LoggerInterface instance
+ */
+ public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null)
+ {
+ $this->dispatcher = $dispatcher;
+ $this->stopwatch = $stopwatch;
+ $this->logger = $logger;
+ $this->called = array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addListener($eventName, $listener, $priority = 0)
+ {
+ $this->dispatcher->addListener($eventName, $listener, $priority);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addSubscriber(EventSubscriberInterface $subscriber)
+ {
+ $this->dispatcher->addSubscriber($subscriber);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function removeListener($eventName, $listener)
+ {
+ return $this->dispatcher->removeListener($eventName, $listener);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function removeSubscriber(EventSubscriberInterface $subscriber)
+ {
+ return $this->dispatcher->removeSubscriber($subscriber);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getListeners($eventName = null)
+ {
+ return $this->dispatcher->getListeners($eventName);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function hasListeners($eventName = null)
+ {
+ return $this->dispatcher->hasListeners($eventName);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function dispatch($eventName, Event $event = null)
+ {
+ if (null === $event) {
+ $event = new Event();
+ }
+
+ $this->preProcess($eventName);
+ $this->preDispatch($eventName, $event);
+
+ $e = $this->stopwatch->start($eventName, 'section');
+
+ $this->dispatcher->dispatch($eventName, $event);
+
+ if ($e->isStarted()) {
+ $e->stop();
+ }
+
+ $this->postDispatch($eventName, $event);
+ $this->postProcess($eventName);
+
+ return $event;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCalledListeners()
+ {
+ $called = array();
+ foreach ($this->called as $eventName => $listeners) {
+ foreach ($listeners as $listener) {
+ $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName);
+ $called[$eventName.'.'.$info['pretty']] = $info;
+ }
+ }
+
+ return $called;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getNotCalledListeners()
+ {
+ try {
+ $allListeners = $this->getListeners();
+ } catch (\Exception $e) {
+ if (null !== $this->logger) {
+ $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e));
+ }
+
+ // unable to retrieve the uncalled listeners
+ return array();
+ }
+
+ $notCalled = array();
+ foreach ($allListeners as $eventName => $listeners) {
+ foreach ($listeners as $listener) {
+ $called = false;
+ if (isset($this->called[$eventName])) {
+ foreach ($this->called[$eventName] as $l) {
+ if ($l->getWrappedListener() === $listener) {
+ $called = true;
+
+ break;
+ }
+ }
+ }
+
+ if (!$called) {
+ $info = $this->getListenerInfo($listener, $eventName);
+ $notCalled[$eventName.'.'.$info['pretty']] = $info;
+ }
+ }
+ }
+
+ return $notCalled;
+ }
+
+ /**
+ * Proxies all method calls to the original event dispatcher.
+ *
+ * @param string $method The method name
+ * @param array $arguments The method arguments
+ *
+ * @return mixed
+ */
+ public function __call($method, $arguments)
+ {
+ return call_user_func_array(array($this->dispatcher, $method), $arguments);
+ }
+
+ /**
+ * Called before dispatching the event.
+ *
+ * @param string $eventName The event name
+ * @param Event $event The event
+ */
+ protected function preDispatch($eventName, Event $event)
+ {
+ }
+
+ /**
+ * Called after dispatching the event.
+ *
+ * @param string $eventName The event name
+ * @param Event $event The event
+ */
+ protected function postDispatch($eventName, Event $event)
+ {
+ }
+
+ private function preProcess($eventName)
+ {
+ foreach ($this->dispatcher->getListeners($eventName) as $listener) {
+ $this->dispatcher->removeListener($eventName, $listener);
+ $info = $this->getListenerInfo($listener, $eventName);
+ $name = isset($info['class']) ? $info['class'] : $info['type'];
+ $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch));
+ }
+ }
+
+ private function postProcess($eventName)
+ {
+ $skipped = false;
+ foreach ($this->dispatcher->getListeners($eventName) as $listener) {
+ // Unwrap listener
+ $this->dispatcher->removeListener($eventName, $listener);
+ $this->dispatcher->addListener($eventName, $listener->getWrappedListener());
+
+ $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName);
+ if ($listener->wasCalled()) {
+ if (null !== $this->logger) {
+ $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty']));
+ }
+
+ if (!isset($this->called[$eventName])) {
+ $this->called[$eventName] = new \SplObjectStorage();
+ }
+
+ $this->called[$eventName]->attach($listener);
+ }
+
+ if (null !== $this->logger && $skipped) {
+ $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName));
+ }
+
+ if ($listener->stoppedPropagation()) {
+ if (null !== $this->logger) {
+ $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName));
+ }
+
+ $skipped = true;
+ }
+ }
+ }
+
+ /**
+ * Returns information about the listener
+ *
+ * @param object $listener The listener
+ * @param string $eventName The event name
+ *
+ * @return array Information about the listener
+ */
+ private function getListenerInfo($listener, $eventName)
+ {
+ $info = array(
+ 'event' => $eventName,
+ );
+ if ($listener instanceof \Closure) {
+ $info += array(
+ 'type' => 'Closure',
+ 'pretty' => 'closure'
+ );
+ } elseif (is_string($listener)) {
+ try {
+ $r = new \ReflectionFunction($listener);
+ $file = $r->getFileName();
+ $line = $r->getStartLine();
+ } catch (\ReflectionException $e) {
+ $file = null;
+ $line = null;
+ }
+ $info += array(
+ 'type' => 'Function',
+ 'function' => $listener,
+ 'file' => $file,
+ 'line' => $line,
+ 'pretty' => $listener,
+ );
+ } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) {
+ if (!is_array($listener)) {
+ $listener = array($listener, '__invoke');
+ }
+ $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0];
+ try {
+ $r = new \ReflectionMethod($class, $listener[1]);
+ $file = $r->getFileName();
+ $line = $r->getStartLine();
+ } catch (\ReflectionException $e) {
+ $file = null;
+ $line = null;
+ }
+ $info += array(
+ 'type' => 'Method',
+ 'class' => $class,
+ 'method' => $listener[1],
+ 'file' => $file,
+ 'line' => $line,
+ 'pretty' => $class.'::'.$listener[1],
+ );
+ }
+
+ return $info;
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php
new file mode 100644
index 00000000..5483e815
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php
@@ -0,0 +1,34 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Debug;
+
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+
+/**
+ * @author Fabien Potencier
+ */
+interface TraceableEventDispatcherInterface extends EventDispatcherInterface
+{
+ /**
+ * Gets the called listeners.
+ *
+ * @return array An array of called listeners
+ */
+ public function getCalledListeners();
+
+ /**
+ * Gets the not called listeners.
+ *
+ * @return array An array of not called listeners
+ */
+ public function getNotCalledListeners();
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php
new file mode 100644
index 00000000..c501662b
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php
@@ -0,0 +1,69 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Debug;
+
+use Symfony\Component\Stopwatch\Stopwatch;
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+
+/**
+ * @author Fabien Potencier
+ */
+class WrappedListener
+{
+ private $listener;
+ private $name;
+ private $called;
+ private $stoppedPropagation;
+ private $stopwatch;
+
+ public function __construct($listener, $name, Stopwatch $stopwatch)
+ {
+ $this->listener = $listener;
+ $this->name = $name;
+ $this->stopwatch = $stopwatch;
+ $this->called = false;
+ $this->stoppedPropagation = false;
+ }
+
+ public function getWrappedListener()
+ {
+ return $this->listener;
+ }
+
+ public function wasCalled()
+ {
+ return $this->called;
+ }
+
+ public function stoppedPropagation()
+ {
+ return $this->stoppedPropagation;
+ }
+
+ public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
+ {
+ $this->called = true;
+
+ $e = $this->stopwatch->start($this->name, 'event_listener');
+
+ call_user_func($this->listener, $event, $eventName, $dispatcher);
+
+ if ($e->isStarted()) {
+ $e->stop();
+ }
+
+ if ($event->isPropagationStopped()) {
+ $this->stoppedPropagation = true;
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
new file mode 100644
index 00000000..afe3ecd1
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
@@ -0,0 +1,106 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+/**
+ * Compiler pass to register tagged services for an event dispatcher.
+ */
+class RegisterListenersPass implements CompilerPassInterface
+{
+ /**
+ * @var string
+ */
+ protected $dispatcherService;
+
+ /**
+ * @var string
+ */
+ protected $listenerTag;
+
+ /**
+ * @var string
+ */
+ protected $subscriberTag;
+
+ /**
+ * Constructor.
+ *
+ * @param string $dispatcherService Service name of the event dispatcher in processed container
+ * @param string $listenerTag Tag name used for listener
+ * @param string $subscriberTag Tag name used for subscribers
+ */
+ public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber')
+ {
+ $this->dispatcherService = $dispatcherService;
+ $this->listenerTag = $listenerTag;
+ $this->subscriberTag = $subscriberTag;
+ }
+
+ public function process(ContainerBuilder $container)
+ {
+ if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) {
+ return;
+ }
+
+ $definition = $container->findDefinition($this->dispatcherService);
+
+ foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
+ $def = $container->getDefinition($id);
+ if (!$def->isPublic()) {
+ throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id));
+ }
+
+ if ($def->isAbstract()) {
+ throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id));
+ }
+
+ foreach ($events as $event) {
+ $priority = isset($event['priority']) ? $event['priority'] : 0;
+
+ if (!isset($event['event'])) {
+ throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag));
+ }
+
+ if (!isset($event['method'])) {
+ $event['method'] = 'on'.preg_replace_callback(array(
+ '/(?<=\b)[a-z]/i',
+ '/[^a-z0-9]/i',
+ ), function ($matches) { return strtoupper($matches[0]); }, $event['event']);
+ $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']);
+ }
+
+ $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority));
+ }
+ }
+
+ foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) {
+ $def = $container->getDefinition($id);
+ if (!$def->isPublic()) {
+ throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id));
+ }
+
+ // We must assume that the class value has been correctly filled, even if the service is created by a factory
+ $class = $def->getClass();
+
+ $refClass = new \ReflectionClass($class);
+ $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
+ if (!$refClass->implementsInterface($interface)) {
+ throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
+ }
+
+ $definition->addMethodCall('addSubscriberService', array($id, $class));
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php
new file mode 100644
index 00000000..bf792a25
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php
@@ -0,0 +1,129 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * Event is the base class for classes containing event data.
+ *
+ * This class contains no event data. It is used by events that do not pass
+ * state information to an event handler when an event is raised.
+ *
+ * You can call the method stopPropagation() to abort the execution of
+ * further listeners in your event listener.
+ *
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ * @author Bernhard Schussek
+ *
+ * @api
+ */
+class Event
+{
+ /**
+ * @var bool Whether no further event listeners should be triggered
+ */
+ private $propagationStopped = false;
+
+ /**
+ * @var EventDispatcher Dispatcher that dispatched this event
+ */
+ private $dispatcher;
+
+ /**
+ * @var string This event's name
+ */
+ private $name;
+
+ /**
+ * Returns whether further event listeners should be triggered.
+ *
+ * @see Event::stopPropagation
+ * @return bool Whether propagation was already stopped for this event.
+ *
+ * @api
+ */
+ public function isPropagationStopped()
+ {
+ return $this->propagationStopped;
+ }
+
+ /**
+ * Stops the propagation of the event to further event listeners.
+ *
+ * If multiple event listeners are connected to the same event, no
+ * further event listener will be triggered once any trigger calls
+ * stopPropagation().
+ *
+ * @api
+ */
+ public function stopPropagation()
+ {
+ $this->propagationStopped = true;
+ }
+
+ /**
+ * Stores the EventDispatcher that dispatches this Event
+ *
+ * @param EventDispatcherInterface $dispatcher
+ *
+ * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
+ *
+ * @api
+ */
+ public function setDispatcher(EventDispatcherInterface $dispatcher)
+ {
+ $this->dispatcher = $dispatcher;
+ }
+
+ /**
+ * Returns the EventDispatcher that dispatches this Event
+ *
+ * @return EventDispatcherInterface
+ *
+ * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
+ *
+ * @api
+ */
+ public function getDispatcher()
+ {
+ return $this->dispatcher;
+ }
+
+ /**
+ * Gets the event's name.
+ *
+ * @return string
+ *
+ * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
+ *
+ * @api
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets the event's name property.
+ *
+ * @param string $name The event name.
+ *
+ * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
+ *
+ * @api
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php
new file mode 100644
index 00000000..222a9371
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php
@@ -0,0 +1,185 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * The EventDispatcherInterface is the central point of Symfony's event listener system.
+ *
+ * Listeners are registered on the manager and events are dispatched through the
+ * manager.
+ *
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ * @author Bernhard Schussek
+ * @author Fabien Potencier
+ * @author Jordi Boggiano
+ * @author Jordan Alliot
+ *
+ * @api
+ */
+class EventDispatcher implements EventDispatcherInterface
+{
+ private $listeners = array();
+ private $sorted = array();
+
+ /**
+ * @see EventDispatcherInterface::dispatch
+ *
+ * @api
+ */
+ public function dispatch($eventName, Event $event = null)
+ {
+ if (null === $event) {
+ $event = new Event();
+ }
+
+ $event->setDispatcher($this);
+ $event->setName($eventName);
+
+ if (!isset($this->listeners[$eventName])) {
+ return $event;
+ }
+
+ $this->doDispatch($this->getListeners($eventName), $eventName, $event);
+
+ return $event;
+ }
+
+ /**
+ * @see EventDispatcherInterface::getListeners
+ */
+ public function getListeners($eventName = null)
+ {
+ if (null !== $eventName) {
+ if (!isset($this->sorted[$eventName])) {
+ $this->sortListeners($eventName);
+ }
+
+ return $this->sorted[$eventName];
+ }
+
+ foreach (array_keys($this->listeners) as $eventName) {
+ if (!isset($this->sorted[$eventName])) {
+ $this->sortListeners($eventName);
+ }
+ }
+
+ return array_filter($this->sorted);
+ }
+
+ /**
+ * @see EventDispatcherInterface::hasListeners
+ */
+ public function hasListeners($eventName = null)
+ {
+ return (bool) count($this->getListeners($eventName));
+ }
+
+ /**
+ * @see EventDispatcherInterface::addListener
+ *
+ * @api
+ */
+ public function addListener($eventName, $listener, $priority = 0)
+ {
+ $this->listeners[$eventName][$priority][] = $listener;
+ unset($this->sorted[$eventName]);
+ }
+
+ /**
+ * @see EventDispatcherInterface::removeListener
+ */
+ public function removeListener($eventName, $listener)
+ {
+ if (!isset($this->listeners[$eventName])) {
+ return;
+ }
+
+ foreach ($this->listeners[$eventName] as $priority => $listeners) {
+ if (false !== ($key = array_search($listener, $listeners, true))) {
+ unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]);
+ }
+ }
+ }
+
+ /**
+ * @see EventDispatcherInterface::addSubscriber
+ *
+ * @api
+ */
+ public function addSubscriber(EventSubscriberInterface $subscriber)
+ {
+ foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
+ if (is_string($params)) {
+ $this->addListener($eventName, array($subscriber, $params));
+ } elseif (is_string($params[0])) {
+ $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
+ } else {
+ foreach ($params as $listener) {
+ $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see EventDispatcherInterface::removeSubscriber
+ */
+ public function removeSubscriber(EventSubscriberInterface $subscriber)
+ {
+ foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
+ if (is_array($params) && is_array($params[0])) {
+ foreach ($params as $listener) {
+ $this->removeListener($eventName, array($subscriber, $listener[0]));
+ }
+ } else {
+ $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0]));
+ }
+ }
+ }
+
+ /**
+ * Triggers the listeners of an event.
+ *
+ * This method can be overridden to add functionality that is executed
+ * for each listener.
+ *
+ * @param callable[] $listeners The event listeners.
+ * @param string $eventName The name of the event to dispatch.
+ * @param Event $event The event object to pass to the event handlers/listeners.
+ */
+ protected function doDispatch($listeners, $eventName, Event $event)
+ {
+ foreach ($listeners as $listener) {
+ call_user_func($listener, $event, $eventName, $this);
+ if ($event->isPropagationStopped()) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Sorts the internal list of listeners for the given event by priority.
+ *
+ * @param string $eventName The name of the event.
+ */
+ private function sortListeners($eventName)
+ {
+ $this->sorted[$eventName] = array();
+
+ if (isset($this->listeners[$eventName])) {
+ krsort($this->listeners[$eventName]);
+ $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
new file mode 100644
index 00000000..3fdbfd88
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php
@@ -0,0 +1,96 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * The EventDispatcherInterface is the central point of Symfony's event listener system.
+ * Listeners are registered on the manager and events are dispatched through the
+ * manager.
+ *
+ * @author Bernhard Schussek
+ *
+ * @api
+ */
+interface EventDispatcherInterface
+{
+ /**
+ * Dispatches an event to all registered listeners.
+ *
+ * @param string $eventName The name of the event to dispatch. The name of
+ * the event is the name of the method that is
+ * invoked on listeners.
+ * @param Event $event The event to pass to the event handlers/listeners.
+ * If not supplied, an empty Event instance is created.
+ *
+ * @return Event
+ *
+ * @api
+ */
+ public function dispatch($eventName, Event $event = null);
+
+ /**
+ * Adds an event listener that listens on the specified events.
+ *
+ * @param string $eventName The event to listen on
+ * @param callable $listener The listener
+ * @param int $priority The higher this value, the earlier an event
+ * listener will be triggered in the chain (defaults to 0)
+ *
+ * @api
+ */
+ public function addListener($eventName, $listener, $priority = 0);
+
+ /**
+ * Adds an event subscriber.
+ *
+ * The subscriber is asked for all the events he is
+ * interested in and added as a listener for these events.
+ *
+ * @param EventSubscriberInterface $subscriber The subscriber.
+ *
+ * @api
+ */
+ public function addSubscriber(EventSubscriberInterface $subscriber);
+
+ /**
+ * Removes an event listener from the specified events.
+ *
+ * @param string|array $eventName The event(s) to remove a listener from
+ * @param callable $listener The listener to remove
+ */
+ public function removeListener($eventName, $listener);
+
+ /**
+ * Removes an event subscriber.
+ *
+ * @param EventSubscriberInterface $subscriber The subscriber
+ */
+ public function removeSubscriber(EventSubscriberInterface $subscriber);
+
+ /**
+ * Gets the listeners of a specific event or all listeners.
+ *
+ * @param string $eventName The name of the event
+ *
+ * @return array The event listeners for the specified event, or all event listeners by event name
+ */
+ public function getListeners($eventName = null);
+
+ /**
+ * Checks whether an event has any registered listeners.
+ *
+ * @param string $eventName The name of the event
+ *
+ * @return bool true if the specified event has any listeners, false otherwise
+ */
+ public function hasListeners($eventName = null);
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
new file mode 100644
index 00000000..080f892f
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php
@@ -0,0 +1,50 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * An EventSubscriber knows himself what events he is interested in.
+ * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
+ * {@link getSubscribedEvents} and registers the subscriber as a listener for all
+ * returned events.
+ *
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ * @author Bernhard Schussek
+ *
+ * @api
+ */
+interface EventSubscriberInterface
+{
+ /**
+ * Returns an array of event names this subscriber wants to listen to.
+ *
+ * The array keys are event names and the value can be:
+ *
+ * * The method name to call (priority defaults to 0)
+ * * An array composed of the method name to call and the priority
+ * * An array of arrays composed of the method names to call and respective
+ * priorities, or 0 if unset
+ *
+ * For instance:
+ *
+ * * array('eventName' => 'methodName')
+ * * array('eventName' => array('methodName', $priority))
+ * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
+ *
+ * @return array The event names to listen to
+ *
+ * @api
+ */
+ public static function getSubscribedEvents();
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php
new file mode 100644
index 00000000..1e8c44a6
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php
@@ -0,0 +1,186 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * Event encapsulation class.
+ *
+ * Encapsulates events thus decoupling the observer from the subject they encapsulate.
+ *
+ * @author Drak
+ */
+class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
+{
+ /**
+ * Event subject.
+ *
+ * @var mixed usually object or callable
+ */
+ protected $subject;
+
+ /**
+ * Array of arguments.
+ *
+ * @var array
+ */
+ protected $arguments;
+
+ /**
+ * Encapsulate an event with $subject and $args.
+ *
+ * @param mixed $subject The subject of the event, usually an object.
+ * @param array $arguments Arguments to store in the event.
+ */
+ public function __construct($subject = null, array $arguments = array())
+ {
+ $this->subject = $subject;
+ $this->arguments = $arguments;
+ }
+
+ /**
+ * Getter for subject property.
+ *
+ * @return mixed $subject The observer subject.
+ */
+ public function getSubject()
+ {
+ return $this->subject;
+ }
+
+ /**
+ * Get argument by key.
+ *
+ * @param string $key Key.
+ *
+ * @throws \InvalidArgumentException If key is not found.
+ *
+ * @return mixed Contents of array key.
+ */
+ public function getArgument($key)
+ {
+ if ($this->hasArgument($key)) {
+ return $this->arguments[$key];
+ }
+
+ throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
+ }
+
+ /**
+ * Add argument to event.
+ *
+ * @param string $key Argument name.
+ * @param mixed $value Value.
+ *
+ * @return GenericEvent
+ */
+ public function setArgument($key, $value)
+ {
+ $this->arguments[$key] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Getter for all arguments.
+ *
+ * @return array
+ */
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
+ /**
+ * Set args property.
+ *
+ * @param array $args Arguments.
+ *
+ * @return GenericEvent
+ */
+ public function setArguments(array $args = array())
+ {
+ $this->arguments = $args;
+
+ return $this;
+ }
+
+ /**
+ * Has argument.
+ *
+ * @param string $key Key of arguments array.
+ *
+ * @return bool
+ */
+ public function hasArgument($key)
+ {
+ return array_key_exists($key, $this->arguments);
+ }
+
+ /**
+ * ArrayAccess for argument getter.
+ *
+ * @param string $key Array key.
+ *
+ * @throws \InvalidArgumentException If key does not exist in $this->args.
+ *
+ * @return mixed
+ */
+ public function offsetGet($key)
+ {
+ return $this->getArgument($key);
+ }
+
+ /**
+ * ArrayAccess for argument setter.
+ *
+ * @param string $key Array key to set.
+ * @param mixed $value Value.
+ */
+ public function offsetSet($key, $value)
+ {
+ $this->setArgument($key, $value);
+ }
+
+ /**
+ * ArrayAccess for unset argument.
+ *
+ * @param string $key Array key.
+ */
+ public function offsetUnset($key)
+ {
+ if ($this->hasArgument($key)) {
+ unset($this->arguments[$key]);
+ }
+ }
+
+ /**
+ * ArrayAccess has argument.
+ *
+ * @param string $key Array key.
+ *
+ * @return bool
+ */
+ public function offsetExists($key)
+ {
+ return $this->hasArgument($key);
+ }
+
+ /**
+ * IteratorAggregate for iterating over the object like an array
+ *
+ * @return \ArrayIterator
+ */
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->arguments);
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
new file mode 100644
index 00000000..b70b81a8
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
@@ -0,0 +1,92 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher;
+
+/**
+ * A read-only proxy for an event dispatcher.
+ *
+ * @author Bernhard Schussek
+ */
+class ImmutableEventDispatcher implements EventDispatcherInterface
+{
+ /**
+ * The proxied dispatcher.
+ * @var EventDispatcherInterface
+ */
+ private $dispatcher;
+
+ /**
+ * Creates an unmodifiable proxy for an event dispatcher.
+ *
+ * @param EventDispatcherInterface $dispatcher The proxied event dispatcher.
+ */
+ public function __construct(EventDispatcherInterface $dispatcher)
+ {
+ $this->dispatcher = $dispatcher;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function dispatch($eventName, Event $event = null)
+ {
+ return $this->dispatcher->dispatch($eventName, $event);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addListener($eventName, $listener, $priority = 0)
+ {
+ throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addSubscriber(EventSubscriberInterface $subscriber)
+ {
+ throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function removeListener($eventName, $listener)
+ {
+ throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function removeSubscriber(EventSubscriberInterface $subscriber)
+ {
+ throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getListeners($eventName = null)
+ {
+ return $this->dispatcher->getListeners($eventName);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function hasListeners($eventName = null)
+ {
+ return $this->dispatcher->hasListeners($eventName);
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE
new file mode 100644
index 00000000..0b3292cf
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2004-2014 Fabien Potencier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md
new file mode 100644
index 00000000..22bf74fd
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md
@@ -0,0 +1,25 @@
+EventDispatcher Component
+=========================
+
+The Symfony2 EventDispatcher component implements the Mediator pattern in a
+simple and effective way to make your projects truly extensible.
+
+ use Symfony\Component\EventDispatcher\EventDispatcher;
+ use Symfony\Component\EventDispatcher\Event;
+
+ $dispatcher = new EventDispatcher();
+
+ $dispatcher->addListener('event_name', function (Event $event) {
+ // ...
+ });
+
+ $dispatcher->dispatch('event_name');
+
+Resources
+---------
+
+You can run the unit tests with the following command:
+
+ $ cd path/to/Symfony/Component/EventDispatcher/
+ $ composer.phar install
+ $ phpunit
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
new file mode 100644
index 00000000..fb3b4caa
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
@@ -0,0 +1,244 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests;
+
+use Symfony\Component\DependencyInjection\Container;
+use Symfony\Component\DependencyInjection\Scope;
+use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class ContainerAwareEventDispatcherTest extends \PHPUnit_Framework_TestCase
+{
+ public function testAddAListenerService()
+ {
+ $event = new Event();
+
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $service
+ ->expects($this->once())
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $dispatcher->dispatch('onEvent', $event);
+ }
+
+ public function testAddASubscriberService()
+ {
+ $event = new Event();
+
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
+
+ $service
+ ->expects($this->once())
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $container = new Container();
+ $container->set('service.subscriber', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');
+
+ $dispatcher->dispatch('onEvent', $event);
+ }
+
+ public function testPreventDuplicateListenerService()
+ {
+ $event = new Event();
+
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $service
+ ->expects($this->once())
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10);
+
+ $dispatcher->dispatch('onEvent', $event);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testTriggerAListenerServiceOutOfScope()
+ {
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $scope = new Scope('scope');
+ $container = new Container();
+ $container->addScope($scope);
+ $container->enterScope('scope');
+
+ $container->set('service.listener', $service, 'scope');
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $container->leaveScope('scope');
+ $dispatcher->dispatch('onEvent');
+ }
+
+ public function testReEnteringAScope()
+ {
+ $event = new Event();
+
+ $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $service1
+ ->expects($this->exactly(2))
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $scope = new Scope('scope');
+ $container = new Container();
+ $container->addScope($scope);
+ $container->enterScope('scope');
+
+ $container->set('service.listener', $service1, 'scope');
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+ $dispatcher->dispatch('onEvent', $event);
+
+ $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $service2
+ ->expects($this->once())
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $container->enterScope('scope');
+ $container->set('service.listener', $service2, 'scope');
+
+ $dispatcher->dispatch('onEvent', $event);
+
+ $container->leaveScope('scope');
+
+ $dispatcher->dispatch('onEvent');
+ }
+
+ public function testHasListenersOnLazyLoad()
+ {
+ $event = new Event();
+
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $event->setDispatcher($dispatcher);
+ $event->setName('onEvent');
+
+ $service
+ ->expects($this->once())
+ ->method('onEvent')
+ ->with($event)
+ ;
+
+ $this->assertTrue($dispatcher->hasListeners());
+
+ if ($dispatcher->hasListeners('onEvent')) {
+ $dispatcher->dispatch('onEvent');
+ }
+ }
+
+ public function testGetListenersOnLazyLoad()
+ {
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $listeners = $dispatcher->getListeners();
+
+ $this->assertTrue(isset($listeners['onEvent']));
+
+ $this->assertCount(1, $dispatcher->getListeners('onEvent'));
+ }
+
+ public function testRemoveAfterDispatch()
+ {
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $dispatcher->dispatch('onEvent', new Event());
+ $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
+ $this->assertFalse($dispatcher->hasListeners('onEvent'));
+ }
+
+ public function testRemoveBeforeDispatch()
+ {
+ $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
+
+ $container = new Container();
+ $container->set('service.listener', $service);
+
+ $dispatcher = new ContainerAwareEventDispatcher($container);
+ $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
+
+ $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
+ $this->assertFalse($dispatcher->hasListeners('onEvent'));
+ }
+}
+
+class Service
+{
+ public function onEvent(Event $e)
+ {
+ }
+}
+
+class SubscriberService implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array(
+ 'onEvent' => 'onEvent',
+ 'onEvent' => array('onEvent', 10),
+ 'onEvent' => array('onEvent'),
+ );
+ }
+
+ public function onEvent(Event $e)
+ {
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
new file mode 100644
index 00000000..8ccfabb1
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php
@@ -0,0 +1,171 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests\Debug;
+
+use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\Stopwatch\Stopwatch;
+
+class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
+{
+ public function testAddRemoveListener()
+ {
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+
+ $tdispatcher->addListener('foo', $listener = function () { ; });
+ $listeners = $dispatcher->getListeners('foo');
+ $this->assertCount(1, $listeners);
+ $this->assertSame($listener, $listeners[0]);
+
+ $tdispatcher->removeListener('foo', $listener);
+ $this->assertCount(0, $dispatcher->getListeners('foo'));
+ }
+
+ public function testGetListeners()
+ {
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+
+ $tdispatcher->addListener('foo', $listener = function () { ; });
+ $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo'));
+ }
+
+ public function testHasListeners()
+ {
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+
+ $this->assertFalse($dispatcher->hasListeners('foo'));
+ $this->assertFalse($tdispatcher->hasListeners('foo'));
+
+ $tdispatcher->addListener('foo', $listener = function () { ; });
+ $this->assertTrue($dispatcher->hasListeners('foo'));
+ $this->assertTrue($tdispatcher->hasListeners('foo'));
+ }
+
+ public function testAddRemoveSubscriber()
+ {
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+
+ $subscriber = new EventSubscriber();
+
+ $tdispatcher->addSubscriber($subscriber);
+ $listeners = $dispatcher->getListeners('foo');
+ $this->assertCount(1, $listeners);
+ $this->assertSame(array($subscriber, 'call'), $listeners[0]);
+
+ $tdispatcher->removeSubscriber($subscriber);
+ $this->assertCount(0, $dispatcher->getListeners('foo'));
+ }
+
+ public function testGetCalledListeners()
+ {
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+ $tdispatcher->addListener('foo', $listener = function () { ; });
+
+ $this->assertEquals(array(), $tdispatcher->getCalledListeners());
+ $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners());
+
+ $tdispatcher->dispatch('foo');
+
+ $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getCalledListeners());
+ $this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
+ }
+
+ public function testLogger()
+ {
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
+
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
+ $tdispatcher->addListener('foo', $listener1 = function () { ; });
+ $tdispatcher->addListener('foo', $listener2 = function () { ; });
+
+ $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
+ $logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
+
+ $tdispatcher->dispatch('foo');
+ }
+
+ public function testLoggerWithStoppedEvent()
+ {
+ $logger = $this->getMock('Psr\Log\LoggerInterface');
+
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
+ $tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); });
+ $tdispatcher->addListener('foo', $listener2 = function () { ; });
+
+ $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\".");
+ $logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\".");
+ $logger->expects($this->at(2))->method('debug')->with("Listener \"closure\" was not called for event \"foo\".");
+
+ $tdispatcher->dispatch('foo');
+ }
+
+ public function testDispatchCallListeners()
+ {
+ $called = array();
+
+ $dispatcher = new EventDispatcher();
+ $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
+ $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; });
+ $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; });
+
+ $tdispatcher->dispatch('foo');
+
+ $this->assertEquals(array('foo1', 'foo2'), $called);
+ }
+
+ public function testDispatchNested()
+ {
+ $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
+ $loop = 1;
+ $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) {
+ ++$loop;
+ if (2 == $loop) {
+ $dispatcher->dispatch('foo');
+ }
+ });
+
+ $dispatcher->dispatch('foo');
+ }
+
+ public function testDispatchReusedEventNested()
+ {
+ $nestedCall = false;
+ $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
+ $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) {
+ $dispatcher->dispatch('bar', $e);
+ });
+ $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) {
+ $nestedCall = true;
+ });
+
+ $this->assertFalse($nestedCall);
+ $dispatcher->dispatch('foo');
+ $this->assertTrue($nestedCall);
+ }
+}
+
+class EventSubscriber implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array('foo' => 'call');
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
new file mode 100644
index 00000000..5959db0d
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
@@ -0,0 +1,140 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
+
+class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * Tests that event subscribers not implementing EventSubscriberInterface
+ * trigger an exception.
+ *
+ * @expectedException \InvalidArgumentException
+ */
+ public function testEventSubscriberWithoutInterface()
+ {
+ // one service, not implementing any interface
+ $services = array(
+ 'my_event_subscriber' => array(0 => array()),
+ );
+
+ $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition->expects($this->atLeastOnce())
+ ->method('isPublic')
+ ->will($this->returnValue(true));
+ $definition->expects($this->atLeastOnce())
+ ->method('getClass')
+ ->will($this->returnValue('stdClass'));
+
+ $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $builder->expects($this->any())
+ ->method('hasDefinition')
+ ->will($this->returnValue(true));
+
+ // We don't test kernel.event_listener here
+ $builder->expects($this->atLeastOnce())
+ ->method('findTaggedServiceIds')
+ ->will($this->onConsecutiveCalls(array(), $services));
+
+ $builder->expects($this->atLeastOnce())
+ ->method('getDefinition')
+ ->will($this->returnValue($definition));
+
+ $registerListenersPass = new RegisterListenersPass();
+ $registerListenersPass->process($builder);
+ }
+
+ public function testValidEventSubscriber()
+ {
+ $services = array(
+ 'my_event_subscriber' => array(0 => array()),
+ );
+
+ $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
+ $definition->expects($this->atLeastOnce())
+ ->method('isPublic')
+ ->will($this->returnValue(true));
+ $definition->expects($this->atLeastOnce())
+ ->method('getClass')
+ ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'));
+
+ $builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
+ $builder->expects($this->any())
+ ->method('hasDefinition')
+ ->will($this->returnValue(true));
+
+ // We don't test kernel.event_listener here
+ $builder->expects($this->atLeastOnce())
+ ->method('findTaggedServiceIds')
+ ->will($this->onConsecutiveCalls(array(), $services));
+
+ $builder->expects($this->atLeastOnce())
+ ->method('getDefinition')
+ ->will($this->returnValue($definition));
+
+ $builder->expects($this->atLeastOnce())
+ ->method('findDefinition')
+ ->will($this->returnValue($definition));
+
+ $registerListenersPass = new RegisterListenersPass();
+ $registerListenersPass->process($builder);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The service "foo" must be public as event listeners are lazy-loaded.
+ */
+ public function testPrivateEventListener()
+ {
+ $container = new ContainerBuilder();
+ $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_listener', array());
+ $container->register('event_dispatcher', 'stdClass');
+
+ $registerListenersPass = new RegisterListenersPass();
+ $registerListenersPass->process($container);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The service "foo" must be public as event subscribers are lazy-loaded.
+ */
+ public function testPrivateEventSubscriber()
+ {
+ $container = new ContainerBuilder();
+ $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_subscriber', array());
+ $container->register('event_dispatcher', 'stdClass');
+
+ $registerListenersPass = new RegisterListenersPass();
+ $registerListenersPass->process($container);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded.
+ */
+ public function testAbstractEventListener()
+ {
+ $container = new ContainerBuilder();
+ $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array());
+ $container->register('event_dispatcher', 'stdClass');
+
+ $registerListenersPass = new RegisterListenersPass();
+ $registerListenersPass->process($container);
+ }
+}
+
+class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
+{
+ public static function getSubscribedEvents() {}
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
new file mode 100644
index 00000000..efc0c29f
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
@@ -0,0 +1,368 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests;
+
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class EventDispatcherTest extends \PHPUnit_Framework_TestCase
+{
+ /* Some pseudo events */
+ const preFoo = 'pre.foo';
+ const postFoo = 'post.foo';
+ const preBar = 'pre.bar';
+ const postBar = 'post.bar';
+
+ /**
+ * @var EventDispatcher
+ */
+ private $dispatcher;
+
+ private $listener;
+
+ protected function setUp()
+ {
+ $this->dispatcher = new EventDispatcher();
+ $this->listener = new TestEventListener();
+ }
+
+ protected function tearDown()
+ {
+ $this->dispatcher = null;
+ $this->listener = null;
+ }
+
+ public function testInitialState()
+ {
+ $this->assertEquals(array(), $this->dispatcher->getListeners());
+ $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
+ }
+
+ public function testAddListener()
+ {
+ $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
+ $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
+ $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
+ $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo));
+ $this->assertCount(2, $this->dispatcher->getListeners());
+ }
+
+ public function testGetListenersSortsByPriority()
+ {
+ $listener1 = new TestEventListener();
+ $listener2 = new TestEventListener();
+ $listener3 = new TestEventListener();
+ $listener1->name = '1';
+ $listener2->name = '2';
+ $listener3->name = '3';
+
+ $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10);
+ $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10);
+ $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo'));
+
+ $expected = array(
+ array($listener2, 'preFoo'),
+ array($listener3, 'preFoo'),
+ array($listener1, 'preFoo'),
+ );
+
+ $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
+ }
+
+ public function testGetAllListenersSortsByPriority()
+ {
+ $listener1 = new TestEventListener();
+ $listener2 = new TestEventListener();
+ $listener3 = new TestEventListener();
+ $listener4 = new TestEventListener();
+ $listener5 = new TestEventListener();
+ $listener6 = new TestEventListener();
+
+ $this->dispatcher->addListener('pre.foo', $listener1, -10);
+ $this->dispatcher->addListener('pre.foo', $listener2);
+ $this->dispatcher->addListener('pre.foo', $listener3, 10);
+ $this->dispatcher->addListener('post.foo', $listener4, -10);
+ $this->dispatcher->addListener('post.foo', $listener5);
+ $this->dispatcher->addListener('post.foo', $listener6, 10);
+
+ $expected = array(
+ 'pre.foo' => array($listener3, $listener2, $listener1),
+ 'post.foo' => array($listener6, $listener5, $listener4),
+ );
+
+ $this->assertSame($expected, $this->dispatcher->getListeners());
+ }
+
+ public function testDispatch()
+ {
+ $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
+ $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
+ $this->dispatcher->dispatch(self::preFoo);
+ $this->assertTrue($this->listener->preFooInvoked);
+ $this->assertFalse($this->listener->postFooInvoked);
+ $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent'));
+ $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
+ $event = new Event();
+ $return = $this->dispatcher->dispatch(self::preFoo, $event);
+ $this->assertEquals('pre.foo', $event->getName());
+ $this->assertSame($event, $return);
+ }
+
+ public function testDispatchForClosure()
+ {
+ $invoked = 0;
+ $listener = function () use (&$invoked) {
+ $invoked++;
+ };
+ $this->dispatcher->addListener('pre.foo', $listener);
+ $this->dispatcher->addListener('post.foo', $listener);
+ $this->dispatcher->dispatch(self::preFoo);
+ $this->assertEquals(1, $invoked);
+ }
+
+ public function testStopEventPropagation()
+ {
+ $otherListener = new TestEventListener();
+
+ // postFoo() stops the propagation, so only one listener should
+ // be executed
+ // Manually set priority to enforce $this->listener to be called first
+ $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10);
+ $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo'));
+ $this->dispatcher->dispatch(self::postFoo);
+ $this->assertTrue($this->listener->postFooInvoked);
+ $this->assertFalse($otherListener->postFooInvoked);
+ }
+
+ public function testDispatchByPriority()
+ {
+ $invoked = array();
+ $listener1 = function () use (&$invoked) {
+ $invoked[] = '1';
+ };
+ $listener2 = function () use (&$invoked) {
+ $invoked[] = '2';
+ };
+ $listener3 = function () use (&$invoked) {
+ $invoked[] = '3';
+ };
+ $this->dispatcher->addListener('pre.foo', $listener1, -10);
+ $this->dispatcher->addListener('pre.foo', $listener2);
+ $this->dispatcher->addListener('pre.foo', $listener3, 10);
+ $this->dispatcher->dispatch(self::preFoo);
+ $this->assertEquals(array('3', '2', '1'), $invoked);
+ }
+
+ public function testRemoveListener()
+ {
+ $this->dispatcher->addListener('pre.bar', $this->listener);
+ $this->assertTrue($this->dispatcher->hasListeners(self::preBar));
+ $this->dispatcher->removeListener('pre.bar', $this->listener);
+ $this->assertFalse($this->dispatcher->hasListeners(self::preBar));
+ $this->dispatcher->removeListener('notExists', $this->listener);
+ }
+
+ public function testAddSubscriber()
+ {
+ $eventSubscriber = new TestEventSubscriber();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
+ }
+
+ public function testAddSubscriberWithPriorities()
+ {
+ $eventSubscriber = new TestEventSubscriber();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+
+ $eventSubscriber = new TestEventSubscriberWithPriorities();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+
+ $listeners = $this->dispatcher->getListeners('pre.foo');
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertCount(2, $listeners);
+ $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
+ }
+
+ public function testAddSubscriberWithMultipleListeners()
+ {
+ $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+
+ $listeners = $this->dispatcher->getListeners('pre.foo');
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertCount(2, $listeners);
+ $this->assertEquals('preFoo2', $listeners[0][1]);
+ }
+
+ public function testRemoveSubscriber()
+ {
+ $eventSubscriber = new TestEventSubscriber();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
+ $this->dispatcher->removeSubscriber($eventSubscriber);
+ $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertFalse($this->dispatcher->hasListeners(self::postFoo));
+ }
+
+ public function testRemoveSubscriberWithPriorities()
+ {
+ $eventSubscriber = new TestEventSubscriberWithPriorities();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->dispatcher->removeSubscriber($eventSubscriber);
+ $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
+ }
+
+ public function testRemoveSubscriberWithMultipleListeners()
+ {
+ $eventSubscriber = new TestEventSubscriberWithMultipleListeners();
+ $this->dispatcher->addSubscriber($eventSubscriber);
+ $this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
+ $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo));
+ $this->dispatcher->removeSubscriber($eventSubscriber);
+ $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
+ }
+
+ public function testEventReceivesTheDispatcherInstance()
+ {
+ $dispatcher = null;
+ $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
+ $dispatcher = $event->getDispatcher();
+ });
+ $this->dispatcher->dispatch('test');
+ $this->assertSame($this->dispatcher, $dispatcher);
+ }
+
+ public function testEventReceivesTheDispatcherInstanceAsArgument()
+ {
+ $listener = new TestWithDispatcher();
+ $this->dispatcher->addListener('test', array($listener, 'foo'));
+ $this->assertNull($listener->name);
+ $this->assertNull($listener->dispatcher);
+ $this->dispatcher->dispatch('test');
+ $this->assertEquals('test', $listener->name);
+ $this->assertSame($this->dispatcher, $listener->dispatcher);
+ }
+
+ /**
+ * @see https://bugs.php.net/bug.php?id=62976
+ *
+ * This bug affects:
+ * - The PHP 5.3 branch for versions < 5.3.18
+ * - The PHP 5.4 branch for versions < 5.4.8
+ * - The PHP 5.5 branch is not affected
+ */
+ public function testWorkaroundForPhpBug62976()
+ {
+ $dispatcher = new EventDispatcher();
+ $dispatcher->addListener('bug.62976', new CallableClass());
+ $dispatcher->removeListener('bug.62976', function () {});
+ $this->assertTrue($dispatcher->hasListeners('bug.62976'));
+ }
+
+ public function testHasListenersWhenAddedCallbackListenerIsRemoved()
+ {
+ $listener = function () {};
+ $this->dispatcher->addListener('foo', $listener);
+ $this->dispatcher->removeListener('foo', $listener);
+ $this->assertFalse($this->dispatcher->hasListeners());
+ }
+
+ public function testGetListenersWhenAddedCallbackListenerIsRemoved()
+ {
+ $listener = function () {};
+ $this->dispatcher->addListener('foo', $listener);
+ $this->dispatcher->removeListener('foo', $listener);
+ $this->assertSame(array(), $this->dispatcher->getListeners());
+ }
+
+ public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled()
+ {
+ $this->assertFalse($this->dispatcher->hasListeners('foo'));
+ $this->assertFalse($this->dispatcher->hasListeners());
+ }
+}
+
+class CallableClass
+{
+ public function __invoke()
+ {
+ }
+}
+
+class TestEventListener
+{
+ public $preFooInvoked = false;
+ public $postFooInvoked = false;
+
+ /* Listener methods */
+
+ public function preFoo(Event $e)
+ {
+ $this->preFooInvoked = true;
+ }
+
+ public function postFoo(Event $e)
+ {
+ $this->postFooInvoked = true;
+
+ $e->stopPropagation();
+ }
+}
+
+class TestWithDispatcher
+{
+ public $name;
+ public $dispatcher;
+
+ public function foo(Event $e, $name, $dispatcher)
+ {
+ $this->name = $name;
+ $this->dispatcher = $dispatcher;
+ }
+}
+
+class TestEventSubscriber implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo');
+ }
+}
+
+class TestEventSubscriberWithPriorities implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array(
+ 'pre.foo' => array('preFoo', 10),
+ 'post.foo' => array('postFoo'),
+ );
+ }
+}
+
+class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array('pre.foo' => array(
+ array('preFoo1'),
+ array('preFoo2', 10)
+ ));
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
new file mode 100644
index 00000000..7a20fe6b
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php
@@ -0,0 +1,84 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests;
+
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+
+/**
+ * Test class for Event.
+ */
+class EventTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var \Symfony\Component\EventDispatcher\Event
+ */
+ protected $event;
+
+ /**
+ * @var \Symfony\Component\EventDispatcher\EventDispatcher
+ */
+ protected $dispatcher;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->event = new Event();
+ $this->dispatcher = new EventDispatcher();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ $this->event = null;
+ $this->dispatcher = null;
+ }
+
+ public function testIsPropagationStopped()
+ {
+ $this->assertFalse($this->event->isPropagationStopped());
+ }
+
+ public function testStopPropagationAndIsPropagationStopped()
+ {
+ $this->event->stopPropagation();
+ $this->assertTrue($this->event->isPropagationStopped());
+ }
+
+ public function testSetDispatcher()
+ {
+ $this->event->setDispatcher($this->dispatcher);
+ $this->assertSame($this->dispatcher, $this->event->getDispatcher());
+ }
+
+ public function testGetDispatcher()
+ {
+ $this->assertNull($this->event->getDispatcher());
+ }
+
+ public function testGetName()
+ {
+ $this->assertNull($this->event->getName());
+ }
+
+ public function testSetName()
+ {
+ $this->event->setName('foo');
+ $this->assertEquals('foo', $this->event->getName());
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
new file mode 100644
index 00000000..5dfda92f
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
@@ -0,0 +1,140 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests;
+
+use Symfony\Component\EventDispatcher\GenericEvent;
+
+/**
+ * Test class for Event.
+ */
+class GenericEventTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var GenericEvent
+ */
+ private $event;
+
+ private $subject;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->subject = new \stdClass();
+ $this->event = new GenericEvent($this->subject, array('name' => 'Event'));
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->subject = null;
+ $this->event = null;
+
+ parent::tearDown();
+ }
+
+ public function testConstruct()
+ {
+ $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event')));
+ }
+
+ /**
+ * Tests Event->getArgs()
+ */
+ public function testGetArguments()
+ {
+ // test getting all
+ $this->assertSame(array('name' => 'Event'), $this->event->getArguments());
+ }
+
+ public function testSetArguments()
+ {
+ $result = $this->event->setArguments(array('foo' => 'bar'));
+ $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event);
+ $this->assertSame($this->event, $result);
+ }
+
+ public function testSetArgument()
+ {
+ $result = $this->event->setArgument('foo2', 'bar2');
+ $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
+ $this->assertEquals($this->event, $result);
+ }
+
+ public function testGetArgument()
+ {
+ // test getting key
+ $this->assertEquals('Event', $this->event->getArgument('name'));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testGetArgException()
+ {
+ $this->event->getArgument('nameNotExist');
+ }
+
+ public function testOffsetGet()
+ {
+ // test getting key
+ $this->assertEquals('Event', $this->event['name']);
+
+ // test getting invalid arg
+ $this->setExpectedException('InvalidArgumentException');
+ $this->assertFalse($this->event['nameNotExist']);
+ }
+
+ public function testOffsetSet()
+ {
+ $this->event['foo2'] = 'bar2';
+ $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event);
+ }
+
+ public function testOffsetUnset()
+ {
+ unset($this->event['name']);
+ $this->assertAttributeSame(array(), 'arguments', $this->event);
+ }
+
+ public function testOffsetIsset()
+ {
+ $this->assertTrue(isset($this->event['name']));
+ $this->assertFalse(isset($this->event['nameNotExist']));
+ }
+
+ public function testHasArgument()
+ {
+ $this->assertTrue($this->event->hasArgument('name'));
+ $this->assertFalse($this->event->hasArgument('nameNotExist'));
+ }
+
+ public function testGetSubject()
+ {
+ $this->assertSame($this->subject, $this->event->getSubject());
+ }
+
+ public function testHasIterator()
+ {
+ $data = array();
+ foreach ($this->event as $key => $value) {
+ $data[$key] = $value;
+ }
+ $this->assertEquals(array('name' => 'Event'), $data);
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
new file mode 100644
index 00000000..80a7e43b
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -0,0 +1,105 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\EventDispatcher\Tests;
+
+use Symfony\Component\EventDispatcher\Event;
+use Symfony\Component\EventDispatcher\ImmutableEventDispatcher;
+
+/**
+ * @author Bernhard Schussek
+ */
+class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $innerDispatcher;
+
+ /**
+ * @var ImmutableEventDispatcher
+ */
+ private $dispatcher;
+
+ protected function setUp()
+ {
+ $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+ $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
+ }
+
+ public function testDispatchDelegates()
+ {
+ $event = new Event();
+
+ $this->innerDispatcher->expects($this->once())
+ ->method('dispatch')
+ ->with('event', $event)
+ ->will($this->returnValue('result'));
+
+ $this->assertSame('result', $this->dispatcher->dispatch('event', $event));
+ }
+
+ public function testGetListenersDelegates()
+ {
+ $this->innerDispatcher->expects($this->once())
+ ->method('getListeners')
+ ->with('event')
+ ->will($this->returnValue('result'));
+
+ $this->assertSame('result', $this->dispatcher->getListeners('event'));
+ }
+
+ public function testHasListenersDelegates()
+ {
+ $this->innerDispatcher->expects($this->once())
+ ->method('hasListeners')
+ ->with('event')
+ ->will($this->returnValue('result'));
+
+ $this->assertSame('result', $this->dispatcher->hasListeners('event'));
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testAddListenerDisallowed()
+ {
+ $this->dispatcher->addListener('event', function () { return 'foo'; });
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testAddSubscriberDisallowed()
+ {
+ $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
+
+ $this->dispatcher->addSubscriber($subscriber);
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testRemoveListenerDisallowed()
+ {
+ $this->dispatcher->removeListener('event', function () { return 'foo'; });
+ }
+
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testRemoveSubscriberDisallowed()
+ {
+ $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
+
+ $this->dispatcher->removeSubscriber($subscriber);
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json
new file mode 100644
index 00000000..3715ece3
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json
@@ -0,0 +1,41 @@
+{
+ "name": "symfony/event-dispatcher",
+ "type": "library",
+ "description": "Symfony EventDispatcher Component",
+ "keywords": [],
+ "homepage": "http://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/dependency-injection": "~2.0",
+ "symfony/config": "~2.0",
+ "symfony/stopwatch": "~2.2",
+ "psr/log": "~1.0"
+ },
+ "suggest": {
+ "symfony/dependency-injection": "",
+ "symfony/http-kernel": ""
+ },
+ "autoload": {
+ "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" }
+ },
+ "target-dir": "Symfony/Component/EventDispatcher",
+ "minimum-stability": "dev",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev"
+ }
+ }
+}
diff --git a/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist
new file mode 100644
index 00000000..cca1259b
--- /dev/null
+++ b/src/lib/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist
@@ -0,0 +1,25 @@
+
+
+
+
+
+ ./Tests/
+
+
+
+
+
+ ./
+
+ ./Resources
+ ./Tests
+ ./vendor
+
+
+
+
diff --git a/src/skin/frontend/base/default/css/smile/elasticsearch.css b/src/skin/frontend/base/default/css/smile/elasticsearch.css
new file mode 100644
index 00000000..92300c02
--- /dev/null
+++ b/src/skin/frontend/base/default/css/smile/elasticsearch.css
@@ -0,0 +1,40 @@
+/**
+ * ElasticSearch stylesheet
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Smile Searchandising Suite to newer
+ * versions in the future.
+ *
+ * @category Smile
+ * @package Smile_ElasticSearch
+ * @author Aurelien FOUCRET
+ * @copyright 2013 Smile
+ * @license Apache License Version 2.0
+ */
+
+/* Autocomplete styles */
+#search_autocomplete dl { background: #FFF; border: 1px solid #999; overflow: hidden; width: 100%; }
+#search_autocomplete dl dt { background: #d12c01; color: #FFF; font-weight: bold; padding: 3px 3px; font-size: 110%; }
+#search_autocomplete dl dd { background: #FFF; cursor: pointer; padding: 3px 5px; font-size: 110%; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
+#search_autocomplete dl dd.selected { background: rgb(253, 233, 229); }
+
+/* Price slider styles */
+.range-slider { padding: 5px 0 0; }
+.range-slider .slider-bkg { margin:10px 0; background-color:#ccc; height:5px; position: relative; background: #BAA; cursor : pointer; }
+.range-slider .handle { margin:-6px 0 0; width:10px; height:8px; background-color:#3399cc; cursor:move; position: absolute; }
+.range-slider .handle:after { content: "-"; color: transparent; width: 0; height: 0; border-top: 8px solid #3399cc; border-left: 5px solid transparent; position: absolute; margin: 8px 0 0; border-right: 5px solid transparent; }
+.range-slider .handle.min { margin-left: -4px; }
+.range-slider .handle.max { margin-left: 4px; }
+.range-slider .limits-container { margin: 0 0 0; }
+.range-slider .validate-button { float: right; }
+.range-slider .limits.min { float:left; margin-left: -5px; }
+.range-slider .limits.max { float:right; margin-left: 5px; }
+.range-slider .clear {clear: both;}
+.range-slider .count.empty { line-height: 10px; color: #AA0000; margin: 0; text-align: center; }
+.range-slider .count { line-height: 20px; margin: 0 50px 0 0; text-align: left; display: block; }
+
+#narrow-by-list .ratings { display: inline-block; margin: 0; }
+#narrow-by-list .ratings .rating-box { margin: 0; }
+
+.block-layered-nav dl dd ol > li > span, .block-layered-nav dl dd ol > li > a { display: inline-block; }
\ No newline at end of file