Skip to content

Commit be69283

Browse files
committed
Harmonize license headers in all PHP files (fixes #248)
1 parent ebe31e3 commit be69283

File tree

129 files changed

+573
-566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+573
-566
lines changed

.devtools/update-headers.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* NOTICE OF LICENSE
5+
*
6+
* This source file is subject to the Open Software License (OSL 3.0)
7+
* that is bundled with this package in the file LICENSE.txt.
8+
* It is also available through the world-wide-web at this URL:
9+
* https://opensource.org/licenses/OSL-3.0
10+
* If you did not receive a copy of the license and are unable to
11+
* obtain it through the world-wide-web, please send an email
12+
* to contact@h-hennes.fr so we can send you a copy immediately.
13+
*
14+
* @author Hennes Hervé <contact@h-hennes.fr>
15+
* @copyright since 2016 Hennes Hervé
16+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
17+
* https://github.com/nenes25/prestashop_console
18+
* https://www.h-hennes.fr/blog/
19+
*/
20+
21+
$licenseFile = __DIR__ . '/licence.txt';
22+
$projectRoot = dirname(__DIR__);
23+
24+
if (!file_exists($licenseFile)) {
25+
echo "Error: licence.txt not found at $licenseFile\n";
26+
exit(1);
27+
}
28+
29+
// Read the new license block (already formatted with /** */)
30+
$newLicenseBlock = file_get_contents($licenseFile);
31+
$newLicenseBlock = trim($newLicenseBlock);
32+
33+
// Function to find PHP files
34+
function findPhpFiles($dir) {
35+
$excludeDirs = ['vendor', 'phar', '.git', 'node_modules'];
36+
$phpFiles = [];
37+
38+
$iterator = new RecursiveIteratorIterator(
39+
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
40+
RecursiveIteratorIterator::SELF_FIRST
41+
);
42+
43+
foreach ($iterator as $file) {
44+
if ($file->isFile() && $file->getExtension() === 'php') {
45+
$path = $file->getPathname();
46+
$excluded = false;
47+
foreach ($excludeDirs as $excludeDir) {
48+
if (strpos($path, DIRECTORY_SEPARATOR . $excludeDir . DIRECTORY_SEPARATOR) !== false) {
49+
$excluded = true;
50+
break;
51+
}
52+
}
53+
if (!$excluded) {
54+
$phpFiles[] = $path;
55+
}
56+
}
57+
}
58+
59+
return $phpFiles;
60+
}
61+
62+
// Function to replace license header
63+
function updateLicenseHeader($filePath, $newLicenseBlock) {
64+
$content = file_get_contents($filePath);
65+
$originalContent = $content;
66+
67+
// Check if file starts with shebang
68+
$hasShebang = strpos($content, '#!') === 0;
69+
$shebang = '';
70+
71+
if ($hasShebang) {
72+
$lines = explode("\n", $content, 2);
73+
$shebang = $lines[0] . "\n";
74+
$content = isset($lines[1]) ? $lines[1] : '';
75+
}
76+
77+
// Remove <?php tag temporarily
78+
$hasPhpTag = preg_match('/^<\?php\s*\n?/s', $content);
79+
if ($hasPhpTag) {
80+
$content = preg_replace('/^<\?php\s*\n?/s', '', $content);
81+
}
82+
83+
// Remove all existing comment blocks at the start
84+
// This handles /** */ and /* */ style comments
85+
while (preg_match('/^\s*\/\*/', $content)) {
86+
$content = preg_replace('/^\s*\/\*.*?\*\/\s*/s', '', $content, 1);
87+
}
88+
89+
// Remove leading whitespace
90+
$content = ltrim($content);
91+
92+
// Build new content
93+
$newContent = $shebang;
94+
$newContent .= "<?php\n";
95+
$newContent .= $newLicenseBlock . "\n\n";
96+
$newContent .= $content;
97+
98+
return $newContent;
99+
}
100+
101+
// Main execution
102+
echo "Starting license header update...\n\n";
103+
104+
$phpFiles = findPhpFiles($projectRoot);
105+
echo "Found " . count($phpFiles) . " PHP files to process\n\n";
106+
107+
$updated = 0;
108+
$errors = 0;
109+
110+
foreach ($phpFiles as $file) {
111+
try {
112+
$relativePath = str_replace($projectRoot . DIRECTORY_SEPARATOR, '', $file);
113+
echo "Processing: $relativePath ... ";
114+
115+
$newContent = updateLicenseHeader($file, $newLicenseBlock);
116+
file_put_contents($file, $newContent);
117+
118+
echo "\n";
119+
$updated++;
120+
} catch (Exception $e) {
121+
echo "✗ Error: " . $e->getMessage() . "\n";
122+
$errors++;
123+
}
124+
}
125+
126+
echo "\n" . str_repeat('=', 60) . "\n";
127+
echo "Update complete!\n";
128+
echo "Files updated: $updated\n";
129+
echo "Errors: $errors\n";
130+
echo str_repeat('=', 60) . "\n";
131+
132+
exit($errors > 0 ? 1 : 0);

.php-cs-fixer.dist.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?php
2+
/**
3+
* NOTICE OF LICENSE
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available through the world-wide-web at this URL:
8+
* https://opensource.org/licenses/OSL-3.0
9+
* If you did not receive a copy of the license and are unable to
10+
* obtain it through the world-wide-web, please send an email
11+
* to contact@h-hennes.fr so we can send you a copy immediately.
12+
*
13+
* @author Hennes Hervé <contact@h-hennes.fr>
14+
* @copyright since 2016 Hennes Hervé
15+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
18+
*/
219

320
$config = new PrestaShop\CodingStandards\CsFixer\Config();
421

build.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
<?php
22
/**
3-
* Script to release a new version
3+
* NOTICE OF LICENSE
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available through the world-wide-web at this URL:
8+
* https://opensource.org/licenses/OSL-3.0
9+
* If you did not receive a copy of the license and are unable to
10+
* obtain it through the world-wide-web, please send an email
11+
* to contact@h-hennes.fr so we can send you a copy immediately.
12+
*
13+
* @author Hennes Hervé <contact@h-hennes.fr>
14+
* @copyright since 2016 Hennes Hervé
15+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
418
*/
19+
520
$binDir = dirname(__FILE__).'/bin/';
621
$versionFile = $binDir.'/phar/current.version';
722

config.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
<?php
22
/**
3-
* Prestashop Console
4-
* Configuration File
3+
* NOTICE OF LICENSE
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available through the world-wide-web at this URL:
8+
* https://opensource.org/licenses/OSL-3.0
9+
* If you did not receive a copy of the license and are unable to
10+
* obtain it through the world-wide-web, please send an email
11+
* to contact@h-hennes.fr so we can send you a copy immediately.
12+
*
13+
* @author Hennes Hervé <contact@h-hennes.fr>
14+
* @copyright since 2016 Hennes Hervé
15+
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
518
*/
19+
620
$configuration = [];
721

822
/**

console.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env php
22
<?php
33
/**
4-
* 2007-2020 Hennes Hervé
5-
*
64
* NOTICE OF LICENSE
75
*
86
* This source file is subject to the Open Software License (OSL 3.0)
@@ -14,9 +12,10 @@
1412
* to contact@h-hennes.fr so we can send you a copy immediately.
1513
*
1614
* @author Hennes Hervé <contact@h-hennes.fr>
17-
* @copyright 2007-2018 Hennes Hervé
15+
* @copyright since 2016 Hennes Hervé
1816
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
19-
* http://www.h-hennes.fr/blog/
17+
* https://github.com/nenes25/prestashop_console
18+
* https://www.h-hennes.fr/blog/
2019
*/
2120

2221
use PrestashopConsole\PrestashopConsoleApplication;

index.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* 2007-2018 Hennes Hervé
4-
*
53
* NOTICE OF LICENSE
64
*
75
* This source file is subject to the Open Software License (OSL 3.0)
@@ -13,9 +11,10 @@
1311
* to contact@h-hennes.fr so we can send you a copy immediately.
1412
*
1513
* @author Hennes Hervé <contact@h-hennes.fr>
16-
* @copyright 2007-2018 Hennes Hervé
14+
* @copyright since 2016 Hennes Hervé
1715
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
18-
* http://www.h-hennes.fr/blog/
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
1918
*/
2019

2120
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

prestashopConsoleWrapper.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Since 2016 Hennes Hervé
4-
*
53
* NOTICE OF LICENSE
64
*
75
* This source file is subject to the Open Software License (OSL 3.0)
@@ -13,32 +11,12 @@
1311
* to contact@h-hennes.fr so we can send you a copy immediately.
1412
*
1513
* @author Hennes Hervé <contact@h-hennes.fr>
16-
* @copyright Since 2016 Hennes Hervé
14+
* @copyright since 2016 Hennes Hervé
1715
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
18-
* http://www.h-hennes.fr/blog/
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
1918
*/
2019

21-
/**
22-
* Console wrapper in browser
23-
*
24-
* With this way you cannot have interaction with the console, every parameters should be provided in url
25-
*
26-
* WARNING: Remove this file after your works as been done as it can be a security issue to let it present
27-
*
28-
* Upload this file in the root directory of your prestashop
29-
* Call the page this way
30-
* http://www.site.com/prestashopConsoleWrapper.php?command=command:name:domain&arguments['argumentKey']=argumentValue&=options['optionkey']=value
31-
*
32-
* Several examples :
33-
*
34-
* Show help of the command admin:user:list
35-
* prestashopConsoleWrapper.php?command=admin:user:list&options[]=help
36-
* List only active modules
37-
* prestashopConsoleWrapper.php?command=module:list&options[]=active
38-
* List only active modules not from prestashop
39-
* prestashopConsoleWrapper.php?command=module:list&options[]=active&options[]=no-native
40-
*
41-
*/
4220
class PrestashopConsoleWrapper
4321
{
4422
/**

src/PrestashopConsole/Command/Admin/ProfilesListCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* 2007-2021 Hennes Hervé
4-
*
53
* NOTICE OF LICENSE
64
*
75
* This source file is subject to the Open Software License (OSL 3.0)
@@ -13,9 +11,9 @@
1311
* to contact@h-hennes.fr so we can send you a copy immediately.
1412
*
1513
* @author Hennes Hervé <contact@h-hennes.fr>
16-
* @copyright 2007-2021 Hennes Hervé
14+
* @copyright since 2016 Hennes Hervé
1715
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
18-
* https://github.com/nenes25/prestashop_console*
16+
* https://github.com/nenes25/prestashop_console
1917
* https://www.h-hennes.fr/blog/
2018
*/
2119

src/PrestashopConsole/Command/Admin/User/CreateCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* 2007-2019 Hennes Hervé
4-
*
53
* NOTICE OF LICENSE
64
*
75
* This source file is subject to the Open Software License (OSL 3.0)
@@ -13,9 +11,10 @@
1311
* to contact@h-hennes.fr so we can send you a copy immediately.
1412
*
1513
* @author Hennes Hervé <contact@h-hennes.fr>
16-
* @copyright 2007-2019 Hennes Hervé
14+
* @copyright since 2016 Hennes Hervé
1715
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
18-
* http://www.h-hennes.fr/blog/
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
1918
*/
2019

2120
namespace PrestashopConsole\Command\Admin\User;

src/PrestashopConsole/Command/Admin/User/ListCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* 2007-2019 Hennes Hervé
4-
*
53
* NOTICE OF LICENSE
64
*
75
* This source file is subject to the Open Software License (OSL 3.0)
@@ -13,9 +11,10 @@
1311
* to contact@h-hennes.fr so we can send you a copy immediately.
1412
*
1513
* @author Hennes Hervé <contact@h-hennes.fr>
16-
* @copyright 2007-2019 Hennes Hervé
14+
* @copyright since 2016 Hennes Hervé
1715
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
18-
* http://www.h-hennes.fr/blog/
16+
* https://github.com/nenes25/prestashop_console
17+
* https://www.h-hennes.fr/blog/
1918
*/
2019

2120
namespace PrestashopConsole\Command\Admin\User;

0 commit comments

Comments
 (0)