Example #1
0
 function dnew($classname, array $arguments = [])
 {
     return Hoa\Core\Consistency::dnew($classname, $arguments);
 }
Example #2
0
            return;
        }
        /**
         * Get the backtrace tree.
         *
         * @access  public
         * @return  array
         */
        public function getTree()
        {
            return $this->_tree;
        }
        /**
         * Print the tree in DOT language.
         *
         * @access  public
         * @return  string
         */
        public function __toString()
        {
            $out = new \Hoa\Tree\Visitor\Dot();
            return $out->visit($this->getTree());
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Log\\Backtrace\\Backtrace');
}
Example #3
0
File: File.php Project: Hywan/File
        public function tell()
        {
            $stream = $this->getStream();
            if (null === $stream) {
                return 0;
            }
            return ftell($stream);
        }
        /**
         * Create a file.
         *
         * @access  public
         * @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);
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\File\\File');
}
Example #4
0
         */
        public function __toString()
        {
            return $this->getBacktrace()->__toString();
        }
    }
}
namespace {
    /**
     * Alias of \Hoa\Log::getInstance()->log().
     *
     * @access  public
     * @param   string  $message    The log message.
     * @param   int     $type       Type of message (please, see the class
     *                              constants).
     * @param   array   $extra      Extra dynamic informations.
     * @return  void
     */
    if (!function_exists('hlog')) {
        function hlog($message, $type = \Hoa\Log::DEBUG, $extra = array())
        {
            return \Hoa\Log::getChannel()->log($message, $type, $extra);
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Log\\Log');
}
Example #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\File\Exception {
    /**
     * Class \Hoa\File\Exception.
     *
     * Extending the \Hoa\Core\Exception class.
     *
     * @author     Ivan Enderlin <*****@*****.**>
     * @copyright  Copyright © 2007-2014 Ivan Enderlin.
     * @license    New BSD License
     */
    class Exception extends \Hoa\Core\Exception
    {
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\File\\Exception\\Exception');
}
Example #6
0
                                $self->setBuffer($char);
                                return $self->_readLine($char);
                            }
                            break 2;
                    }
                }
                return $state;
            }
            $tail = mb_substr($line, $current);
            $current -= $length;
            $self->setLine(mb_substr($line, 0, $current) . $solution . $tail);
            $self->setLineCurrent($current + mb_strlen($solution));
            \Hoa\Console\Cursor::move('←', $length);
            echo $solution;
            \Hoa\Console\Cursor::clear('→');
            echo $tail;
            \Hoa\Console\Cursor::move('←', mb_strlen($tail));
            return $state;
        }
    }
}
namespace {
    /**
     * Advanced interaction.
     */
    Hoa\Console::advancedInteraction();
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Console\\Readline\\Readline');
}
Example #7
0
 * POSSIBILITY OF SUCH DAMAGE.
 */
namespace Hoa\  {
    /**
     * Class \Hoa\ .
     *
     * Just for fun! Ghost code!
     *
     * @author     Ivan Enderlin <*****@*****.**>
     * @copyright  Copyright © 2007-2013 Ivan Enderlin.
     * @license    New BSD License
     */
    class  
    {
        public function  ()
        {
            throw new \Hoa\Core\Exception('I am a ghost class, ouuuuuhouuu!', 0);
        }
        public function   ()
        {
            $  = ' ';
            return $ ;
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\ \\ ');
}
Example #8
0
     * @author     Ivan Enderlin <*****@*****.**>
     * @copyright  Copyright © 2007-2014 Ivan Enderlin.
     * @license    New BSD License
     */
    interface Autocompleter
    {
        /**
         * Complete a word.
         * Returns null for no word, a full-word or an array of full-words.
         *
         * @access  public
         * @param   string  &$prefix    Prefix to autocomplete.
         * @return  mixed
         */
        public function complete(&$prefix);
        /**
         * Get definition of a word.
         * Example: \b\w+\b. PCRE delimiters and options must not be provided.
         *
         * @access  public
         * @return  string
         */
        public function getWordDefinition();
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Console\\Readline\\Autocompleter\\Autocompleter');
}
Example #9
0
            $this->_objectType = $type;
            return $old;
        }
        /**
         * Disable the prototype class type.
         *
         * @access  protected
         * @return  string
         */
        protected function disablePrototypeClassType()
        {
            return $this->setPrototypeClassType(null);
        }
        /**
         * Disable the prototype object type.
         *
         * @access  protected
         * @return  string
         */
        protected function disablePrototypeObjectType()
        {
            return $this->setPrototypeObjectType(null);
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Prototype\\Prototype');
}
Example #10
0
         *                                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.
         *
         * @access  public
         * @return  string
         */
        public static function getTemporaryDirectory()
        {
            return sys_get_temp_dir();
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\File\\Temporary\\Temporary');
}
Example #11
0
         *     ru_oublock       => block output operations;
         *     ru_msgsnd        => messages sent;
         *     ru_msgrcv        => messages received;
         *     ru_nsignals      => signals received;
         *     ru_nvcsw         => voluntary context switches;
         *     ru_nivcsw        => involuntary context switches.
         *
         * Please, see your system's man page on getrusage(2) to get more
         * informations. It is very interesting.
         *
         * @access  public
         * @param   int     $who    If set to 1, it will be called with
         *                          RUSAGE_CHILDREN.
         * @return  array
         * @throw   \Hoa\Memory\Exception
         */
        public static function getRUsage($who = 0)
        {
            if (OS_WIN) {
                throw new Exception('Cannot get the current resource usages on Windows.', 0);
            }
            return getrusage($who);
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Memory\\Memory');
}
Example #12
0
         * Transform data as an array.
         *
         * @access  public
         * @return  array
         */
        public function toArray()
        {
            if (null === $this->__currentAccess) {
                $out = array();
                foreach ($this->__attributes as $attribute) {
                    if (false === $attribute['relation']) {
                        $out[$attribute['name']] = $attribute['value'];
                    }
                }
                return $out;
            }
            $out = array();
            foreach ($this->{$this->__currentAccess} as $i => $value) {
                $out[$i] = $value->toArray();
            }
            $this->__currentAccess = null;
            return $out;
        }
    }
}
namespace {
    /**
     * Flex entity.
     */
    Hoa\Core\Consistency::flexEntity('Hoa\\Model\\Model');
}