Skip to content

Commit 2df9b05

Browse files
committed
[skip-ci] format PHP code same as in owncloud/core
1 parent 5844f30 commit 2df9b05

File tree

12 files changed

+945
-726
lines changed

12 files changed

+945
-726
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ vendor
2929
vendor-bin/**/vendor
3030
vendor-bin/**/composer.lock
3131

32+
# API acceptance tests - auto-generated files
33+
.php-cs-fixer.cache
34+
3235
# drone CI is in .drone.star, do not let someone accidentally commit a local .drone.yml
3336
.drone.yml
3437

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$dirToParse = 'tests/acceptance/';
4+
$dirIterator = new DirectoryIterator(__DIR__ . '/' . $dirToParse);
5+
6+
$excludeDirs = [
7+
'node_modules'
8+
];
9+
10+
$finder = PhpCsFixer\Finder::create()
11+
->exclude($excludeDirs)
12+
->in(__DIR__);
13+
14+
$config = new OC\CodingStandard\Config();
15+
$config->setFinder($finder);
16+
return $config;

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ OCIS_MODULES = \
3232
web \
3333
webdav
3434

35+
# bin file definitions
36+
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
37+
PHP_CODESNIFFER=vendor-bin/php_codesniffer/vendor/bin/phpcs
38+
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
39+
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan
40+
3541
ifneq (, $(shell which go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI
3642
include .bingo/Variables.mk
3743
endif
@@ -64,6 +70,10 @@ help:
6470
@echo -e "\tsee ./tests/acceptance/docker/Makefile"
6571
@echo -e "\tor run ${YELLOW}make -C tests/acceptance/docker help${RESET}"
6672
@echo
73+
@echo -e "${GREEN}Tools for developing tests:\n${RESET}"
74+
@echo -e "\tmake test-php-style\t\t${BLUE}run PHP code style checks${RESET}"
75+
@echo -e "\tmake test-php-style-fix\t\t${BLUE}run PHP code style checks and fix any issues found${RESET}"
76+
@echo
6777

6878
.PHONY: clean-tests
6979
clean-tests:
@@ -194,3 +204,25 @@ l10n-write:
194204
.PHONY: ci-format
195205
ci-format: $(BUILDIFIER)
196206
$(BUILDIFIER) --mode=fix .drone.star
207+
208+
.PHONY: test-php-style
209+
test-php-style: vendor-bin/owncloud-codestyle/vendor vendor-bin/php_codesniffer/vendor
210+
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes --dry-run
211+
$(PHP_CODESNIFFER) --cache --runtime-set ignore_warnings_on_exit --standard=phpcs.xml tests/acceptance
212+
213+
.PHONY: test-php-style-fix
214+
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor
215+
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes
216+
217+
218+
vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock
219+
composer bin owncloud-codestyle install --no-progress
220+
221+
vendor-bin/owncloud-codestyle/composer.lock: vendor-bin/owncloud-codestyle/composer.json
222+
@echo owncloud-codestyle composer.lock is not up to date.
223+
224+
vendor-bin/php_codesniffer/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/php_codesniffer/composer.lock
225+
composer bin php_codesniffer install --no-progress
226+
227+
vendor-bin/php_codesniffer/composer.lock: vendor-bin/php_codesniffer/composer.json
228+
@echo php_codesniffer composer.lock is not up to date.

deployments/examples/oc10_ocis_parallel/config/oc10/oidc.config.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
# reference: https://doc.owncloud.com/server/admin_manual/configuration/user/oidc/
44

5-
function getOIDCConfigFromEnv()
6-
{
7-
$config = [
8-
'openid-connect' => [
9-
'provider-url' => getenv('IDP_OIDC_ISSUER'),
10-
'client-id' => 'oc10',
11-
'client-secret' => getenv('IDP_OIDC_CLIENT_SECRET'),
12-
'loginButtonName' => 'OpenId Connect',
13-
'search-attribute' => 'preferred_username',
14-
'mode' => 'userid',
15-
'autoRedirectOnLoginPage' => true,
16-
'insecure' => true,
17-
'post_logout_redirect_uri' => 'https://' . getenv('CLOUD_DOMAIN'),
18-
],
19-
];
20-
return $config;
5+
function getOIDCConfigFromEnv() {
6+
$config = [
7+
'openid-connect' => [
8+
'provider-url' => getenv('IDP_OIDC_ISSUER'),
9+
'client-id' => 'oc10',
10+
'client-secret' => getenv('IDP_OIDC_CLIENT_SECRET'),
11+
'loginButtonName' => 'OpenId Connect',
12+
'search-attribute' => 'preferred_username',
13+
'mode' => 'userid',
14+
'autoRedirectOnLoginPage' => true,
15+
'insecure' => true,
16+
'post_logout_redirect_uri' => 'https://' . getenv('CLOUD_DOMAIN'),
17+
],
18+
];
19+
return $config;
2120
}
2221

2322
$CONFIG = getOIDCConfigFromEnv();

deployments/examples/oc10_ocis_parallel/config/oc10/web.config.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
# reference: https://owncloud.dev/clients/web/deployments/oc10-app/
44

5-
function getWebConfigFromEnv()
6-
{
7-
$config = [
8-
'web.baseUrl' => 'https://' . getenv('CLOUD_DOMAIN') . '/index.php/apps/web',
9-
'web.rewriteLinks' => getenv('OWNCLOUD_WEB_REWRITE_LINKS') == 'true',
10-
11-
];
12-
return $config;
5+
function getWebConfigFromEnv() {
6+
$config = [
7+
'web.baseUrl' => 'https://' . getenv('CLOUD_DOMAIN') . '/index.php/apps/web',
8+
'web.rewriteLinks' => getenv('OWNCLOUD_WEB_REWRITE_LINKS') == 'true',
9+
10+
];
11+
return $config;
1312
}
1413

1514
$CONFIG = getWebConfigFromEnv();

phpcs.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="ownCloud Standard">
3+
<description>ownCloud coding standard</description>
4+
<arg name="colors" />
5+
<arg value="sp" />
6+
7+
<exclude-pattern>*/vendor/*</exclude-pattern>
8+
<exclude-pattern>*/3rdparty/*</exclude-pattern>
9+
10+
<!-- make sure we use tabs for indent and not spaces -->
11+
<arg name="tab-width" value="4" />
12+
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
13+
<rule ref="Generic.WhiteSpace.ScopeIndent">
14+
<properties>
15+
<property name="indent" value="4" />
16+
<property name="tabIndent" value="true" />
17+
</properties>
18+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed" />
19+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
20+
</rule>
21+
22+
<rule ref="Generic.Files.LineLength">
23+
<exclude name="Generic.Files.LineLength.TooLong" />
24+
</rule>
25+
26+
<rule ref="PEAR">
27+
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
28+
<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
29+
<exclude name="Generic.Commenting.DocComment.MissingShort" />
30+
<exclude name="Generic.Commenting.DocComment.TagValueIndent" />
31+
<exclude name="Generic.Commenting.DocComment.ParamNotFirst" />
32+
<exclude name="PEAR.Commenting.FileComment.IncompleteCopyright" />
33+
<exclude name="PEAR.Commenting.FileComment.IncompleteLicense" />
34+
<exclude name="PEAR.Commenting.FileComment.MissingVersion" />
35+
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag" />
36+
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag" />
37+
<exclude name="PEAR.Commenting.FileComment.MissingLicenseTag" />
38+
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag" />
39+
<exclude name="PEAR.Commenting.ClassComment.MissingCategoryTag" />
40+
<exclude name="PEAR.Commenting.ClassComment.MissingPackageTag" />
41+
<exclude name="PEAR.Commenting.ClassComment.MissingAuthorTag" />
42+
<exclude name="PEAR.Commenting.ClassComment.MissingLicenseTag" />
43+
<exclude name="PEAR.Commenting.ClassComment.MissingLinkTag" />
44+
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment" />
45+
<exclude name="PEAR.Commenting.FunctionComment.SpacingAfterParamType" />
46+
<exclude name="PEAR.Commenting.FunctionComment.SpacingAfterParamName" />
47+
<exclude
48+
name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
49+
<exclude
50+
name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore" />
51+
<exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact" />
52+
<exclude name="PEAR.Functions.FunctionDeclaration.BraceOnSameLine" />
53+
<exclude name="PEAR.Classes.ClassDeclaration.OpenBraceNewLine" />
54+
</rule>
55+
<rule ref="Zend.Files.ClosingTag"/>
56+
<rule ref="Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore" />
57+
<rule ref="Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter" />
58+
<rule ref="Squiz.Commenting.DocCommentAlignment" />
59+
<rule ref="Generic.WhiteSpace.ScopeIndent" />
60+
<rule ref="Squiz.Strings.ConcatenationSpacing">
61+
<properties>
62+
<property name="spacing" value="1" />
63+
<property name="ignoreNewlines" value="true" />
64+
</properties>
65+
</rule>
66+
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
67+
<exclude
68+
name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonDEFAULT" />
69+
<exclude
70+
name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE" />
71+
</rule>
72+
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
73+
<rule ref="Generic.Classes.OpeningBraceSameLine" />
74+
75+
<!-- storage wrapper uses php function names to wrap them -->
76+
<rule ref="PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
77+
<exclude-pattern>*/lib/storagewrapper.php</exclude-pattern>
78+
</rule>
79+
80+
</ruleset>
Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
/**
3+
* ownCloud
4+
*
5+
* @author Phil Davis <[email protected]>
6+
* @copyright Copyright (c) 2020 Phil Davis [email protected]
7+
*
8+
* This code is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License,
10+
* as published by the Free Software Foundation;
11+
* either version 3 of the License, or any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>
20+
*
21+
*/
222

323
use Behat\Behat\Context\Context;
424
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
@@ -11,30 +31,29 @@
1131
* Context for Reva specific steps
1232
*/
1333
class RevaContext implements Context {
34+
/**
35+
* @var FeatureContext
36+
*/
37+
private $featureContext;
1438

15-
/**
16-
* @var FeatureContext
17-
*/
18-
private $featureContext;
19-
20-
/**
21-
* @BeforeScenario
22-
*
23-
* @param BeforeScenarioScope $scope
24-
*
25-
* @return void
26-
* @throws Exception
27-
*/
28-
public function setUpScenario(BeforeScenarioScope $scope): void {
29-
// Get the environment
30-
$environment = $scope->getEnvironment();
31-
// Get all the contexts you need in this context
32-
$this->featureContext = $environment->getContext('FeatureContext');
33-
SetupHelper::init(
34-
$this->featureContext->getAdminUsername(),
35-
$this->featureContext->getAdminPassword(),
36-
$this->featureContext->getBaseUrl(),
37-
$this->featureContext->getOcPath()
38-
);
39-
}
39+
/**
40+
* @BeforeScenario
41+
*
42+
* @param BeforeScenarioScope $scope
43+
*
44+
* @return void
45+
* @throws Exception
46+
*/
47+
public function setUpScenario(BeforeScenarioScope $scope): void {
48+
// Get the environment
49+
$environment = $scope->getEnvironment();
50+
// Get all the contexts you need in this context
51+
$this->featureContext = $environment->getContext('FeatureContext');
52+
SetupHelper::init(
53+
$this->featureContext->getAdminUsername(),
54+
$this->featureContext->getAdminPassword(),
55+
$this->featureContext->getBaseUrl(),
56+
$this->featureContext->getOcPath()
57+
);
58+
}
4059
}

0 commit comments

Comments
 (0)