Skip to content

Commit

Permalink
Revert "Get rid of phpstan/phpstan-strict-rules"
Browse files Browse the repository at this point in the history
This reverts commit ff59ade.
  • Loading branch information
mvorisek committed Jun 17, 2024
1 parent 613629f commit 1b91c1e
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 4 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0",
"roundcube/acl": "*",
"roundcube/additional_message_headers": "*",
Expand Down
36 changes: 36 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\App\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/App.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\Dialog\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/Dialog.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\HtmlEditor\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/HtmlEditor.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\Popupmenu\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/Popupmenu.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\RecipientInput\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/RecipientInput.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\Taskmenu\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/Taskmenu.php

-
message: "#^Parameter \\#1 \\$browser \\(Tests\\\\Browser\\\\Browser\\) of method Tests\\\\Browser\\\\Components\\\\Toolbarmenu\\:\\:assert\\(\\) should be contravariant with parameter \\$browser \\(Laravel\\\\Dusk\\\\Browser\\) of method Laravel\\\\Dusk\\\\Component\\:\\:assert\\(\\)$#"
count: 1
path: tests/Browser/Components/Toolbarmenu.php
16 changes: 16 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- phpstan-baseline.neon

parameters:
level: 4
Expand All @@ -11,6 +12,21 @@ parameters:
- vendor

ignoreErrors:
# relax strict rules
- '~^Only booleans are allowed in .+, .+ given( on the (left|right) side)?\.~'
- '~^Variable (static )?(property access|method call) on .+\.~'
- '~^Variable variables are not allowed.~'
- '~^Variable .* might not be defined\.~'
- '~Call to function array_filter\(\) requires parameter #2 to be passed to avoid loose comparison semantics.~'
# relax strict rules - move to phpstan baseline once almost all l6 errors are fixed
- '~^Dynamic call to static method .+\.~' # TODO in https://github.com/roundcube/roundcubemail/pull/9314
- '~^Construct empty\(\) is not allowed\. Use more strict comparison\.~'
- '~^Loose comparison via "[=!]=" is not allowed\.~'
- '~^Casting to .+ something that''s already .+\.~'
- '~^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.~'
- '~^Call to function (array_search|in_array)\(\) requires parameter #3 to be set\.~'
- '~^Call to function base64_decode\(\) requires parameter #2 to be (set|true).~'

# https://github.com/php/pecl-authentication-krb5
-
path: 'program/lib/Roundcube/rcube_imap_generic.php'
Expand Down
4 changes: 2 additions & 2 deletions plugins/managesieve/managesieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function init()
$this->register_action('plugin.managesieve-save', [$this, 'managesieve_save']);
$this->register_action('plugin.managesieve-saveraw', [$this, 'managesieve_saveraw']);

$task = $this->rc->task ?? null;
$action = $this->rc->action ?? null;
$task = $this->rc->task ?? null; // @phpstan-ignore-line
$action = $this->rc->action ?? null; // @phpstan-ignore-line

if ($task == 'settings') {
$this->add_hook('settings_actions', [$this, 'settings_actions']);
Expand Down
1 change: 1 addition & 0 deletions program/actions/contacts/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function run($args = [])
foreach ($cids as $source => $cid) {
$CONTACTS = self::contact_source($source);

// @phpstan-ignore-next-line
if ($CONTACTS->readonly && empty($CONTACTS->deletable)) {
// more sources? do nothing, probably we have search results from
// more than one source, some of these sources can be readonly
Expand Down
1 change: 1 addition & 0 deletions program/actions/contacts/move.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function run($args = [])
break;
}

// @phpstan-ignore-next-line
if (!$CONTACTS || !$CONTACTS->ready || ($CONTACTS->readonly && empty($CONTACTS->deletable))) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions program/actions/contacts/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public static function process_input()

foreach ($subtypes as $i => $subtype) {
$suffix = $subtype ? ":{$subtype}" : '';
// @phpstan-ignore-next-line
if (!empty($values[$i])) {
$record[$col . $suffix][] = $values[$i];
}
Expand Down
2 changes: 1 addition & 1 deletion program/actions/mail/compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ public static function save_attachment($message, $pid, $compose_id, $params = []
$filename = !empty($params['filename']) ? $params['filename'] : self::attachment_name($part);
} elseif ($message instanceof rcube_message) {
// the whole message requested
$size = $message->size ?? null;
$size = $message->size ?? null; // @phpstan-ignore-line
$mimetype = 'message/rfc822';
$filename = !empty($params['filename']) ? $params['filename'] : 'message_rfc822.eml';
} elseif (is_string($message)) {
Expand Down
2 changes: 1 addition & 1 deletion program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class rcmail extends rcube
public $oauth;

/** @var rcmail_output_cli|rcmail_output_html|rcmail_output_json|null Output handler */
public $output;
public $output; // @phpstan-ignore-line

private $address_books = [];
private $action_args = [];
Expand Down
1 change: 1 addition & 0 deletions program/include/rcmail_sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ public function deliver_message($message, $disconnect = true)
return false;
}

// @phpstan-ignore-next-line
if ($mailbody_file) {
$this->temp_files[$message->headers()['Message-ID']] = $mailbody_file;
}
Expand Down
1 change: 1 addition & 0 deletions program/lib/Roundcube/rcube.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ public function text_exists($name, $domain = null, &$ref_domain = null)

// any of loaded domains (plugins)
if ($domain == '*') {
// @phpstan-ignore-next-line
foreach ($this->plugins->loaded_plugins() as $domain) {
if (isset($this->texts[$domain . '.' . $name])) {
$ref_domain = $domain;
Expand Down

0 comments on commit 1b91c1e

Please sign in to comment.