diff --git a/.travis.yml b/.travis.yml index f02f6a3ac..2ef231296 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,14 @@ php: before_script: - if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then composer require satooshi/php-coveralls:1.* squizlabs/php_codesniffer:2.* -n ; fi + - if [[ "$TRAVIS_PHP_VERSION" == '7.1' ]]; then composer require phpstan/phpstan:^0.10.3 -n ; fi - if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then composer install -n ; fi script: - if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi - if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then vendor/bin/phpunit ; fi - if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpcs ; fi + - if [[ "$TRAVIS_PHP_VERSION" == '7.1' ]]; then vendor/bin/phpstan analyse Slim -l 1 || true ; fi after_script: - if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then php vendor/bin/coveralls --coverage_clover=clover.xml -v ; fi diff --git a/Slim/Container.php b/Slim/Container.php index 1f713ac4e..8d7cefe26 100644 --- a/Slim/Container.php +++ b/Slim/Container.php @@ -31,16 +31,16 @@ * - notAllowedHandler: a callable with the signature: function($request, $response, $allowedHttpMethods) * - callableResolver: an instance of \Slim\Interfaces\CallableResolverInterface * - * @property-read array settings - * @property-read \Slim\Interfaces\Http\EnvironmentInterface environment - * @property-read \Psr\Http\Message\ServerRequestInterface request - * @property-read \Psr\Http\Message\ResponseInterface response - * @property-read \Slim\Interfaces\RouterInterface router - * @property-read \Slim\Interfaces\InvocationStrategyInterface foundHandler - * @property-read callable errorHandler - * @property-read callable notFoundHandler - * @property-read callable notAllowedHandler - * @property-read \Slim\Interfaces\CallableResolverInterface callableResolver + * @property-read array $settings + * @property-read \Slim\Interfaces\Http\EnvironmentInterface $environment + * @property-read \Psr\Http\Message\ServerRequestInterface $request + * @property-read \Psr\Http\Message\ResponseInterface $response + * @property-read \Slim\Interfaces\RouterInterface $router + * @property-read \Slim\Interfaces\InvocationStrategyInterface $foundHandler + * @property-read callable $errorHandler + * @property-read callable $notFoundHandler + * @property-read callable $notAllowedHandler + * @property-read \Slim\Interfaces\CallableResolverInterface $callableResolver */ class Container extends PimpleContainer implements ContainerInterface { diff --git a/Slim/Handlers/AbstractError.php b/Slim/Handlers/AbstractError.php index 42f8dde3d..90bdcdef3 100644 --- a/Slim/Handlers/AbstractError.php +++ b/Slim/Handlers/AbstractError.php @@ -90,7 +90,7 @@ protected function renderThrowableAsText($throwable) /** * Wraps the error_log function so that this can be easily tested * - * @param $message + * @param string $message */ protected function logError($message) { diff --git a/Slim/Interfaces/RouterInterface.php b/Slim/Interfaces/RouterInterface.php index 2ab8b678f..4803c128c 100644 --- a/Slim/Interfaces/RouterInterface.php +++ b/Slim/Interfaces/RouterInterface.php @@ -75,7 +75,7 @@ public function popGroup(); public function getNamedRoute($name); /** - * @param $identifier + * @param string $identifier * * @return \Slim\Interfaces\RouteInterface */ diff --git a/Slim/Router.php b/Slim/Router.php index 83116288c..491727024 100644 --- a/Slim/Router.php +++ b/Slim/Router.php @@ -167,8 +167,9 @@ public function map($methods, $pattern, $handler) // According to RFC methods are defined in uppercase (See RFC 7231) $methods = array_map("strtoupper", $methods); - // Add route + /** @var \Slim\Route */ $route = $this->createRoute($methods, $pattern, $handler); + // Add route $this->routes[$route->getIdentifier()] = $route; $this->routeCounter++; @@ -335,7 +336,8 @@ public function popGroup() } /** - * @param $identifier + * + * @param string $identifier * @return \Slim\Interfaces\RouteInterface */ public function lookupRoute($identifier) @@ -371,6 +373,7 @@ public function relativePathFor($name, array $data = [], array $queryParams = [] $routeDatas = array_reverse($routeDatas); $segments = []; + $segmentName = ''; foreach ($routeDatas as $routeData) { foreach ($routeData as $item) { if (is_string($item)) { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..8006892a0 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + ignoreErrors: +# - '#Parameter \$to of method Slim\\App::redirect\(\) has invalid typehint type Slim\\UriInterface#' +# - '#Variable \$_FILES in isset\(\) always exists and is not nullable#'