diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-12-03 18:54:35 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-12-05 15:38:38 +0100 |
commit | a166796378bb41145559aa0899394583938b900d (patch) | |
tree | e9ac09d0e9f37ee8a3d2a7490d5be5fd6e1c50a7 | |
parent | 3eb3c3f884e1791059e71f5106880ea507f5c12f (diff) | |
download | nextcloud-server-a166796378bb41145559aa0899394583938b900d.tar.gz nextcloud-server-a166796378bb41145559aa0899394583938b900d.zip |
Update license script apps
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r-- | build/license.php | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/build/license.php b/build/license.php index cb19f196fff..a3a44830919 100644 --- a/build/license.php +++ b/build/license.php @@ -161,8 +161,12 @@ With help from many libraries and frameworks including: $license = str_replace('@COPYRIGHT@', $copyrightNotices, $license); } - $source = $this->eatOldLicense($source); - $source = "<?php" . PHP_EOL . $license . PHP_EOL . $source; + [$source, $isStrict] = $this->eatOldLicense($source); + if ($isStrict) { + $source = "<?php" . PHP_EOL . PHP_EOL . 'declare(strict_types=1);' . PHP_EOL . PHP_EOL . $license . PHP_EOL . $source; + } else { + $source = "<?php" . PHP_EOL . $license . PHP_EOL . $source; + } file_put_contents($path,$source); echo "License updated: $path" . PHP_EOL; } @@ -184,18 +188,18 @@ With help from many libraries and frameworks including: return false; } - private function isOwnCloudLicensed($source) { - $lines = explode(PHP_EOL, $source); - while(!empty($lines)) { - $line = $lines[0]; - array_shift($lines); - if (strpos($line, 'ownCloud, Inc') !== false || strpos($line, 'ownCloud GmbH') !== false) { - return true; - } + private function isOwnCloudLicensed($source) { + $lines = explode(PHP_EOL, $source); + while(!empty($lines)) { + $line = $lines[0]; + array_shift($lines); + if (strpos($line, 'ownCloud, Inc') !== false || strpos($line, 'ownCloud GmbH') !== false) { + return true; } + } - return false; - } + return false; + } /** * @param string $source @@ -203,9 +207,25 @@ With help from many libraries and frameworks including: */ private function eatOldLicense($source) { $lines = explode(PHP_EOL, $source); + $isStrict = false; while(!empty($lines)) { $line = $lines[0]; - if (strpos($line, '<?php') !== false) { + if (trim($line) === '<?php') { + array_shift($lines); + continue; + } + if (strpos($line, '<?php declare(strict_types') !== false) { + $isStrict = true; + array_shift($lines); + continue; + } + if (strpos($line, 'declare (strict_types') !== false) { + $isStrict = true; + array_shift($lines); + continue; + } + if (strpos($line, 'declare(strict_types') !== false) { + $isStrict = true; array_shift($lines); continue; } @@ -228,7 +248,7 @@ With help from many libraries and frameworks including: break; } - return implode(PHP_EOL, $lines); + return [implode(PHP_EOL, $lines), $isStrict]; } private function getCopyrightNotices($path, $file) { @@ -364,7 +384,9 @@ if (isset($argv[1])) { $licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false); } else { $licenses->exec([ + '../apps/accessibility', '../apps/admin_audit', + '../apps/cloud_federation_api', '../apps/comments', '../apps/dav', '../apps/encryption', @@ -375,17 +397,21 @@ if (isset($argv[1])) { '../apps/files_sharing', '../apps/files_trashbin', '../apps/files_versions', + '../apps/lookup_server_connector', + '../apps/oauth2', '../apps/provisioning_api', + '../apps/settings', + '../apps/sharebymail', '../apps/systemtags', '../apps/testing', '../apps/theming', + '../apps/twofactor_backupcodes', '../apps/updatenotification', '../apps/user_ldap', '../build/integration/features/bootstrap', '../core', '../lib', '../ocs', - '../settings', '../console.php', '../cron.php', '../index.php', |