mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Run PSR2 Lint cleaner
This commit is contained in:
parent
f1594fd991
commit
d7752b7945
@ -61,7 +61,7 @@ class GetParameter implements Rule, Bypass
|
|||||||
{
|
{
|
||||||
return new Confirmation\Item(
|
return new Confirmation\Item(
|
||||||
$token,
|
$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)
|
sprintf('%s = "%s"', $this->name, $value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -178,8 +178,8 @@ class Url implements Rule, Bypass
|
|||||||
{
|
{
|
||||||
return new Confirmation\Item(
|
return new Confirmation\Item(
|
||||||
$token,
|
$token,
|
||||||
_t(__CLASS__.'.CONFIRMATION_NAME', 'URL is protected'),
|
_t(__CLASS__ . '.CONFIRMATION_NAME', 'URL is protected'),
|
||||||
_t(__CLASS__.'.CONFIRMATION_DESCRIPTION', 'The URL is: "{url}"', ['url' => $url])
|
_t(__CLASS__ . '.CONFIRMATION_DESCRIPTION', 'The URL is: "{url}"', ['url' => $url])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ class UrlPathStartswith implements Rule, Bypass
|
|||||||
{
|
{
|
||||||
return new Confirmation\Item(
|
return new Confirmation\Item(
|
||||||
$token,
|
$token,
|
||||||
_t(__CLASS__.'.CONFIRMATION_NAME', 'URL begins with "{path}"', ['path' => $this->getPath()]),
|
_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_DESCRIPTION', 'The complete URL is: "{url}"', ['url' => $url])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ class DevConfirmationController extends Confirmation\Handler
|
|||||||
$renderer = DebugView::create();
|
$renderer = DebugView::create();
|
||||||
echo $renderer->renderHeader();
|
echo $renderer->renderHeader();
|
||||||
echo $renderer->renderInfo(
|
echo $renderer->renderInfo(
|
||||||
_t(__CLASS__.".INFO_TITLE", "Security Confirmation"),
|
_t(__CLASS__ . ".INFO_TITLE", "Security Confirmation"),
|
||||||
Director::absoluteBaseURL(),
|
Director::absoluteBaseURL(),
|
||||||
_t(__CLASS__.".INFO_DESCRIPTION", "Confirm potentially dangerous operation")
|
_t(__CLASS__ . ".INFO_DESCRIPTION", "Confirm potentially dangerous operation")
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -224,8 +224,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
|||||||
if ($this->record->canDelete()) {
|
if ($this->record->canDelete()) {
|
||||||
$form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
|
$form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
|
||||||
}
|
}
|
||||||
} elseif (
|
} elseif (!$this->record->ID
|
||||||
!$this->record->ID
|
|
||||||
&& !$this->record->canCreate(null, $this->getCreateContext())
|
&& !$this->record->canCreate(null, $this->getCreateContext())
|
||||||
) {
|
) {
|
||||||
// Restrict creation of new records
|
// Restrict creation of new records
|
||||||
|
@ -99,8 +99,8 @@ class Form extends BaseForm
|
|||||||
|
|
||||||
protected function buildActionList(Storage $storage)
|
protected function buildActionList(Storage $storage)
|
||||||
{
|
{
|
||||||
$cancel = FormAction::create('doRefuse', _t(__CLASS__.'.REFUSE', 'Cancel'));
|
$cancel = FormAction::create('doRefuse', _t(__CLASS__ . '.REFUSE', 'Cancel'));
|
||||||
$confirm = FormAction::create('doConfirm', _t(__CLASS__.'.CONFIRM', 'Run the action'))->setAutofocus(true);
|
$confirm = FormAction::create('doConfirm', _t(__CLASS__ . '.CONFIRM', 'Run the action'))->setAutofocus(true);
|
||||||
|
|
||||||
if ($storage->getHttpMethod() === 'POST') {
|
if ($storage->getHttpMethod() === 'POST') {
|
||||||
$confirm->setAttribute('formaction', htmlspecialchars($storage->getSuccessUrl()));
|
$confirm->setAttribute('formaction', htmlspecialchars($storage->getSuccessUrl()));
|
||||||
@ -165,7 +165,7 @@ class Form extends BaseForm
|
|||||||
protected function buildEmptyFieldList()
|
protected function buildEmptyFieldList()
|
||||||
{
|
{
|
||||||
return FieldList::create(
|
return FieldList::create(
|
||||||
HeaderField::create(null, _t(__CLASS__.'.EMPTY_TITLE', 'Nothing to confirm'))
|
HeaderField::create(null, _t(__CLASS__ . '.EMPTY_TITLE', 'Nothing to confirm'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class Handler extends RequestHandler
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Title' => _t(__CLASS__.'.FORM_TITLE', 'Confirm potentially dangerous action'),
|
'Title' => _t(__CLASS__ . '.FORM_TITLE', 'Confirm potentially dangerous action'),
|
||||||
'Form' => $this->Form()
|
'Form' => $this->Form()
|
||||||
];
|
];
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -125,7 +125,7 @@ class Storage
|
|||||||
$token = $item->getToken();
|
$token = $item->getToken();
|
||||||
$salt = $this->getSessionSalt();
|
$salt = $this->getSessionSalt();
|
||||||
|
|
||||||
$salted = $salt.$token;
|
$salted = $salt . $token;
|
||||||
|
|
||||||
return hash(static::HASH_ALGO, $salted, true);
|
return hash(static::HASH_ALGO, $salted, true);
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ class Storage
|
|||||||
{
|
{
|
||||||
$salt = $this->getSessionSalt();
|
$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();
|
$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',
|
'%s.%s%s',
|
||||||
str_replace('\\', '.', __CLASS__),
|
str_replace('\\', '.', __CLASS__),
|
||||||
$this->id,
|
$this->id,
|
||||||
$key ? '.'.$key : ''
|
$key ? '.' . $key : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ trait HttpRequestMockBuilder
|
|||||||
$request->method('getSession')->willReturn($session);
|
$request->method('getSession')->willReturn($session);
|
||||||
|
|
||||||
$request->method('getURL')->will($this->returnCallback(static function ($addParams) use ($url, $getVars) {
|
$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);
|
$request->method('getVars')->willReturn($getVars);
|
||||||
|
@ -68,7 +68,7 @@ class ConfirmationMiddlewareTest extends SapphireTest
|
|||||||
$this->assertFalse($next);
|
$this->assertFalse($next);
|
||||||
$this->assertInstanceOf(HTTPResponse::class, $response);
|
$this->assertInstanceOf(HTTPResponse::class, $response);
|
||||||
$this->assertEquals(302, $response->getStatusCode());
|
$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
|
// Test bypasses have more priority than rules
|
||||||
$middleware->setBypasses([new Url('dev/build')]);
|
$middleware->setBypasses([new Url('dev/build')]);
|
||||||
|
@ -14,7 +14,7 @@ class StorageTest extends SapphireTest
|
|||||||
|
|
||||||
private function getNamespace($id)
|
private function getNamespace($id)
|
||||||
{
|
{
|
||||||
return str_replace('\\', '.', Storage::class).'.'.$id;
|
return str_replace('\\', '.', Storage::class) . '.' . $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNewStorage()
|
public function testNewStorage()
|
||||||
|
Loading…
Reference in New Issue
Block a user