Example #1
0
/**
 * Dump info about object
 * @param string $object
 * @return void
 */
function var_dump($object)
{
    $object = trim((string) $object);
    // Object name isn't valid
    if (empty($object)) {
        return \var_dump(null);
    }
    $storage = storage();
    // Object doesn't exists
    if (!isset($storage['objects'][$object])) {
        return \var_dump(null);
    }
    \var_dump($storage['objects'][$object]);
}
Example #2
0
 public function __construct($storage)
 {
     if (is_object($storage) && !$storage instanceof File) {
         throw new Error('Invalid File Logger Handler, need Onion\\Storage\\File');
     }
     if (is_string($storage)) {
         $storage = storage($storage);
     }
     $this->storage = $storage;
 }
Example #3
0
    exit;
}
if (isset($_POST["postrotate"])) {
    rotate_save();
    exit;
}
if (isset($_POST["rotate-delete"])) {
    rotate_delete();
    exit;
}
if (isset($_POST["rotate-enable"])) {
    rotate_enable();
    exit;
}
if (isset($_GET["storage"])) {
    storage();
    exit;
}
if (isset($_POST["DELETE-ALL"])) {
    schedules_delete();
    exit;
}
if (isset($_POST["DELETE-STORE"])) {
    storage_remove();
    exit;
}
if (isset($_POST["storage-delete"])) {
    storage_delete();
    exit;
}
if (isset($_GET["storage-view-search"])) {
Example #4
0
/**
 * Check is object is an instance of class
 * @param string $object
 * @param string $class
 * @return boolean
 */
function _instanceof($object, $class)
{
    $object = trim((string) $object);
    $class = trim((string) $class);
    // Object name isn't allowed
    if (empty($object)) {
        return false;
    } elseif (empty($class)) {
        // Class name isn't allowed
        trigger_error("Class name cannot be empty", E_USER_ERROR);
    }
    $class_l = strtolower($class);
    $storage = storage();
    // Class doesn't exists
    if (!isset($storage['classes'][$class_l])) {
        trigger_error("Class {$class} not found", E_USER_ERROR);
    } elseif (!isset($storage['objects'][$object])) {
        // Object doesn't exists
        return false;
    } elseif ($class_l === $storage['objects'][$object]['class_l']) {
        return true;
    } elseif (isset($storage['classes'][$class_l]['extends'][0])) {
        // Foreach class parents check if is instance
        foreach ($storage['classes'][$class_l]['extends'] as $value) {
            if (_instanceof($object, $value)) {
                return true;
            }
        }
    }
    return false;
}
Example #5
0
<?php

function getNum($action)
{
    while (1) {
        $num = rand(1000, 9999);
        $stored = $action->send($num);
        if ($stored > 500) {
            break;
        }
    }
}
function storage()
{
    $r = 0;
    while (1) {
        $num = (yield $r);
        if ($num) {
            echo $num . "\n";
            file_put_contents("./car.txt", $num . "\n", FILE_APPEND);
            $r++;
        }
    }
}
$S = storage();
getNum($S);