Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Start with PSR-1 #1

Merged
merged 28 commits into from
Aug 30, 2018
Merged

Start with PSR-1 #1

merged 28 commits into from
Aug 30, 2018

Conversation

thewilkybarkid
Copy link
Contributor

No description provided.

}

---MESSAGES---
5:1 Class name "foobar" is not in PascalCase format
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example of something that can't be fixed automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be safer to include the name of the check rather than the text, as it’s more stable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Preference @giorgiosironi @stephenwf? Currently have to require "squizlabs/php_codesniffer": "^3.3.1" as one of the wordings changed (it reads Squiz.Classes.ValidClassName.NotCamelCaps if using the name of the check).

Copy link
Member

Choose a reason for hiding this comment

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

I agree the class name in the context of this text should be closer to a published API. The user would still see the human message when running the tool or in other CI builds

Copy link
Member

Choose a reason for hiding this comment

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

It may also output multiple messages for the same line with a non-deterministic order, but the current test cases don't go into that so not needed to cater for it.

Copy link
Member

Choose a reason for hiding this comment

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

The class name may lose some detail about what the object being checked is (Foo class, bar method) but the line numbers make that clear anyway.

<?php

$foo = 'bar';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example of something that can be fixed automatically.

tests/Tests.php Outdated
foreach ($messages as $line => $lineMessages) {
foreach ($lineMessages as $column => $columnMessages) {
foreach ($columnMessages as $data) {
yield "{$line}:{$column} {$data['message']}";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Blergh.

@stephenwf
Copy link

Interesting testing suite 👍 like it

.travis.yml Outdated
- stage: Code Quality
env: CODING_STANDARDS
script:
- vendor/bin/phpcs

Choose a reason for hiding this comment

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

Like the multi-stage builds 👍 Does it automatically build a matrix of no-environment variables and environment variables?

Copy link
Contributor Author

@thewilkybarkid thewilkybarkid Aug 25, 2018

Choose a reason for hiding this comment

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

The normal matrix builds get included in the 'Test' stage.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure how to fit it in, but this stage could actually run in parallel with the rest of Test?

Copy link
Member

Choose a reason for hiding this comment

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

Output of the command seems empty, can it be more verbose when run in CI?

interface Foo
{
public function bar_baz() : void
{
Copy link
Contributor Author

@thewilkybarkid thewilkybarkid Aug 26, 2018

Choose a reason for hiding this comment

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

Turns out this error isn't found by token_get_all() (see 3259c5a).

@thewilkybarkid
Copy link
Contributor Author

Will roll this back to PSR-1 so can merge, while the test cases for PSR-2 are finished.

@thewilkybarkid thewilkybarkid changed the title [WIP] Start with PSR-2 Start with PSR-1 Aug 29, 2018
@@ -0,0 +1,42 @@
sudo: false

language: php
Copy link
Member

Choose a reason for hiding this comment

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

important notice: outsources the maintenance of the PHP environments to Travis CI for the library to be cross-checked across PHP versions

tests/Tests.php Outdated
use function token_get_all;
use const TOKEN_PARSE;

final class Tests extends TestCase
Copy link
Member

Choose a reason for hiding this comment

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

PHPUnit convention would push this class name to be SomethingTest?

tests/Tests.php Outdated
private function createFile(string $filename, string $content) : File
{
if (!ini_get('short_open_tag') && false === strpos($content, '<?php')) {
$this->markTestSkipped('short_open_tag option is disabled');
Copy link
Member

Choose a reason for hiding this comment

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

given these tests should run in a controlled CI environment and are the only ones in the library, $this->fail('...') rather than skip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More meant for running the tests locally.

}

---MESSAGES---
9:1 PSR1.Classes.ClassDeclaration.MultipleClasses
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't trigger Squiz.Classes.ClassFileName.NoMatch because of squizlabs/PHP_CodeSniffer#2140 (and why there's not yet a file-name test for traits).

@thewilkybarkid thewilkybarkid merged commit 26d3fec into libero:master Aug 30, 2018
@thewilkybarkid thewilkybarkid deleted the psr-2 branch August 30, 2018 10:36
@thewilkybarkid thewilkybarkid added this to the 0.1.0 milestone Sep 13, 2018
@thewilkybarkid thewilkybarkid added the feature New feature or request label Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants