Skip to content

Commit

Permalink
update both parameter and @param docblock
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 28, 2020
1 parent af16d25 commit 9a06db4
Show file tree
Hide file tree
Showing 30 changed files with 397 additions and 440 deletions.
10 changes: 5 additions & 5 deletions app/Config/Mimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,19 @@ public static function guessTypeFromExtension(string $extension)
* Attempts to determine the best file extension for a given mime type.
*
* @param string $type
* @param string|null $proposed_extension - default extension (in case there is more than one with the same mime type)
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
*
* @return string|null The extension determined, or null if unable to match.
*/
public static function guessExtensionFromType(string $type, string $proposed_extension = null)
public static function guessExtensionFromType(string $type, string $proposedExtension = null)
{
$type = trim(strtolower($type), '. ');

$proposed_extension = trim(strtolower($proposed_extension));
$proposedExtension = trim(strtolower($proposedExtension));

if ($proposed_extension !== '' && array_key_exists($proposed_extension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposed_extension]) ? [static::$mimes[$proposed_extension]] : static::$mimes[$proposed_extension]))
if ($proposedExtension !== '' && array_key_exists($proposedExtension, static::$mimes) && in_array($type, is_string(static::$mimes[$proposedExtension]) ? [static::$mimes[$proposedExtension]] : static::$mimes[$proposedExtension]))
{
return $proposed_extension;
return $proposedExtension;
}

foreach (static::$mimes as $ext => $types)
Expand Down
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Utils\Rector\UnderscoreToCamelCaseLocalVariableNameRector;
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
Expand All @@ -25,5 +25,5 @@
]);

$services = $containerConfigurator->services();
$services->set(UnderscoreToCamelCaseLocalVariableNameRector::class);
$services->set(UnderscoreToCamelCaseVariableNameRector::class);
};
13 changes: 6 additions & 7 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
}

//--------------------------------------------------------------------

/**
* Takes a string and writes it to the command line, wrapping to a maximum
* width. If no maximum width is specified, will wrap to the window's max
Expand All @@ -825,11 +824,11 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
*
* @param string $string
* @param integer $max
* @param integer $pad_left
* @param integer $padLeft
*
* @return string
*/
public static function wrap(string $string = null, int $max = 0, int $pad_left = 0): string
public static function wrap(string $string = null, int $max = 0, int $padLeft = 0): string
{
if (empty($string))
{
Expand All @@ -846,20 +845,20 @@ public static function wrap(string $string = null, int $max = 0, int $pad_left =
$max = CLI::getWidth();
}

$max = $max - $pad_left;
$max = $max - $padLeft;

$lines = wordwrap($string, $max, PHP_EOL);

if ($pad_left > 0)
if ($padLeft > 0)
{
$lines = explode(PHP_EOL, $lines);

$first = true;

array_walk($lines, function (&$line, $index) use ($pad_left, &$first) {
array_walk($lines, function (&$line, $index) use ($padLeft, &$first) {
if (! $first)
{
$line = str_repeat(' ', $pad_left) . $line;
$line = str_repeat(' ', $padLeft) . $line;
}
else
{
Expand Down
51 changes: 24 additions & 27 deletions system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ protected function writeFile($path, $data, $mode = 'wb')
}

//--------------------------------------------------------------------

/**
* Delete Files
*
Expand All @@ -382,14 +381,14 @@ protected function writeFile($path, $data, $mode = 'wb')
* If the second parameter is set to TRUE, any directories contained
* within the supplied base directory will be nuked as well.
*
* @param string $path File path
* @param boolean $del_dir Whether to delete any directories found in the path
* @param boolean $htdocs Whether to skip deleting .htaccess and index page files
* @param integer $_level Current directory depth level (default: 0; internal use only)
* @param string $path File path
* @param boolean $delDir Whether to delete any directories found in the path
* @param boolean $htdocs Whether to skip deleting .htaccess and index page files
* @param integer $_level Current directory depth level (default: 0; internal use only)
*
* @return boolean
*/
protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs = false, int $_level = 0): bool
protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs = false, int $_level = 0): bool
{
// Trim the trailing slash
$path = rtrim($path, '/\\');
Expand All @@ -405,7 +404,7 @@ protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs
{
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.')
{
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $del_dir, $htdocs, $_level + 1);
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
}
elseif ($htdocs !== true || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
{
Expand All @@ -416,11 +415,10 @@ protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs

closedir($currentDir);

return ($del_dir === true && $_level > 0) ? @rmdir($path) : true;
return ($delDir === true && $_level > 0) ? @rmdir($path) : true;
}

//--------------------------------------------------------------------

/**
* Get Directory File Information
*
Expand All @@ -429,36 +427,36 @@ protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs
*
* Any sub-folders contained within the specified path are read as well.
*
* @param string $source_dir Path to source
* @param boolean $top_level_only Look only at the top level directory specified?
* @param boolean $_recursion Internal variable to determine recursion status - do not use in calls
* @param string $sourceDir Path to source
* @param boolean $topLevelOnly Look only at the top level directory specified?
* @param boolean $_recursion Internal variable to determine recursion status - do not use in calls
*
* @return array|false
*/
protected function getDirFileInfo(string $source_dir, bool $top_level_only = true, bool $_recursion = false)
protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, bool $_recursion = false)
{
static $_filedata = [];
$relativePath = $source_dir;
$relativePath = $sourceDir;

if ($fp = @opendir($source_dir))
if ($fp = @opendir($sourceDir))
{
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($_recursion === false)
{
$_filedata = [];
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$_filedata = [];
$sourceDir = rtrim(realpath($sourceDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}

// Used to be foreach (scandir($source_dir, 1) as $file), but scandir() is simply not as fast
while (false !== ($file = readdir($fp)))
{
if (is_dir($source_dir . $file) && $file[0] !== '.' && $top_level_only === false)
if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false)
{
$this->getDirFileInfo($source_dir . $file . DIRECTORY_SEPARATOR, $top_level_only, true);
$this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true);
}
elseif ($file[0] !== '.')
{
$_filedata[$file] = $this->getFileInfo($source_dir . $file);
$_filedata[$file] = $this->getFileInfo($sourceDir . $file);
$_filedata[$file]['relative_path'] = $relativePath;
}
}
Expand All @@ -472,7 +470,6 @@ protected function getDirFileInfo(string $source_dir, bool $top_level_only = tru
}

//--------------------------------------------------------------------

/**
* Get File Info
*
Expand All @@ -481,24 +478,24 @@ protected function getDirFileInfo(string $source_dir, bool $top_level_only = tru
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
* Returns FALSE if the file cannot be found.
*
* @param string $file Path to file
* @param mixed $returned_values Array or comma separated string of information returned
* @param string $file Path to file
* @param mixed $returnedValues Array or comma separated string of information returned
*
* @return array|false
*/
protected function getFileInfo(string $file, $returned_values = ['name', 'server_path', 'size', 'date'])
protected function getFileInfo(string $file, $returnedValues = ['name', 'server_path', 'size', 'date'])
{
if (! is_file($file))
{
return false;
}

if (is_string($returned_values))
if (is_string($returnedValues))
{
$returned_values = explode(',', $returned_values);
$returnedValues = explode(',', $returnedValues);
}

foreach ($returned_values as $key)
foreach ($returnedValues as $key)
{
switch ($key)
{
Expand Down
8 changes: 4 additions & 4 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,24 +594,24 @@ function force_https(int $duration = 31536000, RequestInterface $request = null,
* be just temporary, but would probably be kept for a few years.
*
* @link http://www.hardened-php.net/suhosin/
* @param string $function_name Function to check for
* @param string $functionName Function to check for
* @return boolean TRUE if the function exists and is safe to call,
* FALSE otherwise.
*
* @codeCoverageIgnore This is too exotic
*/
function function_usable(string $function_name): bool
function function_usable(string $functionName): bool
{
static $_suhosin_func_blacklist;

if (function_exists($function_name))
if (function_exists($functionName))
{
if (! isset($_suhosin_func_blacklist))
{
$_suhosin_func_blacklist = extension_loaded('suhosin') ? explode(',', trim(ini_get('suhosin.executor.func.blacklist'))) : [];
}

return ! in_array($function_name, $_suhosin_func_blacklist, true);
return ! in_array($functionName, $_suhosin_func_blacklist, true);
}

return false;
Expand Down
7 changes: 3 additions & 4 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,18 @@ public static function __callStatic(string $name, array $arguments)
}

//--------------------------------------------------------------------

/**
* Reset shared instances and mocks for testing.
*
* @param boolean $init_autoloader Initializes autoloader instance
* @param boolean $initAutoloader Initializes autoloader instance
*/
public static function reset(bool $init_autoloader = false)
public static function reset(bool $initAutoloader = false)
{
static::$mocks = [];

static::$instances = [];

if ($init_autoloader)
if ($initAutoloader)
{
static::autoloader()->initialize(new Autoload(), new Modules());
}
Expand Down
Loading

0 comments on commit 9a06db4

Please sign in to comment.