1<?php
2
3/**
4 * Hoa
5 *
6 *
7 * @license
8 *
9 * New BSD License
10 *
11 * Copyright © 2007-2017, Hoa community. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 *     * Redistributions of source code must retain the above copyright
16 *       notice, this list of conditions and the following disclaimer.
17 *     * Redistributions in binary form must reproduce the above copyright
18 *       notice, this list of conditions and the following disclaimer in the
19 *       documentation and/or other materials provided with the distribution.
20 *     * Neither the name of the Hoa nor the names of its contributors may be
21 *       used to endorse or promote products derived from this software without
22 *       specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37if (false === defined('HOA')) {
38    define('HOA', true);
39}
40
41if (false === defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50400) {
42    throw new Exception(
43        'Hoa needs at least PHP5.4 to work; you have ' . phpversion() . '.'
44    );
45}
46
47require_once __DIR__ . DIRECTORY_SEPARATOR . 'Autoloader.php';
48require_once __DIR__ . DIRECTORY_SEPARATOR . 'Consistency.php';
49
50$define = function ($constantName, $constantValue, $case = false) {
51    if (!defined($constantName)) {
52        return define($constantName, $constantValue, $case);
53    }
54
55    return false;
56};
57
58$define('SUCCEED',        true);
59$define('FAILED',         false);
60$define('…',              '__hoa_core_fill');
61$define('DS',             DIRECTORY_SEPARATOR);
62$define('PS',             PATH_SEPARATOR);
63$define('ROOT_SEPARATOR', ';');
64$define('RS',             ROOT_SEPARATOR);
65$define('CRLF',           "\r\n");
66$define('OS_WIN',         defined('PHP_WINDOWS_VERSION_PLATFORM'));
67$define('S_64_BITS',      PHP_INT_SIZE == 8);
68$define('S_32_BITS',      !S_64_BITS);
69$define('PHP_INT_MIN',    ~PHP_INT_MAX);
70$define('PHP_FLOAT_MIN',  (float) PHP_INT_MIN);
71$define('PHP_FLOAT_MAX',  (float) PHP_INT_MAX);
72$define('π',              M_PI);
73$define('nil',            null);
74$define('_public',        1);
75$define('_protected',     2);
76$define('_private',       4);
77$define('_static',        8);
78$define('_abstract',      16);
79$define('_pure',          32);
80$define('_final',         64);
81$define('_dynamic',       ~_static);
82$define('_concrete',      ~_abstract);
83$define('_overridable',   ~_final);
84$define('WITH_COMPOSER',  class_exists('Composer\Autoload\ClassLoader', false) ||
85                          ('cli' === PHP_SAPI &&
86                          file_exists(__DIR__ . DS . '..' . DS . '..' . DS . 'autoload.php')));
87
88/**
89 * Alias of \Hoa\Consistency\Xcallable.
90 *
91 * @param   mixed   $call    First callable part.
92 * @param   mixed   $able    Second callable part (if needed).
93 * @return  mixed
94 */
95if (!function_exists('xcallable')) {
96    function xcallable($call, $able = '')
97    {
98        if ($call instanceof Hoa\Consistency\Xcallable) {
99            return $call;
100        }
101
102        return new Hoa\Consistency\Xcallable($call, $able);
103    }
104}
105