mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Clean up missing or inconsistent types in Lang, ModuleAction, ModuleInfo parser classes
This commit is contained in:
parent
df6fdd3bc3
commit
141ee7f7e1
3 changed files with 17 additions and 14 deletions
|
|
@ -17,7 +17,7 @@ class LangParser
|
|||
* @param array $xml_langs When converting XML to PHP, only convert these languages. (Optional)
|
||||
* @return void
|
||||
*/
|
||||
public static function convertDirectory($dir, $xml_langs = array())
|
||||
public static function convertDirectory(string $dir, array $xml_langs = []): void
|
||||
{
|
||||
if (file_exists("$dir/lang.xml"))
|
||||
{
|
||||
|
|
@ -43,9 +43,10 @@ class LangParser
|
|||
*
|
||||
* @param string $filename
|
||||
* @param string $language
|
||||
* @return string|false
|
||||
* @param ?string $output_filename (optional)
|
||||
* @return ?string
|
||||
*/
|
||||
public static function compileXMLtoPHP($filename, $language, $output_filename = null)
|
||||
public static function compileXMLtoPHP(string $filename, string $language, ?string $output_filename = null): ?string
|
||||
{
|
||||
// Check if the cache file already exists.
|
||||
if ($output_filename === null)
|
||||
|
|
@ -62,7 +63,7 @@ class LangParser
|
|||
if ($xml === false)
|
||||
{
|
||||
Storage::write($output_filename, '');
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert XML to a PHP array.
|
||||
|
|
@ -103,15 +104,17 @@ class LangParser
|
|||
/**
|
||||
* XML to array conversion callback.
|
||||
*
|
||||
* @param array $items
|
||||
* @param array|object $items
|
||||
* @param array &$lang
|
||||
* @param string $language
|
||||
* @return void
|
||||
*/
|
||||
protected static function _toArray($items, &$lang, $language)
|
||||
protected static function _toArray($items, &$lang, string $language): void
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$name = strval($item['name']);
|
||||
if (@count($item->item))
|
||||
if (countobj($item->item))
|
||||
{
|
||||
$lang[$name] = array();
|
||||
self::_toArray($item->item, $lang[$name], $language);
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ class ModuleActionParser extends BaseParser
|
|||
* Load an XML file.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return object|false
|
||||
* @return ?object
|
||||
*/
|
||||
public static function loadXML(string $filename)
|
||||
public static function loadXML(string $filename): ?object
|
||||
{
|
||||
// Load the XML file.
|
||||
$xml = simplexml_load_string(file_get_contents($filename));
|
||||
if ($xml === false)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the current language.
|
||||
|
|
@ -323,7 +323,7 @@ class ModuleActionParser extends BaseParser
|
|||
* @param array $route
|
||||
* @return object
|
||||
*/
|
||||
public static function analyzeRoute(array $route)
|
||||
public static function analyzeRoute(array $route): object
|
||||
{
|
||||
// Replace variables in the route definition into appropriate regexp.
|
||||
$var_regexp = '#\\$([a-zA-Z0-9_]+)(?::(' . implode('|', array_keys(self::$_shortcuts)) . '))?#';
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ class ModuleInfoParser extends BaseParser
|
|||
* Load an XML file.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return object|false
|
||||
* @return ?object
|
||||
*/
|
||||
public static function loadXML(string $filename)
|
||||
public static function loadXML(string $filename): ?object
|
||||
{
|
||||
// Load the XML file.
|
||||
$xml = simplexml_load_string(file_get_contents($filename));
|
||||
if ($xml === false)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the current language.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue