Skip to content

Commit 25a5995

Browse files
authored
Merge pull request #15 from humhub/rector/auto-update
chore: automated Rector updates
2 parents 64f0a2c + 4e18b25 commit 25a5995

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/rewrite-module-id.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# ---------------------------------------------------------------------------------------------------------------
1010

11-
$baseDir = dirname(dirname(__FILE__));
11+
$baseDir = dirname(__FILE__, 2);
1212

1313
#$oldModuleId = "example-basic";
1414
$moduleInfo = json_decode(file_get_contents($baseDir . '/module.json'), true);
@@ -30,12 +30,12 @@
3030
print "\tNew:\t" . $newModuleId . "\t(" . dashesToCamelCase($newModuleId) . ")\n";
3131
print "\n";
3232

33-
if (strpos($newModuleId, $oldModuleId) !== false && $oldModuleId !== $newModuleId) {
33+
if (str_contains($newModuleId, (string) $oldModuleId) && $oldModuleId !== $newModuleId) {
3434
print "Old module ID cannot be part of the new module id!\n";
3535
die();
3636
}
3737

38-
if (strpos($newNamespace, $oldNamespace) !== false && $oldNamespace !== $newNamespace) {
38+
if (str_contains($newNamespace, $oldNamespace) && $oldNamespace !== $newNamespace) {
3939
print "Old module namespace cannot be part of the new namespace!\n";
4040
die();
4141
}
@@ -44,22 +44,22 @@
4444
$it = new RecursiveDirectoryIterator($baseDir);
4545
foreach (new RecursiveIteratorIterator($it) as $file) {
4646
/** @var SplFileInfo $file */
47-
if (strpos($file, '.git') !== false || strpos($file, '.idea') !== false || $file->isDir() || $file == __FILE__) {
47+
if (str_contains($file, '.git') || str_contains($file, '.idea') || $file->isDir() || $file == __FILE__) {
4848
continue;
4949
}
5050

5151
// Replace in files
5252
$fileContent = file_get_contents($file);
5353
$fileContent = str_replace($oldNamespace, $newNamespace, $fileContent);
5454
$fileContent = str_replace($oldModuleId, $newModuleId, $fileContent);
55-
$fileContent = str_replace(ucfirst($oldModuleId), ucfirst($newModuleId), $fileContent);
55+
$fileContent = str_replace(ucfirst((string) $oldModuleId), ucfirst($newModuleId), $fileContent);
5656
$fileContent = str_replace(dashesToCamelCase($oldModuleId), dashesToCamelCase($newModuleId), $fileContent);
5757
$fileContent = str_replace(ucfirst(dashesToCamelCase($oldModuleId)), ucfirst(dashesToCamelCase($newModuleId)), $fileContent);
5858
file_put_contents($file, $fileContent);
5959
print "Searched&replaced in: " . $file . "\n";
6060

6161
// Rename file names (e.g. resources/js/humhub.example-basic.js)
62-
if (strpos($file->getBasename(), $oldModuleId) !== false) {
62+
if (str_contains($file->getBasename(), (string) $oldModuleId)) {
6363
$newFileName = $file->getPath() . '/' . str_replace($oldModuleId, $newModuleId, $file->getBasename());
6464

6565
rename($file, $newFileName);
@@ -72,7 +72,7 @@
7272
*/
7373
function camelCaseToDashed($className): string
7474
{
75-
return strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $className));
75+
return strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', (string) $className));
7676
}
7777

7878
function dashesToCamelCase($string, $capitalizeFirstCharacter = false): string

0 commit comments

Comments
 (0)