Skip to content

Commit

Permalink
Modern PHP
Browse files Browse the repository at this point in the history
Upgrade coding style for modern PHP
Added php code sniffer to composer.json
Namespace Loaders & Models for PSR-4
Capitalised folder names
  • Loading branch information
AntonyThorpe committed Jun 7, 2024
1 parent ccfd1f0 commit 005604d
Show file tree
Hide file tree
Showing 36 changed files with 505 additions and 554 deletions.
7 changes: 1 addition & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.{yml,js,json,css,scss,eslintrc,feature}]
[*.{yml,js,json,css,scss,feature}]
indent_size = 2
indent_style = space

[composer.json]
indent_size = 4

# Don't perform any clean-up on thirdparty files

[thirdparty/**]
trim_trailing_whitespace = false
insert_final_newline = false

[admin/thirdparty/**]
trim_trailing_whitespace = false
insert_final_newline = false
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"require": {
"silverstripe/framework": "^5.0.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.7.2"
},
"autoload": {
"psr-4": {
"AntonyThorpe\\Consumer\\": "src/",
Expand Down
21 changes: 21 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>

<!-- use short array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
</ruleset>

11 changes: 3 additions & 8 deletions src/ArrayBulkLoaderSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@
*/
class ArrayBulkLoaderSource extends BulkLoaderSource
{

protected $data;

public function __construct($data)
public function __construct(protected array $data)
{
$this->data = $data;
}

public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->data);
}

public function setData($data)
public function setData(array $data): self
{
$this->data = $data;

return $this;
}

public function getData()
public function getData(): array
{
return $this->data;
}
Expand Down
Loading

0 comments on commit 005604d

Please sign in to comment.