From 73e84adbe7adac095232a5b0195b56b0502f6207 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Thu, 14 Feb 2019 10:40:15 -0800 Subject: [PATCH] Default HHAST lints --- .travis.sh | 3 ++ composer.json | 3 +- composer.lock | 49 ++++++++++++++++++++++++-- hhast-lint.json | 3 ++ src/Assert.php | 6 ++-- src/Constraint/TraversableContains.php | 1 + 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 hhast-lint.json diff --git a/.travis.sh b/.travis.sh index ed31ee4..ac985ca 100755 --- a/.travis.sh +++ b/.travis.sh @@ -14,3 +14,6 @@ composer install hh_client vendor/bin/hacktest tests/ +if !(hhvm --version | grep -q -- -dev); then + hhvm vendor/bin/hhast-lint +fi diff --git a/composer.json b/composer.json index 7719384..6367a13 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "facebook/difflib": "^1.0.0" }, "require-dev": { - "hhvm/hhvm-autoload": "^2.0" + "hhvm/hhvm-autoload": "^2.0", + "hhvm/hhast": "^4.0" } } diff --git a/composer.lock b/composer.lock index d21e326..c4a48ec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ee0e09660aa6c38460896cc3a20bbbd7", + "content-hash": "5ffa51748645fa1d036ff1f8233c57fe", "packages": [ { "name": "facebook/difflib", @@ -272,7 +272,52 @@ "time": "2019-02-08T23:10:16+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "hhvm/hhast", + "version": "v4.0.1", + "source": { + "type": "git", + "url": "https://github.com/hhvm/hhast.git", + "reference": "f544be3de790b9c4692d1b6b5d73ddbbc38cf4d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hhvm/hhast/zipball/f544be3de790b9c4692d1b6b5d73ddbbc38cf4d3", + "reference": "f544be3de790b9c4692d1b6b5d73ddbbc38cf4d3", + "shasum": "" + }, + "require": { + "facebook/difflib": "^1.0.0", + "facebook/hh-clilib": "^2.0.0", + "hhvm": "^4.0", + "hhvm/hhvm-autoload": "^2.0", + "hhvm/hsl": "^4.0", + "hhvm/type-assert": "^3.1" + }, + "require-dev": { + "facebook/fbexpect": "^2.1.1", + "facebook/hack-codegen": "^4.0", + "hhvm/hacktest": "^1.3" + }, + "bin": [ + "bin/hhast-lint", + "bin/hhast-inspect", + "bin/hhast-migrate" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "time": "2019-02-12T23:29:04+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/hhast-lint.json b/hhast-lint.json new file mode 100644 index 0000000..6a389c6 --- /dev/null +++ b/hhast-lint.json @@ -0,0 +1,3 @@ +{ + "roots": [ "src/", "tests/" ] +} diff --git a/src/Assert.php b/src/Assert.php index 2623592..dc1ec6e 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -60,6 +60,7 @@ public function assertNotSame( } public function assertEquals($expected, $actual, string $message = ''): void { + /* HHAST_IGNORE_ERROR[NoPHPEquality] */ if ($actual == $expected) { return; } @@ -98,6 +99,7 @@ public function assertNotEquals( $actual, string $message = '', ): void { + /* HHAST_IGNORE_ERROR[NoPHPEquality] */ if ($actual != $expected) { return; } @@ -164,7 +166,7 @@ public function assertNotNull($actual, string $message = '') { } public function assertEmpty($actual, string $message = '') { - if (empty($actual) == true) { + if (empty($actual)) { return; } throw new ExpectationFailedException( @@ -177,7 +179,7 @@ public function assertEmpty($actual, string $message = '') { } public function assertNotEmpty($actual, string $message = '') { - if (empty($actual) != true) { + if (empty($actual)) { return; } throw new ExpectationFailedException( diff --git a/src/Constraint/TraversableContains.php b/src/Constraint/TraversableContains.php index a992073..c9e0c11 100644 --- a/src/Constraint/TraversableContains.php +++ b/src/Constraint/TraversableContains.php @@ -19,6 +19,7 @@ public function matches($other): bool { return false; } foreach ($other as $element) { + /* HHAST_IGNORE_ERROR[NoPHPEquality] */ if ($element == $this->value) { return true; }