Skip to content

Commit

Permalink
Updated coding standards in tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Feb 5, 2024
1 parent 788d994 commit eb67ba1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .drevops/installer/src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ protected static function parseDotenv($filename = '.env'): false|array {
// Replace all # not inside quotes.
$contents = preg_replace('/#(?=(?:(?:[^"]*"){2})*[^"]*$)/', ';', $contents);

return parse_ini_string($contents);
return parse_ini_string((string) $contents);
}

protected static function loadDotenv($filename = '.env', $override_existing = FALSE) {
Expand Down Expand Up @@ -2197,7 +2197,7 @@ protected function commandExists(string $command) {

protected static function toHumanName($value): ?string {
$value = preg_replace('/[^a-zA-Z0-9]/', ' ', (string) $value);
$value = trim($value);
$value = trim((string) $value);

return preg_replace('/\s{2,}/', ' ', $value);
}
Expand All @@ -2211,11 +2211,11 @@ protected static function toMachineName($value, $preserve_chars = []): string {

$value = preg_replace($pattern, '_', (string) $value);

return strtolower($value);
return strtolower((string) $value);
}

protected static function toCamelCase($value, $capitalise_first = FALSE): string|array {
$value = str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9]/', ' ', (string) $value)));
$value = str_replace(' ', '', ucwords((string) preg_replace('/[^a-zA-Z0-9]/', ' ', (string) $value)));

return $capitalise_first ? $value : lcfirst($value);
}
Expand Down
8 changes: 6 additions & 2 deletions .drevops/installer/tests/phpunit/Unit/UnitTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ public function cleanupFixtureDir(): void {

/**
* Create fixture files.
*
* @return string[]
* Created file names.
*/
protected function createFixtureFiles($files, $basedir = NULL, $append_rand = TRUE) {
protected function createFixtureFiles($files, $basedir = NULL, $append_rand = TRUE): array {
$fs = new Filesystem();
$created = [];

foreach ($files as $file) {
$basedir = $basedir ?? dirname((string) $file);
$relative_dst = ltrim(str_replace($basedir, '', (string) $file), '/') . ($append_rand ? rand(1000, 9999) : '');
Expand All @@ -69,7 +73,7 @@ protected function createFixtureFiles($files, $basedir = NULL, $append_rand = TR
* @return string
* Fixture directory path.
*/
protected function getFixtureDir($name = NULL) {
protected function getFixtureDir($name = NULL): string {
$parent = dirname(__FILE__);
$path = $parent . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Fixtures';
$path .= $name ? DIRECTORY_SEPARATOR . $name : '';
Expand Down

0 comments on commit eb67ba1

Please sign in to comment.