Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 139980f

Browse files
authored
Merge pull request #517 from OndraM/feature/phpstan
Use PHPStan for static analysis, lint PHP
2 parents 04cff83 + bc2b2d5 commit 139980f

28 files changed

+69
-68
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ matrix:
7070
- php: 7.1
7171
env: CHECK_CODESTYLE=1
7272
before_script: ~
73-
script: composer codestyle:check
73+
script:
74+
- composer require phpstan/phpstan-shim # Not part of require-dev, because it won't install on PHP 5.6
75+
- composer analyze
76+
- composer codestyle:check
7477
after_script: ~
7578
after_success: ~
7679

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"squizlabs/php_codesniffer": "^2.6",
2525
"php-mock/php-mock-phpunit": "^1.1",
2626
"php-coveralls/php-coveralls": "^2.0",
27-
"symfony/var-dumper": "^3.3 || ^4.0"
27+
"symfony/var-dumper": "^3.3 || ^4.0",
28+
"jakub-onderka/php-parallel-lint": "^0.9.2"
2829
},
2930
"autoload": {
3031
"psr-4": {
@@ -45,6 +46,10 @@
4546
"codestyle:fix": [
4647
"vendor/bin/php-cs-fixer fix --diff || exit 0",
4748
"vendor/bin/phpcbf --standard=PSR2 ./lib/ ./tests/"
49+
],
50+
"analyze": [
51+
"vendor/bin/parallel-lint -j 10 ./lib ./tests",
52+
"vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi"
4853
]
4954
},
5055
"extra": {

lib/Firefox/FirefoxProfile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function setPreference($key, $value)
110110
}
111111

112112
/**
113-
* @param $key
113+
* @param mixed $key
114114
* @return mixed
115115
*/
116116
public function getPreference($key)

lib/Support/Events/EventFiringWebDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function findElement(WebDriverBy $by)
133133
}
134134

135135
/**
136-
* @param $script
136+
* @param string $script
137137
* @param array $arguments
138138
* @throws WebDriverException
139139
* @return mixed
@@ -161,7 +161,7 @@ public function executeScript($script, array $arguments = [])
161161
}
162162

163163
/**
164-
* @param $script
164+
* @param string $script
165165
* @param array $arguments
166166
* @throws WebDriverException
167167
* @return mixed
@@ -396,7 +396,7 @@ protected function newElement(WebDriverElement $element)
396396

397397
/**
398398
* @param mixed $method
399-
* @param mixed $arguments,...
399+
* @param mixed ...$arguments
400400
*/
401401
protected function dispatch($method, ...$arguments)
402402
{

lib/Support/Events/EventFiringWebDriverNavigation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function to($url)
149149

150150
/**
151151
* @param mixed $method
152-
* @param mixed $arguments,...
152+
* @param mixed ...$arguments
153153
*/
154154
protected function dispatch($method, ...$arguments)
155155
{

lib/Support/Events/EventFiringWebElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ protected function dispatchOnException(WebDriverException $exception)
392392

393393
/**
394394
* @param mixed $method
395-
* @param mixed $arguments,...
395+
* @param mixed ...$arguments
396396
*/
397397
protected function dispatch($method, ...$arguments)
398398
{

lib/WebDriverExpectedCondition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function (WebDriver $driver) use ($by) {
213213
if ($element->isDisplayed()) {
214214
$visibleElements[] = $element;
215215
}
216-
} catch (StateElementReferenceException $e) {
216+
} catch (StaleElementReferenceException $e) {
217217
}
218218
}
219219

@@ -399,7 +399,7 @@ function (WebDriver $driver) use ($by) {
399399
/**
400400
* An expectation for checking that an element with text is either invisible or not present on the DOM.
401401
*
402-
* @param WebdriverBy $by The locator used to find the element.
402+
* @param WebDriverBy $by The locator used to find the element.
403403
* @param string $text The text of the element.
404404
* @return WebDriverExpectedCondition<bool> Condition returns whether the text is found in the element located.
405405
*/

lib/WebDriverHasInputDevices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
interface WebDriverHasInputDevices
2222
{
2323
/**
24-
* @return WebDriverKeyBoard
24+
* @return WebDriverKeyboard
2525
*/
2626
public function getKeyboard();
2727

phpstan.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#Class Symfony\\Component\\Process\\ProcessBuilder not found.#'
4+
- '#Instantiated class Symfony\\Component\\Process\\ProcessBuilder not found.#'
5+
- '#Call to method setPrefix\(\) on an unknown class Symfony\\Component\\Process\\ProcessBuilder#'
6+
# To be fixed:
7+
- '#Call to an undefined method RecursiveIteratorIterator::getSubPathName\(\)#'
8+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriver::getTouch\(\)#'
9+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::getCoordinates\(\)#'
10+
- '#Call to an undefined method Facebook\\WebDriver\\WebDriverElement::equals\(\)#'

tests/functional/Chrome/ChromeDriverServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
/**
2121
* @group exclude-saucelabs
22-
* @covers Facebook\WebDriver\Chrome\ChromeDriverService
23-
* @covers Facebook\WebDriver\Remote\Service\DriverService
22+
* @covers \Facebook\WebDriver\Chrome\ChromeDriverService
23+
* @covers \Facebook\WebDriver\Remote\Service\DriverService
2424
*/
2525
class ChromeDriverServiceTest extends TestCase
2626
{

0 commit comments

Comments
 (0)