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

Commit cec193f

Browse files
committed
Use PHPStan for static analysis
1 parent 04cff83 commit cec193f

File tree

10 files changed

+28
-12
lines changed

10 files changed

+28
-12
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
"codestyle:fix": [
4646
"vendor/bin/php-cs-fixer fix --diff || exit 0",
4747
"vendor/bin/phpcbf --standard=PSR2 ./lib/ ./tests/"
48+
],
49+
"analyze": [
50+
"vendor/bin/phpstan.phar analyze ./lib ./tests --level 2 -c phpstan.neon --ansi"
4851
]
4952
},
5053
"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/WebDriverByTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class WebDriverByTest extends WebDriverTestCase
2525
{
2626
/**
2727
* @dataProvider textElementsProvider
28-
* @param $webDriverByLocatorMethod
29-
* @param $webDriverByLocatorValue
28+
* @param string $webDriverByLocatorMethod
29+
* @param string $webDriverByLocatorValue
3030
* @param string $expectedText
3131
* @param string $expectedAttributeValue
3232
*/

0 commit comments

Comments
 (0)