JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrPKZj_nyydebugbar/composer.jsonnu[{ "name": "maximebf/debugbar", "description": "Debug bar in the browser for php application", "keywords": ["debug", "debugbar"], "homepage": "https://github.com/maximebf/php-debugbar", "type": "library", "license": "MIT", "authors": [ { "name": "Maxime Bouroumeau-Fuseau", "email": "maxime.bouroumeau@gmail.com", "homepage": "http://maximebf.com" }, { "name": "Barry vd. Heuvel", "email": "barryvdh@gmail.com" } ], "require": { "php": "^7.1|^8", "psr/log": "^1|^2|^3", "symfony/var-dumper": "^4|^5|^6" }, "require-dev": { "phpunit/phpunit": ">=7.5.20 <10.0", "twig/twig": "^1.38|^2.7|^3.0" }, "autoload": { "psr-4": { "DebugBar\\": "src/DebugBar/" } }, "suggest": { "kriswallsmith/assetic": "The best way to manage assets", "monolog/monolog": "Log using Monolog", "predis/predis": "Redis storage" }, "extra": { "branch-alias": { "dev-master": "1.18-dev" } } } PKZp<8 8 %debugbar/src/DebugBar/OpenHandler.phpnu[isDataPersisted()) { throw new DebugBarException("DebugBar must have a storage backend to use OpenHandler"); } $this->debugBar = $debugBar; } /** * Handles the current request * * @param array $request Request data * @param bool $echo * @param bool $sendHeader * @return string * @throws DebugBarException */ public function handle($request = null, $echo = true, $sendHeader = true) { if ($request === null) { $request = $_REQUEST; } $op = 'find'; if (isset($request['op'])) { $op = $request['op']; if (!in_array($op, array('find', 'get', 'clear'))) { throw new DebugBarException("Invalid operation '{$request['op']}'"); } } if ($sendHeader) { $this->debugBar->getHttpDriver()->setHeaders(array( 'Content-Type' => 'application/json' )); } $response = json_encode(call_user_func(array($this, $op), $request)); if ($echo) { echo $response; } return $response; } /** * Find operation * @param $request * @return array */ protected function find($request) { $max = 20; if (isset($request['max'])) { $max = $request['max']; } $offset = 0; if (isset($request['offset'])) { $offset = $request['offset']; } $filters = array(); foreach (array('utime', 'datetime', 'ip', 'uri', 'method') as $key) { if (isset($request[$key])) { $filters[$key] = $request[$key]; } } return $this->debugBar->getStorage()->find($filters, $max, $offset); } /** * Get operation * @param $request * @return array * @throws DebugBarException */ protected function get($request) { if (!isset($request['id'])) { throw new DebugBarException("Missing 'id' parameter in 'get' operation"); } return $this->debugBar->getStorage()->get($request['id']); } /** * Clear operation */ protected function clear($request) { $this->debugBar->getStorage()->clear(); return array('success' => true); } } PKZm 11+debugbar/src/DebugBar/DebugBarException.phpnu[redis = $redis; $this->hash = $hash; } /** * {@inheritdoc} */ public function save($id, $data) { $this->redis->hSet("$this->hash:meta", $id, serialize($data['__meta'])); unset($data['__meta']); $this->redis->hSet("$this->hash:data", $id, serialize($data)); } /** * {@inheritdoc} */ public function get($id) { return array_merge(unserialize($this->redis->hGet("$this->hash:data", $id)), array('__meta' => unserialize($this->redis->hGet("$this->hash:meta", $id)))); } /** * {@inheritdoc} */ public function find(array $filters = [], $max = 20, $offset = 0) { $results = []; $cursor = "0"; $isPhpRedis = get_class($this->redis) === 'Redis' || get_class($this->redis) === 'RedisCluster'; do { if ($isPhpRedis) { $data = $this->redis->hScan("$this->hash:meta", $cursor); } else { [$cursor, $data] = $this->redis->hScan("$this->hash:meta", $cursor); } foreach ($data as $meta) { if ($meta = unserialize($meta)) { if ($this->filter($meta, $filters)) { $results[] = $meta; } } } } while($cursor); usort($results, static function ($a, $b) { return $b['utime'] <=> $a['utime']; }); return array_slice($results, $offset, $max); } /** * Filter the metadata for matches. */ protected function filter($meta, $filters) { foreach ($filters as $key => $value) { if (!isset($meta[$key]) || fnmatch($value, $meta[$key]) === false) { return false; } } return true; } /** * {@inheritdoc} */ public function clear() { $this->redis->del("$this->hash:data"); $this->redis->del("$this->hash:meta"); } } PKZxx> -debugbar/src/DebugBar/Storage/FileStorage.phpnu[dirname = rtrim($dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } /** * {@inheritdoc} */ public function save($id, $data) { if (!file_exists($this->dirname)) { mkdir($this->dirname, 0777, true); } file_put_contents($this->makeFilename($id), json_encode($data)); } /** * {@inheritdoc} */ public function get($id) { return json_decode(file_get_contents($this->makeFilename($id)), true); } /** * {@inheritdoc} */ public function find(array $filters = array(), $max = 20, $offset = 0) { //Loop through all .json files and remember the modified time and id. $files = array(); foreach (new \DirectoryIterator($this->dirname) as $file) { if ($file->getExtension() == 'json') { $files[] = array( 'time' => $file->getMTime(), 'id' => $file->getBasename('.json') ); } } //Sort the files, newest first usort($files, function ($a, $b) { return $a['time'] <=> $b['time']; }); //Load the metadata and filter the results. $results = array(); $i = 0; foreach ($files as $file) { //When filter is empty, skip loading the offset if ($i++ < $offset && empty($filters)) { $results[] = null; continue; } $data = $this->get($file['id']); $meta = $data['__meta']; unset($data); if ($this->filter($meta, $filters)) { $results[] = $meta; } if (count($results) >= ($max + $offset)) { break; } } return array_slice($results, $offset, $max); } /** * Filter the metadata for matches. * * @param array $meta * @param array $filters * @return bool */ protected function filter($meta, $filters) { foreach ($filters as $key => $value) { if (!isset($meta[$key]) || fnmatch($value, $meta[$key]) === false) { return false; } } return true; } /** * {@inheritdoc} */ public function clear() { foreach (new \DirectoryIterator($this->dirname) as $file) { if (substr($file->getFilename(), 0, 1) !== '.') { unlink($file->getPathname()); } } } /** * @param string $id * @return string */ public function makeFilename($id) { return $this->dirname . basename($id). ".json"; } } PKZJf((4debugbar/src/DebugBar/Storage/pdo_storage_schema.sqlnu[CREATE TABLE phpdebugbar ( id TEXT PRIMARY KEY, data TEXT, meta_utime TEXT, meta_datetime TEXT, meta_uri TEXT, meta_ip TEXT, meta_method TEXT ); CREATE INDEX idx_debugbar_id ON phpdebugbar (id); CREATE INDEX idx_debugbar_meta_utime ON phpdebugbar (meta_utime); CREATE INDEX idx_debugbar_meta_datetime ON phpdebugbar (meta_datetime); CREATE INDEX idx_debugbar_meta_uri ON phpdebugbar (meta_uri); CREATE INDEX idx_debugbar_meta_ip ON phpdebugbar (meta_ip); CREATE INDEX idx_debugbar_meta_method ON phpdebugbar (meta_method); PKZ 2debugbar/src/DebugBar/Storage/MemcachedStorage.phpnu[memcached = $memcached; $this->keyNamespace = $keyNamespace; $this->expiration = $expiration; } /** * {@inheritdoc} */ public function save($id, $data) { $key = $this->createKey($id); $this->memcached->set($key, $data, $this->expiration); if (!$this->memcached->append($this->keyNamespace, "|$key")) { $this->memcached->set($this->keyNamespace, $key, $this->expiration); } else if ($this->expiration) { // append doesn't support updating expiration, so do it here: $this->memcached->touch($this->keyNamespace, $this->expiration); } } /** * {@inheritdoc} */ public function get($id) { return $this->memcached->get($this->createKey($id)); } /** * {@inheritdoc} */ public function find(array $filters = array(), $max = 20, $offset = 0) { if (!($keys = $this->memcached->get($this->keyNamespace))) { return array(); } $results = array(); $keys = array_reverse(explode('|', $keys)); // Reverse so newest comes first $keyPosition = 0; // Index in $keys to try to get next items from $remainingItems = $max + $offset; // Try to obtain this many remaining items // Loop until we've found $remainingItems matching items or no more items may exist. while ($remainingItems > 0 && $keyPosition < count($keys)) { // Consume some keys from $keys: $itemsToGet = array_slice($keys, $keyPosition, $remainingItems); $keyPosition += $remainingItems; // Try to get them, and filter them: $newItems = $this->memcachedGetMulti($itemsToGet, Memcached::GET_PRESERVE_ORDER); if ($newItems) { foreach ($newItems as $data) { $meta = $data['__meta']; if ($this->filter($meta, $filters)) { $remainingItems--; // Keep the result only if we've discarded $offset items first if ($offset <= 0) { $results[] = $meta; } else { $offset--; } } } } } return $results; } /** * Filter the metadata for matches. * * @param array $meta * @param array $filters * @return bool */ protected function filter($meta, $filters) { foreach ($filters as $key => $value) { if (!isset($meta[$key]) || fnmatch($value, $meta[$key]) === false) { return false; } } return true; } /** * {@inheritdoc} */ public function clear() { if (!($keys = $this->memcached->get($this->keyNamespace))) { return; } $this->memcached->delete($this->keyNamespace); $this->memcached->deleteMulti(explode('|', $keys)); } /** * @param string $id * @return string */ protected function createKey($id) { return md5("{$this->keyNamespace}.$id"); } /** * The memcached getMulti function changed in version 3.0.0 to only have two parameters. * * @param array $keys * @param int $flags */ protected function memcachedGetMulti($keys, $flags) { if ($this->newGetMultiSignature === null) { $this->newGetMultiSignature = (new ReflectionMethod('Memcached', 'getMulti'))->getNumberOfParameters() === 2; } if ($this->newGetMultiSignature) { return $this->memcached->getMulti($keys, $flags); } else { $null = null; return $this->memcached->getMulti($keys, $null, $flags); } } } PKZW"||2debugbar/src/DebugBar/Storage/StorageInterface.phpnu[ "INSERT INTO %tablename% (id, data, meta_utime, meta_datetime, meta_uri, meta_ip, meta_method) VALUES (?, ?, ?, ?, ?, ?, ?)", 'get' => "SELECT data FROM %tablename% WHERE id = ?", 'find' => "SELECT data FROM %tablename% %where% ORDER BY meta_datetime DESC LIMIT %limit% OFFSET %offset%", 'clear' => "DELETE FROM %tablename%" ); /** * @param \PDO $pdo The PDO instance * @param string $tableName * @param array $sqlQueries */ public function __construct(PDO $pdo, $tableName = 'phpdebugbar', array $sqlQueries = array()) { $this->pdo = $pdo; $this->tableName = $tableName; $this->setSqlQueries($sqlQueries); } /** * Sets the sql queries to be used * * @param array $queries */ public function setSqlQueries(array $queries) { $this->sqlQueries = array_merge($this->sqlQueries, $queries); } /** * {@inheritdoc} */ public function save($id, $data) { $sql = $this->getSqlQuery('save'); $stmt = $this->pdo->prepare($sql); $meta = $data['__meta']; $stmt->execute(array($id, serialize($data), $meta['utime'], $meta['datetime'], $meta['uri'], $meta['ip'], $meta['method'])); } /** * {@inheritdoc} */ public function get($id) { $sql = $this->getSqlQuery('get'); $stmt = $this->pdo->prepare($sql); $stmt->execute(array($id)); if (($data = $stmt->fetchColumn(0)) !== false) { return unserialize($data); } return null; } /** * {@inheritdoc} */ public function find(array $filters = array(), $max = 20, $offset = 0) { $where = array(); $params = array(); foreach ($filters as $key => $value) { $where[] = "meta_$key = ?"; $params[] = $value; } if (count($where)) { $where = " WHERE " . implode(' AND ', $where); } else { $where = ''; } $sql = $this->getSqlQuery('find', array( 'where' => $where, 'offset' => $offset, 'limit' => $max )); $stmt = $this->pdo->prepare($sql); $stmt->execute($params); $results = array(); foreach ($stmt->fetchAll() as $row) { $data = unserialize($row['data']); $results[] = $data['__meta']; unset($data); } return $results; } /** * {@inheritdoc} */ public function clear() { $this->pdo->exec($this->getSqlQuery('clear')); } /** * Get a SQL Query for a task, with the variables replaced * * @param string $name * @param array $vars * @return string */ protected function getSqlQuery($name, array $vars = array()) { $sql = $this->sqlQueries[$name]; $vars = array_merge(array('tablename' => $this->tableName), $vars); foreach ($vars as $k => $v) { $sql = str_replace("%$k%", $v, $sql); } return $sql; } } PKZd0debugbar/src/DebugBar/Bridge/PropelCollector.phpnu[ * $debugbar->addCollector(new PropelCollector($debugbar['messages'])); * PropelCollector::enablePropelProfiling(); * */ class PropelCollector extends DataCollector implements BasicLogger, Renderable, AssetProvider { protected $logger; protected $statements = array(); protected $accumulatedTime = 0; protected $peakMemory = 0; /** * Sets the needed configuration option in propel to enable query logging * * @param PropelConfiguration $config Apply profiling on a specific config */ public static function enablePropelProfiling(PropelConfiguration $config = null) { if ($config === null) { $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); } $config->setParameter('debugpdo.logging.details.method.enabled', true); $config->setParameter('debugpdo.logging.details.time.enabled', true); $config->setParameter('debugpdo.logging.details.mem.enabled', true); $allMethods = array( 'PropelPDO::__construct', // logs connection opening 'PropelPDO::__destruct', // logs connection close 'PropelPDO::exec', // logs a query 'PropelPDO::query', // logs a query 'PropelPDO::beginTransaction', // logs a transaction begin 'PropelPDO::commit', // logs a transaction commit 'PropelPDO::rollBack', // logs a transaction rollBack (watch out for the capital 'B') 'DebugPDOStatement::execute', // logs a query from a prepared statement ); $config->setParameter('debugpdo.logging.methods', $allMethods, false); } /** * @param LoggerInterface $logger A logger to forward non-query log lines to * @param PropelPDO $conn Bound this collector to a connection only */ public function __construct(LoggerInterface $logger = null, PropelPDO $conn = null) { if ($conn) { $conn->setLogger($this); } else { Propel::setLogger($this); } $this->logger = $logger; $this->logQueriesToLogger = false; } public function setLogQueriesToLogger($enable = true) { $this->logQueriesToLogger = $enable; return $this; } public function isLogQueriesToLogger() { return $this->logQueriesToLogger; } public function emergency($m) { $this->log($m, Propel::LOG_EMERG); } public function alert($m) { $this->log($m, Propel::LOG_ALERT); } public function crit($m) { $this->log($m, Propel::LOG_CRIT); } public function err($m) { $this->log($m, Propel::LOG_ERR); } public function warning($m) { $this->log($m, Propel::LOG_WARNING); } public function notice($m) { $this->log($m, Propel::LOG_NOTICE); } public function info($m) { $this->log($m, Propel::LOG_INFO); } public function debug($m) { $this->log($m, Propel::LOG_DEBUG); } public function log($message, $severity = null) { if (strpos($message, 'DebugPDOStatement::execute') !== false) { list($sql, $duration_str) = $this->parseAndLogSqlQuery($message); if (!$this->logQueriesToLogger) { return; } $message = "$sql ($duration_str)"; } if ($this->logger !== null) { $this->logger->log($this->convertLogLevel($severity), $message); } } /** * Converts Propel log levels to PSR log levels * * @param int $level * @return string */ protected function convertLogLevel($level) { $map = array( Propel::LOG_EMERG => LogLevel::EMERGENCY, Propel::LOG_ALERT => LogLevel::ALERT, Propel::LOG_CRIT => LogLevel::CRITICAL, Propel::LOG_ERR => LogLevel::ERROR, Propel::LOG_WARNING => LogLevel::WARNING, Propel::LOG_NOTICE => LogLevel::NOTICE, Propel::LOG_DEBUG => LogLevel::DEBUG ); return $map[$level]; } /** * Parse a log line to extract query information * * @param string $message */ protected function parseAndLogSqlQuery($message) { $parts = explode('|', $message, 4); $sql = trim($parts[3]); $duration = 0; if (preg_match('/([0-9]+\.[0-9]+)/', $parts[1], $matches)) { $duration = (float) $matches[1]; } $memory = 0; if (preg_match('/([0-9]+\.[0-9]+) ([A-Z]{1,2})/', $parts[2], $matches)) { $memory = (float) $matches[1]; if ($matches[2] == 'KB') { $memory *= 1024; } elseif ($matches[2] == 'MB') { $memory *= 1024 * 1024; } } $this->statements[] = array( 'sql' => $sql, 'is_success' => true, 'duration' => $duration, 'duration_str' => $this->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->formatBytes($memory) ); $this->accumulatedTime += $duration; $this->peakMemory = max($this->peakMemory, $memory); return array($sql, $this->formatDuration($duration)); } public function collect() { return array( 'nb_statements' => count($this->statements), 'nb_failed_statements' => 0, 'accumulated_duration' => $this->accumulatedTime, 'accumulated_duration_str' => $this->formatDuration($this->accumulatedTime), 'peak_memory_usage' => $this->peakMemory, 'peak_memory_usage_str' => $this->formatBytes($this->peakMemory), 'statements' => $this->statements ); } public function getName() { return 'propel'; } public function getWidgets() { return array( "propel" => array( "icon" => "bolt", "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", "map" => "propel", "default" => "[]" ), "propel:badge" => array( "map" => "propel.nb_statements", "default" => 0 ) ); } public function getAssets() { return array( 'css' => 'widgets/sqlqueries/widget.css', 'js' => 'widgets/sqlqueries/widget.js' ); } } PKZcJ4debugbar/src/DebugBar/Bridge/CacheCacheCollector.phpnu[ * $debugbar->addCollector(new CacheCacheCollector(CacheManager::get('default'))); * // or * $debugbar->addCollector(new CacheCacheCollector()); * $debugbar['cache']->addCache(CacheManager::get('default')); * */ class CacheCacheCollector extends MonologCollector { protected $logger; /** * CacheCacheCollector constructor. * @param Cache|null $cache * @param Logger|null $logger * @param bool $level * @param bool $bubble */ public function __construct(Cache $cache = null, Logger $logger = null, $level = Logger::DEBUG, $bubble = true) { parent::__construct(null, $level, $bubble); if ($logger === null) { $logger = new Logger('Cache'); } $this->logger = $logger; if ($cache !== null) { $this->addCache($cache); } } /** * @param Cache $cache */ public function addCache(Cache $cache) { $backend = $cache->getBackend(); if (!($backend instanceof LoggingBackend)) { $backend = new LoggingBackend($backend, $this->logger); } $cache->setBackend($backend); $this->addLogger($backend->getLogger()); } /** * @return string */ public function getName() { return 'cache'; } } PKZK""1debugbar/src/DebugBar/Bridge/Propel2Collector.phpnu[ * $debugbar->addCollector(new \DebugBar\Bridge\Propel2Collector(\Propel\Runtime\Propel::getServiceContainer()->getReadConnection())); * */ class Propel2Collector extends DataCollector implements Renderable, AssetProvider { /** * @var null|TestHandler */ protected $handler = null; /** * @var null|Logger */ protected $logger = null; /** * @var array */ protected $config = array(); /** * @var array */ protected $errors = array(); /** * @var int */ protected $queryCount = 0; /** * @param ConnectionInterface $connection Propel connection */ public function __construct( ConnectionInterface $connection, array $logMethods = array( 'beginTransaction', 'commit', 'rollBack', 'forceRollBack', 'exec', 'query', 'execute' ) ) { if ($connection instanceof ProfilerConnectionWrapper) { $connection->setLogMethods($logMethods); $this->config = $connection->getProfiler()->getConfiguration(); $this->handler = new TestHandler(); if ($connection->getLogger() instanceof Logger) { $this->logger = $connection->getLogger(); $this->logger->pushHandler($this->handler); } else { $this->errors[] = 'Supported only monolog logger'; } } else { $this->errors[] = 'You need set ProfilerConnectionWrapper'; } } /** * @return TestHandler|null */ public function getHandler() { return $this->handler; } /** * @return array */ public function getConfig() { return $this->config; } /** * @return Logger|null */ public function getLogger() { return $this->logger; } /** * @return LoggerInterface */ protected function getDefaultLogger() { return Propel::getServiceContainer()->getLogger(); } /** * @return int */ protected function getQueryCount() { return $this->queryCount; } /** * @param array $records * @param array $config * @return array */ protected function getStatements($records, $config) { $statements = array(); foreach ($records as $record) { $duration = null; $memory = null; $isSuccess = ( LogLevel::INFO === strtolower($record['level_name']) ); $detailsCount = count($config['details']); $parameters = explode($config['outerGlue'], $record['message'], $detailsCount + 1); if (count($parameters) === ($detailsCount + 1)) { $parameters = array_map('trim', $parameters); $_details = array(); foreach (array_splice($parameters, 0, $detailsCount) as $string) { list($key, $value) = array_map('trim', explode($config['innerGlue'], $string, 2)); $_details[$key] = $value; } $details = array(); foreach ($config['details'] as $key => $detail) { if (isset($_details[$detail['name']])) { $value = $_details[$detail['name']]; if ('time' === $key) { if (substr_count($value, 'ms')) { $value = (float)$value / 1000; } else { $value = (float)$value; } } else { $suffixes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $suffix = substr($value, -2); $i = array_search($suffix, $suffixes, true); $i = (false === $i) ? 0 : $i; $value = ((float)$value) * pow(1024, $i); } $details[$key] = $value; } } if (isset($details['time'])) { $duration = $details['time']; } if (isset($details['memDelta'])) { $memory = $details['memDelta']; } $message = end($parameters); if ($isSuccess) { $this->queryCount++; } } else { $message = $record['message']; } $statement = array( 'sql' => $message, 'is_success' => $isSuccess, 'duration' => $duration, 'duration_str' => $this->getDataFormatter()->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->getDataFormatter()->formatBytes($memory), ); if (false === $isSuccess) { $statement['sql'] = ''; $statement['error_code'] = $record['level']; $statement['error_message'] = $message; } $statements[] = $statement; } return $statements; } /** * @return array */ public function collect() { if (count($this->errors)) { return array( 'statements' => array_map(function ($message) { return array('sql' => '', 'is_success' => false, 'error_code' => 500, 'error_message' => $message); }, $this->errors), 'nb_statements' => 0, 'nb_failed_statements' => count($this->errors), ); } if ($this->getHandler() === null) { return array(); } $statements = $this->getStatements($this->getHandler()->getRecords(), $this->getConfig()); $failedStatement = count(array_filter($statements, function ($statement) { return false === $statement['is_success']; })); $accumulatedDuration = array_reduce($statements, function ($accumulatedDuration, $statement) { $time = isset($statement['duration']) ? $statement['duration'] : 0; return $accumulatedDuration += $time; }); $memoryUsage = array_reduce($statements, function ($memoryUsage, $statement) { $time = isset($statement['memory']) ? $statement['memory'] : 0; return $memoryUsage += $time; }); return array( 'nb_statements' => $this->getQueryCount(), 'nb_failed_statements' => $failedStatement, 'accumulated_duration' => $accumulatedDuration, 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($accumulatedDuration), 'memory_usage' => $memoryUsage, 'memory_usage_str' => $this->getDataFormatter()->formatBytes($memoryUsage), 'statements' => $statements ); } /** * @return string */ public function getName() { $additionalName = ''; if ($this->getLogger() !== $this->getDefaultLogger()) { $additionalName = ' ('.$this->getLogger()->getName().')'; } return 'propel2'.$additionalName; } /** * @return array */ public function getWidgets() { return array( $this->getName() => array( 'icon' => 'bolt', 'widget' => 'PhpDebugBar.Widgets.SQLQueriesWidget', 'map' => $this->getName(), 'default' => '[]' ), $this->getName().':badge' => array( 'map' => $this->getName().'.nb_statements', 'default' => 0 ), ); } /** * @return array */ public function getAssets() { return array( 'css' => 'widgets/sqlqueries/widget.css', 'js' => 'widgets/sqlqueries/widget.js' ); } } PKZ܎5debugbar/src/DebugBar/Bridge/TwigProfileCollector.phpnu[ * $env = new Twig_Environment($loader); // Or from a PSR11-container * $profile = new Twig_Profiler_Profile(); * $env->addExtension(new Twig_Extension_Profile($profile)); * $debugbar->addCollector(new TwigProfileCollector($profile, $env)); * // or: $debugbar->addCollector(new TwigProfileCollector($profile, $loader)); * * * @deprecated Use `\Debugbar\Bridge\NamespacedTwigProfileCollector` instead for Twig 2.x and 3.x */ class TwigProfileCollector extends DataCollector implements Renderable, AssetProvider { /** * @var \Twig_Profiler_Profile */ private $profile; /** * @var \Twig_LoaderInterface */ private $loader; /** @var int */ private $templateCount; /** @var int */ private $blockCount; /** @var int */ private $macroCount; /** * @var array[] { * @var string $name * @var int $render_time * @var string $render_time_str * @var string $memory_str * @var string $xdebug_link * } */ private $templates; /** * TwigProfileCollector constructor. * * @param \Twig_Profiler_Profile $profile * @param \Twig_LoaderInterface|\Twig_Environment $loaderOrEnv */ public function __construct(\Twig_Profiler_Profile $profile, $loaderOrEnv = null) { $this->profile = $profile; if ($loaderOrEnv instanceof \Twig_Environment) { $loaderOrEnv = $loaderOrEnv->getLoader(); } $this->loader = $loaderOrEnv; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see DebugBar\JavascriptRenderer::addControl()} * * @return array */ public function getWidgets() { return array( 'twig' => array( 'icon' => 'leaf', 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', 'map' => 'twig', 'default' => json_encode(array('templates' => array())), ), 'twig:badge' => array( 'map' => 'twig.badge', 'default' => 0, ), ); } /** * @return array */ public function getAssets() { return array( 'css' => 'widgets/templates/widget.css', 'js' => 'widgets/templates/widget.js', ); } /** * Called by the DebugBar when data needs to be collected * * @return array Collected data */ public function collect() { $this->templateCount = $this->blockCount = $this->macroCount = 0; $this->templates = array(); $this->computeData($this->profile); return array( 'nb_templates' => $this->templateCount, 'nb_blocks' => $this->blockCount, 'nb_macros' => $this->macroCount, 'templates' => $this->templates, 'accumulated_render_time' => $this->profile->getDuration(), 'accumulated_render_time_str' => $this->getDataFormatter()->formatDuration($this->profile->getDuration()), 'memory_usage_str' => $this->getDataFormatter()->formatBytes($this->profile->getMemoryUsage()), 'callgraph' => $this->getHtmlCallGraph(), 'badge' => implode( '/', array( $this->templateCount, $this->blockCount, $this->macroCount, ) ), ); } /** * Returns the unique name of the collector * * @return string */ public function getName() { return 'twig'; } public function getHtmlCallGraph() { $dumper = new \Twig_Profiler_Dumper_Html(); return $dumper->dump($this->profile); } /** * Get an Xdebug Link to a file * * @return array { * @var string url * @var bool ajax * } */ public function getXdebugLink($template, $line = 1) { if (is_null($this->loader)) { return null; } $file = $this->loader->getSourceContext($template)->getPath(); return parent::getXdebugLink($file, $line); } private function computeData(\Twig_Profiler_Profile $profile) { $this->templateCount += ($profile->isTemplate() ? 1 : 0); $this->blockCount += ($profile->isBlock() ? 1 : 0); $this->macroCount += ($profile->isMacro() ? 1 : 0); if ($profile->isTemplate()) { $this->templates[] = array( 'name' => $profile->getName(), 'render_time' => $profile->getDuration(), 'render_time_str' => $this->getDataFormatter()->formatDuration($profile->getDuration()), 'memory_str' => $this->getDataFormatter()->formatBytes($profile->getMemoryUsage()), 'xdebug_link' => $this->getXdebugLink($profile->getTemplate()), ); } foreach ($profile as $p) { $this->computeData($p); } } } PKZcth h 2debugbar/src/DebugBar/Bridge/DoctrineCollector.phpnu[ * $debugStack = new Doctrine\DBAL\Logging\DebugStack(); * $entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack); * $debugbar->addCollector(new DoctrineCollector($debugStack)); * */ class DoctrineCollector extends DataCollector implements Renderable, AssetProvider { protected $debugStack; /** * DoctrineCollector constructor. * @param $debugStackOrEntityManager * @throws DebugBarException */ public function __construct($debugStackOrEntityManager) { if ($debugStackOrEntityManager instanceof EntityManager) { $debugStackOrEntityManager = $debugStackOrEntityManager->getConnection()->getConfiguration()->getSQLLogger(); } if (!($debugStackOrEntityManager instanceof DebugStack)) { throw new DebugBarException("'DoctrineCollector' requires an 'EntityManager' or 'DebugStack' object"); } $this->debugStack = $debugStackOrEntityManager; } /** * @return array */ public function collect() { $queries = array(); $totalExecTime = 0; foreach ($this->debugStack->queries as $q) { $queries[] = array( 'sql' => $q['sql'], 'params' => (object) $q['params'], 'duration' => $q['executionMS'], 'duration_str' => $this->formatDuration($q['executionMS']) ); $totalExecTime += $q['executionMS']; } return array( 'nb_statements' => count($queries), 'accumulated_duration' => $totalExecTime, 'accumulated_duration_str' => $this->formatDuration($totalExecTime), 'statements' => $queries ); } /** * @return string */ public function getName() { return 'doctrine'; } /** * @return array */ public function getWidgets() { return array( "database" => array( "icon" => "arrow-right", "widget" => "PhpDebugBar.Widgets.SQLQueriesWidget", "map" => "doctrine", "default" => "[]" ), "database:badge" => array( "map" => "doctrine.nb_statements", "default" => 0 ) ); } /** * @return array */ public function getAssets() { return array( 'css' => 'widgets/sqlqueries/widget.css', 'js' => 'widgets/sqlqueries/widget.js' ); } } PKZ.`i?debugbar/src/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.phpnu[messagesLogger = new Swift_Plugins_MessageLogger(); $mailer->registerPlugin($this->messagesLogger); } public function collect() { $mails = array(); foreach ($this->messagesLogger->getMessages() as $msg) { $mails[] = array( 'to' => $this->formatTo($msg->getTo()), 'subject' => $msg->getSubject(), 'headers' => $msg->getHeaders()->toString() ); } return array( 'count' => count($mails), 'mails' => $mails ); } protected function formatTo($to) { if (!$to) { return ''; } $f = array(); foreach ($to as $k => $v) { $f[] = (empty($v) ? '' : "$v ") . "<$k>"; } return implode(', ', $f); } public function getName() { return 'swiftmailer_mails'; } public function getWidgets() { return array( 'emails' => array( 'icon' => 'inbox', 'widget' => 'PhpDebugBar.Widgets.MailsWidget', 'map' => 'swiftmailer_mails.mails', 'default' => '[]', 'title' => 'Mails' ), 'emails:badge' => array( 'map' => 'swiftmailer_mails.count', 'default' => 'null' ) ); } public function getAssets() { return array( 'css' => 'widgets/mails/widget.css', 'js' => 'widgets/mails/widget.js' ); } } PKZjU;/ZZ>debugbar/src/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.phpnu[registerPlugin(new Swift_Plugins_LoggerPlugin($this)); } public function add($entry) { $this->addMessage($entry); } public function dump() { $dump = ''; foreach ($this->messages as $message) { if (!$message['is_string']) { continue; } $dump .= $message['message'] . PHP_EOL; } return $dump; } public function getName() { return 'swiftmailer_logs'; } } PKZsn=debugbar/src/DebugBar/Bridge/Symfony/SymfonyMailCollector.phpnu[messages[] = $message->getOriginalMessage(); } public function showMessageDetail() { $this->showDetailed = true; } public function collect() { $mails = array(); foreach ($this->messages as $message) { /* @var \Symfony\Component\Mime\Message $message */ $mails[] = array( 'to' => array_map(function ($address) { /* @var \Symfony\Component\Mime\Address $address */ return $address->toString(); }, $message->getTo()), 'subject' => $message->getSubject(), 'headers' => ($this->showDetailed ? $message : $message->getHeaders())->toString(), );; } return array( 'count' => count($mails), 'mails' => $mails, ); } public function getName() { return 'symfonymailer_mails'; } public function getWidgets() { return array( 'emails' => array( 'icon' => 'inbox', 'widget' => 'PhpDebugBar.Widgets.MailsWidget', 'map' => 'symfonymailer_mails.mails', 'default' => '[]', 'title' => 'Mails' ), 'emails:badge' => array( 'map' => 'symfonymailer_mails.count', 'default' => 'null' ) ); } public function getAssets() { return array( 'css' => 'widgets/mails/widget.css', 'js' => 'widgets/mails/widget.js' ); } } PKZy@ 8?debugbar/src/DebugBar/Bridge/NamespacedTwigProfileCollector.phpnu[ * $env = new \Twig\Environment($loader); // Or from a PSR11-container * $profile = new \Twig\Profiler\Profile(); * $env->addExtension(new \Twig\Extension\ProfilerExtension($profile)); * $debugbar->addCollector(new ModernTwigProfileCollector($profile, $env)); * // or: $debugbar->addCollector(new ModernTwigProfileCollector($profile, $loader)); * */ class NamespacedTwigProfileCollector extends DataCollector implements Renderable, AssetProvider { /** * @var Profile */ private $profile; /** * @var LoaderInterface|Environment|null */ private $loader; /** * @var int */ private $templateCount; /** * @var int */ private $blockCount; /** * @var int */ private $macroCount; /** * @var array[] { * @var string $name * @var int $render_time * @var string $render_time_str * @var string $memory_str * @var string $xdebug_link * } */ private $templates; /** * TwigProfileCollector constructor. * * @param Profile $profile * @param LoaderInterface|Environment $loaderOrEnv */ public function __construct(Profile $profile, $loaderOrEnv = null) { $this->profile = $profile; if ($loaderOrEnv instanceof Environment) { $loaderOrEnv = $loaderOrEnv->getLoader(); } $this->loader = $loaderOrEnv; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @return array */ public function getWidgets() { return [ 'twig' => [ 'icon' => 'leaf', 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', 'map' => 'twig', 'default' => json_encode(['templates' => []]), ], 'twig:badge' => [ 'map' => 'twig.badge', 'default' => 0, ], ]; } /** * @return array */ public function getAssets() { return [ 'css' => 'widgets/templates/widget.css', 'js' => 'widgets/templates/widget.js', ]; } /** * Called by the DebugBar when data needs to be collected * * @return array Collected data */ public function collect() { $this->templateCount = $this->blockCount = $this->macroCount = 0; $this->templates = []; $this->computeData($this->profile); return [ 'nb_templates' => $this->templateCount, 'nb_blocks' => $this->blockCount, 'nb_macros' => $this->macroCount, 'templates' => $this->templates, 'accumulated_render_time' => $this->profile->getDuration(), 'accumulated_render_time_str' => $this->getDataFormatter()->formatDuration($this->profile->getDuration()), 'memory_usage_str' => $this->getDataFormatter()->formatBytes($this->profile->getMemoryUsage()), 'callgraph' => $this->getHtmlCallGraph(), 'badge' => implode( '/', [ $this->templateCount, $this->blockCount, $this->macroCount, ] ), ]; } /** * Returns the unique name of the collector * * @return string */ public function getName() { return 'twig'; } public function getHtmlCallGraph() { $dumper = new HtmlDumper(); return $dumper->dump($this->profile); } /** * Get an Xdebug Link to a file * * @return array { * @var string url * @var bool ajax * } */ public function getXdebugLink($template, $line = 1) { if (is_null($this->loader)) { return null; } $file = $this->loader->getSourceContext($template)->getPath(); return parent::getXdebugLink($file, $line); } private function computeData(Profile $profile) { $this->templateCount += ($profile->isTemplate() ? 1 : 0); $this->blockCount += ($profile->isBlock() ? 1 : 0); $this->macroCount += ($profile->isMacro() ? 1 : 0); if ($profile->isTemplate()) { $this->templates[] = [ 'name' => $profile->getName(), 'render_time' => $profile->getDuration(), 'render_time_str' => $this->getDataFormatter()->formatDuration($profile->getDuration()), 'memory_str' => $this->getDataFormatter()->formatBytes($profile->getMemoryUsage()), 'xdebug_link' => $this->getXdebugLink($profile->getTemplate()), ]; } foreach ($profile as $p) { $this->computeData($p); } } } PKZI ;debugbar/src/DebugBar/Bridge/Twig/TraceableTwigTemplate.phpnu[env = $env; $this->template = $template; } public function __call($name, $arguments) { return call_user_func_array(array($this->template, $name), $arguments); } public function doDisplay(array $context, array $blocks = array()) { return $this->template->doDisplay($context, $blocks); } public function getTemplateName() { return $this->template->getTemplateName(); } public function getEnvironment() { return $this->template->getEnvironment(); } public function getParent(array $context) { return $this->template->getParent($context); } public function isTraitable() { return $this->template->isTraitable(); } public function displayParentBlock($name, array $context, array $blocks = array()) { $this->template->displayParentBlock($name, $context, $blocks); } public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true) { $this->template->displayBlock($name, $context, $blocks, $useBlocks); } public function renderParentBlock($name, array $context, array $blocks = array()) { return $this->template->renderParentBlock($name, $context, $blocks); } public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true) { return $this->template->renderBlock($name, $context, $blocks, $useBlocks); } public function hasBlock($name) { return $this->template->hasBlock($name); } public function getBlockNames() { return $this->template->getBlockNames(); } public function getBlocks() { return $this->template->getBlocks(); } public function display(array $context, array $blocks = array()) { $start = microtime(true); $this->template->display($context, $blocks); $end = microtime(true); if ($timeDataCollector = $this->env->getTimeDataCollector()) { $name = sprintf("twig.render(%s)", $this->template->getTemplateName()); $timeDataCollector->addMeasure($name, $start, $end); } $this->env->addRenderedTemplate(array( 'name' => $this->template->getTemplateName(), 'render_time' => $end - $start )); } public function render(array $context) { $level = ob_get_level(); ob_start(); try { $this->display($context); } catch (Exception $e) { while (ob_get_level() > $level) { ob_end_clean(); } throw $e; } return ob_get_clean(); } public static function clearCache() { Twig_Template::clearCache(); } } PKZW􂧻$$>debugbar/src/DebugBar/Bridge/Twig/TraceableTwigEnvironment.phpnu[twig = $twig; $this->timeDataCollector = $timeDataCollector; } public function __call($name, $arguments) { return call_user_func_array(array($this->twig, $name), $arguments); } public function getRenderedTemplates() { return $this->renderedTemplates; } public function addRenderedTemplate(array $info) { $this->renderedTemplates[] = $info; } public function getTimeDataCollector() { return $this->timeDataCollector; } public function getBaseTemplateClass() { return $this->twig->getBaseTemplateClass(); } public function setBaseTemplateClass($class) { $this->twig->setBaseTemplateClass($class); } public function enableDebug() { $this->twig->enableDebug(); } public function disableDebug() { $this->twig->disableDebug(); } public function isDebug() { return $this->twig->isDebug(); } public function enableAutoReload() { $this->twig->enableAutoReload(); } public function disableAutoReload() { $this->twig->disableAutoReload(); } public function isAutoReload() { return $this->twig->isAutoReload(); } public function enableStrictVariables() { $this->twig->enableStrictVariables(); } public function disableStrictVariables() { $this->twig->disableStrictVariables(); } public function isStrictVariables() { return $this->twig->isStrictVariables(); } public function getCache($original = true) { return $this->twig->getCache($original); } public function setCache($cache) { $this->twig->setCache($cache); } public function getCacheFilename($name) { return $this->twig->getCacheFilename($name); } public function getTemplateClass($name, $index = null) { return $this->twig->getTemplateClass($name, $index); } public function getTemplateClassPrefix() { return $this->twig->getTemplateClassPrefix(); } public function render($name, array $context = array()) { return $this->loadTemplate($name)->render($context); } public function display($name, array $context = array()) { $this->loadTemplate($name)->display($context); } public function loadTemplate($name, $index = null) { $cls = $this->twig->getTemplateClass($name, $index); if (isset($this->twig->loadedTemplates[$cls])) { return $this->twig->loadedTemplates[$cls]; } if (!class_exists($cls, false)) { if (false === $cache = $this->getCacheFilename($name)) { eval('?>'.$this->compileSource($this->getLoader()->getSource($name), $name)); } else { if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) { $this->writeCacheFile($cache, $this->compileSource($this->getLoader()->getSource($name), $name)); } require_once $cache; } } if (!$this->twig->runtimeInitialized) { $this->initRuntime(); } return $this->twig->loadedTemplates[$cls] = new TraceableTwigTemplate($this, new $cls($this)); } public function isTemplateFresh($name, $time) { return $this->twig->isTemplateFresh($name, $time); } public function resolveTemplate($names) { return $this->twig->resolveTemplate($names); } public function clearTemplateCache() { $this->twig->clearTemplateCache(); } public function clearCacheFiles() { $this->twig->clearCacheFiles(); } public function getLexer() { return $this->twig->getLexer(); } public function setLexer(Twig_LexerInterface $lexer) { $this->twig->setLexer($lexer); } public function tokenize($source, $name = null) { return $this->twig->tokenize($source, $name); } public function getParser() { return $this->twig->getParser(); } public function setParser(Twig_ParserInterface $parser) { $this->twig->setParser($parser); } public function parse(Twig_TokenStream $tokens) { return $this->twig->parse($tokens); } public function getCompiler() { return $this->twig->getCompiler(); } public function setCompiler(Twig_CompilerInterface $compiler) { $this->twig->setCompiler($compiler); } public function compile(Twig_NodeInterface $node) { return $this->twig->compile($node); } public function compileSource($source, $name = null) { return $this->twig->compileSource($source, $name); } public function setLoader(Twig_LoaderInterface $loader) { $this->twig->setLoader($loader); } public function getLoader() { return $this->twig->getLoader(); } public function setCharset($charset) { $this->twig->setCharset($charset); } public function getCharset() { return $this->twig->getCharset(); } public function initRuntime() { $this->twig->initRuntime(); } public function hasExtension($name) { return $this->twig->hasExtension($name); } public function getExtension($name) { return $this->twig->getExtension($name); } public function addExtension(Twig_ExtensionInterface $extension) { $this->twig->addExtension($extension); } public function removeExtension($name) { $this->twig->removeExtension($name); } public function setExtensions(array $extensions) { $this->twig->setExtensions($extensions); } public function getExtensions() { return $this->twig->getExtensions(); } public function addTokenParser(Twig_TokenParserInterface $parser) { $this->twig->addTokenParser($parser); } public function getTokenParsers() { return $this->twig->getTokenParsers(); } public function getTags() { return $this->twig->getTags(); } public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) { $this->twig->addNodeVisitor($visitor); } public function getNodeVisitors() { return $this->twig->getNodeVisitors(); } public function addFilter($name, $filter = null) { $this->twig->addFilter($name, $filter); } public function getFilter($name) { return $this->twig->getFilter($name); } public function registerUndefinedFilterCallback($callable) { $this->twig->registerUndefinedFilterCallback($callable); } public function getFilters() { return $this->twig->getFilters(); } public function addTest($name, $test = null) { $this->twig->addTest($name, $test); } public function getTests() { return $this->twig->getTests(); } public function getTest($name) { return $this->twig->getTest($name); } public function addFunction($name, $function = null) { $this->twig->addFunction($name, $function); } public function getFunction($name) { return $this->twig->getFunction($name); } public function registerUndefinedFunctionCallback($callable) { $this->twig->registerUndefinedFunctionCallback($callable); } public function getFunctions() { return $this->twig->getFunctions(); } public function addGlobal($name, $value) { $this->twig->addGlobal($name, $value); } public function getGlobals() { return $this->twig->getGlobals(); } public function mergeGlobals(array $context) { return $this->twig->mergeGlobals($context); } public function getUnaryOperators() { return $this->twig->getUnaryOperators(); } public function getBinaryOperators() { return $this->twig->getBinaryOperators(); } public function computeAlternatives($name, $items) { return $this->twig->computeAlternatives($name, $items); } } PKZ]NCdebugbar/src/DebugBar/Bridge/Twig/TimeableTwigExtensionProfiler.phpnu[timeDataCollector = $timeDataCollector; } public function __construct(\Twig_Profiler_Profile $profile, TimeDataCollector $timeDataCollector = null) { parent::__construct($profile); $this->timeDataCollector = $timeDataCollector; } public function enter(Twig_Profiler_Profile $profile) { if ($this->timeDataCollector && $profile->isTemplate()) { $this->timeDataCollector->startMeasure($profile->getName(), 'template ' . $profile->getName()); } parent::enter($profile); } public function leave(Twig_Profiler_Profile $profile) { parent::leave($profile); if ($this->timeDataCollector && $profile->isTemplate()) { $this->timeDataCollector->stopMeasure($profile->getName()); } } } PKZU U 3debugbar/src/DebugBar/Bridge/Twig/TwigCollector.phpnu[ * $env = new TraceableTwigEnvironment(new Twig_Environment($loader)); * $debugbar->addCollector(new TwigCollector($env)); * * * @deprecated use DebugBar\Bridge\TwigProfileCollector instead */ class TwigCollector extends DataCollector implements Renderable, AssetProvider { public function __construct(TraceableTwigEnvironment $twig) { $this->twig = $twig; } public function collect() { $templates = array(); $accuRenderTime = 0; foreach ($this->twig->getRenderedTemplates() as $tpl) { $accuRenderTime += $tpl['render_time']; $templates[] = array( 'name' => $tpl['name'], 'render_time' => $tpl['render_time'], 'render_time_str' => $this->formatDuration($tpl['render_time']) ); } return array( 'nb_templates' => count($templates), 'templates' => $templates, 'accumulated_render_time' => $accuRenderTime, 'accumulated_render_time_str' => $this->formatDuration($accuRenderTime) ); } public function getName() { return 'twig'; } public function getWidgets() { return array( 'twig' => array( 'icon' => 'leaf', 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', 'map' => 'twig', 'default' => json_encode(array('templates' => array())), ), 'twig:badge' => array( 'map' => 'twig.nb_templates', 'default' => 0 ) ); } public function getAssets() { return array( 'css' => 'widgets/templates/widget.css', 'js' => 'widgets/templates/widget.js' ); } } PKZ) 1debugbar/src/DebugBar/Bridge/MonologCollector.phpnu[ * $debugbar->addCollector(new MonologCollector($logger)); * */ class MonologCollector extends AbstractProcessingHandler implements DataCollectorInterface, Renderable, MessagesAggregateInterface { protected $name; protected $records = array(); /** * @param Logger $logger * @param int $level * @param boolean $bubble * @param string $name */ public function __construct(Logger $logger = null, $level = Logger::DEBUG, $bubble = true, $name = 'monolog') { parent::__construct($level, $bubble); $this->name = $name; if ($logger !== null) { $this->addLogger($logger); } } /** * Adds logger which messages you want to log * * @param Logger $logger */ public function addLogger(Logger $logger) { $logger->pushHandler($this); } /** * @param array|\Monolog\LogRecord $record */ protected function write($record): void { $this->records[] = array( 'message' => $record['formatted'], 'is_string' => true, 'label' => strtolower($record['level_name']), 'time' => $record['datetime']->format('U') ); } /** * @return array */ public function getMessages() { return $this->records; } /** * @return array */ public function collect() { return array( 'count' => count($this->records), 'records' => $this->records ); } /** * @return string */ public function getName() { return $this->name; } /** * @return array */ public function getWidgets() { $name = $this->getName(); return array( $name => array( "icon" => "suitcase", "widget" => "PhpDebugBar.Widgets.MessagesWidget", "map" => "$name.records", "default" => "[]" ), "$name:badge" => array( "map" => "$name.count", "default" => "null" ) ); } } PKZ 00.debugbar/src/DebugBar/Bridge/SlimCollector.phpnu[slim = $slim; if ($log = $slim->getLog()) { $this->originalLogWriter = $log->getWriter(); $log->setWriter($this); $log->setEnabled(true); } } public function write($message, $level) { if ($this->originalLogWriter) { $this->originalLogWriter->write($message, $level); } $this->addMessage($message, $this->getLevelName($level)); } protected function getLevelName($level) { $map = array( Log::EMERGENCY => LogLevel::EMERGENCY, Log::ALERT => LogLevel::ALERT, Log::CRITICAL => LogLevel::CRITICAL, Log::ERROR => LogLevel::ERROR, Log::WARN => LogLevel::WARNING, Log::NOTICE => LogLevel::NOTICE, Log::INFO => LogLevel::INFO, Log::DEBUG => LogLevel::DEBUG ); return $map[$level]; } public function getName() { return 'slim'; } } PKZT`t,debugbar/src/DebugBar/RequestIdGenerator.phpnu[= 5.3.0, but OpenSSL may not always be available return 'X' . bin2hex(openssl_random_pseudo_bytes(16)); } else { // Fall back to a rudimentary ID generator: // * $_SERVER array will make the ID unique to this request. // * spl_object_hash($this) will make the ID unique to this object instance. // (note that object hashes can be reused, but the other data here should prevent issues here). // * uniqid('', true) will use the current microtime(), plus additional random data. // * $this->index guarantees the uniqueness of IDs from the current object. $this->index++; $entropy = serialize($_SERVER) . uniqid('', true) . spl_object_hash($this) . $this->index; return 'X' . md5($entropy); } } } PKZJ*debugbar/src/DebugBar/StandardDebugBar.phpnu[addCollector(new PhpInfoCollector()); $this->addCollector(new MessagesCollector()); $this->addCollector(new RequestDataCollector()); $this->addCollector(new TimeDataCollector()); $this->addCollector(new MemoryCollector()); $this->addCollector(new ExceptionsCollector()); } } PKZ6H-debugbar/src/DebugBar/HttpDriverInterface.phpnu[debugbar/src/DebugBar/DataFormatter/DataFormatterInterface.phpnu[ 0, 'styles' => array( // NOTE: 'default' CSS is also specified in debugbar.css 'default' => 'word-wrap: break-word; white-space: pre-wrap; word-break: normal', 'num' => 'font-weight:bold; color:#1299DA', 'const' => 'font-weight:bold', 'str' => 'font-weight:bold; color:#3A9B26', 'note' => 'color:#1299DA', 'ref' => 'color:#7B7B7B', 'public' => 'color:#000000', 'protected' => 'color:#000000', 'private' => 'color:#000000', 'meta' => 'color:#B729D9', 'key' => 'color:#3A9B26', 'index' => 'color:#1299DA', 'ellipsis' => 'color:#A0A000', ), ); protected $clonerOptions; protected $dumperOptions; /** @var VarCloner */ protected $cloner; /** @var DebugBarHtmlDumper */ protected $dumper; /** * Gets the VarCloner instance with configuration options set. * * @return VarCloner */ protected function getCloner() { if (!$this->cloner) { $clonerOptions = $this->getClonerOptions(); if (isset($clonerOptions['casters'])) { $this->cloner = new VarCloner($clonerOptions['casters']); } else { $this->cloner = new VarCloner(); } if (isset($clonerOptions['additional_casters'])) { $this->cloner->addCasters($clonerOptions['additional_casters']); } if (isset($clonerOptions['max_items'])) { $this->cloner->setMaxItems($clonerOptions['max_items']); } if (isset($clonerOptions['max_string'])) { $this->cloner->setMaxString($clonerOptions['max_string']); } // setMinDepth was added to Symfony 3.4: if (isset($clonerOptions['min_depth']) && method_exists($this->cloner, 'setMinDepth')) { $this->cloner->setMinDepth($clonerOptions['min_depth']); } } return $this->cloner; } /** * Gets the DebugBarHtmlDumper instance with configuration options set. * * @return DebugBarHtmlDumper */ protected function getDumper() { if (!$this->dumper) { $this->dumper = new DebugBarHtmlDumper(); $dumperOptions = $this->getDumperOptions(); if (isset($dumperOptions['styles'])) { $this->dumper->setStyles($dumperOptions['styles']); } } return $this->dumper; } /** * Gets the array of non-default VarCloner configuration options. * * @return array */ public function getClonerOptions() { if ($this->clonerOptions === null) { $this->clonerOptions = self::$defaultClonerOptions; } return $this->clonerOptions; } /** * Merges an array of non-default VarCloner configuration options with the existing non-default * options. * * Configuration options are: * - casters: a map of VarDumper Caster objects to use instead of the default casters. * - additional_casters: a map of VarDumper Caster objects to use in addition to the default * casters. * - max_items: maximum number of items to clone beyond the minimum depth. * - max_string: maximum string size * - min_depth: minimum tree depth to clone before counting items against the max_items limit. * (Requires Symfony 3.4; ignored on older versions.) * * @param array $options */ public function mergeClonerOptions($options) { $this->clonerOptions = $options + $this->getClonerOptions(); $this->cloner = null; } /** * Resets the array of non-default VarCloner configuration options without retaining any of the * existing non-default options. * * Configuration options are: * - casters: a map of VarDumper Caster objects to use instead of the default casters. * - additional_casters: a map of VarDumper Caster objects to use in addition to the default * casters. * - max_items: maximum number of items to clone beyond the minimum depth. * - max_string: maximum string size * - min_depth: minimum tree depth to clone before counting items against the max_items limit. * (Requires Symfony 3.4; ignored on older versions.) * * @param array $options */ public function resetClonerOptions($options = null) { $this->clonerOptions = ($options ?: array()) + self::$defaultClonerOptions; $this->cloner = null; } /** * Gets the array of non-default HtmlDumper configuration options. * * @return array */ public function getDumperOptions() { if ($this->dumperOptions === null) { $this->dumperOptions = self::$defaultDumperOptions; } return $this->dumperOptions; } /** * Merges an array of non-default HtmlDumper configuration options with the existing non-default * options. * * Configuration options are: * - styles: a map of CSS styles to include in the assets, as documented in * HtmlDumper::setStyles. * - expanded_depth: the tree depth to initially expand. * (Requires Symfony 3.2; ignored on older versions.) * - max_string: maximum string size. * (Requires Symfony 3.2; ignored on older versions.) * - file_link_format: link format for files; %f expanded to file and %l expanded to line * (Requires Symfony 3.2; ignored on older versions.) * * @param array $options */ public function mergeDumperOptions($options) { $this->dumperOptions = $options + $this->getDumperOptions(); $this->dumper = null; } /** * Resets the array of non-default HtmlDumper configuration options without retaining any of the * existing non-default options. * * Configuration options are: * - styles: a map of CSS styles to include in the assets, as documented in * HtmlDumper::setStyles. * - expanded_depth: the tree depth to initially expand. * (Requires Symfony 3.2; ignored on older versions.) * - max_string: maximum string size. * (Requires Symfony 3.2; ignored on older versions.) * - file_link_format: link format for files; %f expanded to file and %l expanded to line * (Requires Symfony 3.2; ignored on older versions.) * * @param array $options */ public function resetDumperOptions($options = null) { $this->dumperOptions = ($options ?: array()) + self::$defaultDumperOptions; $this->dumper = null; } /** * Captures the data from a variable and serializes it for later rendering. * * @param mixed $data The variable to capture. * @return string Serialized variable data. */ public function captureVar($data) { return serialize($this->getCloner()->cloneVar($data)); } /** * Gets the display options for the HTML dumper. * * @return array */ protected function getDisplayOptions() { $displayOptions = array(); $dumperOptions = $this->getDumperOptions(); // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['expanded_depth'])) { $displayOptions['maxDepth'] = $dumperOptions['expanded_depth']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['max_string'])) { $displayOptions['maxStringLength'] = $dumperOptions['max_string']; } // Only used by Symfony 3.2 and newer: if (isset($dumperOptions['file_link_format'])) { $displayOptions['fileLinkFormat'] = $dumperOptions['file_link_format']; } return $displayOptions; } /** * Renders previously-captured data from captureVar to HTML and returns it as a string. * * @param string $capturedData Captured data from captureVar. * @param array $seekPath Pass an array of keys to traverse if you only want to render a subset * of the data. * @return string HTML rendering of the variable. */ public function renderCapturedVar($capturedData, $seekPath = array()) { $data = unserialize($capturedData); if (!method_exists($data, 'seek')) { $data = new SeekingData($data->getRawData()); } foreach ($seekPath as $key) { $data = $data->seek($key); } return $this->dump($data); } /** * Captures and renders the data from a variable to HTML and returns it as a string. * * @param mixed $data The variable to capture and render. * @return string HTML rendering of the variable. */ public function renderVar($data) { return $this->dump($this->getCloner()->cloneVar($data)); } /** * Returns assets required for rendering variables. * * @return array */ public function getAssets() { $dumper = $this->getDumper(); $dumper->resetDumpHeader(); // this will cause the default dump header to regenerate return array( 'inline_head' => array( 'html_var_dumper' => $dumper->getDumpHeaderByDebugBar(), ), ); } /** * Helper function to dump a Data object to HTML. * * @param Data $data * @return string */ protected function dump(Data $data) { $dumper = $this->getDumper(); $output = fopen('php://memory', 'r+b'); $dumper->setOutput($output); $dumper->setDumpHeader(''); // we don't actually want a dump header // NOTE: Symfony 3.2 added the third $extraDisplayOptions parameter. Older versions will // safely ignore it. $dumper->dump($data, null, $this->getDisplayOptions()); $result = stream_get_contents($output, -1, 0); fclose($output); return $result; } } PKZqt#VVDdebugbar/src/DebugBar/DataFormatter/VarDumper/DebugBarHtmlDumper.phpnu[dumpHeader = null; } public function getDumpHeaderByDebugBar() { // getDumpHeader is protected: return str_replace('pre.sf-dump', '.phpdebugbar pre.sf-dump', $this->getDumpHeader()); } } PKZX`qdd5debugbar/src/DebugBar/DataFormatter/DataFormatter.phpnu[cloner = new VarCloner(); $this->dumper = new CliDumper(); } /** * @param $data * @return string */ public function formatVar($data) { $output = ''; $this->dumper->dump( $this->cloner->cloneVar($data), function ($line, $depth) use (&$output) { // A negative depth means "end of dump" if ($depth >= 0) { // Adds a two spaces indentation to the line $output .= str_repeat(' ', $depth).$line."\n"; } } ); return trim($output); } /** * @param float $seconds * @return string */ public function formatDuration($seconds) { if ($seconds < 0.001) { return round($seconds * 1000000) . 'μs'; } elseif ($seconds < 0.1) { return round($seconds * 1000, 2) . 'ms'; } elseif ($seconds < 1) { return round($seconds * 1000) . 'ms'; } return round($seconds, 2) . 's'; } /** * @param string $size * @param int $precision * @return string */ public function formatBytes($size, $precision = 2) { if ($size === 0 || $size === null) { return "0B"; } $sign = $size < 0 ? '-' : ''; $size = abs($size); $base = log($size) / log(1024); $suffixes = array('B', 'KB', 'MB', 'GB', 'TB'); return $sign . round(pow(1024, $base - floor($base)), $precision) . $suffixes[(int) floor($base)]; } } PKZ8 7debugbar/src/DebugBar/DataCollector/ConfigCollector.phpnu[useHtmlVarDumper = $value; return $this; } /** * Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable * rendering. * * @return mixed */ public function isHtmlVarDumperUsed() { return $this->useHtmlVarDumper; } /** * @param array $data * @param string $name */ public function __construct(array $data = array(), $name = 'config') { $this->name = $name; $this->data = $data; } /** * Sets the data * * @param array $data */ public function setData(array $data) { $this->data = $data; } /** * @return array */ public function collect() { $data = array(); foreach ($this->data as $k => $v) { if ($this->isHtmlVarDumperUsed()) { $v = $this->getVarDumper()->renderVar($v); } else if (!is_string($v)) { $v = $this->getDataFormatter()->formatVar($v); } $data[$k] = $v; } return $data; } /** * @return string */ public function getName() { return $this->name; } /** * @return array */ public function getAssets() { return $this->isHtmlVarDumperUsed() ? $this->getVarDumper()->getAssets() : array(); } /** * @return array */ public function getWidgets() { $name = $this->getName(); $widget = $this->isHtmlVarDumperUsed() ? "PhpDebugBar.Widgets.HtmlVariableListWidget" : "PhpDebugBar.Widgets.VariableListWidget"; return array( "$name" => array( "icon" => "gear", "widget" => $widget, "map" => "$name", "default" => "{}" ) ); } } PKZϒ%=debugbar/src/DebugBar/DataCollector/LocalizationCollector.phpnu[ $this->getLocale(), 'domain' => $this->getDomain(), ); } /** * @return string */ public function getName() { return 'localization'; } /** * @return array */ public function getWidgets() { return array( 'domain' => array( 'icon' => 'bookmark', 'map' => 'localization.domain', ), 'locale' => array( 'icon' => 'flag', 'map' => 'localization.locale', ) ); } } PKZ&I 5debugbar/src/DebugBar/DataCollector/AssetProvider.phpnu[ tag) * - inline_js: an array map of content ID to inline JS content (not including ' . "\n", $file); } foreach ($inlineJs as $content) { $html .= sprintf('' . "\n", $nonce, $content); } foreach ($inlineHead as $content) { $html .= $content . "\n"; } if ($this->enableJqueryNoConflict && !$this->useRequireJs) { $html .= '' . "\n"; } return $html; } /** * Register shutdown to display the debug bar * * @param boolean $here Set position of HTML. True if is to current position or false for end file * @param boolean $initialize Whether to render the de bug bar initialization code * @param bool $renderStackedData * @param bool $head * @return string Return "{--DEBUGBAR_OB_START_REPLACE_ME--}" or return an empty string if $here == false */ public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true, $head = false) { register_shutdown_function(array($this, "replaceTagInBuffer"), $here, $initialize, $renderStackedData, $head); if (ob_get_level() === 0) { ob_start(); } return ($here) ? self::REPLACEABLE_TAG : ""; } /** * Same as renderOnShutdown() with $head = true * * @param boolean $here * @param boolean $initialize * @param boolean $renderStackedData * @return string */ public function renderOnShutdownWithHead($here = true, $initialize = true, $renderStackedData = true) { return $this->renderOnShutdown($here, $initialize, $renderStackedData, true); } /** * Is callback function for register_shutdown_function(...) * * @param boolean $here Set position of HTML. True if is to current position or false for end file * @param boolean $initialize Whether to render the de bug bar initialization code * @param bool $renderStackedData * @param bool $head */ public function replaceTagInBuffer($here = true, $initialize = true, $renderStackedData = true, $head = false) { $render = ($head ? $this->renderHead() : "") . $this->render($initialize, $renderStackedData); $current = ($here && ob_get_level() > 0) ? ob_get_clean() : self::REPLACEABLE_TAG; echo str_replace(self::REPLACEABLE_TAG, $render, $current, $count); if ($count === 0) { echo $render; } } /** * Returns the code needed to display the debug bar * * AJAX request should not render the initialization code. * * @param boolean $initialize Whether or not to render the debug bar initialization code * @param boolean $renderStackedData Whether or not to render the stacked data * @return string */ public function render($initialize = true, $renderStackedData = true) { $js = ''; if ($initialize) { $js = $this->getJsInitializationCode(); } if ($renderStackedData && $this->debugBar->hasStackedData()) { foreach ($this->debugBar->getStackedData() as $id => $data) { $js .= $this->getAddDatasetCode($id, $data, '(stacked)'); } } $suffix = !$initialize ? '(ajax)' : null; $js .= $this->getAddDatasetCode($this->debugBar->getCurrentRequestId(), $this->debugBar->getData(), $suffix); $nonce = $this->getNonceAttribute(); if ($nonce != '') { $js = preg_replace("/\n"; } else { return "\n"; } } /** * Returns the js code needed to initialize the debug bar * * @return string */ protected function getJsInitializationCode() { $js = ''; if (($this->initialization & self::INITIALIZE_CONSTRUCTOR) === self::INITIALIZE_CONSTRUCTOR) { $js .= sprintf("var %s = new %s();\n", $this->variableName, $this->javascriptClass); } if (($this->initialization & self::INITIALIZE_CONTROLS) === self::INITIALIZE_CONTROLS) { $js .= $this->getJsControlsDefinitionCode($this->variableName); } if ($this->ajaxHandlerClass) { $js .= sprintf("%s.ajaxHandler = new %s(%s, undefined, %s);\n", $this->variableName, $this->ajaxHandlerClass, $this->variableName, $this->ajaxHandlerAutoShow ? 'true' : 'false' ); if ($this->ajaxHandlerBindToFetch) { $js .= sprintf("%s.ajaxHandler.bindToFetch();\n", $this->variableName); } if ($this->ajaxHandlerBindToXHR) { $js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName); } elseif ($this->ajaxHandlerBindToJquery) { $js .= sprintf("if (jQuery) %s.ajaxHandler.bindToJquery(jQuery);\n", $this->variableName); } } if ($this->openHandlerUrl !== null) { $js .= sprintf("%s.setOpenHandler(new %s(%s));\n", $this->variableName, $this->openHandlerClass, json_encode(array("url" => $this->openHandlerUrl))); } return $js; } /** * Returns the js code needed to initialized the controls and data mapping of the debug bar * * Controls can be defined by collectors themselves or using {@see addControl()} * * @param string $varname Debug bar's variable name * @return string */ protected function getJsControlsDefinitionCode($varname) { $js = ''; $dataMap = array(); $excludedOptions = array('indicator', 'tab', 'map', 'default', 'widget', 'position'); // finds controls provided by collectors $widgets = array(); foreach ($this->debugBar->getCollectors() as $collector) { if (($collector instanceof Renderable) && !in_array($collector->getName(), $this->ignoredCollectors)) { if ($w = $collector->getWidgets()) { $widgets = array_merge($widgets, $w); } } } $controls = array_merge($widgets, $this->controls); foreach (array_filter($controls) as $name => $options) { $opts = array_diff_key($options, array_flip($excludedOptions)); if (isset($options['tab']) || isset($options['widget'])) { if (!isset($opts['title'])) { $opts['title'] = ucfirst(str_replace('_', ' ', $name)); } $js .= sprintf("%s.addTab(\"%s\", new %s({%s%s}));\n", $varname, $name, isset($options['tab']) ? $options['tab'] : 'PhpDebugBar.DebugBar.Tab', substr(json_encode($opts, JSON_FORCE_OBJECT), 1, -1), isset($options['widget']) ? sprintf('%s"widget": new %s()', count($opts) ? ', ' : '', $options['widget']) : '' ); } elseif (isset($options['indicator']) || isset($options['icon'])) { $js .= sprintf("%s.addIndicator(\"%s\", new %s(%s), \"%s\");\n", $varname, $name, isset($options['indicator']) ? $options['indicator'] : 'PhpDebugBar.DebugBar.Indicator', json_encode($opts, JSON_FORCE_OBJECT), isset($options['position']) ? $options['position'] : 'right' ); } if (isset($options['map']) && isset($options['default'])) { $dataMap[$name] = array($options['map'], $options['default']); } } // creates the data mapping object $mapJson = array(); foreach ($dataMap as $name => $values) { $mapJson[] = sprintf('"%s": ["%s", %s]', $name, $values[0], $values[1]); } $js .= sprintf("%s.setDataMap({\n%s\n});\n", $varname, implode(",\n", $mapJson)); // activate state restoration $js .= sprintf("%s.restoreState();\n", $varname); return $js; } /** * Returns the js code needed to add a dataset * * @param string $requestId * @param array $data * @param mixed $suffix * @return string */ protected function getAddDatasetCode($requestId, $data, $suffix = null) { $js = sprintf("%s.addDataSet(%s, \"%s\"%s);\n", $this->variableName, json_encode($data), $requestId, $suffix ? ", " . json_encode($suffix) : '' ); return $js; } /** * If a nonce it set, create the correct attribute * @return string */ protected function getNonceAttribute() { if ($nonce = $this->getCspNonce()) { return ' nonce="' . $nonce .'"'; } return ''; } } PKZzBXBX*debugbar/src/DebugBar/Resources/widgets.jsnu[if (typeof(PhpDebugBar) == 'undefined') { // namespace var PhpDebugBar = {}; PhpDebugBar.$ = jQuery; } (function($) { /** * @namespace */ PhpDebugBar.Widgets = {}; var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-'); /** * Replaces spaces with   and line breaks with
* * @param {String} text * @return {String} */ var htmlize = PhpDebugBar.Widgets.htmlize = function(text) { return text.replace(/\n/g, '
').replace(/\s/g, " ") }; /** * Returns a string representation of value, using JSON.stringify * if it's an object. * * @param {Object} value * @param {Boolean} prettify Uses htmlize() if true * @return {String} */ var renderValue = PhpDebugBar.Widgets.renderValue = function(value, prettify) { if (typeof(value) !== 'string') { if (prettify) { return htmlize(JSON.stringify(value, undefined, 2)); } return JSON.stringify(value); } return value; }; /** * Highlights a block of code * * @param {String} code * @param {String} lang * @return {String} */ var highlight = PhpDebugBar.Widgets.highlight = function(code, lang) { if (typeof(code) === 'string') { if (typeof(hljs) === 'undefined') { return htmlize(code); } if (lang) { return hljs.highlight(code, {language: lang}).value; } return hljs.highlightAuto(code).value; } if (typeof(hljs) === 'object') { code.each(function(i, e) { hljs.highlightElement(e); }); } return code; }; /** * Creates a
 element with a block of code
     *
     * @param  {String} code
     * @param  {String} lang
     * @param  {Number} [firstLineNumber] If provided, shows line numbers beginning with the given value.
     * @param  {Number} [highlightedLine] If provided, the given line number will be highlighted.
     * @return {String}
     */
    var createCodeBlock = PhpDebugBar.Widgets.createCodeBlock = function(code, lang, firstLineNumber, highlightedLine) {
        var pre = $('
').addClass(csscls('code-block'));
        // Add a newline to prevent  element from vertically collapsing too far if the last
        // code line was empty: that creates problems with the horizontal scrollbar being
        // incorrectly positioned - most noticeable when line numbers are shown.
        var codeElement = $('').text(code + '\n').appendTo(pre);

        // Add a span with a special class if we are supposed to highlight a line.  highlight.js will
        // still correctly format code even with existing markup in it.
        if ($.isNumeric(highlightedLine)) {
            if ($.isNumeric(firstLineNumber)) {
                highlightedLine = highlightedLine - firstLineNumber + 1;
            }
            codeElement.html(function (index, html) {
                var currentLine = 1;
                return html.replace(/^.*$/gm, function(line) {
                    if (currentLine++ == highlightedLine) {
                        return '' + line + '';
                    } else {
                        return line;
                    }
                });
            });
        }

        // Format the code
        if (lang) {
            pre.addClass("language-" + lang);
        }
        highlight(pre);

        // Show line numbers in a list
        if ($.isNumeric(firstLineNumber)) {
            var lineCount = code.split('\n').length;
            var $lineNumbers = $('