Skip to content

Conversation

@GabrielAnca
Copy link
Contributor

Why?

The PSR2 convention is followed in all the source files, so why not enforce PSR2 via CI 😃

How?

I added the PHP Code Sniffer validation to the CircleCI build. However, the tests were not compliant.

To make them compliant:

  • I had to add a namespace to each of them
  • After having a namespace, all un-namespaced dependencies (PHPUnit_Framework_TestCase, stdClass and DateTimeImmutable) need to either be imported with an use statement or include a backward slash in front of them.

SeanHealy33
SeanHealy33 previously approved these changes Sep 7, 2018
use GuzzleHttp\Middleware;

class IntercomUsersTest extends PHPUnit_Framework_TestCase
class IntercomUsersTest extends \PHPUnit_Framework_TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

is the \ actually a php convention 😒

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of, in a file with a namespace, if you don't specify the full path, it will look for the classes relative to the current namespace. That means without the slash it would be looking for Intercom\Test\PHPUnit_Framework_TestCase (which of course doesn't exist).

I have added a new commit that imports the external dependency so that we don't need that ugly backslash 😄

btw, PHPUnit 4 is very EOL, the new versions have a proper namespace (use PHPUnit\Framework\TestCase). We should consider upgrading it ⚒

@GabrielAnca GabrielAnca merged commit 6c4905f into master Sep 10, 2018
@GabrielAnca GabrielAnca deleted the ga/add-linting-to-ci branch September 10, 2018 09:58
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.

3 participants