Skip to content

Commit

Permalink
Apply types
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jul 22, 2022
1 parent c76a51c commit f7d8640
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
22 changes: 13 additions & 9 deletions examples/Alerts.php
Expand Up @@ -16,10 +16,8 @@ class Alerts extends AlertsConfig
{
/**
* Template to use for HTML output.
*
* @var string
*/
public $template = 'Tatter\Alerts\Views\Bootstrap4';
public string $template = 'Tatter\Alerts\Views\Bootstrap4';

/**
* Mapping of Session keys to their CSS classes.
Expand All @@ -28,20 +26,26 @@ class Alerts extends AlertsConfig
*
* @var array<string,string>
*/
public $classes = [
public array $classes = [
// Bootstrap classes
'primary' => 'primary',
'message' => 'primary',
'secondary' => 'secondary',
'notice' => 'secondary',
'success' => 'success',
'danger' => 'danger',
'warning' => 'warning',
'info' => 'info',

// Additional log levels
'message' => 'primary',
'notice' => 'secondary',
'error' => 'danger',
'errors' => 'danger',
'critical' => 'danger',
'emergency' => 'danger',
'warning' => 'warning',
'alert' => 'warning',
'info' => 'info',
'debug' => 'info',

// Common framework keys
'messages' => 'primary',
'errors' => 'danger',
];
}
2 changes: 1 addition & 1 deletion src/Collectors/Alerts.php
Expand Up @@ -44,7 +44,7 @@ class Alerts extends BaseCollector
*
* @var array<string[]>
*/
protected $alerts;
protected array $alerts;

//--------------------------------------------------------------------

Expand Down
6 changes: 2 additions & 4 deletions src/Config/Alerts.php
Expand Up @@ -8,10 +8,8 @@ class Alerts extends BaseConfig
{
/**
* Template to use for HTML output.
*
* @var string
*/
public $template = 'Tatter\Alerts\Views\Bootstrap4';
public string $template = 'Tatter\Alerts\Views\Bootstrap4';

/**
* Mapping of Session keys to their CSS classes.
Expand All @@ -20,7 +18,7 @@ class Alerts extends BaseConfig
*
* @var array<string,string>
*/
public $classes = [
public array $classes = [
// Bootstrap classes
'primary' => 'primary',
'secondary' => 'secondary',
Expand Down
3 changes: 1 addition & 2 deletions src/Filters/AlertsFilter.php
Expand Up @@ -24,8 +24,7 @@ class AlertsFilter implements FilterInterface
public static function gather(AlertsConfig $config): array
{
// Gather alerts from the Session
$session = service('session');
$alerts = [];
$alerts = [];

foreach ($config->classes as $key => $class) {
$content = session($key);
Expand Down
5 changes: 1 addition & 4 deletions tests/CollectorTest.php
Expand Up @@ -8,10 +8,7 @@
*/
final class CollectorTest extends TestCase
{
/**
* @var Alerts
*/
protected $collector;
protected Alerts $collector;

protected function setUp(): void
{
Expand Down
5 changes: 1 addition & 4 deletions tests/FilterTest.php
Expand Up @@ -12,10 +12,7 @@ final class FilterTest extends TestCase
{
use FilterTestTrait;

/**
* @var string
*/
private $body = <<<'EOD'
private string $body = <<<'EOD'
<html>
<head>
<title>Test</title>
Expand Down

0 comments on commit f7d8640

Please sign in to comment.