Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions component/admin/src/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

class DisplayController extends BaseController
{
public function display($cachable = false, $urlparams = false)
public function display($cachable = false, $urlparams = [])
{
$input = $this->input;
$view = $input->getCmd('view', 'blocklist');

$pluginInstalled = $this->checkWhetherPluginInstalled();
if (!$pluginInstalled)
{
return;
return $this;
}
$this->warnIfAdminUserExists();
$this->warnIfHtAccessNotWorking();
Expand All @@ -43,7 +43,7 @@ public function display($cachable = false, $urlparams = false)
$this->warnIfUnblockLinksNeedLiveSite();
}
$input->set('view', $view);
parent::display($cachable);
return parent::display($cachable);
}

public function warnIfAdminUserExists()
Expand Down
1 change: 1 addition & 0 deletions component/admin/src/Controller/HtblockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ public function cancel($key = null)
$this->setRedirect(
Route::_('index.php?option=com_bfstop&view=htblocklist', false)
);
return true;
}
}
2 changes: 1 addition & 1 deletion component/admin/src/Model/HtblockModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HtblockModel extends AdminModel
{
public function getItem($pk = null)
{
return array('ipaddress' => '0.0.0.0');
return (object) array('ipaddress' => '0.0.0.0');
}

public function getForm($data = array(), $loadData = true)
Expand Down
2 changes: 1 addition & 1 deletion component/admin/src/View/Settings/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ protected function addToolbar()
}
ToolbarHelper::cancel('settings.cancel');
ToolbarHelper::custom('settings.testNotify', 'preview', '',
'COM_BFSTOP_TEST_NOTIFICATION', false, false);
'COM_BFSTOP_TEST_NOTIFICATION', false);
}
}
4 changes: 2 additions & 2 deletions component/site/src/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class DisplayController extends BaseController
{
public function display($cachable = false, $urlparams = false)
public function display($cachable = false, $urlparams = [])
{
parent::display($cachable, $urlparams);
return parent::display($cachable, $urlparams);
}
}
4 changes: 3 additions & 1 deletion library/src/Helper/DnsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public static function buildQuery($id, $name)
/**
* Reads the (possibly compressed) domain name at $offset of $packet.
*
* @param int $next set to the offset after the name where it is stored
* @param string $packet
* @param int $offset
* @param int|null $next set to the offset after the name where it is stored
* @return string|null null if the name is malformed
*/
private static function readName($packet, $offset, &$next)
Expand Down
3 changes: 0 additions & 3 deletions library/src/Helper/LoggerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ class LoggerHelper
// disk (a visitor can make the plugin log by failing logins)
public const MaxLogFileBytes = self::DefaultMaxSizeMB * 1048576;

private $maxBytes;

public function __construct($log_level, $maxBytes = self::MaxLogFileBytes)
{
$this->log_level = $log_level;
$this->maxBytes = $maxBytes;
$priorities = Log::ALL;
if ($log_level > self::Disabled)
{
Expand Down
66 changes: 0 additions & 66 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ parameters:
count: 1
path: component/admin/src/Controller/BlocklistController.php

-
message: '#^Default value of the parameter \#2 \$urlparams \(false\) of method Codeling\\Component\\Bfstop\\Administrator\\Controller\\DisplayController\:\:display\(\) is incompatible with type array\.$#'
identifier: parameter.defaultValue
count: 1
path: component/admin/src/Controller/DisplayController.php

-
message: '#^Method Codeling\\Component\\Bfstop\\Administrator\\Controller\\DisplayController\:\:display\(\) should return static\(Codeling\\Component\\Bfstop\\Administrator\\Controller\\DisplayController\) but empty return statement found\.$#'
identifier: return.empty
count: 1
path: component/admin/src/Controller/DisplayController.php

-
message: '#^Method Codeling\\Component\\Bfstop\\Administrator\\Controller\\DisplayController\:\:display\(\) should return static\(Codeling\\Component\\Bfstop\\Administrator\\Controller\\DisplayController\) but return statement is missing\.$#'
identifier: return.missing
count: 1
path: component/admin/src/Controller/DisplayController.php

-
message: '#^Cannot call method purgeOlderThan\(\) on bool\|Joomla\\CMS\\MVC\\Model\\BaseDatabaseModel\.$#'
identifier: method.nonObject
Expand All @@ -48,12 +30,6 @@ parameters:
count: 1
path: component/admin/src/Controller/HtblockController.php

-
message: '#^Method Codeling\\Component\\Bfstop\\Administrator\\Controller\\HtblockController\:\:cancel\(\) should return bool but return statement is missing\.$#'
identifier: return.missing
count: 1
path: component/admin/src/Controller/HtblockController.php

-
message: '#^Cannot call method unblock\(\) on bool\|Joomla\\CMS\\MVC\\Model\\BaseDatabaseModel\.$#'
identifier: method.nonObject
Expand Down Expand Up @@ -102,12 +78,6 @@ parameters:
count: 1
path: component/admin/src/Model/HtblockModel.php

-
message: '#^Method Codeling\\Component\\Bfstop\\Administrator\\Model\\HtblockModel\:\:getItem\(\) should return stdClass\|false but returns array\{ipaddress\: ''0\.0\.0\.0''\}\.$#'
identifier: return.type
count: 1
path: component/admin/src/Model/HtblockModel.php

-
message: '#^Call to an undefined method Joomla\\CMS\\Application\\CMSApplicationInterface\:\:getUserState\(\)\.$#'
identifier: method.notFound
Expand Down Expand Up @@ -264,12 +234,6 @@ parameters:
count: 1
path: component/admin/src/View/Settings/HtmlView.php

-
message: '#^Parameter \#6 \$formId of static method Joomla\\CMS\\Toolbar\\ToolbarHelper\:\:custom\(\) expects string\|null, false given\.$#'
identifier: argument.type
count: 1
path: component/admin/src/View/Settings/HtmlView.php

-
message: '#^Call to an undefined method Joomla\\CMS\\Application\\CMSApplicationInterface\:\:getDocument\(\)\.$#'
identifier: method.notFound
Expand All @@ -294,18 +258,6 @@ parameters:
count: 1
path: component/admin/src/View/Usernamestats/HtmlView.php

-
message: '#^Default value of the parameter \#2 \$urlparams \(false\) of method Codeling\\Component\\Bfstop\\Site\\Controller\\DisplayController\:\:display\(\) is incompatible with type array\.$#'
identifier: parameter.defaultValue
count: 1
path: component/site/src/Controller/DisplayController.php

-
message: '#^Method Codeling\\Component\\Bfstop\\Site\\Controller\\DisplayController\:\:display\(\) should return static\(Codeling\\Component\\Bfstop\\Site\\Controller\\DisplayController\) but return statement is missing\.$#'
identifier: return.missing
count: 1
path: component/site/src/Controller/DisplayController.php

-
message: '#^Call to an undefined method Joomla\\CMS\\Application\\CMSApplicationInterface\:\:allowCache\(\)\.$#'
identifier: method.notFound
Expand Down Expand Up @@ -336,24 +288,6 @@ parameters:
count: 1
path: library/src/Helper/ApiHelper.php

-
message: '#^Parameter &\$next by\-ref type of method Codeling\\Library\\Bfstop\\Helper\\DnsHelper\:\:readName\(\) expects int, \(float\|int\) given\.$#'
identifier: parameterByRef.type
count: 2
path: library/src/Helper/DnsHelper.php

-
message: '#^Parameter &\$next by\-ref type of method Codeling\\Library\\Bfstop\\Helper\\DnsHelper\:\:readName\(\) expects int, null given\.$#'
identifier: parameterByRef.type
count: 1
path: library/src/Helper/DnsHelper.php

-
message: '#^Property Codeling\\Library\\Bfstop\\Helper\\LoggerHelper\:\:\$maxBytes is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: library/src/Helper/LoggerHelper.php

-
message: '#^Call to an undefined method Joomla\\Database\\QueryInterface\:\:returning\(\)\.$#'
identifier: method.notFound
Expand Down
17 changes: 11 additions & 6 deletions tests/Integration/LoggerHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,33 @@ private static function header()

public function testPruneRemovesOldEntriesOnly()
{
// each entry is built once: entry() reads the clock, so building the
// expected one again could land in the next second
$recent = self::entry(27, 'recent');
$new = self::entry(0, 'new');
file_put_contents($this->file, self::header().
self::entry(40, 'ancient').
"continuation of the ancient entry\n".
self::entry(29, 'old').
self::entry(27, 'recent').
$recent.
"continuation of the recent entry\n".
self::entry(0, 'new'));
$new);
$this->assertSame(2, LoggerHelper::pruneByAge(28));
$this->assertSame(self::header().
self::entry(27, 'recent').
$recent.
"continuation of the recent entry\n".
self::entry(0, 'new'),
$new,
file_get_contents($this->file));
}

public function testPruneAlsoCoversThePreviousGeneration()
{
file_put_contents($this->rotated, self::header().self::entry(100, 'ancient'));
file_put_contents($this->file, self::header().self::entry(1, 'new'));
$new = self::entry(1, 'new');
file_put_contents($this->file, self::header().$new);
$this->assertSame(1, LoggerHelper::pruneByAge(28));
$this->assertSame(self::header(), file_get_contents($this->rotated));
$this->assertSame(self::header().self::entry(1, 'new'), file_get_contents($this->file));
$this->assertSame(self::header().$new, file_get_contents($this->file));
}

public function testPruneWithoutAgeKeepsEverything()
Expand Down