Run PSR2 Lint cleaner

This commit is contained in:
Damian Mooyman 2019-10-04 13:26:31 +13:00
parent f1594fd991
commit d7752b7945
No known key found for this signature in database
GPG Key ID: 19B1752E86A700BB
11 changed files with 19 additions and 20 deletions

View File

@ -61,7 +61,7 @@ class GetParameter implements Rule, Bypass
{
return new Confirmation\Item(
$token,
_t(__CLASS__.'.CONFIRMATION_NAME', '"{key}" GET parameter', ['key' => $this->name]),
_t(__CLASS__ . '.CONFIRMATION_NAME', '"{key}" GET parameter', ['key' => $this->name]),
sprintf('%s = "%s"', $this->name, $value)
);
}

View File

@ -178,8 +178,8 @@ class Url implements Rule, Bypass
{
return new Confirmation\Item(
$token,
_t(__CLASS__.'.CONFIRMATION_NAME', 'URL is protected'),
_t(__CLASS__.'.CONFIRMATION_DESCRIPTION', 'The URL is: "{url}"', ['url' => $url])
_t(__CLASS__ . '.CONFIRMATION_NAME', 'URL is protected'),
_t(__CLASS__ . '.CONFIRMATION_DESCRIPTION', 'The URL is: "{url}"', ['url' => $url])
);
}

View File

@ -34,8 +34,8 @@ class UrlPathStartswith implements Rule, Bypass
{
return new Confirmation\Item(
$token,
_t(__CLASS__.'.CONFIRMATION_NAME', 'URL begins with "{path}"', ['path' => $this->getPath()]),
_t(__CLASS__.'.CONFIRMATION_DESCRIPTION', 'The complete URL is: "{url}"', ['url' => $url])
_t(__CLASS__ . '.CONFIRMATION_NAME', 'URL begins with "{path}"', ['path' => $this->getPath()]),
_t(__CLASS__ . '.CONFIRMATION_DESCRIPTION', 'The complete URL is: "{url}"', ['url' => $url])
);
}

View File

@ -23,9 +23,9 @@ class DevConfirmationController extends Confirmation\Handler
$renderer = DebugView::create();
echo $renderer->renderHeader();
echo $renderer->renderInfo(
_t(__CLASS__.".INFO_TITLE", "Security Confirmation"),
_t(__CLASS__ . ".INFO_TITLE", "Security Confirmation"),
Director::absoluteBaseURL(),
_t(__CLASS__.".INFO_DESCRIPTION", "Confirm potentially dangerous operation")
_t(__CLASS__ . ".INFO_DESCRIPTION", "Confirm potentially dangerous operation")
);
return $response;

View File

@ -224,8 +224,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
if ($this->record->canDelete()) {
$form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
}
} elseif (
!$this->record->ID
} elseif (!$this->record->ID
&& !$this->record->canCreate(null, $this->getCreateContext())
) {
// Restrict creation of new records

View File

@ -99,8 +99,8 @@ class Form extends BaseForm
protected function buildActionList(Storage $storage)
{
$cancel = FormAction::create('doRefuse', _t(__CLASS__.'.REFUSE', 'Cancel'));
$confirm = FormAction::create('doConfirm', _t(__CLASS__.'.CONFIRM', 'Run the action'))->setAutofocus(true);
$cancel = FormAction::create('doRefuse', _t(__CLASS__ . '.REFUSE', 'Cancel'));
$confirm = FormAction::create('doConfirm', _t(__CLASS__ . '.CONFIRM', 'Run the action'))->setAutofocus(true);
if ($storage->getHttpMethod() === 'POST') {
$confirm->setAttribute('formaction', htmlspecialchars($storage->getSuccessUrl()));
@ -165,7 +165,7 @@ class Form extends BaseForm
protected function buildEmptyFieldList()
{
return FieldList::create(
HeaderField::create(null, _t(__CLASS__.'.EMPTY_TITLE', 'Nothing to confirm'))
HeaderField::create(null, _t(__CLASS__ . '.EMPTY_TITLE', 'Nothing to confirm'))
);
}
}

View File

@ -47,7 +47,7 @@ class Handler extends RequestHandler
public function index()
{
return [
'Title' => _t(__CLASS__.'.FORM_TITLE', 'Confirm potentially dangerous action'),
'Title' => _t(__CLASS__ . '.FORM_TITLE', 'Confirm potentially dangerous action'),
'Form' => $this->Form()
];
return $this;

View File

@ -125,7 +125,7 @@ class Storage
$token = $item->getToken();
$salt = $this->getSessionSalt();
$salted = $salt.$token;
$salted = $salt . $token;
return hash(static::HASH_ALGO, $salted, true);
}
@ -139,7 +139,7 @@ class Storage
{
$salt = $this->getSessionSalt();
return bin2hex(hash(static::HASH_ALGO, $salt.'cookie key', true));
return bin2hex(hash(static::HASH_ALGO, $salt . 'cookie key', true));
}
/**
@ -151,7 +151,7 @@ class Storage
{
$salt = $this->getSessionSalt();
return base64_encode(hash(static::HASH_ALGO, $salt.'csrf token', true));
return base64_encode(hash(static::HASH_ALGO, $salt . 'csrf token', true));
}
/**
@ -441,7 +441,7 @@ class Storage
'%s.%s%s',
str_replace('\\', '.', __CLASS__),
$this->id,
$key ? '.'.$key : ''
$key ? '.' . $key : ''
);
}
}

View File

@ -29,7 +29,7 @@ trait HttpRequestMockBuilder
$request->method('getSession')->willReturn($session);
$request->method('getURL')->will($this->returnCallback(static function ($addParams) use ($url, $getVars) {
return $addParams && count($getVars) ? $url.'?'.http_build_query($getVars) : $url;
return $addParams && count($getVars) ? $url . '?' . http_build_query($getVars) : $url;
}));
$request->method('getVars')->willReturn($getVars);

View File

@ -68,7 +68,7 @@ class ConfirmationMiddlewareTest extends SapphireTest
$this->assertFalse($next);
$this->assertInstanceOf(HTTPResponse::class, $response);
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(Director::baseURL().'dev/confirm/middleware', $response->getHeader('location'));
$this->assertEquals(Director::baseURL() . 'dev/confirm/middleware', $response->getHeader('location'));
// Test bypasses have more priority than rules
$middleware->setBypasses([new Url('dev/build')]);

View File

@ -14,7 +14,7 @@ class StorageTest extends SapphireTest
private function getNamespace($id)
{
return str_replace('\\', '.', Storage::class).'.'.$id;
return str_replace('\\', '.', Storage::class) . '.' . $id;
}
public function testNewStorage()