Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Psalm support #277

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

Merged
corpsee merged 8 commits into php-censor:master from panosru:master
Feb 16, 2019
Merged

Psalm support #277

corpsee merged 8 commits into php-censor:master from panosru:master
Feb 16, 2019

Conversation

Copy link
Contributor

@panosru panosru commented Feb 13, 2019

Ref issue #276

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 160 characters

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 155 characters

}

// Template:
// MissingConstructor - src/Plugins/Foobar.php:29:15 - Foo\Bar has an uninitialized variable $this->filesystem, but no constructor
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 142 characters

does not have any issues, instead of an empty json, it returns nothing,
making previous code fail even if the project had no issues.
$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('ERROR: ' . $error['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $error['message'], BuildError::SEVERITY_HIGH, $error['file'], $error['line_from'], $error['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 156 characters

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Only one argument is allowed per line in a multi-line function call

$this->builder->logFailure('INFO: ' . $info['full_message'] . \PHP_EOL);

$this->build->reportError(
$this->builder, self::pluginName(), $info['message'], BuildError::SEVERITY_LOW, $info['file'], $info['line_from'], $info['line_to']
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 151 characters

}

// Template:
// MissingConstructor - src/Plugins/Foobar.php:29:15 - Foo\Bar has an uninitialized variable $this->filesystem, but no constructor
Copy link
Member

@php-censor-bot php-censor-bot Feb 13, 2019

Choose a reason for hiding this comment

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

PHPCS: Line exceeds 120 characters; contains 146 characters

Copy link
Contributor Author

panosru commented Feb 13, 2019
edited
Loading

The only issue with that is that you have to run composer global require vimeo/psalm on your worker manually because of incompatibility issues: #276 (comment)

I haven't yet placed that warning to the docks; I hope you will be able to support me ton fixing the composer.json file to support vimeo/psalm.

I'm gonna fix those code styling issues tomorrow...

Thanks!

Copy link
Member

corpsee commented Feb 13, 2019
edited
Loading

@panosru Awesome work! Thank you. I can review PR by the end of the week when I have more free time.

@corpsee corpsee self-requested a review February 13, 2019 13:48
@corpsee corpsee added this to the Version 1.x.0 (minor) milestone Feb 13, 2019
- Removed metadata storage
.gitignore Outdated

/tests/runtime
!/tests/runtime/.gitkeep
/.idea/
Copy link
Member

Choose a reason for hiding this comment

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

Directory .idea should be in your homedir .gitignore config (for all your projects).

panosru reacted with thumbs up emoji
* Class Psalm
* @package PHPCensor\Plugin
*/
class Psalm extends Plugin implements ZeroConfigPluginInterface
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't use ZeroConfigPluginInterface and zero_config option for this plugin. It will break builds without configuration on PHP5.6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@corpsee Can you please explain a bit more why will break configuration for PHP 5.6?

Copy link
Contributor

Choose a reason for hiding this comment

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

canExecuteOnStage could always return false if PHP < 7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@garas & @corpsee tbh, I did not read the code of PHP Censor, I just focused on the plugin and just took a few things from other plugins as a reference. I can't yet understand the role of ZeroConfigPluginInterface and the canExecuteOnStage and why it will return false and why that will break compatibility, but since you both say so, then what I should use instead of ZeroConfigPluginInterface or what should I do to maintain the compatibility for PHP 5.6 and keep ZeroConfigPluginInterface if that is necessary?

$this->executable = $this->findBinary('psalm');

if (isset($options['zero_config']) && $options['zero_config']) {
$this->allowedWarnings = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I guess It should be:

$this->allowedWarnings = -1;
$this->allowedErrors = -1;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I intentionally placed zero instead of minus one. Minus one will ignore any errors and warnings while 0 will not.

Copy link
Member

corpsee commented Feb 15, 2019
edited
Loading

@panosru I created branch psalm-dep with installed vimeo/psalm (v1.1.9) package for PHP5.6+. If someone wants to use newest version he should install psalm by himself.

With this changes you may keep ZeroConfigPluginInterface for the plugin.

Copy link
Contributor Author

panosru commented Feb 15, 2019

@corpsee from your explanation and the comment on the code I believe that I do not fully understand the role of ZeroConfigPluginInterface. while the name itself is self-explanatory, my question is, why it will break compatibility with PHP 5.6 and what is the difference when using ZeroConfigPluginInterface.

If I should not use ZeroConfigPluginInterface do you recommend me to use another interface instead?

Thanks!

Copy link
Member

corpsee commented Feb 15, 2019
edited
Loading

  1. ZeroConfigPluginInterface assume that PHP Censor have in dependencies list the plugin's binary because it is case for project without any config file (User don't say path for binary clearly).

  2. When you manually add psalm to .php-censor.yml config you know what you are doing. And if Psalm broke the build on PHP5.6 it is your fault. But if you don't have any .php-censor.yml config then default plugins should work fine for all PHP versions.

P.S.: You have 2 variants. You may make plugin non-zero-configurated or you may add psalm package to PHP Censor installation.

panosru reacted with thumbs up emoji

Copy link
Contributor Author

panosru commented Feb 16, 2019

@corpsee Thank you for the explanation! Now I got it! ;)

@corpsee corpsee merged commit a175672 into php-censor:master Feb 16, 2019
Copy link
Member

corpsee commented Feb 16, 2019

@panosru Thanks! 👍

Copy link
Member

corpsee commented Feb 17, 2019

The PR merged to master branch and will be released with next minor version 1.1.0.

panosru reacted with thumbs up emoji

@corpsee corpsee modified the milestones: Version 1.1.0 (minor), 1.1.0 May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@corpsee corpsee corpsee left review comments

@php-censor-bot php-censor-bot php-censor-bot left review comments

+1 more reviewer

@garas garas garas left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Projects
None yet
Milestone
1.1.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /