Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Add phpstan level 1 analysis #9873

Closed
wants to merge 1 commit into from
Closed

NEW: Add phpstan level 1 analysis #9873

wants to merge 1 commit into from

Conversation

sminnee
Copy link
Member

@sminnee sminnee commented Feb 25, 2021

This is a really simple level of phpstan execution, but can pass with
a relatively small commit.

It will be included in the build if silverstripe/silverstripe-travis-shared#12 is merged (done)

This is a really simple level of phpstan execution, but can pass with
a relative small commit.
@sminnee sminnee requested a review from chillu February 25, 2021 22:38
Copy link
Member Author

@sminnee sminnee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a few explanatory notews

@@ -397,8 +397,6 @@ public function getViewer($action)
$templates = $this->templates[$action];
} elseif (isset($this->templates['index']) && $this->templates['index']) {
$templates = $this->templates['index'];
} elseif ($this->template) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable isn't defined. In theory people could define it in a subclass, but it's far from being a published API. This code goes back to the project's inception and I think it's an oversight.

In Security.php, private static $template is defined, which does not populate this variable - it's used as a config var. Notably, this code on PHP 7.4 failed to print HELLO

<?php

class A {
  function foo() {
    return $this->template;
  }
}

class B extends A {
  static $template = 'HELLO';
}

echo (new B())->foo();

In my view, removing this isn't a breaking change, but it's moderately controversial. As an alternative I would add a /** @phpstan-ignore-next-line */ flag; attempting to define template breaks other things.

@@ -30,38 +30,7 @@ class DebugView
private static $columns = 100;

protected static $error_types = [
0 => [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values aren't being used anywhere, only the errno-mapped ones are. And 2 conflicted with E_USER_WARNING

@sminnee sminnee closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant