From 15ac079a8134a8d9b66f45f1da638ae0d4c91dad Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 3 Aug 2019 14:03:04 +0530 Subject: [PATCH 1/2] Bump up phpstan checks to level 4. --- .gitlab-ci.yml | 2 +- phpstan.neon | 4 ++++ src/OAuth2/Provider/Vimeo.php | 6 ++++-- src/OpenID/AbstractProvider.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 phpstan.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7859d1868..fd8b1364c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ phpstan: image: registry.gitlab.com/socialconnect-php/auth:7.3 script: - composer install -o - - ./vendor/bin/phpstan.phar analyse src/ tests/ --no-progress --level 2 + - ./vendor/bin/phpstan.phar analyse src/ tests/ --no-progress tags: - docker diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..deae8eef4 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 4 + ignoreErrors: + - '#should return SocialConnect\\Common\\Entity\\User but returns object#' diff --git a/src/OAuth2/Provider/Vimeo.php b/src/OAuth2/Provider/Vimeo.php index 75461018f..2eaf9dd76 100644 --- a/src/OAuth2/Provider/Vimeo.php +++ b/src/OAuth2/Provider/Vimeo.php @@ -73,8 +73,10 @@ public function parseToken(string $body) 'name' => 'fullname', ]); - $this->user = $hydrator->hydrate(new User(), $response['user']); - $this->user->id = str_replace('/users/', '', $this['user']['uri']); + /** @var \SocialConnect\Common\Entity\User $user */ + $user = $hydrator->hydrate(new User(), $response['user']); + $this->user = $user; + $this->user->id = str_replace('/users/', '', $response['user']['uri']); $token->setUserId((string) $this->user->id); } diff --git a/src/OpenID/AbstractProvider.php b/src/OpenID/AbstractProvider.php index c07357094..2e4c812eb 100644 --- a/src/OpenID/AbstractProvider.php +++ b/src/OpenID/AbstractProvider.php @@ -72,7 +72,7 @@ protected function discover(string $url) $xml = new \SimpleXMLElement($response->getBody()->getContents()); $this->version = 2; - $this->loginEntrypoint = $xml->XRD->Service->URI; + $this->loginEntrypoint = (string)$xml->XRD->Service->URI; return $this->getOpenIdUrl(); } From 40f7ad98e83c2dfb4d7bf4546180a424b5a37812 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 3 Aug 2019 19:32:59 +0530 Subject: [PATCH 2/2] Update travis config. Add separate jobs for phpcs and phpstan checks. --- .travis.yml | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7081be264..dd864012f 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,10 @@ - dist: trusty sudo: false +env: + global: + - DEFAULT=1 + language: php php: @@ -9,18 +12,31 @@ php: - 7.2 - 7.3 +matrix: + fast_finish: true + + include: + - php: 7.3 + env: DEFAULT=0 STATIC_ANALYSIS=1 + + - php: 7.3 + env: DEFAULT=0 PHPCS=1 + install: - - composer self-update - composer --prefer-dist install script: - - ./vendor/bin/phpcs --standard=PSR2 --report=emacs --extensions=php --warning-severity=0 src/ tests/Test - - 'if [ {$TRAVIS_PHP_VERSION} = "7.3" ]; then - ./vendor/bin/phpunit --process-isolation -v --debug --coverage-clover=coverage.clover; - else - ./vendor/bin/phpunit -v --debug --no-coverage; - fi' + - if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == "7.3" ]]; then vendor/bin/phpunit --process-isolation -v --debug --coverage-clover=coverage.clover; fi + - if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION != "7.3" ]]; then vendor/bin/phpunit -v --debug --no-coverage; fi + - if [[ $PHPCS == 1 ]]; then vendor/bin/phpcs --standard=PSR2 --report=emacs --extensions=php --warning-severity=0 src/ tests/Test; fi + - if [[ $STATIC_ANALYSIS == 1 ]]; then vendor/bin/phpstan.phar analyse src/ tests/; fi after_script: - - if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi + - | + if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == "7.3" ]]; then + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover + fi + +notifications: + email: false \ No newline at end of file