- Added the ability to clean arrays in \ncc\Utilities > Functions > cleanArray()
This commit is contained in:
parent
0e8397ec1f
commit
45c53981ef
4 changed files with 26 additions and 2 deletions
|
@ -27,6 +27,7 @@ features and reduced the number of exceptions down to 15 exceptions.
|
||||||
- Added a new interface class `TemplateInterface` to implement template classes
|
- Added a new interface class `TemplateInterface` to implement template classes
|
||||||
- Added new template PhpCliTemplate `phpcli`
|
- Added new template PhpCliTemplate `phpcli`
|
||||||
- Added new template PhpLibraryTemplate `phplib`
|
- Added new template PhpLibraryTemplate `phplib`
|
||||||
|
- Added the ability to clean arrays in `\ncc\Utilities > Functions > cleanArray()`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()`
|
- Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()`
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
use ncc\Objects\ProjectConfiguration;
|
use ncc\Objects\ProjectConfiguration;
|
||||||
use ncc\Objects\ProjectConfiguration\Compiler;
|
use ncc\Objects\ProjectConfiguration\Compiler;
|
||||||
use ncc\Utilities\Console;
|
use ncc\Utilities\Console;
|
||||||
|
use ncc\Utilities\Functions;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
|
||||||
class ProjectManager
|
class ProjectManager
|
||||||
|
|
|
@ -437,11 +437,14 @@
|
||||||
{
|
{
|
||||||
if(!$bytecode)
|
if(!$bytecode)
|
||||||
{
|
{
|
||||||
Functions::encodeJsonFile($this->toArray($bytecode), $path, Functions::FORCE_ARRAY | Functions::PRETTY | Functions::ESCAPE_UNICODE);
|
Functions::encodeJsonFile(
|
||||||
|
Functions::cleanArray($this->toArray($bytecode)), $path,
|
||||||
|
Functions::FORCE_ARRAY | Functions::PRETTY | Functions::ESCAPE_UNICODE
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Functions::encodeJsonFile($this->toArray($bytecode), $path, Functions::FORCE_ARRAY);
|
Functions::encodeJsonFile(Functions::cleanArray($this->toArray($bytecode)), $path, Functions::FORCE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1058,4 +1058,23 @@
|
||||||
RuntimeCache::set('posix_isatty', posix_isatty(STDOUT));
|
RuntimeCache::set('posix_isatty', posix_isatty(STDOUT));
|
||||||
return (bool)RuntimeCache::get('posix_isatty');
|
return (bool)RuntimeCache::get('posix_isatty');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans an array by removing empty values
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function cleanArray(array $input): array
|
||||||
|
{
|
||||||
|
foreach ($input as $key => $value)
|
||||||
|
{
|
||||||
|
if (is_array($value) && ($input[$key] = self::cleanArray($value)) === [])
|
||||||
|
{
|
||||||
|
unset($input[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue