Completed
Push — master ( 8e973a...811a95 )
by
unknown
03:40 queued 01:04
created
lib-vendor-organizer.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 $sourceDirectory = $argv[1];
10
-$sourceDirectory = rtrim($sourceDirectory, '/') . '/';
10
+$sourceDirectory = rtrim($sourceDirectory, '/').'/';
11 11
 
12 12
 if (!str_starts_with('/', $sourceDirectory)) {
13
-	$sourceDirectory = getcwd() . '/' . $sourceDirectory;
13
+	$sourceDirectory = getcwd().'/'.$sourceDirectory;
14 14
 }
15 15
 
16 16
 $stripNamespacePrefix = $argv[2] ?? '';
@@ -23,39 +23,39 @@  discard block
 block discarded – undo
23 23
 	exit(1);
24 24
 }
25 25
 $organizationList = [];
26
-foreach(scandir($sourceDirectory) as $file) {
27
-	if (!is_dir($sourceDirectory . $file) || $file === '.' || $file === '..') {
26
+foreach (scandir($sourceDirectory) as $file) {
27
+	if (!is_dir($sourceDirectory.$file) || $file === '.' || $file === '..') {
28 28
 		continue;
29 29
 	}
30
-	$organizationList[] = $sourceDirectory . $file . '/';
30
+	$organizationList[] = $sourceDirectory.$file.'/';
31 31
 }
32 32
 
33 33
 $projectList = [];
34
-foreach($organizationList as $organizationDir) {
35
-	foreach(scandir($organizationDir) as $file) {
36
-		if (!is_dir($organizationDir . $file) || $file === '.' || $file === '..') {
34
+foreach ($organizationList as $organizationDir) {
35
+	foreach (scandir($organizationDir) as $file) {
36
+		if (!is_dir($organizationDir.$file) || $file === '.' || $file === '..') {
37 37
 			continue;
38 38
 		}
39
-		$projectList[] = $organizationDir . $file . '/';
39
+		$projectList[] = $organizationDir.$file.'/';
40 40
 	}
41 41
 }
42 42
 
43 43
 $knownDestination = [];
44 44
 foreach ($projectList as $projectDir) {
45
-	if (!file_exists($projectDir . 'composer.json')) {
45
+	if (!file_exists($projectDir.'composer.json')) {
46 46
 		continue;
47 47
 	}
48 48
 
49
-	$projectInfo = json_decode(file_get_contents($projectDir . 'composer.json'), true);
49
+	$projectInfo = json_decode(file_get_contents($projectDir.'composer.json'), true);
50 50
 	if (!isset($projectInfo['autoload']['psr-4'])) {
51
-		printf("No supported autoload configuration in %s" . PHP_EOL, $projectDir);
51
+		printf("No supported autoload configuration in %s".PHP_EOL, $projectDir);
52 52
 		exit(2);
53 53
 	}
54 54
 	foreach ($projectInfo['autoload']['psr-4'] as $namespace => $codeDir) {
55 55
 		if ($stripNamespacePrefix !== '' && strpos($namespace, $stripNamespacePrefix) === 0) {
56 56
 			$namespace = str_replace($stripNamespacePrefix, '', $namespace);
57 57
 		}
58
-		$destination = rtrim($sourceDirectory, '/') . str_replace('\\', '/', $namespace);
58
+		$destination = rtrim($sourceDirectory, '/').str_replace('\\', '/', $namespace);
59 59
 
60 60
 		if (!in_array($destination, $knownDestination)) {
61 61
 			if (file_exists($destination)) {
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
 			$knownDestination[] = $destination;
66 66
 		}
67 67
 
68
-		if (!rename_or_move($projectDir . $codeDir, $destination)) {
69
-			printf("Failed to move %s to %s" . PHP_EOL, $projectDir . $codeDir, $destination);
68
+		if (!rename_or_move($projectDir.$codeDir, $destination)) {
69
+			printf("Failed to move %s to %s".PHP_EOL, $projectDir.$codeDir, $destination);
70 70
 			exit(3);
71 71
 		}
72 72
 	}
73 73
 }
74 74
 
75
-foreach($organizationList as $organizationDir) {
75
+foreach ($organizationList as $organizationDir) {
76 76
 	rmdir_recursive($organizationDir);
77 77
 }
78 78
 
79 79
 function rmdir_recursive($dir) {
80
-	foreach(scandir($dir) as $file) {
80
+	foreach (scandir($dir) as $file) {
81 81
 		if ('.' === $file || '..' === $file) {
82 82
 			continue;
83 83
 		}
Please login to merge, or discard this patch.