Skip to content

Commit 3f6f5e7

Browse files
committed
Added phpcs ruleset. Ran phpcbf to fix any phpcs errors.
1 parent 92a3a73 commit 3f6f5e7

12 files changed

Lines changed: 1006 additions & 958 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This repository contains the firewall engine of Patchstack.
44
It can be implemented inside of other content management systems to provide firewall functionality.
55

6-
## How do I get set up? ##
6+
## How do I get it set up? ##
77

88
Since the firewall engine depends on the opis/closure and laravel/serializable-closure packages which both require different PHP versions, sticking to one PHP version is tricky.
99

@@ -15,7 +15,8 @@ Therefore, in order to use this package, the composer install command must be ex
1515
- ✅ First initial concept and implementation
1616
- ⬜️ Unit tests
1717
- ⬜️ Test on many different environments and combinations with other plugins
18-
- ⬜️ Attach PHP CS Fixer
18+
- ✅ Attach PHP CS ruleset
19+
- ⬜️ Write proper readme instructions
1920

2021
## Who do I talk to? ##
2122

phpcs.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="Patchstack CS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Patchstack">
3+
<arg name="colors"/>
4+
<arg name="extensions" value="php"/>
5+
<file>./src</file>
6+
<file>./tests</file>
7+
<exclude-pattern>*/vendor/*</exclude-pattern>
8+
<rule ref="PSR12">
9+
<exclude name="Generic.Files.LineLength.TooLong" />
10+
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
11+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
12+
</rule>
13+
</ruleset>

src/Extensions/ExtensionInterface.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,57 @@ interface ExtensionInterface
1010
{
1111
/**
1212
* Log the request, this can be of type BLOCK, LOG or REDIRECT.
13-
*
14-
* @param int $ruleId
15-
* @param string $bodyData
16-
* @param string $blockType
13+
*
14+
* @param int $ruleId
15+
* @param string $bodyData
16+
* @param string $blockType
1717
* @return void
1818
*/
1919
public function logRequest($ruleId, $bodyData, $blockType);
2020

2121
/**
2222
* Determine if the current visitor can bypass the firewall.
23-
*
23+
*
2424
* @return bool
2525
*/
2626
public function canBypass();
2727

2828
/**
2929
* Determine if the visitor is blocked from the website.
30-
*
31-
* @param int $minutes
32-
* @param int $blockTime
33-
* @param int $attempts
30+
*
31+
* @param int $minutes
32+
* @param int $blockTime
33+
* @param int $attempts
3434
* @return bool
3535
*/
3636
public function isBlocked($minutes, $blockTime, $attempts);
3737

3838
/**
3939
* Force exit the page when a request has been blocked.
40-
*
41-
* @param int $ruleId
40+
*
41+
* @param int $ruleId
4242
* @return void
4343
*/
4444
public function forceExit($ruleId);
4545

4646
/**
4747
* Get the IP address of the request.
48-
*
48+
*
4949
* @return string
5050
*/
5151
public function getIpAddress();
5252

5353
/**
5454
* Determine if the request should be passed without going through the firewall.
55-
*
55+
*
5656
* @param array $whitelistRules
5757
* @param array $request
5858
*/
5959
public function isWhitelisted($whitelistRules, $request);
6060

6161
/**
6262
* Determine if the current request is a file upload request.
63-
*
63+
*
6464
* @return boolean
6565
*/
6666
public function isFileUploadRequest();

src/Extensions/Test/Extension.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class Extension implements ExtensionInterface
88
{
99
/**
1010
* Log the request, this can be of type BLOCK, LOG or REDIRECT.
11-
*
12-
* @param int $ruleId
13-
* @param string $bodyData
14-
* @param string $blockType
11+
*
12+
* @param int $ruleId
13+
* @param string $bodyData
14+
* @param string $blockType
1515
* @return void
1616
*/
1717
public function logRequest($ruleId, $bodyData, $blockType)
@@ -21,7 +21,7 @@ public function logRequest($ruleId, $bodyData, $blockType)
2121

2222
/**
2323
* Determine if the current visitor can bypass the firewall.
24-
*
24+
*
2525
* @return bool
2626
*/
2727
public function canBypass()
@@ -31,10 +31,10 @@ public function canBypass()
3131

3232
/**
3333
* Determine if the visitor is blocked from the website.
34-
*
35-
* @param int $minutes
36-
* @param int $blockTime
37-
* @param int $attempts
34+
*
35+
* @param int $minutes
36+
* @param int $blockTime
37+
* @param int $attempts
3838
* @return bool
3939
*/
4040
public function isBlocked($minutes, $blockTime, $attempts)
@@ -44,8 +44,8 @@ public function isBlocked($minutes, $blockTime, $attempts)
4444

4545
/**
4646
* Force exit the page when a request has been blocked.
47-
*
48-
* @param int $ruleId
47+
*
48+
* @param int $ruleId
4949
* @return void
5050
*/
5151
public function forceExit($ruleId)
@@ -55,7 +55,7 @@ public function forceExit($ruleId)
5555

5656
/**
5757
* Get the IP address of the request.
58-
*
58+
*
5959
* @return string
6060
*/
6161
public function getIpAddress()
@@ -65,7 +65,7 @@ public function getIpAddress()
6565

6666
/**
6767
* Determine if the request should not go through the firewall.
68-
*
68+
*
6969
* @param array $whitelistRules
7070
* @param array $request
7171
*/
@@ -76,11 +76,11 @@ public function isWhitelisted($whitelistRules, $request)
7676

7777
/**
7878
* Determine if the current request is a file upload request.
79-
*
79+
*
8080
* @return boolean
8181
*/
8282
public function isFileUploadRequest()
8383
{
8484
return false;
8585
}
86-
}
86+
}

0 commit comments

Comments
 (0)