Skip to content

Commit

Permalink
Merge branch 'add-phpstan-config-and-some-fixes' into 3.x
Browse files Browse the repository at this point in the history
Closes #2505
  • Loading branch information
akrabat committed Nov 25, 2018
2 parents 25da5eb + 6267d67 commit 8caa5c7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -14,12 +14,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 ; fi

after_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then php vendor/bin/coveralls --coverage_clover=clover.xml -v ; fi
Expand Down
1 change: 1 addition & 0 deletions Slim/App.php
Expand Up @@ -9,6 +9,7 @@
namespace Slim;

use Exception;
use Psr\Http\Message\UriInterface;
use Slim\Exception\InvalidMethodException;
use Slim\Http\Response;
use Throwable;
Expand Down
20 changes: 10 additions & 10 deletions Slim/Container.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Slim/Handlers/AbstractError.php
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/UploadedFile.php
Expand Up @@ -85,7 +85,7 @@ public static function createFromEnvironment(Environment $env)
{
if (is_array($env['slim.files']) && $env->has('slim.files')) {
return $env['slim.files'];
} elseif (isset($_FILES)) {
} elseif (! empty($_FILES)) {
return static::parseUploadedFiles($_FILES);
}

Expand Down
2 changes: 1 addition & 1 deletion Slim/Interfaces/RouterInterface.php
Expand Up @@ -75,7 +75,7 @@ public function popGroup();
public function getNamedRoute($name);

/**
* @param $identifier
* @param string $identifier
*
* @return \Slim\Interfaces\RouteInterface
*/
Expand Down
7 changes: 5 additions & 2 deletions Slim/Router.php
Expand Up @@ -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++;

Expand Down Expand Up @@ -335,7 +336,8 @@ public function popGroup()
}

/**
* @param $identifier
*
* @param string $identifier
* @return \Slim\Interfaces\RouteInterface
*/
public function lookupRoute($identifier)
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
@@ -0,0 +1,2 @@
parameters:
level: 1

0 comments on commit 8caa5c7

Please sign in to comment.