aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 18:29:30 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:36:04 +0200
commit36bc1870f21fac04736a1049c1d5b8e127d729f4 (patch)
tree9d102331eeaf1ef3cd23e656320d7c08e65757ed /build
parent8875d385d0579b451dac4d9bda465172b4f69ee0 (diff)
parent149375253685b3a38996f63015a74b7a0f53aa14 (diff)
downloadforums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.gz
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.bz2
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.xz
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.zip
Merge remote-tracking branch 'upstream/prep-release-3.1.11'
Diffstat (limited to 'build')
-rw-r--r--build/build.xml191
-rwxr-xr-xbuild/build_announcement.php50
-rwxr-xr-xbuild/build_changelog.php12
-rw-r--r--build/build_helper.php75
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php232
-rw-r--r--build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php143
-rw-r--r--build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php60
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php248
-rw-r--r--build/code_sniffer/ruleset-minimum.xml18
-rw-r--r--build/code_sniffer/ruleset-php-extensions.xml8
-rw-r--r--build/code_sniffer/ruleset-php-legacy-core.xml11
-rw-r--r--build/code_sniffer/ruleset-php-legacy.xml92
-rw-r--r--build/code_sniffer/ruleset-php-strict-core.xml9
-rw-r--r--build/code_sniffer/ruleset-php-strict.xml48
-rwxr-xr-xbuild/package.php142
-rw-r--r--build/sami-all.conf.php2
16 files changed, 1257 insertions, 84 deletions
diff --git a/build/build.xml b/build/build.xml
index ea98842f85..20ecfefc61 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -2,9 +2,9 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
- <property name="newversion" value="3.0.14" />
- <property name="prevversion" value="3.0.14-RC1" />
- <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.10, 3.0.11, 3.0.12, 3.0.13, 3.0.13-PL1" />
+ <property name="newversion" value="3.1.11" />
+ <property name="prevversion" value="3.1.10" />
+ <property name="olderversions" value="3.0.14, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.7-pl1, 3.1.8, 3.1.9, 3.1.11-RC1" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
@@ -49,7 +49,7 @@
-->
<target name="composer">
<exec dir="phpBB"
- command="php ../composer.phar install --dev"
+ command="php ../composer.phar install --ignore-platform-reqs"
checkreturn="true"
passthru="true" />
</target>
@@ -73,6 +73,50 @@
passthru="true" />
</target>
+ <target name="sniff">
+ <exec command="phpBB/vendor/bin/phpcs
+ -s -p
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-strict-core.xml
+ --ignore=${project.basedir}/phpBB/phpbb/db/migration/data/v30x/*
+ phpBB/phpbb"
+ dir="." returnProperty="retval-php-strict" passthru="true" />
+ <exec command="phpBB/vendor/bin/phpcs
+ -s -p
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-legacy-core.xml
+ --ignore=${project.basedir}/phpBB/cache/*
+ --ignore=${project.basedir}/phpBB/develop/*
+ --ignore=${project.basedir}/phpBB/ext/*
+ --ignore=${project.basedir}/phpBB/includes/diff/*.php
+ --ignore=${project.basedir}/phpBB/includes/sphinxapi.php
+ --ignore=${project.basedir}/phpBB/includes/utf/data/*
+ --ignore=${project.basedir}/phpBB/install/data/*
+ --ignore=${project.basedir}/phpBB/install/database_update.php
+ --ignore=${project.basedir}/phpBB/phpbb/*
+ --ignore=${project.basedir}/phpBB/vendor/*
+ phpBB"
+ dir="." returnProperty="retval-php-legacy" passthru="true" />
+ <exec command="phpBB/vendor/bin/phpcs
+ -s -p
+ --extensions=php
+ --standard=build/code_sniffer/ruleset-php-extensions.xml
+ --ignore=${project.basedir}/phpBB/ext/*/tests/*
+ --ignore=${project.basedir}/phpBB/ext/*/vendor/*
+ phpBB/ext"
+ dir="." returnProperty="retval-php-ext" passthru="true" />
+ <if>
+ <or>
+ <not><equals arg1="${retval-php-strict}" arg2="0" /></not>
+ <not><equals arg1="${retval-php-legacy}" arg2="0" /></not>
+ <not><equals arg1="${retval-php-ext}" arg2="0" /></not>
+ </or>
+ <then>
+ <fail message="PHP Code Sniffer failed." />
+ </then>
+ </if>
+ </target>
+
<!-- Builds docs for current branch into build/api/output/master -->
<target name="docs">
<exec dir="."
@@ -99,14 +143,16 @@
<phingcall target="export">
<property name="revision" value="release-${version}" />
<property name="dir" value="build/old_versions/release-${version}" />
+ <property name="skip-composer" value="true" />
</phingcall>
<phingcall target="clean-diff-dir">
<property name="dir" value="build/old_versions/release-${version}" />
</phingcall>
- <exec dir="build/old_versions" command="LC_ALL=C diff -crNEBwd release-${version} release-${newversion} >
+ <exec dir="build/old_versions" command="LC_ALL=C diff -crNEBZbd release-${version} release-${newversion} >
../new_version/patches/phpBB-${version}_to_${newversion}.patch" escape="false" />
+ <exec dir="build/old_versions" command="LC_ALL=C diff -qr release-${version} release-${newversion} | grep 'Only in release-${version}' > ../new_version/patches/phpBB-${version}_to_${newversion}.deleted" escape="false" />
</target>
<target name="prepare-new-version">
@@ -132,13 +178,13 @@
<target name="package" depends="clean,prepare,prepare-new-version,old-version-diffs">
<exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" />
<exec dir="build" escape="false"
- command="diff -crNEBwd old_versions/release-${prevversion}/language new_version/phpBB3/language >
+ command="LC_ALL=C diff -crNEBZbd old_versions/release-${prevversion}/language new_version/phpBB3/language >
save/phpbb-${prevversion}_to_${newversion}_language.patch" />
<exec dir="build" escape="false"
- command="diff -crNEBwd old_versions/release-${prevversion}/styles/prosilver new_version/phpBB3/styles/prosilver >
+ command="LC_ALL=C diff -crNEBZbd old_versions/release-${prevversion}/styles/prosilver new_version/phpBB3/styles/prosilver >
save/phpbb-${prevversion}_to_${newversion}_prosilver.patch" />
<exec dir="build" escape="false"
- command="diff -crNEBwd old_versions/release-${prevversion}/styles/subsilver2 new_version/phpBB3/styles/subsilver2 >
+ command="LC_ALL=C diff -crNEBZbd old_versions/release-${prevversion}/styles/subsilver2 new_version/phpBB3/styles/subsilver2 >
save/phpbb-${prevversion}_to_${newversion}_subsilver2.patch" />
<exec dir="build" escape="false"
@@ -206,26 +252,35 @@
<equals arg1="${composer-has-dependencies}" arg2="1" trim="true" />
<then>
<!-- We have non-dev composer dependencies -->
- <exec dir="."
- command="git ls-tree ${revision} composer.phar"
- checkreturn="true"
- outputProperty='composer-ls-tree-output' />
<if>
- <equals arg1="${composer-ls-tree-output}" arg2="" trim="true" />
+ <not><isset property="skip-composer" /></not>
<then>
- <fail message="There are composer dependencies, but composer.phar is missing." />
- </then>
- <else>
- <!-- Export the phar, install dependencies, delete phar. -->
<exec dir="."
- command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
- checkreturn="true" />
- <exec dir="${dir}"
- command="php composer.phar install --no-dev"
+ command="git ls-tree ${revision} composer.phar"
checkreturn="true"
- passthru="true" />
- <delete file="${dir}/composer.phar" />
- </else>
+ outputProperty='composer-ls-tree-output' />
+ <if>
+ <equals arg1="${composer-ls-tree-output}" arg2="" trim="true" />
+ <then>
+ <fail message="There are composer dependencies, but composer.phar is missing." />
+ </then>
+ <else>
+ <!-- Export the phar, install dependencies, delete phar. -->
+ <exec dir="."
+ command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
+ checkreturn="true" />
+ <exec dir="${dir}"
+ command="php composer.phar install --no-dev --optimize-autoloader --ignore-platform-reqs"
+ checkreturn="true"
+ passthru="true" />
+ <delete file="${dir}/composer.phar" />
+
+ <phingcall target="clean-vendor-dir">
+ <property name="dir" value="${dir}" />
+ </phingcall>
+ </else>
+ </if>
+ </then>
</if>
</then>
<else>
@@ -235,6 +290,9 @@
</else>
</if>
+ <!-- Create schema.json -->
+ <exec dir="${dir}" command="php develop/create_schema_files.php" />
+
<delete file="${dir}/config.php" />
<delete dir="${dir}/develop" />
<delete dir="${dir}/install/data" />
@@ -250,6 +308,91 @@
<chmod mode="0777" file="${dir}/images/avatars/upload" />
</target>
+ <target name="clean-vendor-dir">
+ <!-- Delete unrelated files from vendor/, see PHPBB3-12390 -->
+ <delete dir="${dir}/vendor/lusitanian/oauth/examples" />
+ <delete dir="${dir}/vendor/lusitanian/oauth/tests" />
+ <delete file="${dir}/vendor/lusitanian/oauth/.gitignore" />
+ <delete file="${dir}/vendor/lusitanian/oauth/.scrutinizer.yml" />
+ <delete file="${dir}/vendor/lusitanian/oauth/.travis.yml" />
+ <delete file="${dir}/vendor/lusitanian/oauth/phpunit.xml.dist" />
+ <delete file="${dir}/vendor/lusitanian/oauth/README.md" />
+
+ <delete dir="${dir}/vendor/psr/log/Psr/Log/Test" />
+ <delete file="${dir}/vendor/psr/log/.gitignore" />
+ <delete file="${dir}/vendor/psr/log/README.md" />
+
+ <delete dir="${dir}/vendor/symfony/config/Symfony/Component/Config/Tests" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/.gitignore" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/README.md" />
+ <delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/console/Symfony/Component/Console/Tests" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/.gitignore" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/README.md" />
+ <delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/debug/Symfony/Component/Debug/Tests" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/.gitignore" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/README.md" />
+ <delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md" />
+ <delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md" />
+ <delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/Tests" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/.gitignore" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/README.md" />
+ <delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md" />
+ <delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md" />
+ <delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/routing/Symfony/Component/Routing/Tests" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/.gitignore" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/README.md" />
+ <delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/Tests" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/README.md" />
+ <delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist" />
+
+ <delete dir="${dir}/vendor/twig/twig/doc" />
+ <delete dir="${dir}/vendor/twig/twig/ext" />
+ <delete dir="${dir}/vendor/twig/twig/test" />
+ <delete file="${dir}/vendor/twig/twig/.editorconfig" />
+ <delete file="${dir}/vendor/twig/twig/.gitignore" />
+ <delete file="${dir}/vendor/twig/twig/.travis.yml" />
+ <delete file="${dir}/vendor/twig/twig/CHANGELOG" />
+ <delete file="${dir}/vendor/twig/twig/phpunit.xml.dist" />
+ <delete file="${dir}/vendor/twig/twig/README.rst" />
+ </target>
+
<target name="clean-diff-dir">
<delete dir="${dir}/cache" />
<delete dir="${dir}/docs" />
diff --git a/build/build_announcement.php b/build/build_announcement.php
index 3ee96fc67d..0718bbc82a 100755
--- a/build/build_announcement.php
+++ b/build/build_announcement.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -22,16 +26,20 @@ $checksum_algorithm = $_SERVER['argv'][4];
$series_version = substr($version, 0, 3);
$base_url = "https://download.phpbb.com/pub/release/$series_version";
-if (strpos($version, 'RC') === false)
+if (version_compare($version, "$series_version.0", '<'))
+{
+ // Everything before 3.x.0, i.e. unstable (e.g. alpha, beta, rc)
+ $url = "$base_url/unstable/$version";
+}
+else if (strpos($version, 'RC') !== false)
{
- // Final release
- $install_url = "$base_url/$version";
- $update_url = "$base_url/update/to_$version";
+ // Release candidate of stable release
+ $url = "$base_url/qa/$version";
}
else
{
- $install_url = "$base_url/release_candidates/$version";
- $update_url = "$base_url/release_candidates/update/other_to_$version";
+ // Stable release (e.g. 3.x.0, 3.x.1, 3.x.2, 3.x.3-PL1)
+ $url = "$base_url/$version";
}
if ($mode === 'bbcode')
@@ -58,41 +66,19 @@ function phpbb_string_ends_with($haystack, $needle)
return substr($haystack, -strlen($needle)) === $needle;
}
-function phpbb_is_update_file($filename)
-{
- return strpos($filename, '_to_') !== false;
-}
-
function phpbb_get_checksum($checksum_file)
{
return array_shift(explode(' ', file_get_contents($checksum_file)));
}
-$install_files = $update_files = array();
foreach (phpbb_rnatsort(array_diff(scandir($root), array('.', '..'))) as $filename)
{
if (phpbb_string_ends_with($filename, $checksum_algorithm))
{
continue;
}
- else if (phpbb_is_update_file($filename))
- {
- $update_files[] = $filename;
- }
else
{
- $install_files[] = $filename;
+ printf($template, $url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
}
}
-
-foreach ($install_files as $filename)
-{
- printf($template, $install_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
-}
-
-echo "\n";
-
-foreach ($update_files as $filename)
-{
- printf($template, $update_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
-}
diff --git a/build/build_changelog.php b/build/build_changelog.php
index 1e80959adf..2d38480f9f 100755
--- a/build/build_changelog.php
+++ b/build/build_changelog.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -16,7 +20,7 @@ if ($_SERVER['argc'] != 2)
$fixVersion = $_SERVER['argv'][1];
-$query = 'project = PHPBB3
+$query = 'project IN (PHPBB3, SECURITY)
AND resolution = Fixed
AND fixVersion = "' . $fixVersion . '"
AND status IN ("Unverified Fix", Closed)';
diff --git a/build/build_helper.php b/build/build_helper.php
index d6169b913b..3ff1b89eab 100644
--- a/build/build_helper.php
+++ b/build/build_helper.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -18,11 +22,11 @@ class build_package
// -r - compare recursive
// -N - Treat missing files as empty
// -E - Ignore tab expansions
- // not used: -b - Ignore space changes.
- // -w - Ignore all whitespace
+ // -Z - Ignore white space at line end.
+ // -b - Ignore changes in the amount of white space.
// -B - Ignore blank lines
// -d - Try to find smaller set of changes
- var $diff_options = '-crNEBwd';
+ var $diff_options = '-crNEBZbd';
var $diff_options_long = '-x images -crNEB'; // -x fonts -x imageset //imageset not used here, because it includes the imageset.cfg file. ;)
var $verbose = false;
@@ -312,4 +316,63 @@ class build_package
return $result;
}
+
+ /**
+ * Collect the list of the deleted files from a list of deleted files and folders.
+ *
+ * @param string $deleted_filename The full path to a file containing the list of deleted files and directories
+ * @param string $package_name The name of the package
+ * @return array
+ */
+ public function collect_deleted_files($deleted_filename, $package_name)
+ {
+ $result = array();
+ $file_contents = file($deleted_filename);
+
+ foreach ($file_contents as $filename)
+ {
+ $filename = trim($filename);
+
+ if (!$filename)
+ {
+ continue;
+ }
+
+ $filename = str_replace('Only in ' . $package_name, '', $filename);
+ $filename = ltrim($filename, '/');
+
+ if (substr($filename, 0, 1) == ':')
+ {
+ $replace = '';
+ }
+ else
+ {
+ $replace = '/';
+ }
+
+ $filename = str_replace(': ', $replace, $filename);
+
+ if (is_dir("{$this->locations['old_versions']}{$package_name}/{$filename}"))
+ {
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator(
+ "{$this->locations['old_versions']}{$package_name}/{$filename}",
+ \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
+
+ foreach ($iterator as $file_info)
+ {
+ $result[] = "{$filename}/{$iterator->getSubPathname()}";
+ }
+ }
+ else
+ {
+ $result[] = $filename;
+ }
+ }
+
+ return $result;
+ }
}
diff --git a/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
new file mode 100644
index 0000000000..8c0ec853ff
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
@@ -0,0 +1,232 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* Checks that each PHP source file contains a valid header as defined by the
+* phpBB Coding Guidelines.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_OPEN_TAG);
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token
+ * in the stack passed in $tokens.
+ *
+ * @return null
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ // We are only interested in the first file comment.
+ if ($stackPtr !== 0)
+ {
+ if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false)
+ {
+ return;
+ }
+ }
+
+ // Fetch next non whitespace token
+ $tokens = $phpcsFile->getTokens();
+ $start = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
+
+ // Skip empty files
+ if ($tokens[$start]['code'] === T_CLOSE_TAG)
+ {
+ return;
+ }
+ // Mark as error if this is not a doc comment
+ else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT_OPEN_TAG)
+ {
+ $phpcsFile->addError('Missing required file doc comment.', $stackPtr);
+ return;
+ }
+
+ // Find comment end token
+ $end = $tokens[$start]['comment_closer'];
+
+ // If there is no end, skip processing here
+ if ($end === false)
+ {
+ return;
+ }
+
+ // check comment lines without the first(/**) an last(*/) line
+ for ($token = $start + 1, $c = $end - 2; $token <= $c; ++$token)
+ {
+ // Check that each line starts with a '*'
+ if ($tokens[$token]['column'] === 1 && (($tokens[$token]['content'] !== '*' && $tokens[$token]['content'] !== ' ') || ($tokens[$token]['content'] === ' ' && $tokens[$token + 1]['content'] !== '*')))
+ {
+ $message = 'The file doc comment should not be indented.';
+ $phpcsFile->addWarning($message, $token);
+ }
+ }
+
+ // Check that the first and last line is empty
+ // /**T_WHITESPACE
+ // (T_WHITESPACE)*T_WHITESPACE
+ // (T_WHITESPACE)* ...
+ // (T_WHITESPACE)*T_WHITESPACE
+ // T_WHITESPACE*/
+ if (!(($tokens[$start + 2]['content'] !== '*' && $tokens[$start + 4]['content'] !== '*') || ($tokens[$start + 3]['content'] !== '*' && $tokens[$start + 6]['content'] !== '*')))
+ {
+ $message = 'The first file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($start + 1));
+ }
+
+ if ($tokens[$end - 3]['content'] !== '*' && $tokens[$end - 6]['content'] !== '*')
+ {
+ $message = 'The last file comment line should be empty.';
+ $phpcsFile->addWarning($message, $end - 1);
+ }
+
+ //$this->processPackage($phpcsFile, $start, $tags);
+ //$this->processVersion($phpcsFile, $start, $tags);
+ $this->processCopyright($phpcsFile, $start, $tokens[$start]['comment_tags']);
+ $this->processLicense($phpcsFile, $start, $tokens[$start]['comment_tags']);
+ }
+
+ /**
+ * Checks that the tags array contains a valid package tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['package']))
+ {
+ $message = 'Missing require @package tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
+ {
+ $message = 'Invalid content found for @package tag.';
+ $phpcsFile->addWarning($message, $tags['package'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid version tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['version']))
+ {
+ $message = 'Missing require @version tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
+ {
+ $message = 'Invalid content found for @version tag, use "$Id: $".';
+ $phpcsFile->addError($message, $tags['version'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid copyright tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $copyright = '(c) phpBB Limited <https://www.phpbb.com>';
+ $tokens = $phpcsFile->getTokens();
+
+ foreach ($tags as $tag)
+ {
+ if ($tokens[$tag]['content'] === '@copyright')
+ {
+ if ($tokens[$tag + 2]['content'] !== $copyright)
+ {
+ $message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
+ $phpcsFile->addError($message, $tags['copyright'][0][1]);
+ }
+
+ return;
+ }
+ }
+
+ $message = 'Missing require @copyright tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+
+ /**
+ * Checks that the tags array contains a valid license tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return null
+ */
+ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $license = 'GNU General Public License, version 2 (GPL-2.0)';
+ $tokens = $phpcsFile->getTokens();
+
+ $found = false;
+ foreach ($tags as $tag)
+ {
+ if ($tokens[$tag]['content'] === '@license')
+ {
+ if ($found)
+ {
+ $message = 'It must be only one @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+
+ $found = true;
+
+ if ($tokens[$tag + 2]['content'] !== $license)
+ {
+ $message = 'Invalid content found for @license tag, use "' . $license . '".';
+ $phpcsFile->addError($message, $tags['license'][0][1]);
+ }
+ }
+ }
+
+ if (!$found)
+ {
+ $message = 'Missing require @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ }
+}
diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
new file mode 100644
index 0000000000..885c38c5b4
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
@@ -0,0 +1,143 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+ * Checks that the opening brace of a control structures is on the line after.
+ * From Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff
+ */
+class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Registers the tokens that this sniff wants to listen for.
+ */
+ public function register()
+ {
+ return array(
+ T_IF,
+ T_ELSE,
+ T_FOREACH,
+ T_WHILE,
+ T_DO,
+ T_FOR,
+ T_SWITCH,
+ );
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in the
+ * stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ if (isset($tokens[$stackPtr]['scope_opener']) === false)
+ {
+ return;
+ }
+
+ /*
+ * ...
+ * }
+ * else if ()
+ * {
+ * ...
+ */
+ if ($tokens[$stackPtr]['code'] === T_ELSE && $tokens[$stackPtr + 2]['code'] === T_IF)
+ {
+ return;
+ }
+
+ $openingBrace = $tokens[$stackPtr]['scope_opener'];
+
+ /*
+ * ...
+ * do
+ * {
+ * <code>
+ * } while();
+ * ...
+ * }
+ * else
+ * {
+ * ...
+ */
+ if ($tokens[$stackPtr]['code'] === T_DO ||$tokens[$stackPtr]['code'] === T_ELSE)
+ {
+ $cs_line = $tokens[$stackPtr]['line'];
+ }
+ else
+ {
+ // The end of the function occurs at the end of the argument list. Its
+ // like this because some people like to break long function declarations
+ // over multiple lines.
+ $cs_line = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line'];
+ }
+
+ $braceLine = $tokens[$openingBrace]['line'];
+
+ $lineDifference = ($braceLine - $cs_line);
+
+ if ($lineDifference === 0)
+ {
+ $error = 'Opening brace should be on a new line';
+ $phpcsFile->addError($error, $openingBrace, 'BraceOnSameLine');
+ return;
+ }
+
+ if ($lineDifference > 1)
+ {
+ $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
+ $data = array(($lineDifference - 1));
+ $phpcsFile->addError($error, $openingBrace, 'BraceSpacing', $data);
+ return;
+ }
+
+ // We need to actually find the first piece of content on this line,
+ // as if this is a method with tokens before it (public, static etc)
+ // or an if with an else before it, then we need to start the scope
+ // checking from there, rather than the current token.
+ $lineStart = $stackPtr;
+ while (($lineStart = $phpcsFile->findPrevious(array(T_WHITESPACE), ($lineStart - 1), null, false)) !== false)
+ {
+ if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false)
+ {
+ break;
+ }
+ }
+
+ // We found a new line, now go forward and find the first non-whitespace
+ // token.
+ $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), $lineStart, null, true);
+
+ // The opening brace is on the correct line, now it needs to be
+ // checked to be correctly indented.
+ $startColumn = $tokens[$lineStart]['column'];
+ $braceIndent = $tokens[$openingBrace]['column'];
+
+ if ($braceIndent !== $startColumn)
+ {
+ $error = 'Opening brace indented incorrectly; expected %s spaces, found %s';
+ $data = array(
+ ($startColumn - 1),
+ ($braceIndent - 1),
+ );
+ $phpcsFile->addError($error, $openingBrace, 'BraceIndent', $data);
+ }
+ }
+}
diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
new file mode 100644
index 0000000000..349bccbb02
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+/**
+ * Checks that there is exactly one space between the keyword and the opening
+ * parenthesis of a control structures.
+ */
+class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Registers the tokens that this sniff wants to listen for.
+ */
+ public function register()
+ {
+ return array(
+ T_IF,
+ T_FOREACH,
+ T_WHILE,
+ T_FOR,
+ T_SWITCH,
+ T_ELSEIF,
+ T_CATCH,
+ );
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in the
+ * stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ if ($tokens[$stackPtr + 1]['content'] === '(')
+ {
+ $error = 'There should be exactly one space between the keyword and opening parenthesis';
+ $phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeOpeningParenthesis');
+ }
+ else if ($tokens[$stackPtr + 1]['content'] !== ' ')
+ {
+ $error = 'There should be exactly one space between the keyword and opening parenthesis';
+ $phpcsFile->addError($error, $stackPtr, 'IncorrectSpaceBeforeOpeningParenthesis');
+ }
+ }
+}
diff --git a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
new file mode 100644
index 0000000000..3125e4f05f
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
@@ -0,0 +1,248 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* Checks that each use statement is used.
+*/
+class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function register()
+ {
+ return array(T_USE);
+ }
+
+ protected function check($phpcsFile, $found_name, $full_name, $short_name, $line)
+ {
+
+ if ($found_name === $full_name)
+ {
+ $error = 'Either use statement or full name must be used.';
+ $phpcsFile->addError($error, $line, 'FullName');
+ }
+
+ if ($found_name === $short_name)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ if ($this->should_ignore_use($phpcsFile, $stackPtr) === true)
+ {
+ return;
+ }
+
+ $tokens = $phpcsFile->getTokens();
+
+ $class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($stackPtr + 1));
+
+ $find = array(
+ T_NS_SEPARATOR,
+ T_STRING,
+ T_WHITESPACE,
+ );
+
+ $class_name_end = $phpcsFile->findNext($find, ($stackPtr + 1), null, true);
+
+ $aliasing_as_position = $phpcsFile->findNext(T_AS, $class_name_end, null, false, null, true);
+ if ($aliasing_as_position !== false)
+ {
+ $alias_position = $phpcsFile->findNext(T_STRING, $aliasing_as_position, null, false, null, true);
+ $class_name_short = $tokens[$alias_position]['content'];
+ $class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start - 1));
+ }
+ else
+ {
+ $class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start));
+ $class_name_short = $tokens[$class_name_end - 1]['content'];
+ }
+
+ $ok = false;
+
+ // Checks in simple statements (new, instanceof and extends)
+ foreach (array(T_INSTANCEOF, T_NEW, T_EXTENDS) as $keyword)
+ {
+ $old_simple_statement = $stackPtr;
+ while (($simple_statement = $phpcsFile->findNext($keyword, ($old_simple_statement + 1))) !== false)
+ {
+ $old_simple_statement = $simple_statement;
+
+ $simple_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($simple_statement + 1));
+ $simple_class_name_end = $phpcsFile->findNext($find, ($simple_statement + 1), null, true);
+
+ $simple_class_name = trim($phpcsFile->getTokensAsString($simple_class_name_start, ($simple_class_name_end - $simple_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $simple_class_name, $class_name_full, $class_name_short, $simple_statement) ? true : $ok;
+ }
+ }
+
+ // Checks paamayim nekudotayim
+ $old_paamayim_nekudotayim = $stackPtr;
+ while (($paamayim_nekudotayim = $phpcsFile->findNext(T_PAAMAYIM_NEKUDOTAYIM, ($old_paamayim_nekudotayim + 1))) !== false)
+ {
+ $old_paamayim_nekudotayim = $paamayim_nekudotayim;
+
+ $paamayim_nekudotayim_class_name_start = $phpcsFile->findPrevious($find, $paamayim_nekudotayim - 1, null, true);
+ $paamayim_nekudotayim_class_name_end = $paamayim_nekudotayim - 1;
+
+ $paamayim_nekudotayim_class_name = trim($phpcsFile->getTokensAsString($paamayim_nekudotayim_class_name_start + 1, ($paamayim_nekudotayim_class_name_end - $paamayim_nekudotayim_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $paamayim_nekudotayim_class_name, $class_name_full, $class_name_short, $paamayim_nekudotayim) ? true : $ok;
+ }
+
+ // Checks in implements
+ $old_implements = $stackPtr;
+ while (($implements = $phpcsFile->findNext(T_IMPLEMENTS, ($old_implements + 1))) !== false)
+ {
+ $old_implements = $implements;
+
+ $old_implemented_class = $implements;
+ while (($implemented_class = $phpcsFile->findNext(T_STRING, ($old_implemented_class + 1), null, false, null, true)) !== false)
+ {
+ $old_implemented_class = $implemented_class;
+
+ $implements_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($implemented_class - 1));
+ $implements_class_name_end = $phpcsFile->findNext($find, ($implemented_class - 1), null, true);
+
+ $implements_class_name = trim($phpcsFile->getTokensAsString($implements_class_name_start, ($implements_class_name_end - $implements_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $implements_class_name, $class_name_full, $class_name_short, $implements) ? true : $ok;
+ }
+ }
+
+ $old_docblock = $stackPtr;
+ while (($docblock = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, ($old_docblock + 1))) !== false)
+ {
+ $old_docblock = $docblock;
+ $ok = $this->checkDocblock($phpcsFile, $docblock, $tokens, $class_name_full, $class_name_short) ? true : $ok;
+ }
+
+ // Checks in type hinting
+ $old_function_declaration = $stackPtr;
+ while (($function_declaration = $phpcsFile->findNext(T_FUNCTION, ($old_function_declaration + 1))) !== false)
+ {
+ $old_function_declaration = $function_declaration;
+
+ // Check type hint
+ $params = $phpcsFile->getMethodParameters($function_declaration);
+ foreach ($params as $param)
+ {
+ $ok = $this->check($phpcsFile, $param['type_hint'], $class_name_full, $class_name_short, $function_declaration) ? true : $ok;
+ }
+ }
+
+ // Checks in catch blocks
+ $old_catch = $stackPtr;
+ while (($catch = $phpcsFile->findNext(T_CATCH, ($old_catch + 1))) !== false)
+ {
+ $old_catch = $catch;
+
+ $caught_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), $catch + 1);
+ $caught_class_name_end = $phpcsFile->findNext($find, $caught_class_name_start + 1, null, true);
+
+ $caught_class_name = trim($phpcsFile->getTokensAsString($caught_class_name_start, ($caught_class_name_end - $caught_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $caught_class_name, $class_name_full, $class_name_short, $catch) ? true : $ok;
+ }
+
+ if (!$ok)
+ {
+ $error = 'There must not be unused USE statements.';
+ $phpcsFile->addError($error, $stackPtr, 'Unused');
+ }
+ }
+
+ /**
+ * Check if this use statement is part of the namespace block.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in
+ * the stack passed in $tokens.
+ *
+ * @return bool
+ */
+ private function should_ignore_use(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ // Ignore USE keywords inside closures.
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
+ if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS)
+ {
+ return true;
+ }
+
+ // Ignore USE keywords for traits.
+ if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true)
+ {
+ return true;
+ }
+
+ return false;
+
+ }
+
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile
+ * @param int $field
+ * @param array $tokens
+ * @param string $class_name_full
+ * @param string $class_name_short
+ * @param bool $ok
+ *
+ * @return bool
+ */
+ private function checkDocblock(PHP_CodeSniffer_File $phpcsFile, $comment_end, $tokens, $class_name_full, $class_name_short)
+ {
+ $ok = false;
+
+ $comment_start = $tokens[$comment_end]['comment_opener'];
+ foreach ($tokens[$comment_start]['comment_tags'] as $tag)
+ {
+ if (!in_array($tokens[$tag]['content'], array('@param', '@var', '@return', '@throws'), true))
+ {
+ continue;
+ }
+
+ $classes = $tokens[($tag + 2)]['content'];
+ $space = strpos($classes, ' ');
+ if ($space !== false)
+ {
+ $classes = substr($classes, 0, $space);
+ }
+
+ $tab = strpos($classes, "\t");
+ if ($tab !== false)
+ {
+ $classes = substr($classes, 0, $tab);
+ }
+
+ $classes = explode('|', str_replace('[]', '', $classes));
+ foreach ($classes as $class)
+ {
+ $ok = $this->check($phpcsFile, $class, $class_name_full, $class_name_short, $tokens[$tag + 2]['line']) ? true : $ok;
+ }
+ }
+
+ return $ok;
+ }
+}
diff --git a/build/code_sniffer/ruleset-minimum.xml b/build/code_sniffer/ruleset-minimum.xml
new file mode 100644
index 0000000000..13f122cae7
--- /dev/null
+++ b/build/code_sniffer/ruleset-minimum.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB Minimum Standard">
+
+ <description>phpBB minimum coding standard</description>
+
+ <!-- All code files MUST use only UTF-8 without BOM. -->
+ <rule ref="Generic.Files.ByteOrderMark" />
+
+ <!-- All code files MUST use the Unix LF (linefeed) line ending. -->
+ <rule ref="Generic.Files.LineEndings" />
+
+ <!-- Tabs MUST be used for indentation -->
+ <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
+
+ <!-- ALL braces MUST be on their own lines. -->
+ <rule ref="./phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-extensions.xml b/build/code_sniffer/ruleset-php-extensions.xml
new file mode 100644
index 0000000000..2d388103c3
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-extensions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard Extensions">
+
+ <description>phpBB coding standard for PHP files of phpBB extensions</description>
+
+ <rule ref="./ruleset-php-strict.xml" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-legacy-core.xml b/build/code_sniffer/ruleset-php-legacy-core.xml
new file mode 100644
index 0000000000..55f2461a04
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-legacy-core.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Legacy Standard Core">
+
+ <description>phpBB legacy coding standard for PHP files of phpBB core</description>
+
+ <rule ref="./ruleset-php-legacy.xml" />
+
+ <!-- Each file MUST start with a valid header as defined by the Coding Guidelines -->
+ <rule ref="./phpbb/Sniffs/Commenting/FileCommentSniff.php" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-legacy.xml b/build/code_sniffer/ruleset-php-legacy.xml
new file mode 100644
index 0000000000..c740c6080f
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-legacy.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Legacy Standard">
+
+ <description>phpBB legacy coding standard for PHP files</description>
+
+ <rule ref="./ruleset-minimum.xml" />
+
+ <!-- "for (; bar; )" should be "while (bar)" instead -->
+ <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
+
+ <!-- A method MUST not only call its parent -->
+ <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
+
+ <!-- The body of each structure MUST be enclosed by braces. -->
+ <rule ref="Generic.ControlStructures.InlineControlStructure" />
+
+ <!-- There MUST not be more than one statement per line. -->
+ <rule ref="Generic.Formatting.DisallowMultipleStatements" />
+
+ <!-- Call-time pass-by-reference MUST not be used. -->
+ <rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" />
+
+ <!-- Filenames MUST be lowercase. -->
+ <rule ref="Generic.Files.LowercasedFilename" />
+
+ <!-- The function brace MUST be on the line following the function declaration
+ and MUST be indented to the same column as the start of the function declaration. -->
+ <rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman" />
+
+ <!-- There MUST be exactly one space after a cast. -->
+ <rule ref="Generic.Formatting.SpaceAfterCast" />
+
+ <!-- Class constants MUST be declared in all upper case with underscore separators. -->
+ <rule ref="Generic.NamingConventions.UpperCaseConstantName" />
+
+ <!-- Only <?php, no short tags. -->
+ <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound" />
+
+ <!-- Method arguments with default values MUST go at the end of the argument list. -->
+ <rule ref="PEAR.Functions.ValidDefaultValue" />
+
+ <!-- Each file MUST end with exactly one newline character -->
+ <rule ref="PSR2.Files.EndFileNewline" />
+
+ <!-- When referencing arrays there MUST NOT be any whitespace around the opening bracket
+ or before the closing bracket. -->
+ <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
+
+ <!-- The "else if" statement MUST be written with a space between the words else and if. -->
+ <rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
+
+ <!-- There MUST be a space between each element of a foreach loop. -->
+ <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
+
+ <!-- In a for loop declaration, there MUST be no space inside the brackets
+ and there MUST be 0 spaces before and 1 space after semicolons. -->
+ <rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
+
+ <!-- In the argument list, there MUST NOT be a space before each comma,
+ and there MUST be one space after each comma. -->
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
+ <properties>
+ <property name="equalsSpacing" value="1"/>
+ </properties>
+ </rule>
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
+
+ <!-- All built-in PHP functions MUST be called lowercased. -->
+ <rule ref="Squiz.Functions.LowercaseFunctionKeywords" />
+
+ <!-- The eval() function MUST NOT be used. -->
+ <rule ref="Squiz.PHP.Eval" />
+
+ <!-- There MUST NOT be trailing whitespace at the end of lines. -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
+
+ <!-- There MUST NOT be whitespace before the first content of a file -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
+
+ <!-- There MUST NOT be whitespace after the last content of a file -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
+
+ <!-- Functions MUST NOT contain multiple empty lines in a row -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
+
+ <!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
+ <rule ref="Zend.Files.ClosingTag" />
+
+ <!-- There MUST be one space between control structure and opening parenthesis -->
+ <rule ref="./phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-strict-core.xml b/build/code_sniffer/ruleset-php-strict-core.xml
new file mode 100644
index 0000000000..5ca4d0cf1e
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-strict-core.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard Core">
+
+ <description>phpBB coding standard for PHP files of phpBB core</description>
+
+ <rule ref="./ruleset-php-legacy-core.xml" />
+ <rule ref="./ruleset-php-strict.xml" />
+
+</ruleset>
diff --git a/build/code_sniffer/ruleset-php-strict.xml b/build/code_sniffer/ruleset-php-strict.xml
new file mode 100644
index 0000000000..9e2f0664d8
--- /dev/null
+++ b/build/code_sniffer/ruleset-php-strict.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<ruleset name="phpBB PHP Strict Standard">
+
+ <description>phpBB coding standard for PHP files</description>
+
+ <rule ref="./ruleset-php-legacy.xml" />
+
+ <!-- There SHOULD NOT be more than 80 characters per line
+ There MUST NOT be more than 120 characters per line -->
+ <!--
+ <rule ref="Generic.Files.LineLength">
+ <properties>
+ <property name="lineLimit" value="80"/>
+ <property name="absoluteLineLimit" value="120"/>
+ </properties>
+ </rule>
+ -->
+
+ <!-- The PHP constants true, false, and null MUST be in lower case. -->
+ <rule ref="Generic.PHP.LowerCaseConstant" />
+
+ <!-- PHP keywords MUST be in lower case. -->
+ <rule ref="Generic.PHP.LowerCaseKeyword" />
+
+ <!-- Constructors MUST be called __construct() instead of after the class. -->
+ <rule ref="Generic.NamingConventions.ConstructorName" />
+
+ <!-- Classes etc. MUST be namespaced -->
+ <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
+
+ <!-- A file MUST not contain more than one class/interface -->
+ <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" />
+
+ <!-- Files containing classes MUST not have any side-effects -->
+ <rule ref="PSR1.Files.SideEffects.FoundWithSymbols" />
+
+ <!-- When present, all use declarations MUST go after the namespace declaration.
+ There MUST be one use keyword per declaration.
+ There MUST be one blank line after the use block. -->
+ <rule ref="PSR2.Namespaces.UseDeclaration" />
+
+ <!-- There MUST be one blank line after the namespace declaration -->
+ <rule ref="PSR2.Namespaces.NamespaceDeclaration" />
+
+ <!-- There MUST NOT be unused use statements. -->
+ <rule ref="./phpbb/Sniffs/Namespaces/UnusedUseSniff.php" />
+
+</ruleset>
diff --git a/build/package.php b/build/package.php
index 22ea4e52af..d168957ca5 100755
--- a/build/package.php
+++ b/build/package.php
@@ -2,9 +2,13 @@
<?php
/**
*
-* @package build
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -45,6 +49,10 @@ if (sizeof($package->old_packages))
$package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch',
$_package_name
);
+ $diff_file_changes[$_package_name]['deleted'] = $package->collect_deleted_files(
+ $package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.deleted',
+ $_package_name
+ );
}
// Now put those files determined within the correct directories
@@ -121,6 +129,7 @@ if (sizeof($package->old_packages))
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $dest_filename_dir);
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $dest_filename_dir);
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $dest_filename_dir);
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update');
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update/old');
@@ -138,6 +147,12 @@ if (sizeof($package->old_packages))
{
unset($file_contents['all'][$index]);
}
+
+ $source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
+ if (!file_exists($source_filename))
+ {
+ unset($file_contents['all'][$index]);
+ }
}
// First of all, fill the 'old' directory
@@ -173,16 +188,27 @@ if (sizeof($package->old_packages))
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
}
+ /**
+ * We try to keep the update packages as small as possible while creating them.
+ * However, we sometimes need to include additional files that are not included
+ * in the diff in order to be able to correctly include the relatively
+ * referenced files from the same or subsequent directories.
+ */
+ $copy_relative_directories = array(
+ 'config/' => array(
+ 'copied' => false,
+ 'copy' => array(
+ 'config/*.yml' => 'config',
+ ),
+ ),
+ );
+
// Then fill the 'new' directory
foreach ($file_contents['all'] as $file)
{
$source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
$dest_filename = $dest_filename_dir . '/install/update/new/' . $file;
-
- if (!file_exists($source_filename))
- {
- continue;
- }
+ $filename = $file;
// Create Directories along the way?
$file = explode('/', $file);
@@ -204,6 +230,73 @@ if (sizeof($package->old_packages))
}
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
+
+ foreach ($copy_relative_directories as $reference => $data)
+ {
+ // Copy all relative referenced files if needed
+ if (strpos($filename, $reference) === 0 && !$data['copied'])
+ {
+ foreach ($data['copy'] as $source_dir_files => $destination_dir)
+ {
+ // Create directories along the way?
+ $directories = explode('/', $destination_dir);
+
+ chdir($dest_filename_dir . '/install/update/new');
+ foreach ($directories as $dir)
+ {
+ $dir = trim($dir);
+ if ($dir)
+ {
+ if (!file_exists('./' . $dir))
+ {
+ $package->run_command('mkdir ' . $dir);
+ }
+ chdir('./' . $dir);
+ }
+ }
+ $source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_dir_files;
+ $destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
+ $package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
+ }
+ $copy_relative_directories[$reference]['copied'] = true;
+ }
+ }
+ }
+
+ /**
+ * We need to always copy the template and asset files that we need in
+ * the update, to ensure that the page is displayed correctly.
+ */
+ $copy_update_files = array(
+ 'adm/images/*' => 'adm/images',
+ 'adm/style/admin.css' => 'adm/style',
+ 'adm/style/admin.js' => 'adm/style',
+ 'adm/style/ajax.js' => 'adm/style',
+ 'adm/style/install_*' => 'adm/style',
+ 'assets/javascript/*' => 'assets/javascript',
+ );
+
+ foreach ($copy_update_files as $source_files => $destination_dir)
+ {
+ // Create directories along the way?
+ $directories = explode('/', $destination_dir);
+
+ chdir($dest_filename_dir . '/install/update/new');
+ foreach ($directories as $dir)
+ {
+ $dir = trim($dir);
+ if ($dir)
+ {
+ if (!file_exists('./' . $dir))
+ {
+ $package->run_command('mkdir ' . $dir);
+ }
+ chdir('./' . $dir);
+ }
+ }
+ $source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_files;
+ $destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
+ $package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
}
// Build index.php file for holding the file structure
@@ -221,29 +314,32 @@ $update_info = array(
if (sizeof($file_contents['all']))
{
- $index_contents .= '\'files\' => array(\'' . implode("',\n\t'", $file_contents['all']) . '\'),
-';
+ $index_contents .= "\t'files' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['all']) . "',\n\t),\n";
}
else
{
- $index_contents .= '\'files\' => array(),
-';
+ $index_contents .= "\t'files' => array(),\n";
}
if (sizeof($file_contents['binary']))
{
- $index_contents .= '\'binary\' => array(\'' . implode("',\n\t'", $file_contents['binary']) . '\'),
-';
+ $index_contents .= "\t'binary' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['binary']) . "',\n\t),\n";
}
else
{
- $index_contents .= '\'binary\' => array(),
-';
+ $index_contents .= "\t'binary' => array(),\n";
}
- $index_contents .= ');
+ if (sizeof($file_contents['deleted']))
+ {
+ $index_contents .= "\t'deleted' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['deleted']) . "',\n\t),\n";
+ }
+ else
+ {
+ $index_contents .= "\t'deleted' => array(),\n";
+ }
-?' . '>';
+ $index_contents .= ");\n";
$fp = fopen($dest_filename_dir . '/install/update/index.php', 'wt');
fwrite($fp, $index_contents);
@@ -256,6 +352,7 @@ $update_info = array(
// Copy the install files to their respective locations
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('patch_directory'));
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('patch_directory'));
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('patch_directory'));
// Remove some files
chdir($package->get('patch_directory') . '/install');
@@ -297,6 +394,7 @@ if (sizeof($package->old_packages))
$package->run_command('mkdir ' . $package->get('files_directory') . '/release');
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('files_directory') . '/release');
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('files_directory') . '/release');
+ $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('files_directory') . '/release');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_install.php');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_update.php');
@@ -372,14 +470,22 @@ chdir($package->get('dest_dir') . '/install');
// $package->run_command('rm -v database_update.php');
$package->run_command('rm -v install_update.php');
+chdir($package->get('dest_dir'));
+$package->run_command('mv -v styles/subsilver2 ../subsilver2');
+$package->run_command('cp -p docs/COPYING ../subsilver2/license.txt');
+
chdir($package->locations['package_dir']);
foreach ($compress_programs as $extension => $compress_command)
{
$package->begin_status('Packaging phpBB for ' . $extension);
$package->run_command('rm -v ./release_files/' . $package->get('release_filename') . ".{$extension}");
+ $package->run_command('rm -v ./release_files/subsilver2_' . $package->get('new_version_number') . ".{$extension}");
// Build Package
$package->run_command("$compress_command ./release_files/" . $package->get('release_filename') . '.' . $extension . ' ' . $package->get('package_name'));
+
+ // Build subSilver2 Package
+ $package->run_command("$compress_command ./release_files/subsilver2_" . $package->get('new_version_number') . '.' . $extension . ' subsilver2');
}
// Microsoft Web PI packaging
diff --git a/build/sami-all.conf.php b/build/sami-all.conf.php
index fb1a269206..4bf812eb02 100644
--- a/build/sami-all.conf.php
+++ b/build/sami-all.conf.php
@@ -25,6 +25,8 @@ $config['versions'] = Sami\Version\GitVersionCollection::create(__DIR__ . '/../'
*/
->add('3.0.x')
->add('3.1.x')
+ ->add('3.2.x')
+ ->add('master')
;
return new Sami\Sami($iterator, $config);