config() public static method

Set or get configuration options
public static config ( string $key, mixed | null $value = null ) : mixed
$key string
$value mixed | null
return mixed
Exemplo n.º 1
0
 /**
  * Setup ref
  * 
  * @return void
  */
 public static function init()
 {
     \ref::config('expLvl', 0);
     \ref::config('maxDepth', 10);
     \ref::config('showIteratorContents', TRUE);
     \ref::config('showPrivateMembers', TRUE);
 }
Exemplo n.º 2
0
 public function endExp()
 {
     if (ref::config('showBacktrace') && ($trace = ref::getBacktrace())) {
         $this->out .= " " . $trace['file'] . ':' . $trace['line'];
     }
     $this->out .= " \n";
 }
Exemplo n.º 3
0
 public function startGroup($prefix = '')
 {
     $maxDepth = ref::config('maxDepth');
     if ($maxDepth > 0 && $this->level + 1 > $maxDepth) {
         $this->emptyGroup('...');
         return false;
     }
     $this->level++;
     $this->out .= '(';
     $this->indent += $this->levelPad[$this->level - 1];
     return true;
 }
Exemplo n.º 4
0
 public function endExp()
 {
     if (ref::config('showBacktrace') && ($trace = ref::getBacktrace())) {
         $this->out .= ' - ' . $trace['file'] . ':' . $trace['line'];
     }
     $this->out .= "\n" . str_repeat('=', strlen($this->out)) . "\n";
 }
Exemplo n.º 5
0
<?php

// configuration for php-ref
ref::config('showMethods', false);
Exemplo n.º 6
0
 public function endExp()
 {
     if (ref::config('showBacktrace')) {
         $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         if (isset($traces[2])) {
             $trace = $traces[2];
             $this->out .= ' - ' . $trace['file'] . ':' . $trace['line'];
         }
     }
     $this->out .= "\n" . str_repeat('=', strlen($this->out)) . "\n";
 }
Exemplo n.º 7
0
function print_vars($vars)
{
    if ($GLOBALS['cli']) {
        if (function_exists('rt')) {
            ref::config('shortcutFunc', array('print_vars'));
            ref::config('showUrls', FALSE);
            if (OBS_DEBUG > 0) {
                $trace = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
                ref::config('Backtrace', $trace);
                // pass original backtrace
                ref::config('showStringMatches', FALSE);
            } else {
                ref::config('showBacktrace', FALSE);
                ref::config('showResourceInfo', FALSE);
                ref::config('showStringMatches', FALSE);
                ref::config('showMethods', FALSE);
            }
            rt($vars);
        } else {
            print_r($vars);
        }
    } else {
        if (function_exists('r')) {
            ref::config('shortcutFunc', array('print_vars'));
            ref::config('showUrls', FALSE);
            if (OBS_DEBUG > 0) {
                $trace = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
                ref::config('Backtrace', $trace);
                // pass original backtrace
            } else {
                ref::config('showBacktrace', FALSE);
                ref::config('showResourceInfo', FALSE);
                ref::config('showStringMatches', FALSE);
                ref::config('showMethods', FALSE);
            }
            //ref::config('stylePath',  $GLOBALS['config']['html_dir'] . '/css/ref.css');
            //ref::config('scriptPath', $GLOBALS['config']['html_dir'] . '/js/ref.js');
            r($vars);
        } else {
            print_r($vars);
        }
    }
}
Exemplo n.º 8
0
<?php

ref::config('showPrivateMembers', true);
ref::config('expLvl', 3);
ref::config('showUrls', false);
// init app
$app = new \SlimController\Slim(array('templates.path' => dirname(__DIR__) . '/views', 'cookies.secret_key' => md5('appsecretkey'), 'controller.class_suffix' => '', 'controller.method_suffix' => '', 'controller.template_suffix' => 'twig', 'mode' => 'production', 'debug' => true));
if ($app->config('debug') === true) {
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
    $app->config('whoops.editor', 'sublime');
    $app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
}
/** Create monolog logger and store logger in container as singleton
 * (Singleton resources retrieve the same log resource definition each time)
 *  $app->log->info("Log error");
 *  try catch hook
 *  $app->applyHook('log.request.info', $e->getMessage());
 *  $app->log->error($e);
 */
$app->container->singleton('log', function () use($app) {
    $logpath = APP_PATH . '/app/logs/' . date('Y/m');
    $logfile = $logpath . '/' . date('d') . '.log';
    $old = umask(0);
    if (!is_dir($logpath)) {
        mkdir($logpath, 0777, true);
    }
    if (!is_writable($logpath)) {
        chmod($logfile, 0777);
    }
    if (!file_exists($logfile)) {
Exemplo n.º 9
0
<?php

if (isset($_GET['mode'])) {
    $htmlMode = $_GET['mode'] !== 'text';
    require dirname(__DIR__) . '/ref.php';
    require __DIR__ . '/example.class.php';
    ref::config('showPrivateMembers', true);
    ref::config('showIteratorContents', true);
    ref::config('showUrls', true);
    ref::config('showBacktrace', false);
    /**
     * Test class
     */
    final class Today extends \Tests\ClassTest
    {
    }
    /**
     * Test function
     *
     * @param   $test  Test argument
     * @return  void   Nothing
     */
    function today($test)
    {
    }
    $closedCurlRes = curl_init();
    curl_close($closedCurlRes);
    $array = array('hèllo world' => '(͡°͜ʖ͡°)', 'empty string' => '', 'multiline string' => "first line and some padding   \nsecond line", 'infinity' => INF, 'regular expression (pcre)' => '/^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$/', 'multi' => array(1, 2, 3, array(4, 5, 6), 'FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU'), 'matching class' => 'DateTime', 'matching file' => 'file.txt', 'incomplete object' => unserialize('O:3:"Foo":1:{s:3:"bar";i:5;}'), 'empty object' => new \StdClass(), 'closed CURL resource' => $closedCurlRes, 'matching date/file/function/class' => 'today', 'url' => 'http://google.com');
    $array['reference to self'] =& $array;
    $obj = new \Tests\ClassTest(array('foo', 'bar'), $array);
    if ($htmlMode) {
Exemplo n.º 10
0
<?php

if (isset($_GET['mode'])) {
    $htmlMode = $_GET['mode'] !== 'text';
    require dirname(__DIR__) . '/ref.php';
    require __DIR__ . '/example.class.php';
    ref::config('showPrivateMembers', true);
    ref::config('showIteratorContents', true);
    /**
     * Test class
     */
    final class Today extends \Tests\ClassTest
    {
    }
    /**
     * Test function
     *
     * @param   $test  Test argument
     * @return  void   Nothing
     */
    function today($test)
    {
    }
    $array = array('hèllo world' => '(͡°͜ʖ͡°)', 'empty string' => '', 'multiline string' => "first line and some padding   \nsecond line", 'infinity' => INF, 'regular expression (pcre)' => '/^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$/', 'multi' => array(1, 2, 3, array(4, 5, 6), 'FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU'), 'matching class' => 'DateTime', 'matching file' => 'file.txt', 'incomplete object' => unserialize('O:3:"Foo":1:{s:3:"bar";i:5;}'), 'empty object' => new \StdClass(), 'matching date/file/function/class' => 'today');
    $array['reference to self'] =& $array;
    $obj = new \Tests\ClassTest(array('foo', 'bar'), $array);
    if ($htmlMode) {
        r(true, false, 'I can haz a 강남스타일 string', '1492-10-14 04:20:00 America/Nassau', null, 4.2);
        r(array(), $array, serialize(array('A', 'serialized', 'string')));
        r(fopen('php://stdin', 'r'), function ($x, $d) {
        });
Exemplo n.º 11
0
 /**
  * Get styles and javascript (only generated for the 1st call)
  *
  * @return  string
  */
 public static function getAssets()
 {
     // first call? include styles and javascript
     if (static::$didAssets) {
         return '';
     }
     ob_start();
     if (ref::config('stylePath') !== false) {
         ?>
         <style>
             <?php 
         readfile(str_replace('{:dir}', __DIR__, ref::config('stylePath')));
         ?>
         </style>
         <?php 
     }
     if (ref::config('scriptPath') !== false) {
         ?>
         <script>
             <?php 
         readfile(str_replace('{:dir}', __DIR__, ref::config('scriptPath')));
         ?>
         </script>
         <?php 
     }
     // normalize space and remove comments
     $output = preg_replace('/\\s+/', ' ', trim(ob_get_clean()));
     $output = preg_replace('!/\\*.*?\\*/!s', '', $output);
     $output = preg_replace('/\\n\\s*\\n/', "\n", $output);
     static::$didAssets = true;
     return $output;
 }