From 7cead7b168daf59cf86c6e5ee73485fdf4f79488 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 2 Jan 2025 01:13:21 +0100 Subject: [PATCH 1/3] Add fix-codestyle.sh --- .woodpecker/.code_standards_check.yml | 1 + bin/dev/fix-codestyle.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 bin/dev/fix-codestyle.sh diff --git a/.woodpecker/.code_standards_check.yml b/.woodpecker/.code_standards_check.yml index e6b02c3d7d..1217ea3f0b 100644 --- a/.woodpecker/.code_standards_check.yml +++ b/.woodpecker/.code_standards_check.yml @@ -39,6 +39,7 @@ steps: check: image: php:8.3 commands: + - echo "**** Use bin/dev/fix-codestyle.sh in case of errors ****" - apt-get update -q - DEBIAN_FRONTEND=noninteractive apt-get install -q -y git - if [ ! -z "$${CI_COMMIT_PULL_REQUEST}" ]; then diff --git a/bin/dev/fix-codestyle.sh b/bin/dev/fix-codestyle.sh new file mode 100755 index 0000000000..3a66b2ec8c --- /dev/null +++ b/bin/dev/fix-codestyle.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2010-2025 the Friendica project +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# this script checks or fixes php-files, based on the php-cs rules +# +# You can use the following variables: +# COMMAND ... the php-cs command to execute (default is "check --diff") +# TARGET_BRANCH ... set the target branch for the current branch to create a diff between them +# +## + +COMMAND=${COMMAND:-"check --diff"} + +if [ -n "${TARGET_BRANCH}" ]; then + CHANGED_FILES="$(git diff --name-only --diff-filter=ACMRTUXB "$(git ls-remote -q | grep refs/heads/"${TARGET_BRANCH}"$ | awk '{print $1}' | xargs git rev-parse )".."$(git rev-parse HEAD)")"; +else + CHANGED_FILES="$(git diff --name-only --diff-filter=ACMRTUXB "$(git rev-parse HEAD)")"; +fi + +EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); + +./bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer ${COMMAND} --config=.php-cs-fixer.dist.php -v --using-cache=no ${EXTRA_ARGS} From 0ff7a1c72b32d0593f11a29bcdbac75f20d258fe Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 2 Jan 2025 01:39:10 +0100 Subject: [PATCH 2/3] temporary add App.php --- src/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.php b/src/App.php index 9cacfaf6cf..4e35ef5e70 100644 --- a/src/App.php +++ b/src/App.php @@ -64,7 +64,7 @@ class App { const PLATFORM = 'Friendica'; const CODENAME = 'Interrupted Fern'; - const VERSION = '2025.02-dev'; + const VERSION = '2025.02-dev'; public static function fromDice(Dice $dice): self { From ad549cc5d6be8c496a901ea7148456c6f91bb96a Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 2 Jan 2025 02:03:58 +0100 Subject: [PATCH 3/3] Execute `COMMAND=fix TARGET_BRANCH=develop bin/dev/fix-codestyle.sh` --- src/App.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App.php b/src/App.php index 4e35ef5e70..a233e079f1 100644 --- a/src/App.php +++ b/src/App.php @@ -64,7 +64,7 @@ class App { const PLATFORM = 'Friendica'; const CODENAME = 'Interrupted Fern'; - const VERSION = '2025.02-dev'; + const VERSION = '2025.02-dev'; public static function fromDice(Dice $dice): self { @@ -537,7 +537,7 @@ class App $requeststring = ($serverVars['REQUEST_METHOD'] ?? '') . ' ' . ($serverVars['REQUEST_URI'] ?? '') . ' ' . ($serverVars['SERVER_PROTOCOL'] ?? ''); $this->logger->debug('Request received', ['address' => $serverVars['REMOTE_ADDR'] ?? '', 'request' => $requeststring, 'referer' => $serverVars['HTTP_REFERER'] ?? '', 'user-agent' => $serverVars['HTTP_USER_AGENT'] ?? '']); $request_start = microtime(true); - $request = $_REQUEST; + $request = $_REQUEST; $this->profiler->set($start_time, 'start'); $this->profiler->set(microtime(true), 'classinit'); @@ -701,7 +701,7 @@ class App $router = $this->container->create(Router::class); $moduleClass = $moduleClass ?? $router->getModuleClass(); - $parameters = $router->getParameters(); + $parameters = $router->getParameters(); $dice_profiler_threshold = $this->config->get('system', 'dice_profiler_threshold', 0);