Skip to content

Commit

Permalink
MNT: use short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Sep 12, 2023
1 parent 6d2ec29 commit fa8366e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/EditableSpamProtectionField.php
Expand Up @@ -41,15 +41,15 @@ class EditableSpamProtectionField extends EditableFormField
* @var array
* @config
*/
private static $check_fields = array(
private static $check_fields = [
EditableEmailField::class,
EditableTextField::class,
EditableNumericField::class
);
];

private static $db = array(
private static $db = [
'SpamFieldSettings' => 'Text'
);
];

/**
* @var FormField
Expand All @@ -69,7 +69,7 @@ public function getFormField()
}

// Extract saved field mappings and update this field.
$fieldMapping = array();
$fieldMapping = [];
foreach ($this->getCandidateFields() as $otherField) {
$mapSetting = "Map-{$otherField->Name}";
$spamField = $this->spamMapValue($mapSetting);
Expand Down Expand Up @@ -106,7 +106,7 @@ protected function getCandidateFields()

// Get list of all configured classes available for spam detection
$types = $this->config()->get('check_fields');
$typesInherit = array();
$typesInherit = [];
foreach ($types as $type) {
$subTypes = ClassInfo::subclassesFor($type);
$typesInherit = array_merge($typesInherit, $subTypes);
Expand All @@ -132,7 +132,7 @@ public function onBeforeWrite()
{
$fieldMap = json_decode($this->SpamFieldSettings ?? '', true);
if (empty($fieldMap)) {
$fieldMap = array();
$fieldMap = [];
}

foreach ($this->record as $key => $value) {
Expand Down Expand Up @@ -202,7 +202,7 @@ public function spamMapValue($mapSetting)
{
$map = json_decode($this->SpamFieldSettings ?? '', true);
if (empty($map)) {
$map = array();
$map = [];
}

if (array_key_exists($mapSetting, $map ?? [])) {
Expand Down
12 changes: 6 additions & 6 deletions src/Extension/CommentSpamProtection.php
Expand Up @@ -14,19 +14,19 @@ class CommentSpamProtection extends Extension
{
public function alterCommentForm(&$form)
{
$form->enableSpamProtection(array(
$form->enableSpamProtection([
'name' => 'IsSpam',
'mapping' => array(
'mapping' => [
'Name' => 'authorName',
'Email' => 'authorEmail',
'URL' => 'authorUrl',
'Comment' => 'body',
'ReturnURL' => 'contextUrl'
),
'checks' => array(
],
'checks' => [
'spam',
'profanity'
)
));
]
]);
}
}
6 changes: 3 additions & 3 deletions src/Extension/FormSpamProtectionExtension.php
Expand Up @@ -37,7 +37,7 @@ class FormSpamProtectionExtension extends Extension
*
* @var array $mappable_fields
*/
private static $mappable_fields = array(
private static $mappable_fields = [
'id',
'title',
'body',
Expand All @@ -48,7 +48,7 @@ class FormSpamProtectionExtension extends Extension
'authorUrl',
'authorIp',
'authorId'
);
];

/**
* @config
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function get_protector($options = null)
* @throws LogicException when get_protector method returns NULL.
* @return Object
*/
public function enableSpamProtection($options = array())
public function enableSpamProtection($options = [])
{

// captcha form field name (must be unique)
Expand Down

0 comments on commit fa8366e

Please sign in to comment.