Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit f9e2034

Browse files
committed
Updated phpcs.yml to PSR-12
* Updated phpcs.yml t code standard PSR-12 and fixed all style bugs
1 parent 41ccf6e commit f9e2034

File tree

9 files changed

+44
-206
lines changed

9 files changed

+44
-206
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
## [Unreleased]
55
#### Changed
66
- Slightly modified text displayed on WAYF
7+
- Updated phpcs ruleset to PSR-12
78

89
#### Fixed
910
- Fixed wrong dictionary name in post.php

config-templates/module_perun.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
* OPTIONAL
100100
* Default: show all received services
101101
*/
102-
'status.shown_services'=> [
102+
'status.shown_services' => [
103103
'serviceIdentifier' => [
104104
'name' => 'serviceName',
105105
'description' => 'serviceDescription'

lib/Auth/Process/PerunAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function process(&$request)
7676
$attributes = [];
7777
if ($this->mode === self::MODE_FULL) {
7878
$attributes = array_keys($this->attrMap);
79-
} else if ($this->mode === self::MODE_PARTIAL) {
79+
} elseif ($this->mode === self::MODE_PARTIAL) {
8080
// Check if attribute has some value
8181
foreach ($this->attrMap as $attrName => $attrValue) {
8282
if (isset($request['Attributes'][$attrValue])) {

lib/Disco.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function __construct(array $metadataSets, $instance)
6666
if (isset($state) && isset($state['SPMetadata'])) {
6767
$this->originalsp = $state['SPMetadata'];
6868
}
69-
7069
}
7170

7271
/**

phpcs.xml

Lines changed: 26 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,207 +1,46 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PSR2" xsi:noNamespaceSchemaLocation="../../../phpcs.xsd">
3-
<description>The PSR-2 coding standard.</description>
4-
<arg name="tab-width" value="4"/>
5-
6-
<!-- 2. General -->
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PSR12" xsi:noNamespaceSchemaLocation="../../../phpcs.xsd">
3+
<description>The PSR-12 coding standard.</description>
74

8-
<!-- 2.1 Basic Coding Standard -->
5+
<file>config-templates</file>
6+
<file>dictionaries</file>
7+
<file>lib</file>
8+
<file>templates</file>
9+
<file>tests</file>
10+
<file>themes</file>
11+
<file>www</file>
912

10-
<!-- Include the whole PSR-1 standard -->
11-
<rule ref="PSR1"/>
13+
<arg name="extensions" value="php"/>
1214

13-
<!-- 2.2 Files -->
14-
15-
<!-- All PHP files MUST use the Unix LF (linefeed) line ending. -->
16-
<rule ref="Generic.Files.LineEndings">
17-
<properties>
18-
<property name="eolChar" value="\n"/>
19-
</properties>
20-
</rule>
15+
<arg name="tab-width" value="4"/>
2116

22-
<!-- All PHP files MUST end with a single blank line. -->
23-
<!-- checked by PSR2.Files.EndFileNewline -->
17+
<config name="ignore_warnings_on_exit" value="1"/>
2418

25-
<!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
26-
<!-- checked by PSR2.Files.ClosingTag -->
2719

28-
<!-- 2.3 Lines -->
20+
<!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
21+
<rule ref="PSR12"/>
2922

30-
<!-- The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit. -->
23+
<!-- Lines can be a little bit longer before they break the build -->
3124
<rule ref="Generic.Files.LineLength">
3225
<properties>
3326
<property name="lineLimit" value="120"/>
34-
<property name="absoluteLineLimit" value="0"/>
35-
</properties>
36-
</rule>
37-
38-
<!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
39-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
40-
<properties>
41-
<property name="ignoreBlankLines" value="true"/>
42-
</properties>
43-
</rule>
44-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
45-
<severity>0</severity>
46-
</rule>
47-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
48-
<severity>0</severity>
49-
</rule>
50-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
51-
<severity>0</severity>
52-
</rule>
53-
54-
<!-- There MUST NOT be more than one statement per line. -->
55-
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
56-
57-
<!-- 2.4 Indenting -->
58-
59-
<!-- Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. -->
60-
<rule ref="Generic.WhiteSpace.ScopeIndent">
61-
<properties>
62-
<property name="ignoreIndentationTokens" type="array">
63-
<element value="T_COMMENT"/>
64-
<element value="T_DOC_COMMENT_OPEN_TAG"/>
65-
</property>
66-
</properties>
67-
</rule>
68-
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
69-
70-
<!-- 2.5 Keywords and True/False/Null -->
71-
72-
<!-- PHP keywords MUST be in lower case. -->
73-
<rule ref="Generic.PHP.LowerCaseKeyword"/>
74-
75-
<!-- The PHP constants true, false, and null MUST be in lower case. -->
76-
<rule ref="Generic.PHP.LowerCaseConstant"/>
77-
78-
<!-- 3. Namespace and Use Declarations -->
79-
80-
<!-- When present, there MUST be one blank line after the namespace declaration. -->
81-
<!-- checked by PSR2.Namespaces.NamespaceDeclaration -->
82-
83-
<!-- When present, all use declarations MUST go after the namespace declaration.
84-
There MUST be one use keyword per declaration.
85-
There MUST be one blank line after the use block. -->
86-
<!-- checked by PSR2.Namespaces.UseDeclaration -->
87-
88-
<!-- 4. Classes, Properties, and Methods -->
89-
90-
<!-- 4.1. Extends and Implements -->
91-
92-
<!-- The extends and implements keywords MUST be declared on the same line as the class name.
93-
The opening brace for the class go MUST go on its own line; the closing brace for the class MUST go on the next line after the body.
94-
Lists of implements MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line. -->
95-
<!-- checked by PSR2.Classes.ClassDeclaration -->
96-
97-
<!-- 4.2. Properties -->
98-
99-
<!-- Visibility MUST be declared on all properties.
100-
The var keyword MUST NOT be used to declare a property.
101-
There MUST NOT be more than one property declared per statement.
102-
Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. -->
103-
<!-- checked by PSR2.Classes.PropertyDeclaration -->
104-
105-
<!-- 4.3 Methods -->
106-
107-
<!-- Visibility MUST be declared on all methods. -->
108-
<rule ref="Squiz.Scope.MethodScope"/>
109-
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
110-
111-
<!-- Method names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. -->
112-
<!-- checked by PSR2.Methods.MethodDeclaration -->
113-
114-
<!-- Method names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. -->
115-
<!-- checked by PSR2.Methods.FunctionClosingBrace -->
116-
<rule ref="Squiz.Functions.FunctionDeclaration"/>
117-
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
118-
119-
<!-- 4.4 Method Arguments -->
120-
121-
<!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
122-
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
123-
<properties>
124-
<property name="equalsSpacing" value="1"/>
27+
<property name="absoluteLineLimit" value="130"/>
12528
</properties>
126-
</rule>
127-
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
128-
<severity>0</severity>
129-
</rule>
13029

131-
<!-- Method arguments with default values MUST go at the end of the argument list. -->
132-
<rule ref="PEAR.Functions.ValidDefaultValue"/>
30+
<!-- Exclude files with long lines that we cannot immediately fix -->
13331

134-
<!-- Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
135-
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
136-
137-
<!-- 4.5 abstract, final, and static -->
138-
139-
<!-- When present, the abstract and final declarations MUST precede the visibility declaration.
140-
When present, the static declaration MUST come after the visibility declaration. -->
141-
<!-- checked by PSR2.Methods.MethodDeclaration -->
142-
143-
<!-- 4.6 Method and Function Calls -->
144-
145-
<!-- When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis, there MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.
146-
Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. -->
147-
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
148-
<rule ref="PSR2.Methods.FunctionCallSignature.SpaceAfterCloseBracket">
149-
<severity>0</severity>
15032
</rule>
151-
<rule ref="PSR2.Methods.FunctionCallSignature.OpeningIndent">
152-
<severity>0</severity>
153-
</rule>
154-
155-
<!-- 5. Control Structures -->
15633

157-
<!-- The general style rules for control structures are as follows:
158-
There MUST be one space after the control structure keyword
159-
There MUST NOT be a space after the opening parenthesis
160-
There MUST NOT be a space before the closing parenthesis
161-
There MUST be one space between the closing parenthesis and the opening brace
162-
The structure body MUST be indented once
163-
The closing brace MUST be on the next line after the body -->
164-
<rule ref="Squiz.ControlStructures.ControlSignature"/>
165-
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/>
166-
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/>
167-
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
168-
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
169-
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
170-
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
171-
<severity>0</severity>
172-
</rule>
173-
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
174-
<severity>0</severity>
34+
<!-- Ignore wrong casing until we can rename then in SSP 2.0 -->
35+
<rule ref="PSR1.Methods.CamelCapsMethodName">
36+
<exclude-pattern>lib/SimpleSAML/XHTML/Template.php</exclude-pattern>
17537
</rule>
176-
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
177-
<!-- checked by PSR2.ControlStructures.ControlStructureSpacing -->
17838

179-
<!-- exclude this message as it is already checked Generic.PHP.LowerCaseKeyword -->
180-
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
181-
<severity>0</severity>
39+
<!-- Ignore files with side effects that we cannot fix -->
40+
<rule ref="PSR1.Files.SideEffects">
41+
<exclude-pattern>bin/*</exclude-pattern>
42+
<exclude-pattern>lib/_autoload_modules.php</exclude-pattern>
43+
<exclude-pattern>tests/_autoload_modules.php</exclude-pattern>
44+
<exclude-pattern>www/_include.php</exclude-pattern>
18245
</rule>
183-
184-
<!-- The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. -->
185-
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
186-
187-
<!-- 5.1. if, elseif, else -->
188-
189-
<!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. -->
190-
<!-- checked by PSR2.ControlStructures.ElseIfDeclaration -->
191-
192-
<!-- 5.2. switch, case -->
193-
194-
<!-- The case statement MUST be indented once from switch, and the break keyword (or other terminating keyword) MUST be indented at the same level as the case body. There MUST be a comment such as // no break when fall-through is intentional in a non-empty case body. -->
195-
<!-- checked by PSR2.ControlStructures.SwitchDeclaration -->
196-
197-
<!-- 6. Closures -->
198-
199-
<!-- Closures MUST be declared with a space after the function keyword, and a space before and after the use keyword.
200-
The opening brace MUST go on the same line, and the closing brace MUST go on the next line following the body.
201-
There MUST NOT be a space after the opening parenthesis of the argument list or variable list, and there MUST NOT be a space before the closing parenthesis of the argument list or variable list.
202-
In the argument list and variable list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.
203-
Closure arguments with default values MUST go at the end of the argument list.
204-
Argument lists and variable lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable per line.
205-
When the ending list (whether or arguments or variables) is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
206-
<!-- checked in Squiz.Functions.MultiLineFunctionDeclaration -->
20746
</ruleset>

templates/listOfSps-tpl.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' .
1212
Module::getModuleUrl('perun/res/css/listOfSps.css') . '" />';
1313

14-
$this->data['head'] .= '<meta name="translations" id="translations" content="'.htmlspecialchars(json_encode([
14+
$this->data['head'] .= '<meta name="translations" id="translations" content="' . htmlspecialchars(json_encode([
1515
'saml_production' => $this->t('{perun:listOfSps:saml_production}'),
1616
'saml_test' => $this->t('{perun:listOfSps:saml_test}'),
1717
'oidc_production' => $this->t('{perun:listOfSps:oidc_production}'),
1818
'oidc_test' => $this->t('{perun:listOfSps:oidc_test}'),
19-
])).'">';
19+
])) . '">';
2020

2121
$statistics = $this->data['statistics'];
2222
$attributesToShow = $this->data['attributesToShow'];
@@ -31,12 +31,12 @@
3131
$samlProductionCount = $statistics['samlServicesCount'] - $statistics['samlTestServicesCount'];
3232
$oidcProductionCount = $statistics['oidcServicesCount'] - $statistics['oidcTestServicesCount'];
3333

34-
$this->data['head'] .= '<meta name="data" id="data" content="'.htmlspecialchars(json_encode([
34+
$this->data['head'] .= '<meta name="data" id="data" content="' . htmlspecialchars(json_encode([
3535
'samlProductionCount' => $samlProductionCount,
3636
'samlTestServicesCount' => $statistics['samlTestServicesCount'],
3737
'oidcProductionCount' => $oidcProductionCount,
3838
'oidcTestServicesCount' => $statistics['oidcTestServicesCount'],
39-
])).'">';
39+
])) . '">';
4040

4141
$this->includeAtTemplateBase('includes/header.php');
4242
?>

themes/perun/consent/consentform.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function perun_present_attributes($t, $attributes, $nameParent, $labelCol = 5)
4646
$translator = $t->getTranslator();
4747

4848
if (strlen($nameParent) > 0) {
49-
$parentStr = strtolower($nameParent).'_';
49+
$parentStr = strtolower($nameParent) . '_';
5050
$str = '<ul class="perun-attributes">';
5151
} else {
5252
$parentStr = '';
@@ -55,23 +55,23 @@ function perun_present_attributes($t, $attributes, $nameParent, $labelCol = 5)
5555

5656
foreach ($attributes as $name => $value) {
5757
$nameraw = $name;
58-
$name = $translator->getAttributeTranslation($parentStr.$nameraw);
58+
$name = $translator->getAttributeTranslation($parentStr . $nameraw);
5959

6060
if (preg_match('/^child_/', $nameraw)) {
6161
// insert child table
6262
throw new Exception('Unsupported');
6363
} else {
6464
// insert values directly
65-
$str .= "\n".'<li>'
65+
$str .= "\n" . '<li>'
6666
. '<div class="row"><div class="col-sm-' . $labelCol
6767
. '"><h2 class="perun-attrname h4">'
68-
. htmlspecialchars(str_replace("domovksé", "domovské", $name)).'</h2></div>';
68+
. htmlspecialchars(str_replace("domovksé", "domovské", $name)) . '</h2></div>';
6969

70-
$str .= '<div class="perun-attrcontainer col-sm-' . (12-$labelCol) . '">';
70+
$str .= '<div class="perun-attrcontainer col-sm-' . (12 - $labelCol) . '">';
7171
$isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
7272
if ($isHidden) {
7373
$hiddenId = \SimpleSAML\Utils\Random::generateID();
74-
$str .= '<span class="perun-attrvalue hidden" id="hidden_'.$hiddenId.'">';
74+
$str .= '<span class="perun-attrvalue hidden" id="hidden_' . $hiddenId . '">';
7575
} else {
7676
$str .= '<span class="perun-attrvalue">';
7777
}
@@ -86,10 +86,10 @@ function perun_present_attributes($t, $attributes, $nameParent, $labelCol = 5)
8686
$str .= '</span>';
8787

8888
if ($isHidden) {
89-
$str .= '<div class="perun-attrvalue consent_showattribute" id="visible_'.$hiddenId.'">';
89+
$str .= '<div class="perun-attrvalue consent_showattribute" id="visible_' . $hiddenId . '">';
9090
$str .= '&#8230; ';
91-
$str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId;
92-
$str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">';
91+
$str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId;
92+
$str .= '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">';
9393
$str .= $t->t('{consent:consent:show_attribute}');
9494
$str .= '</a>';
9595
$str .= '</div>';

themes/perun/perun/disco-tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
echo getOr();
131131

132132
echo '<a id="showEntries" class="metaentry btn btn-block btn-default btn-lg" href="#">' .
133-
$this->t('{perun:disco:sign_with_other_institution}') .'</a>' ;
133+
$this->t('{perun:disco:sign_with_other_institution}') . '</a>' ;
134134
echo '<div id="entries" style="display: none">';
135135
}
136136

@@ -311,7 +311,7 @@ function showTaggedIdPs($t, $tag, $showSignInWith = false)
311311
$counter = 0;
312312

313313
$fullRowCount = floor($idpCount / 3);
314-
for ($i = 0; $i < $fullRowCount; $i++ ) {
314+
for ($i = 0; $i < $fullRowCount; $i++) {
315315
$html .= '<div class="row">';
316316
for ($j = 0; $j < 3; $j++) {
317317
$html .= '<div class="col-md-4">';

www/status.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ function getBadgeByStatus($status)
6363
return '<span class="status label label-danger">CRITICAL</span>';
6464
}
6565
}
66-

0 commit comments

Comments
 (0)