Exemple #1
0
        $this->_backend = $backend;
        return;
    }
    /**
     * Clean cache.
     *
     * @param   int  $lifetime    Lifetime of caches.
     * @return  void
     */
    public function cleanCache($lifetime = Cache::CLEAN_EXPIRED)
    {
        if (null === $this->_backend) {
            return;
        }
        return $this->_backend->clean($lifetime);
    }
    /**
     * Get the backend.
     *
     * @return  \Hoa\Cache\Backend
     */
    public function getBackend()
    {
        return $this->_backend;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Cache\\Frontend\\Frontend');
Exemple #2
0
     * Save data.
     *
     * @param   mixed  $data    Data to store.
     * @return  void
     */
    public abstract function store($data);
    /**
     * Load data.
     *
     * @return  mixed
     */
    public abstract function load();
    /**
     * Clean data.
     *
     * @param   int  $lifetime    Lifetime of caches.
     * @return  void
     */
    public abstract function clean($lifetime = Cache::CLEAN_EXPIRED);
    /**
     * Remove data.
     *
     * @return  void
     */
    public abstract function remove();
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Cache\\Backend\\Backend');
Exemple #3
0
 /**
  * The entry method.
  *
  * @return  int
  */
 public function main()
 {
     $directories = [];
     $files = [];
     $namespaces = [];
     $filter = [];
     $debug = false;
     $php = null;
     $concurrentProcesses = 2;
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case 'a':
                 $iterator = new File\Finder();
                 $iterator->in(resolve('hoa://Library/', true, true))->directories()->maxDepth(1);
                 foreach ($iterator as $fileinfo) {
                     $libraryName = $fileinfo->getBasename();
                     if (true === Consistency::isKeyword($libraryName)) {
                         continue;
                     }
                     $pathname = resolve('hoa://Library/' . $libraryName);
                     $tests = $pathname . DS . 'Test' . DS;
                     $manualTests = $tests . 'Unit';
                     $automaticTests = $tests . 'Praspel' . DS . 'Unit';
                     if (is_dir($manualTests)) {
                         $directories[] = $manualTests;
                     }
                     if (is_dir($automaticTests)) {
                         $directories[] = $automaticTests;
                     }
                 }
                 break;
             case 'l':
                 foreach ($this->parser->parseSpecialValue($v) as $library) {
                     $libraryName = ucfirst(strtolower($library));
                     $pathname = resolve('hoa://Library/' . $libraryName);
                     $tests = $pathname . DS . 'Test';
                     if (!is_dir($tests)) {
                         throw new Console\Exception('Library %s does not exist or has no test.', 0, $libraryName);
                     }
                     $directories[] = $tests;
                     $namespaces[] = 'Hoa\\' . $libraryName;
                 }
                 break;
             case 'n':
                 foreach ($this->parser->parseSpecialValue($v) as $namespace) {
                     $namespace = str_replace('.', '\\', $namespace);
                     $parts = explode('\\', $namespace);
                     if (2 > count($parts)) {
                         throw new Console\Exception('Namespace %s is too short.', 1, $namespace);
                     }
                     $head = resolve('hoa://Library/' . $parts[1]);
                     $tail = implode(DS, array_slice($parts, 2));
                     $namespaceDirectory = $head . DS . $tail;
                     if (!is_dir($namespaceDirectory)) {
                         throw new Console\Exception('Namespace %s does not exist.', 2, $namespace);
                     }
                     $tests = $head . DS . 'Test' . DS;
                     $manualTests = $tests . 'Unit' . DS . $tail;
                     $automaticTests = $tests . 'Praspel' . DS . 'Unit' . DS . $tail;
                     if (is_dir($manualTests)) {
                         $directories[] = $manualTests;
                     }
                     if (is_dir($automaticTests)) {
                         $directories[] = $automaticTests;
                     }
                     $namespaces[] = $namespace;
                 }
                 break;
             case 'd':
                 foreach ($this->parser->parseSpecialValue($v) as $directory) {
                     if (!is_dir($directory)) {
                         throw new Console\Exception('Directory %s does not exist.', 3, $directory);
                     }
                     $directories[] = $directory;
                 }
                 break;
             case 'f':
                 foreach ($this->parser->parseSpecialValue($v) as $file) {
                     if (!file_exists($file)) {
                         throw new Console\Exception('File %s does not exist.', 4, $file);
                     }
                     $files[] = $file;
                 }
                 break;
             case 'F':
                 $filter = $v;
                 break;
             case 'D':
                 $debug = $v;
                 break;
             case 'p':
                 $php = $v;
                 break;
             case 'P':
                 $concurrentProcesses = intval($v);
                 break;
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
             case 'h':
             case '?':
             default:
                 return $this->usage();
                 break;
         }
     }
     $atoum = 'atoum';
     if (WITH_COMPOSER) {
         $atoum = __DIR__ . DS . '..' . DS . '..' . DS . '..' . DS . 'bin' . DS . 'atoum';
     } elseif (isset($_SERVER['HOA_ATOUM_BIN'])) {
         $atoum = $_SERVER['HOA_ATOUM_BIN'];
     }
     $command = $atoum . ' --configurations ' . resolve('hoa://Library/Test/.atoum.php') . ' --bootstrap-file ' . resolve('hoa://Library/Test/.bootstrap.atoum.php') . ' --force-terminal' . ' --max-children-number ' . $concurrentProcesses;
     if (true === $debug) {
         $command .= ' --debug';
     }
     if (null !== $php) {
         $command .= ' --php ' . $php;
     }
     if (!empty($directories)) {
         $command .= ' --directories ' . implode(' ', $directories);
     } elseif (!empty($files)) {
         $command .= ' --files ' . implode(' ', $files);
     } else {
         return $this->usage();
     }
     if (!empty($namespaces)) {
         $command .= ' --namespaces ' . implode(' ', $namespaces);
     }
     if (!empty($filter)) {
         $command .= ' --filter \'' . str_replace('\'', '\'"\'"\'', $filter) . '\'';
     }
     $_server = $_SERVER;
     $_server['HOA_PREVIOUS_CWD'] = getcwd();
     $processus = new Processus($command, null, null, resolve('hoa://Library/Test/'), $_server);
     $processus->on('input', function ($bucket) {
         return false;
     });
     $processus->on('output', function ($bucket) {
         $data = $bucket->getData();
         echo $data['line'], "\n";
         return;
     });
     $processus->run();
     return;
 }
Exemple #4
0
            } else {
                throw new Exception('Cannot remove the stream filter %s because no resource was ' . 'found with this name.', 2, $streamFilter);
            }
        }
        return stream_filter_remove($streamFilter);
    }
    /**
     * Check if a filter is already registered or not.
     *
     * @param   string  $name    Filter name.
     * @return  bool
     */
    public static function isRegistered($name)
    {
        return in_array($name, self::getRegistered());
    }
    /**
     * Get all registered filer names.
     *
     * @return  array
     */
    public static function getRegistered()
    {
        return stream_get_filters();
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Stream\\Filter\\Filter');
Exemple #5
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Xyl\Element;

use Hoa\Consistency;
use Hoa\Xml;
/**
 * Class \Hoa\Xyl\Element.
 *
 * Represent any XYL element.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
interface Element extends Xml\Element
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Xyl\\Element\\Element');
Exemple #6
0
use Hoa\Consistency;
use Hoa\Xyl;
/**
 * Class \Hoa\Xyl\Interpreter\Html.
 *
 * HTML interpreter.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Html extends Xyl\Interpreter
{
    /**
     * Rank: abstract elements to concrete elements.
     *
     * @var array
     */
    protected $_rank = ['document' => '\\Hoa\\Xyl\\Interpreter\\Html\\Document', 'title' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'definition' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylYield', 'value' => '\\Hoa\\Xyl\\Interpreter\\Common\\Value', 'yield' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylYield', 'fragment' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylYield', 'snippet' => '\\Hoa\\Xyl\\Interpreter\\Common\\Snippet', 'if' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylIf', 'elseif' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylElseif', 'else' => '\\Hoa\\Xyl\\Interpreter\\Common\\XylElse', '_' => '\\Hoa\\Xyl\\Interpreter\\Common\\Translate', 'script' => '\\Hoa\\Xyl\\Interpreter\\Html\\Script', 'noscript' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'section' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'nav' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'article' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'aside' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'h1' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'h2' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'h3' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'h4' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'h5' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'h6' => '\\Hoa\\Xyl\\Interpreter\\Html\\Heading', 'hgroup' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'header' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'footer' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'address' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'tableofcontents' => '\\Hoa\\Xyl\\Interpreter\\Html\\Tableofcontents', 'p' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'blockquote' => '\\Hoa\\Xyl\\Interpreter\\Html\\Q', 'hr' => '\\Hoa\\Xyl\\Interpreter\\Html\\Hr', 'pre' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'ol' => '\\Hoa\\Xyl\\Interpreter\\Html\\Ol', 'ul' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'li' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'dl' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'dt' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'dd' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'figure' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'figcaption' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'main' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'div' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'error' => '\\Hoa\\Xyl\\Interpreter\\Html\\Error', 'a' => '\\Hoa\\Xyl\\Interpreter\\Html\\A', 'em' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'strong' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'small' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 's' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'cite' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'q' => '\\Hoa\\Xyl\\Interpreter\\Html\\Q', 'dfn' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'abbr' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'data' => '\\Hoa\\Xyl\\Interpreter\\Html\\Data', 'time' => '\\Hoa\\Xyl\\Interpreter\\Html\\Time', 'code' => '\\Hoa\\Xyl\\Interpreter\\Html\\Code', 'var' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'samp' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'kbd' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'sub' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'sup' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'i' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'b' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'u' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'mark' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'ruby' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'rt' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'rp' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'bdi' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'bdo' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'span' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'br' => '\\Hoa\\Xyl\\Interpreter\\Html\\Br', 'wbr' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'ins' => '\\Hoa\\Xyl\\Interpreter\\Html\\Mod', 'del' => '\\Hoa\\Xyl\\Interpreter\\Html\\Mod', 'img' => '\\Hoa\\Xyl\\Interpreter\\Html\\Img', 'iframe' => '\\Hoa\\Xyl\\Interpreter\\Html\\Iframe', 'video' => '\\Hoa\\Xyl\\Interpreter\\Html\\Video', 'audio' => '\\Hoa\\Xyl\\Interpreter\\Html\\Media', 'source' => '\\Hoa\\Xyl\\Interpreter\\Html\\Source', 'track' => '\\Hoa\\Xyl\\Interpreter\\Html\\Track', 'object' => '\\Hoa\\Xyl\\Interpreter\\Html\\HtmlObject', 'param' => '\\Hoa\\Xyl\\Interpreter\\Html\\Param', 'canvas' => '\\Hoa\\Xyl\\Interpreter\\Html\\Canvas', 'table' => '\\Hoa\\Xyl\\Interpreter\\Html\\Table', 'caption' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'colgroup' => '\\Hoa\\Xyl\\Interpreter\\Html\\TableCol', 'col' => '\\Hoa\\Xyl\\Interpreter\\Html\\TableCol', 'tbody' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'thead' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'tfoot' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'tr' => '\\Hoa\\Xyl\\Interpreter\\Html\\Generic', 'td' => '\\Hoa\\Xyl\\Interpreter\\Html\\Td', 'th' => '\\Hoa\\Xyl\\Interpreter\\Html\\Th', 'form' => '\\Hoa\\Xyl\\Interpreter\\Html\\Form', 'async' => '\\Hoa\\Xyl\\Interpreter\\Html\\Async', 'fieldset' => '\\Hoa\\Xyl\\Interpreter\\Html\\Fieldset', 'legend' => '\\Hoa\\Xyl\\Interpreter\\Html\\GenericPhrasing', 'label' => '\\Hoa\\Xyl\\Interpreter\\Html\\Label', 'input' => '\\Hoa\\Xyl\\Interpreter\\Html\\Input', 'button' => '\\Hoa\\Xyl\\Interpreter\\Html\\Button', 'select' => '\\Hoa\\Xyl\\Interpreter\\Html\\Select', 'optgroup' => '\\Hoa\\Xyl\\Interpreter\\Html\\Optgroup', 'option' => '\\Hoa\\Xyl\\Interpreter\\Html\\Option', 'textarea' => '\\Hoa\\Xyl\\Interpreter\\Html\\Textarea', 'keygen' => '\\Hoa\\Xyl\\Interpreter\\Html\\Keygen', 'output' => '\\Hoa\\Xyl\\Interpreter\\Html\\Output', 'progress' => '\\Hoa\\Xyl\\Interpreter\\Html\\Progress', 'meter' => '\\Hoa\\Xyl\\Interpreter\\Html\\Meter', 'tabs' => '\\Hoa\\Xyl\\Interpreter\\Html\\Tabs', 'tablist' => '\\Hoa\\Xyl\\Interpreter\\Html\\Tablist', 'tab' => '\\Hoa\\Xyl\\Interpreter\\Html\\Tab', 'tabpanel' => '\\Hoa\\Xyl\\Interpreter\\Html\\Tabpanel', 'checkpoint' => '\\Hoa\\Xyl\\Interpreter\\Html\\Checkpoint', '__text' => '\\Hoa\\Xyl\\Interpreter\\Html\\Text'];
    /**
     * Resource path.
     *
     * @var string
     */
    protected $_resourcePath = 'Html/Resource/';
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Xyl\\Interpreter\\Html\\Html');
Exemple #7
0
                case 'double':
                    $self->withFloat((double) $value->readAll());
                    break;
                case 'i4':
                case 'int':
                    $self->withInteger((int) $value->readAll());
                    break;
                case 'string':
                    $self->withString(htmlspecialchars_decode($value->readAll()));
                    break;
                case 'struct':
                    $self = $self->withStructure();
                    foreach ($value->member as $member) {
                        $self->withName($member->name->readAll());
                        $this->computeValues($member->xpath('./value/*'), $self);
                    }
                    $self = $self->endStructure();
                    break;
                case 'nil':
                    $self->withNull();
                    break;
            }
        }
        return;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\XmlRpc\\Message\\Message');
Exemple #8
0
     *
     * @return  bool
     */
    public function eof()
    {
        return feof($this->getStream());
    }
    /**
     * Get filename component of path.
     *
     * @return  string
     */
    public function getBasename()
    {
        return basename($this->getSocket()->__toString());
    }
    /**
     * Get directory name component of path.
     *
     * @return  string
     */
    public function getDirname()
    {
        return dirname($this->getSocket()->__toString());
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Socket\\Connection\\Connection');
Exemple #9
0
 /**
  * Try the handshake by trying different protocol implementation.
  *
  * @return  void
  * @throws  \Hoa\Websocket\Exception
  * @throws  \Hoa\Websocket\Exception\BadProtocol
  */
 protected function doHandshake()
 {
     static $_tail = ['A', 'Q', 'g', 'w'];
     $connection = $this->getConnection();
     $connection->connect();
     $connection->setStreamBlocking(true);
     $key = substr(base64_encode(Consistency::uuid()), 0, 21) . $_tail[mt_rand(0, 3)] . '==';
     $expected = base64_encode(sha1($key . Protocol\Rfc6455::GUID, true));
     if (null === ($host = $this->getHost())) {
         throw new Exception('Host name is null. Please, use the %s::setHost() method.', 0, __CLASS__);
     }
     $connection->writeAll($request = 'GET ' . $this->getEndPoint() . ' HTTP/1.1' . CRLF . 'Host: ' . $host . CRLF . 'User-Agent: Hoa' . CRLF . 'Upgrade: WebSocket' . CRLF . 'Connection: Upgrade' . CRLF . 'Pragma: no-cache' . CRLF . 'Cache-Control: no-cache' . CRLF . 'Sec-WebSocket-Key: ' . $key . CRLF . 'Sec-WebSocket-Version: 13' . CRLF . CRLF);
     $buffer = $connection->read(2048);
     $response = $this->getResponse();
     $response->parse($buffer);
     if ($response::STATUS_SWITCHING_PROTOCOLS !== $response['status'] || 'websocket' !== strtolower($response['upgrade']) || 'upgrade' !== strtolower($response['connection']) || $expected !== $response['sec-websocket-accept']) {
         throw new Exception\BadProtocol('Handshake has failed, the server did not return a valid ' . 'response.' . "\n\n" . 'Client:' . "\n" . '    %s' . "\n" . 'Server:' . "\n" . '    %s', 0, [str_replace("\n", "\n" . '    ', $request), str_replace("\n", "\n" . '    ', $buffer)]);
     }
     $currentNode = $connection->getCurrentNode();
     $currentNode->setHandshake(SUCCEED);
     $currentNode->setProtocolImplementation(new Protocol\Rfc6455($connection));
     $this->getListener()->fire('open', new Event\Bucket());
     return;
 }
Exemple #10
0
     *
     * @return  int
     */
    public function tell()
    {
        $stream = $this->getStream();
        if (null === $stream) {
            return 0;
        }
        return ftell($stream);
    }
    /**
     * Create a file.
     *
     * @param   string  $name     File name.
     * @param   mixed   $dummy    To be compatible with childs.
     * @return  bool
     */
    public static function create($name, $dummy)
    {
        if (file_exists($name)) {
            return true;
        }
        return touch($name);
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\File\\File');
Exemple #11
0
     * By default, the last ID is removed.
     *
     * @return  void
     */
    protected function removeId()
    {
        unset(self::$_id[$this->getId()]);
        return;
    }
    /**
     * Sort array of arrays etc., according to keys, recursively.
     *
     * @param   array   $array    Array to sort.
     * @return  array
     */
    public function ksort(array &$array)
    {
        ksort($array);
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $array[$key] = $this->ksort($value);
            }
        }
        return $array;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Cache\\Cache');
Exemple #12
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Compiler\Exception;

use Hoa\Consistency;
use Hoa\Exception as HoaException;
/**
 * Class \Hoa\Compiler\Exception.
 *
 * Extending the \Hoa\Exception\Exception class.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Exception extends HoaException
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Compiler\\Exception\\Exception');
Exemple #13
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Math\Exception;

use Hoa\Consistency;
use Hoa\Exception as HoaException;
/**
 * Class \Hoa\Math\Exception.
 *
 * Extending the \Hoa\Exception\Exception class.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Exception extends HoaException
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Math\\Exception\\Exception');
Exemple #14
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Http\Exception;

use Hoa\Consistency;
use Hoa\Exception as HoaException;
/**
 * Class \Hoa\Http\Exception.
 *
 * Extending the \Hoa\Exception\Exception class.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Exception extends HoaException
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Http\\Exception\\Exception');
Exemple #15
0
    public function isSecured()
    {
        return $this->_secured;
    }
    /**
     * Get a string that represents the socket address.
     *
     * @return  string
     */
    public function __toString()
    {
        $out = null;
        if (true === $this->hasTransport()) {
            $out .= $this->getTransport() . '://';
        }
        if (true === $this->hasPort()) {
            if (self::ADDRESS_IPV6 === $this->getAddressType()) {
                $out .= '[' . $this->getAddress() . ']';
            } else {
                $out .= $this->getAddress();
            }
            return $out . ':' . $this->getPort();
        }
        return $out . $this->getAddress();
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Socket\\Socket');
Exemple #16
0
     * @param   string  $protocol    The wrapper name to be restored.
     * @return  bool
     */
    public static function restore($protocol)
    {
        return stream_wrapper_restore($protocol);
    }
    /**
     * Check if a protocol is registered or not.
     *
     * @param   string  $protocol    Protocol name.
     */
    public static function isRegistered($protocol)
    {
        return in_array($protocol, self::getRegistered());
    }
    /**
     * Get all registered wrapper.
     *
     * @return  array
     */
    public static function getRegistered()
    {
        return stream_get_wrappers();
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Stream\\Wrapper\\Wrapper');
Exemple #17
0
    public function setPPRepresentation($pp)
    {
        $old = $this->_pp;
        $this->_pp = $pp;
        $this->_transitional = false;
        return $old;
    }
    /**
     * Get PP representation of the rule.
     *
     * @return  string
     */
    public function getPPRepresentation()
    {
        return $this->_pp;
    }
    /**
     * Check whether the rule is transitional or not.
     *
     * @return  bool
     */
    public function isTransitional()
    {
        return $this->_transitional;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Compiler\\Llk\\Rule\\Rule');
Exemple #18
0
    /**
     * Get root the protocol.
     *
     * @return  \Hoa\Protocol\Node\Node
     */
    public static function getRoot()
    {
        return Protocol::getInstance();
    }
    /**
     * Print a tree of component.
     *
     * @return  string
     */
    public function __toString()
    {
        static $i = 0;
        $out = str_repeat('  ', $i) . $this->getName() . "\n";
        foreach ($this as $node) {
            ++$i;
            $out .= $node;
            --$i;
        }
        return $out;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Protocol\\Node\\Node');
Exemple #19
0
    /**
     * Component's name.
     *
     * @var string
     */
    protected $_name = 'Stream';
    /**
     * ID of the component.
     *
     * @param   string  $id    ID of the component.
     * @return  mixed
     */
    public function reachId($id)
    {
        return Stream::getStreamHandler($id);
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Stream\\Stream');
/**
 * Shutdown method.
 */
Consistency::registerShutdownFunction(xcallable('Hoa\\Stream\\Stream::_Hoa_Stream'));
/**
 * Add the `hoa://Library/Stream` node. Should be use to reach/get an entry
 * in the stream register.
 */
$protocol = Protocol::getInstance();
$protocol['Library'][] = new _Protocol();
Exemple #20
0
        throw new File\Exception('Cannot find an appropriated object that matches with ' . 'path %s when defining it.', 1, $target);
    }
    /**
     * Get the target name of a symbolic link.
     *
     * @return  string
     */
    public function getTargetName()
    {
        return readlink($this->getStreamName());
    }
    /**
     * Create a link.
     *
     * @param   string  $name      Link name.
     * @param   string  $target    Target name.
     * @return  bool
     */
    public static function create($name, $target)
    {
        if (false != linkinfo($name)) {
            return true;
        }
        return symlink($target, $name);
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\File\\Link\\Link');
Exemple #21
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Websocket\Exception;

use Hoa\Consistency;
use Hoa\Exception as HoaException;
/**
 * Class \Hoa\Websocket\Exception.
 *
 * Extending the \Hoa\Exception\Exception class.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Exception extends HoaException
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Websocket\\Exception\\Exception');
Exemple #22
0
     * @return  string
     */
    protected function setCurrentNamespace($namespace)
    {
        $old = $this->_currentNamespace;
        $this->_currentNamespace = $namespace;
        return $old;
    }
    /**
     * Generate a token value.
     * Complete and set next token namespace.
     *
     * @param   \Hoa\Compiler\Llk\Rule\Token  $token    Token.
     * @return  string
     */
    protected function generateToken(Compiler\Llk\Rule\Token $token)
    {
        $toNamespace = $this->completeToken($token);
        $this->setCurrentNamespace($toNamespace);
        $out = $this->_tokenSampler->visit($token->getAST());
        if (isset($this->_tokens[$this->_currentNamespace]['skip'])) {
            $out .= $this->_tokenSampler->visit($this->getSkipTokenAST());
        }
        return $out;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Compiler\\Llk\\Sampler\\Sampler');
Exemple #23
0
     * @return  string
     */
    public function getHash()
    {
        return $this->_hash;
    }
    /**
     * Delete head buffer.
     *
     * @return  void
     */
    public function __destruct()
    {
        $last = current(self::$_stack);
        if ($this->getHash() != $last[0]) {
            return;
        }
        for ($i = 0, $max = $last[1]; $i < $max; ++$i) {
            $this->flush();
            if (0 < $this->getBufferLevel()) {
                $this->deleteBuffer();
            }
        }
        return;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Http\\Response\\Response');
Exemple #24
0
Fichier : Xyl.php Projet : Jir4/Xyl
        }
        throw new Exception('Selector %s is not a valid selector.', 22, $selector);
    }
    /**
     * Destruct XYL object.
     *
     * @return  void
     */
    public function __destruct()
    {
        $protocol = Protocol::getInstance();
        unset($protocol['Library']['Xyl[' . $this->_i . ']']);
        return;
    }
}
/**
 * Class \Hoa\Xyl\_Protocol.
 *
 * The `hoa://Library/Xyl` node.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class _Protocol extends Protocol\Node
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Xyl\\Xyl');
Event::getEvent('hoa://Event/Exception')->attach(xcallable('Hoa\\Xyl\\Interpreter\\Common\\Debug', 'receiveException'));
Exemple #25
0
                    $out[] = $solution;
                }
            }
            return $out;
        }
        if (true !== $exists) {
            return $handle[0];
        }
        foreach ($handle as $solution) {
            if (file_exists($solution)) {
                return $solution;
            }
        }
        return static::NO_RESOLUTION;
    }
    /**
     * Clear the cache.
     *
     * @return  void
     */
    public static function clearCache()
    {
        self::$_cache = [];
        return;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Protocol\\Protocol');
Exemple #26
0
                     ? 3.4028235e38 - 1
                     : 1.7976931348623157e308 - 1;
        */
        if ($lower > $upper) {
            throw new Math\Exception('Unexpected values, float %f should be lower than %f', 2, [$lower, $upper]);
        }
        return $this->_getFloat($lower, $upper);
    }
    /**
     * Generate a continuous uniform distribution.
     *
     * @param   float      $lower    Lower bound value.
     * @param   float      $upper    Upper bound value.
     * @return  float
     */
    protected abstract function _getFloat($lower, $upper);
    /**
     * Get an exclude set.
     *
     * @return  array
     */
    public function getExcludeSet()
    {
        return [];
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Math\\Sampler\\Sampler');
Exemple #27
0
        $this->_body = $body;
        return $old;
    }
    /**
     * Get request body.
     *
     * @return  string
     */
    public function getBody()
    {
        return $this->_body;
    }
    /**
     * Dump (parse^-1).
     *
     * @return  string
     */
    public function __toString()
    {
        $out = null;
        foreach ($this->getHeaders() as $key => $value) {
            $out .= $key . ': ' . $value . CRLF;
        }
        return $out;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Http\\Http');
Exemple #28
0
     *
     * @param   string  $directory    Directory where the temporary filename
     *                                will be created. If the directory does not
     *                                exist, it may generate a file in the
     *                                system's temporary directory.
     * @param   string  $prefix       Prefix of the generated temporary
     *                                filename.
     * @return  string
     */
    public static function create($directory = null, $prefix = '__hoa_')
    {
        if (null === $directory || false === is_dir($directory)) {
            $directory = static::getTemporaryDirectory();
        }
        return tempnam($directory, $prefix);
    }
    /**
     * Get the directory path used for temporary files.
     *
     * @return  string
     */
    public static function getTemporaryDirectory()
    {
        return sys_get_temp_dir();
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\File\\Temporary\\Temporary');
Exemple #29
0
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\Irc\Exception;

use Hoa\Consistency;
use Hoa\Exception as HoaException;
/**
 * Class \Hoa\Irc\Exception.
 *
 * Extending the \Hoa\Exception\Exception class.
 *
 * @copyright  Copyright © 2007-2016 Hoa community
 * @license    New BSD License
 */
class Exception extends HoaException
{
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Irc\\Exception\\Exception');
Exemple #30
0
     * @return  void
     * @throws  \Hoa\Event\Exception
     */
    public static function notify($eventId, Source $source, Bucket $data)
    {
        if (false === self::eventExists($eventId)) {
            throw new Exception('Event ID %s does not exist, cannot send notification.', 3, $eventId);
        }
        $data->setSource($source);
        $event = self::getEvent($eventId);
        foreach ($event->_callable as $callable) {
            $callable($data);
        }
        return;
    }
    /**
     * Check whether an event exists.
     *
     * @param   string  $eventId    Event ID.
     * @return  bool
     */
    public static function eventExists($eventId)
    {
        return array_key_exists($eventId, self::$_register) && self::$_register[$eventId][self::KEY_SOURCE] !== null;
    }
}
/**
 * Flex entity.
 */
Consistency::flexEntity('Hoa\\Event\\Event');