改名
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
@@ -21,13 +21,13 @@ abstract class AbstractConsole extends Component
|
||||
/**
|
||||
* @var Command[]
|
||||
*/
|
||||
public $commands = [];
|
||||
public array $commands = [];
|
||||
|
||||
/** @var Input $parameters */
|
||||
private $parameters;
|
||||
private Input $parameters;
|
||||
|
||||
/** @var array */
|
||||
private $_config;
|
||||
private array $_config;
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Console;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
@@ -11,9 +12,9 @@ use Snowflake\Abstracts\Input;
|
||||
*/
|
||||
class DefaultCommand extends Command
|
||||
{
|
||||
public $command = 'list';
|
||||
public string $command = 'list';
|
||||
|
||||
public $description = 'help';
|
||||
public string $description = 'help';
|
||||
|
||||
public function onHandler(Input $dtl)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 14:42
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
use Snowflake\Abstracts\Component;
|
||||
@@ -24,26 +24,28 @@ class ActiveQuery extends Component
|
||||
use QueryTrait;
|
||||
|
||||
/** @var array */
|
||||
public $with = [];
|
||||
public array $with = [];
|
||||
|
||||
/** @var bool */
|
||||
public $asArray = FALSE;
|
||||
public bool $asArray = FALSE;
|
||||
|
||||
/** @var bool */
|
||||
public $useCache = FALSE;
|
||||
public bool $useCache = FALSE;
|
||||
|
||||
/** @var Connection $db */
|
||||
public $db = NULL;
|
||||
/**
|
||||
* @var Connection|null
|
||||
*/
|
||||
public ?Connection $db = NULL;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* 参数绑定
|
||||
*/
|
||||
public $attributes = [];
|
||||
public array $attributes = [];
|
||||
|
||||
|
||||
/** @var ActiveRecord */
|
||||
public $modelClass;
|
||||
public ActiveRecord $modelClass;
|
||||
|
||||
/**
|
||||
* Comply constructor.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:39
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
* @return mixed|ActiveQuery
|
||||
* @throws Exception
|
||||
*/
|
||||
public function hasOne($modelName, $foreignKey, $localKey)
|
||||
public function hasOne(string $modelName, $foreignKey, $localKey)
|
||||
{
|
||||
if (!$this->has($localKey)) {
|
||||
throw new Exception("Need join table primary key.");
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* Date: 2018/4/9 0009
|
||||
* Time: 9:44
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Base;
|
||||
|
||||
|
||||
use ArrayIterator;
|
||||
use Database\ActiveQuery;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Database\ActiveRecord;
|
||||
@@ -25,12 +26,11 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
/**
|
||||
* @var ActiveRecord[]
|
||||
*/
|
||||
protected $_item = [];
|
||||
protected array $_item = [];
|
||||
|
||||
/** @var ActiveRecord */
|
||||
protected $model;
|
||||
protected ?ActiveRecord $model;
|
||||
|
||||
protected $query;
|
||||
protected ActiveQuery $query;
|
||||
|
||||
/**
|
||||
* Collection constructor.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:39
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Base;
|
||||
|
||||
|
||||
@@ -38,23 +38,23 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
protected $_attributes = [];
|
||||
protected array $_attributes = [];
|
||||
|
||||
/** @var array */
|
||||
protected $_oldAttributes = [];
|
||||
protected array $_oldAttributes = [];
|
||||
|
||||
/** @var array */
|
||||
protected $_relate = [];
|
||||
protected array $_relate = [];
|
||||
|
||||
/** @var null|string */
|
||||
protected $primary = NULL;
|
||||
protected ?string $primary = NULL;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isNewExample = TRUE;
|
||||
protected bool $isNewExample = TRUE;
|
||||
|
||||
protected $actions = [];
|
||||
protected array $actions = [];
|
||||
|
||||
/** @var Relation */
|
||||
protected $_relation = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Base;
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@ use Snowflake\Snowflake;
|
||||
class CollectionIterator extends \ArrayIterator
|
||||
{
|
||||
|
||||
/** @var ActiveRecord */
|
||||
private $model;
|
||||
private ActiveRecord $model;
|
||||
|
||||
|
||||
/** @var ActiveQuery */
|
||||
private $query;
|
||||
private ActiveQuery $query;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Base;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ use Database\Condition\RLikeCondition;
|
||||
class ConditionClassMap
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
public static $conditionMap = [
|
||||
public static array $conditionMap = [
|
||||
'IN' => [
|
||||
'class' => InCondition::class
|
||||
],
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 13:38
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
use Database\Base\AbstractCollection;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 15:23
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
@@ -28,19 +28,19 @@ class Command extends Component
|
||||
const FETCH_COLUMN = 'FETCH_COLUMN';
|
||||
|
||||
/** @var Connection */
|
||||
public $db;
|
||||
public Connection $db;
|
||||
|
||||
/** @var string */
|
||||
public $sql = '';
|
||||
public string $sql = '';
|
||||
|
||||
/** @var array */
|
||||
public $params = [];
|
||||
public array $params = [];
|
||||
|
||||
/** @var string */
|
||||
private $_modelName;
|
||||
private string $_modelName;
|
||||
|
||||
/** @var PDOStatement */
|
||||
private $prepare;
|
||||
private PDOStatement $prepare;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -17,7 +17,7 @@ use Snowflake\Snowflake;
|
||||
class ArrayCondition extends Condition
|
||||
{
|
||||
|
||||
private $math = ['like', 'in', 'or', 'eq', 'neq', 'gt', 'ngt', 'lt', 'nlt'];
|
||||
private array $math = ['like', 'in', 'or', 'eq', 'neq', 'gt', 'ngt', 'lt', 'nlt'];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -14,15 +14,15 @@ use Snowflake\Core\Str;
|
||||
abstract class Condition extends BaseObject
|
||||
{
|
||||
|
||||
protected $column = '';
|
||||
protected $opera = '=';
|
||||
protected string $column = '';
|
||||
protected string $opera = '=';
|
||||
|
||||
/** @var array|mixed */
|
||||
protected $value;
|
||||
|
||||
const INT_TYPE = ['bit', 'bool', 'tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'timestamp'];
|
||||
|
||||
protected $attributes = [];
|
||||
protected array $attributes = [];
|
||||
|
||||
abstract public function builder();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Condition;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Snowflake\Core\Str;
|
||||
class LLikeCondition extends Condition
|
||||
{
|
||||
|
||||
public $pos = '';
|
||||
public string $pos = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Snowflake\Core\Str;
|
||||
class LikeCondition extends Condition
|
||||
{
|
||||
|
||||
public $pos = '';
|
||||
public string $pos = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Database\Condition;
|
||||
class MathematicsCondition extends Condition
|
||||
{
|
||||
|
||||
public $type = '';
|
||||
public string $type = '';
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Snowflake\Core\Str;
|
||||
class NotLikeCondition extends Condition
|
||||
{
|
||||
|
||||
public $pos = '';
|
||||
public string $pos = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Snowflake\Core\Str;
|
||||
class RLikeCondition extends Condition
|
||||
{
|
||||
|
||||
public $pos = '';
|
||||
public string $pos = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database;
|
||||
|
||||
|
||||
+2
-4
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 15:40
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
use Database\Traits\QueryTrait;
|
||||
@@ -20,9 +20,7 @@ class Db
|
||||
{
|
||||
use QueryTrait;
|
||||
|
||||
private static $db;
|
||||
|
||||
private static $isActive = false;
|
||||
private static bool $isActive = false;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 15:47
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database;
|
||||
|
||||
@@ -22,28 +23,30 @@ abstract class HasBase
|
||||
/** @var ActiveRecord|Collection */
|
||||
protected $data;
|
||||
|
||||
/** @var ActiveRecord */
|
||||
protected $model;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $model;
|
||||
|
||||
/** @var */
|
||||
protected $primaryId;
|
||||
|
||||
/** @var array */
|
||||
protected $value = [];
|
||||
protected array $value = [];
|
||||
|
||||
|
||||
/** @var Relation $_relation */
|
||||
protected $_relation;
|
||||
protected Relation $_relation;
|
||||
|
||||
/**
|
||||
* HasBase constructor.
|
||||
* @param ActiveRecord $model
|
||||
* @param $model
|
||||
* @param $primaryId
|
||||
* @param $value
|
||||
* @param Relation $relation
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($model, $primaryId, $value, $relation)
|
||||
public function __construct($model, $primaryId, $value, Relation $relation)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
if (empty($value)) $value = [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 13:58
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/4 0004
|
||||
* Time: 13:47
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
use Exception;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:39
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* Time: 17:22
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Mysql;
|
||||
|
||||
|
||||
@@ -21,20 +23,42 @@ use Snowflake\Core\JSON;
|
||||
class Columns extends Component
|
||||
{
|
||||
|
||||
private $columns = [];
|
||||
/**
|
||||
* @var array
|
||||
* field types
|
||||
*/
|
||||
private array $columns = [];
|
||||
|
||||
/** @var Connection $db */
|
||||
public $db;
|
||||
public $table = '';
|
||||
private $_primary = [];
|
||||
private $_auto_increment = [];
|
||||
/**
|
||||
* @var Connection
|
||||
* Mysql client
|
||||
*/
|
||||
public Connection $db;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* tableName
|
||||
*/
|
||||
public string $table = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* field primary key
|
||||
*/
|
||||
private array $_primary = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* by mysql field auto_increment
|
||||
*/
|
||||
private array $_auto_increment = [];
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function table($table)
|
||||
public function table(string $table)
|
||||
{
|
||||
return $this->structure($this->table = $table);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Mysql;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Orm;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Orm;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Orm;
|
||||
|
||||
|
||||
+8
-12
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database;
|
||||
|
||||
@@ -19,28 +19,25 @@ class Pagination extends Component
|
||||
{
|
||||
|
||||
/** @var ActiveQuery */
|
||||
private $activeQuery;
|
||||
private ActiveQuery $activeQuery;
|
||||
|
||||
/** @var int 从第几个开始查 */
|
||||
private $_offset = 0;
|
||||
private int $_offset = 0;
|
||||
|
||||
/** @var int 每页数量 */
|
||||
private $_limit = 100;
|
||||
private int $_limit = 100;
|
||||
|
||||
/** @var int 最大查询数量 */
|
||||
private $_max = 0;
|
||||
private int $_max = 0;
|
||||
|
||||
/** @var int 当前已查询数量 */
|
||||
private $_length = 0;
|
||||
private int $_length = 0;
|
||||
|
||||
/** @var Closure */
|
||||
private $_callback;
|
||||
|
||||
/** @var Coroutine\Channel */
|
||||
private $_channel;
|
||||
private Closure $_callback;
|
||||
|
||||
/** @var Coroutine\WaitGroup */
|
||||
private $_group;
|
||||
private Coroutine\WaitGroup $_group;
|
||||
|
||||
/**
|
||||
* PaginationIteration constructor.
|
||||
@@ -51,7 +48,6 @@ class Pagination extends Component
|
||||
{
|
||||
parent::__construct($config);
|
||||
$this->activeQuery = $activeQuery;
|
||||
// $this->_channel = new Coroutine\Channel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database;
|
||||
|
||||
@@ -13,10 +13,10 @@ use Snowflake\Abstracts\Component;
|
||||
class Relation extends Component
|
||||
{
|
||||
|
||||
private $_relations = [];
|
||||
private array $_relations = [];
|
||||
|
||||
/** @var ActiveQuery[] $_query */
|
||||
private $_query = [];
|
||||
private array $_query = [];
|
||||
|
||||
/**
|
||||
* @param string $identification
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/6/27 0027
|
||||
* Time: 17:49
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/3/30 0030
|
||||
* Time: 14:56
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Database\Traits;
|
||||
|
||||
|
||||
@@ -20,21 +20,23 @@ use Exception;
|
||||
*/
|
||||
trait QueryTrait
|
||||
{
|
||||
public $where = [];
|
||||
public $select = [];
|
||||
public $join = [];
|
||||
public $order = [];
|
||||
public $offset = NULL;
|
||||
public $limit = NULL;
|
||||
public $group = '';
|
||||
public $from = '';
|
||||
public $alias = 't1';
|
||||
public $filter = [];
|
||||
public array $where = [];
|
||||
public array $select = [];
|
||||
public array $join = [];
|
||||
public array $order = [];
|
||||
public ?int $offset = NULL;
|
||||
public ?int $limit = NULL;
|
||||
public string $group = '';
|
||||
public string $from = '';
|
||||
public string $alias = 't1';
|
||||
public array $filter = [];
|
||||
|
||||
public $ifNotWhere = false;
|
||||
public bool $ifNotWhere = false;
|
||||
|
||||
/** @var ActiveRecord */
|
||||
public $modelClass;
|
||||
/**
|
||||
* @var ActiveRecord
|
||||
*/
|
||||
public ActiveRecord $modelClass;
|
||||
|
||||
/**
|
||||
* clear
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
@@ -9,5 +9,5 @@ use Swoole\Coroutine;
|
||||
|
||||
abstract class BaseContext
|
||||
{
|
||||
protected static $pool = [];
|
||||
protected static array $pool = [];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
@@ -52,7 +52,7 @@ abstract class Callback extends Application
|
||||
const EVENT_EXIT = 'WORKER:EXIT';
|
||||
|
||||
|
||||
private $_MESSAGE = [
|
||||
private array $_MESSAGE = [
|
||||
self::EVENT_ERROR => 'The server error. at No.',
|
||||
self::EVENT_STOP => 'The server stop. at No.',
|
||||
self::EVENT_EXIT => 'The server exit. at No.',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/11/8 0008
|
||||
* Time: 18:37
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Abstracts;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class ServerBase extends Application
|
||||
{
|
||||
|
||||
/** @var Server */
|
||||
protected $server;
|
||||
protected Server $server;
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/5/24 0024
|
||||
* Time: 11:34
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
|
||||
@@ -25,31 +26,31 @@ use Swoole\Coroutine\Client as SCClient;
|
||||
*/
|
||||
class Client
|
||||
{
|
||||
private $host = '';
|
||||
private string $host = '';
|
||||
|
||||
private $header = [];
|
||||
private array $header = [];
|
||||
|
||||
private $timeout = 0;
|
||||
private int $timeout = 0;
|
||||
|
||||
private $callback = null;
|
||||
private $method = 'get';
|
||||
private ?\Closure $callback = null;
|
||||
private string $method = 'get';
|
||||
|
||||
private $isSSL = false;
|
||||
private $agent = '';
|
||||
private $errorCodeField = '';
|
||||
private $errorMsgField = '';
|
||||
private $use_swoole = false;
|
||||
private bool $isSSL = false;
|
||||
private string $agent = '';
|
||||
private string $errorCodeField = '';
|
||||
private string $errorMsgField = '';
|
||||
private bool $use_swoole = false;
|
||||
|
||||
private $ssl_cert_file = '';
|
||||
private $ssl_key_file = '';
|
||||
private $ca = '';
|
||||
private $port = '';
|
||||
private string $ssl_cert_file = '';
|
||||
private string $ssl_key_file = '';
|
||||
private string $ca = '';
|
||||
private int $port = 80;
|
||||
|
||||
/** @var string $_message 错误信息 */
|
||||
private $_message = '';
|
||||
private $_data = '';
|
||||
private string $_message = '';
|
||||
private string $_data = '';
|
||||
|
||||
private $connect_timeout = 1;
|
||||
private int $connect_timeout = 1;
|
||||
|
||||
const GET = 'get';
|
||||
const PUT = 'put';
|
||||
@@ -92,17 +93,17 @@ class Client
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getPort(): string
|
||||
public function getPort(): int
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $port
|
||||
* @param int $port
|
||||
*/
|
||||
public function setPort(string $port): void
|
||||
public function setPort(int $port): void
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
@@ -135,17 +136,17 @@ class Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSslCertFile(): string
|
||||
public function hasSslCertFile(): bool
|
||||
{
|
||||
return !empty($this->ssl_cert_file) && file_exists($this->ssl_cert_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSslKeyFile(): string
|
||||
public function hasSslKeyFile(): bool
|
||||
{
|
||||
return !empty($this->ssl_key_file) && file_exists($this->ssl_key_file);
|
||||
}
|
||||
|
||||
+24
-24
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
|
||||
@@ -26,55 +26,55 @@ class Curl
|
||||
const PUT = 'put';
|
||||
|
||||
|
||||
private $curl_multi = [];
|
||||
private array $curl_multi = [];
|
||||
|
||||
private $headers = [
|
||||
private array $headers = [
|
||||
'Connection' => 'Keep-Alive',
|
||||
'Keep-Alive' => '300'
|
||||
];
|
||||
|
||||
/** @var Closure|array */
|
||||
private $callback;
|
||||
/** @var ?Closure */
|
||||
private ?\Closure $callback;
|
||||
|
||||
/** @var string */
|
||||
private $errorCodeField = '';
|
||||
private string $errorCodeField = '';
|
||||
|
||||
/** @var string */
|
||||
private $errorMsgField = '';
|
||||
private string $errorMsgField = '';
|
||||
|
||||
/** @var int */
|
||||
private $timeout = -1;
|
||||
private int $timeout = -1;
|
||||
|
||||
/** @var int */
|
||||
private $connection_timeout = 2;
|
||||
private int $connection_timeout = 2;
|
||||
|
||||
/** @var bool */
|
||||
private $useKeepAlive = true;
|
||||
private bool $useKeepAlive = true;
|
||||
|
||||
/** @var string */
|
||||
private $agent = '';
|
||||
private string $agent = '';
|
||||
|
||||
/** @var string */
|
||||
private $ssl_key = '';
|
||||
private string $ssl_key = '';
|
||||
|
||||
/** @var string */
|
||||
private $ssl_cert = '';
|
||||
private string $ssl_cert = '';
|
||||
|
||||
/** @var string */
|
||||
private $ssl_ca = '';
|
||||
private string $ssl_ca = '';
|
||||
|
||||
/** @var string */
|
||||
private $host = '127.0.0.1';
|
||||
private string $host = '127.0.0.1';
|
||||
|
||||
/** @var string */
|
||||
private $port = '9958';
|
||||
/** @var int */
|
||||
private int $port = 9958;
|
||||
|
||||
/** @var bool */
|
||||
private $isSsl = true;
|
||||
private bool $isSsl = true;
|
||||
|
||||
|
||||
/** @var Curl */
|
||||
private static $instance;
|
||||
private static Curl $instance;
|
||||
|
||||
/**
|
||||
* @return array|Closure
|
||||
@@ -85,9 +85,9 @@ class Curl
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|Closure $callback
|
||||
* @param Closure $callback
|
||||
*/
|
||||
public function setCallback($callback): void
|
||||
public function setCallback(Closure $callback): void
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ class Curl
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPort(): string
|
||||
public function getPort(): int
|
||||
{
|
||||
if (empty($this->port)) {
|
||||
return 80;
|
||||
@@ -315,9 +315,9 @@ class Curl
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $port
|
||||
* @param int $port
|
||||
*/
|
||||
public function setPort(string $port): void
|
||||
public function setPort(int $port): void
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
|
||||
@@ -20,11 +20,11 @@ class Http2 extends Component
|
||||
{
|
||||
|
||||
/** @var H2Client[] */
|
||||
private $_clients = [];
|
||||
private array $_clients = [];
|
||||
|
||||
|
||||
/** @var Request[] */
|
||||
private $_requests = [];
|
||||
private array $_requests = [];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
|
||||
@@ -19,14 +20,14 @@ class Result
|
||||
{
|
||||
public $code;
|
||||
public $message;
|
||||
public $count = 0;
|
||||
public $data;
|
||||
public $header;
|
||||
public $httpStatus = 200;
|
||||
public int $count = 0;
|
||||
public array|string $data;
|
||||
public array $header;
|
||||
public int $httpStatus = 200;
|
||||
|
||||
public $startTime = 0;
|
||||
public $requestTime = 0;
|
||||
public $runTime = 0;
|
||||
public int $startTime = 0;
|
||||
public int $requestTime = 0;
|
||||
public float $runTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer;
|
||||
|
||||
@@ -21,18 +21,18 @@ class Controller extends Application
|
||||
{
|
||||
|
||||
/** @var HttpParams $input */
|
||||
public $input;
|
||||
public HttpParams $input;
|
||||
|
||||
|
||||
/** @var HttpHeaders */
|
||||
public $headers;
|
||||
public HttpHeaders $headers;
|
||||
|
||||
|
||||
/** @var Request */
|
||||
public $request;
|
||||
public Request $request;
|
||||
|
||||
|
||||
public $goto;
|
||||
public BaseGoto $goto;
|
||||
|
||||
|
||||
public $app;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
@@ -31,7 +31,7 @@ class OnClose extends Callback
|
||||
public function onHandler(Server $server, int $fd)
|
||||
{
|
||||
try {
|
||||
[$manager, $name] = $this->resovle($server, $fd);
|
||||
[$manager, $name] = $this->resolve($server, $fd);
|
||||
if ($manager !== null && !$manager->has($name)) {
|
||||
$manager->runWith($name, [$fd]);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class OnClose extends Callback
|
||||
* @return array|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function resovle($server, $fd)
|
||||
public function resolve($server, $fd)
|
||||
{
|
||||
if ($server instanceof WServer) {
|
||||
if (!$server->isEstablished($fd)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
@@ -20,12 +20,12 @@ class OnPacket extends Callback
|
||||
{
|
||||
|
||||
|
||||
/** @var Closure|array */
|
||||
public $unpack;
|
||||
/** @var Closure */
|
||||
public Closure $unpack;
|
||||
|
||||
|
||||
/** @var Closure|array */
|
||||
public $pack;
|
||||
/** @var Closure */
|
||||
public Closure $pack;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
@@ -20,12 +20,12 @@ class OnReceive extends Callback
|
||||
{
|
||||
|
||||
|
||||
/** @var Closure|array */
|
||||
public $unpack;
|
||||
/** @var Closure */
|
||||
public Closure $unpack;
|
||||
|
||||
|
||||
/** @var Closure|array */
|
||||
public $pack;
|
||||
/** @var Closure */
|
||||
public Closure $pack;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
use HttpServer\Abstracts\Callback;
|
||||
use HttpServer\IInterface\Task;
|
||||
use HttpServer\IInterface\Task as ITask;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Snowflake;
|
||||
@@ -40,10 +42,9 @@ class OnTask extends Callback
|
||||
* @param string $data
|
||||
*
|
||||
* @return mixed|void
|
||||
* @throws Exception
|
||||
* 异步任务
|
||||
* @throws Exception 异步任务
|
||||
*/
|
||||
public function onTask(Server $server, $task_id, $from_id, $data)
|
||||
public function onTask(Server $server, int $task_id, int $from_id, string $data)
|
||||
{
|
||||
$time = microtime(TRUE);
|
||||
if (empty($data)) {
|
||||
@@ -102,7 +103,7 @@ class OnTask extends Callback
|
||||
$finish['class'] = get_class($serialize);
|
||||
$finish['params'] = $params;
|
||||
$finish['status'] = 'success';
|
||||
$finish['info'] = $serialize->handler();
|
||||
$finish['info'] = $serialize->onHandler();
|
||||
} catch (\Throwable $exception) {
|
||||
$finish['status'] = 'error';
|
||||
$finish['info'] = $this->format($exception);
|
||||
@@ -119,7 +120,7 @@ class OnTask extends Callback
|
||||
* @param $data
|
||||
* @return ITask|null
|
||||
*/
|
||||
protected function before($data)
|
||||
protected function before($data): Task|null
|
||||
{
|
||||
if (empty($serialize = unserialize($data))) {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
@@ -11,6 +11,10 @@ use Snowflake\Exception\ConfigException;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Server;
|
||||
|
||||
/**
|
||||
* Class OnWorkerError
|
||||
* @package HttpServer\Events
|
||||
*/
|
||||
class OnWorkerError extends Callback
|
||||
{
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Events;
|
||||
|
||||
|
||||
use HttpServer\Abstracts\Callback;
|
||||
|
||||
/**
|
||||
* Class OnWorkerStop
|
||||
* @package HttpServer\Events
|
||||
*/
|
||||
class OnWorkerStop extends Callback
|
||||
{
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/5/25 0025
|
||||
* Time: 10:14
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Exception;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Exception;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Exception;
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ use Swoole\Coroutine;
|
||||
class Context extends BaseContext
|
||||
{
|
||||
|
||||
protected static $_requests = [];
|
||||
protected static array $_requests = [];
|
||||
|
||||
protected static $_response = [];
|
||||
protected static array $_response = [];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Http;
|
||||
|
||||
@@ -12,14 +12,14 @@ use Snowflake\Snowflake;
|
||||
class File
|
||||
{
|
||||
|
||||
public $name = '';
|
||||
public $tmp_name = '';
|
||||
public $error = '';
|
||||
public $type = '';
|
||||
public $size = '';
|
||||
public string $name = '';
|
||||
public string $tmp_name = '';
|
||||
public string $error = '';
|
||||
public string $type = '';
|
||||
public string $size = '';
|
||||
|
||||
private $newName = '';
|
||||
private $errorInfo = [
|
||||
private string $newName = '';
|
||||
private array $errorInfo = [
|
||||
0 => 'UPLOAD_ERR_OK.',
|
||||
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
|
||||
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/8 0008
|
||||
* Time: 17:51
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Http\Formatter;
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/8 0008
|
||||
* Time: 17:18
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Http\Formatter;
|
||||
|
||||
use Exception;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2018/4/8 0008
|
||||
* Time: 17:29
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Http\Formatter;
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ use HttpServer\IInterface\IFormatter;
|
||||
class XmlFormatter extends Application implements IFormatter
|
||||
{
|
||||
|
||||
public $data = '';
|
||||
public ?string $data = '';
|
||||
|
||||
/** @var Response */
|
||||
public $status;
|
||||
public Response $status;
|
||||
|
||||
public $header = [];
|
||||
public array $header = [];
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
@@ -61,7 +61,7 @@ class XmlFormatter extends Application implements IFormatter
|
||||
* @param SimpleXMLElement $dom
|
||||
* @param $data
|
||||
*/
|
||||
public function toXml($dom, $data)
|
||||
public function toXml(SimpleXMLElement $dom, $data)
|
||||
{
|
||||
foreach ($data as $key => $val) {
|
||||
if (is_numeric($key)) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Date: 2019-03-18
|
||||
* Time: 14:54
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Http;
|
||||
|
||||
/**
|
||||
@@ -18,12 +18,12 @@ class HttpHeaders
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $headers = [];
|
||||
private array $headers = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $response = [];
|
||||
private array $response = [];
|
||||
|
||||
/**
|
||||
* HttpHeaders constructor.
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
* Date: 2019-03-18
|
||||
* Time: 14:54
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace HttpServer\Http;
|
||||
|
||||
use Exception;
|
||||
use HttpServer\Exception\RequestException;
|
||||
use Snowflake\Core\Help;
|
||||
use Snowflake\Core\JSON;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
@@ -21,13 +22,13 @@ class HttpParams
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $body = [];
|
||||
private array $body = [];
|
||||
|
||||
/** @var array */
|
||||
private $gets = [];
|
||||
private array $gets = [];
|
||||
|
||||
/** @var array */
|
||||
private $files = [];
|
||||
private array $files = [];
|
||||
|
||||
/**
|
||||
* HttpParams constructor.
|
||||
|
||||
+12
-11
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Http;
|
||||
|
||||
use Snowflake\Core\Help;
|
||||
use Exception;
|
||||
use HttpServer\Application;
|
||||
use HttpServer\IInterface\AuthIdentity;
|
||||
use Snowflake\Core\JSON;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use function router;
|
||||
|
||||
defined('REQUEST_OK') or define('REQUEST_OK', 0);
|
||||
defined('REQUEST_FAIL') or define('REQUEST_FAIL', 500);
|
||||
@@ -32,26 +33,26 @@ class Request extends Application
|
||||
{
|
||||
|
||||
/** @var int $fd */
|
||||
public $fd = 0;
|
||||
public int $fd = 0;
|
||||
|
||||
/** @var HttpParams */
|
||||
public $params;
|
||||
public HttpParams $params;
|
||||
|
||||
/** @var HttpHeaders */
|
||||
public $headers;
|
||||
public HttpHeaders $headers;
|
||||
|
||||
/** @var bool */
|
||||
public $isCli = FALSE;
|
||||
public bool $isCli = FALSE;
|
||||
|
||||
/** @var float */
|
||||
public $startTime;
|
||||
public float $startTime;
|
||||
|
||||
public $uri = '';
|
||||
public string $uri = '';
|
||||
|
||||
public $statusCode = 200;
|
||||
public int $statusCode = 200;
|
||||
|
||||
/** @var string[] */
|
||||
private $explode = [];
|
||||
private array $explode = [];
|
||||
|
||||
const PLATFORM_MAC_OX = 'mac';
|
||||
const PLATFORM_IPHONE = 'iphone';
|
||||
@@ -62,7 +63,7 @@ class Request extends Application
|
||||
/**
|
||||
* @var AuthIdentity|null
|
||||
*/
|
||||
private $_grant = null;
|
||||
private ?AuthIdentity $_grant = null;
|
||||
|
||||
|
||||
/**
|
||||
@@ -212,7 +213,7 @@ class Request extends Application
|
||||
public function adapter()
|
||||
{
|
||||
if (!$this->isHead()) {
|
||||
return router()->runHandler();
|
||||
return router()->dispatch();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Date: 2018/4/24 0024
|
||||
* Time: 19:39
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Http;
|
||||
|
||||
@@ -14,9 +15,7 @@ use HttpServer\Http\Formatter\JsonFormatter;
|
||||
use HttpServer\Http\Formatter\XmlFormatter;
|
||||
use Exception;
|
||||
use Snowflake\Core\Help;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Http\Response as SResponse;
|
||||
use Swoole\Http2\Response as S2Response;
|
||||
|
||||
@@ -31,20 +30,20 @@ class Response extends Application
|
||||
const XML = 'xml';
|
||||
const HTML = 'html';
|
||||
|
||||
/** @var string */
|
||||
public $format = null;
|
||||
/** @var ?string */
|
||||
public ?string $format = null;
|
||||
|
||||
/** @var int */
|
||||
public $statusCode = 200;
|
||||
public int $statusCode = 200;
|
||||
|
||||
/** @var SResponse */
|
||||
public $response;
|
||||
public $isWebSocket = false;
|
||||
public $headers = [];
|
||||
public SResponse $response;
|
||||
public bool $isWebSocket = false;
|
||||
public array $headers = [];
|
||||
|
||||
private $startTime = 0;
|
||||
private int $startTime = 0;
|
||||
|
||||
private $_format_maps = [
|
||||
private array $_format_maps = [
|
||||
self::JSON => JsonFormatter::class,
|
||||
self::XML => XmlFormatter::class,
|
||||
self::HTML => HtmlFormatter::class
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace HttpServer\IInterface;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user