Adding PHP8.3 support and some type hints
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
33da0eb223
commit
ada7729320
|
@ -122,19 +122,19 @@ class mtgMetaInfo
|
|||
unset($this->units[$unit->object->getMetaId()]);
|
||||
}
|
||||
|
||||
function getUnits()
|
||||
function getUnits() : array
|
||||
{
|
||||
return $this->units;
|
||||
}
|
||||
|
||||
function findUnit($id)
|
||||
function findUnit($id) : ?mtgMetaInfoUnit
|
||||
{
|
||||
if(isset($this->units[$id]))
|
||||
return $this->units[$id];
|
||||
return null;
|
||||
}
|
||||
|
||||
function getUnit($id)
|
||||
function getUnit($id) : mtgMetaInfoUnit
|
||||
{
|
||||
if(isset($this->units[$id]))
|
||||
return $this->units[$id];
|
||||
|
@ -154,7 +154,7 @@ abstract class mtgMetaUnit
|
|||
|
||||
protected $tokens = array();
|
||||
|
||||
protected $origin;
|
||||
protected ?mtgOrigin $origin;
|
||||
|
||||
function getTokens()
|
||||
{
|
||||
|
@ -166,17 +166,17 @@ abstract class mtgMetaUnit
|
|||
$this->tokens = $tokens;
|
||||
}
|
||||
|
||||
function setToken($name, $val)
|
||||
function setToken(string $name, $val)
|
||||
{
|
||||
$this->tokens[$name] = $val;
|
||||
}
|
||||
|
||||
function delToken($name)
|
||||
function delToken(string $name)
|
||||
{
|
||||
unset($this->tokens[$name]);
|
||||
}
|
||||
|
||||
function getToken($name)
|
||||
function getToken(string $name)
|
||||
{
|
||||
return $this->hasToken($name) ? $this->tokens[$name] : null;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ abstract class mtgMetaUnit
|
|||
$this->origin = $origin;
|
||||
}
|
||||
|
||||
function getOrigin()
|
||||
function getOrigin() : ?mtgOrigin
|
||||
{
|
||||
return $this->origin;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class mtgMetaInfoParser
|
|||
$config['valid_tokens'][] = 'enum_replace';
|
||||
}
|
||||
|
||||
function parse(mtgMetaInfo $meta, $raw_file)
|
||||
function parse(mtgMetaInfo $meta, string $raw_file)
|
||||
{
|
||||
$this->current_meta = $meta;
|
||||
|
||||
|
@ -136,7 +136,7 @@ class mtgMetaInfoParser
|
|||
$this->_parse($file);
|
||||
}
|
||||
|
||||
private function _parse($file)
|
||||
private function _parse(string $file)
|
||||
{
|
||||
if(isset($this->parsed_files[$file]))
|
||||
return;
|
||||
|
@ -194,7 +194,7 @@ class mtgMetaInfoParser
|
|||
}
|
||||
}
|
||||
|
||||
private function _parseInclude(mtgMetaParsedModule $module, $file)
|
||||
private function _parseInclude(mtgMetaParsedModule $module, string $file)
|
||||
{
|
||||
$this->_parse($file);
|
||||
|
||||
|
@ -211,7 +211,7 @@ class mtgMetaInfoParser
|
|||
$this->_error("Invalid 'shared_tokens' formant, invalid JSON");
|
||||
}
|
||||
|
||||
private function _parseType($can_be_multi = false)
|
||||
private function _parseType(bool $can_be_multi = false)
|
||||
{
|
||||
$types = array();
|
||||
|
||||
|
@ -298,7 +298,7 @@ class mtgMetaInfoParser
|
|||
return $ftype;
|
||||
}
|
||||
|
||||
private function _resolveIncludes(mtgMetaParsedModule $module, &$text)
|
||||
private function _resolveIncludes(mtgMetaParsedModule $module, string &$text)
|
||||
{
|
||||
$include_paths = $this->config['include_path'];
|
||||
|
||||
|
@ -317,7 +317,7 @@ class mtgMetaInfoParser
|
|||
$text = implode("\n", $result);
|
||||
}
|
||||
|
||||
private function _processInclude(mtgMetaParsedModule $module, $include, array $include_paths)
|
||||
private function _processInclude(mtgMetaParsedModule $module, string $include, array $include_paths)
|
||||
{
|
||||
$file = false;
|
||||
foreach($include_paths as $include_path)
|
||||
|
@ -478,7 +478,7 @@ class mtgMetaInfoParser
|
|||
return $funcs;
|
||||
}
|
||||
|
||||
private function _parseDotName()
|
||||
private function _parseDotName() : string
|
||||
{
|
||||
$dot_name = '';
|
||||
|
||||
|
@ -498,7 +498,7 @@ class mtgMetaInfoParser
|
|||
return $dot_name;
|
||||
}
|
||||
|
||||
private function _parseFunc()
|
||||
private function _parseFunc() : mtgMetaFunc
|
||||
{
|
||||
$name = $this->_parseDotName();
|
||||
$fn = new mtgMetaFunc($name);
|
||||
|
@ -655,7 +655,7 @@ class mtgMetaInfoParser
|
|||
$this->_addUnit(new mtgMetaInfoUnit($this->module, $rpc));
|
||||
}
|
||||
|
||||
private function _parsePropTokens()
|
||||
private function _parsePropTokens() : array
|
||||
{
|
||||
$prop_tokens = array();
|
||||
|
||||
|
@ -716,7 +716,7 @@ class mtgMetaInfoParser
|
|||
throw new Exception("Unknown property token '@$name'");
|
||||
}
|
||||
|
||||
private function _nextT($stop_on_new_line = false)
|
||||
private function _nextT(bool $stop_on_new_line = false)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
|
@ -867,8 +867,13 @@ class mtgMetaInfoParser
|
|||
if($this->cursor_char === "\n")
|
||||
$this->line++;
|
||||
//EOF
|
||||
if($this->cursor_char === false)
|
||||
if($this->cursor_char === '' ||
|
||||
//keeping BC with substr(..) before php 8.0
|
||||
//@phpstan-ignore-next-line
|
||||
is_bool($this->cursor_char))
|
||||
{
|
||||
$this->cursor_char = '';
|
||||
}
|
||||
}
|
||||
|
||||
private function _nextIf(int $t) : bool
|
||||
|
@ -901,11 +906,11 @@ class mtgMetaInfoParser
|
|||
|
||||
class mtgMetaParsedModule
|
||||
{
|
||||
public $file;
|
||||
public string $file;
|
||||
public $units = array();
|
||||
public $includes = array();
|
||||
|
||||
function __construct($file)
|
||||
function __construct(string $file)
|
||||
{
|
||||
$this->file = $file;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue