diff --git a/.gitattributes b/.gitattributes index e1c5eeb5d..98d9b08bf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,4 @@ tests export-ignore .scrutinizer.yml export-ignore phpunit.xml.dist export-ignore phpmd.xml.dist export-ignore +phpstan.neon export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 206d62df6..3e86571b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,4 +68,4 @@ jobs: - name: Run phpstan if: success() || failure() - run: vendor/bin/phpstan.phar analyse src/ tests/ --no-progress --level 2 \ No newline at end of file + run: vendor/bin/phpstan \ No newline at end of file diff --git a/composer.json b/composer.json index a6492194c..b6ee2f5c7 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "squizlabs/php_codesniffer": "^3.3.2", "phpunit/phpunit": "^7.5", "socialconnect/http-client": "^1.0", - "phpstan/phpstan-shim": "^0.11.12" + "phpstan/phpstan": "^0.12.88" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..44f437e74 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + level: 4 + paths: + - src/ + - tests/ + ignoreErrors: + - + message: "#^Method Test\\\\Provider\\\\ProviderMock\\:\\:getAccessTokenByRequestParameters\\(\\) should return SocialConnect\\\\Provider\\\\AccessTokenInterface but return statement is missing\\.$#" + count: 1 + path: tests/Test/Provider/ProviderMock.php diff --git a/src/OAuth1/Provider/Atlassian.php b/src/OAuth1/Provider/Atlassian.php index 802ff0abd..8fffe6ec4 100644 --- a/src/OAuth1/Provider/Atlassian.php +++ b/src/OAuth1/Provider/Atlassian.php @@ -104,11 +104,9 @@ public function __construct(HttpStack $httpStack, SessionInterface $session, arr */ public function getIdentity(AccessTokenInterface $accessToken) { - $this->consumerToken = $accessToken; - $parameters = [ 'oauth_consumer_key' => $this->consumer->getKey(), - 'oauth_token' => $this->consumerToken->getToken(), + 'oauth_token' => $accessToken->getToken(), ]; $response = $this->oauthRequest( diff --git a/src/OAuth1/Provider/Px500.php b/src/OAuth1/Provider/Px500.php index ff42af85c..1470da5a6 100644 --- a/src/OAuth1/Provider/Px500.php +++ b/src/OAuth1/Provider/Px500.php @@ -63,8 +63,6 @@ public function getName() */ public function getIdentity(AccessTokenInterface $accessToken) { - $this->consumerToken = $accessToken; - $result = $this->request( 'GET', 'users', diff --git a/src/OAuth1/Provider/Trello.php b/src/OAuth1/Provider/Trello.php index a1c9113aa..568753e5e 100644 --- a/src/OAuth1/Provider/Trello.php +++ b/src/OAuth1/Provider/Trello.php @@ -62,8 +62,6 @@ public function getName() */ public function getIdentity(AccessTokenInterface $accessToken) { - $this->consumerToken = $accessToken; - $parameters = [ 'key' => $this->consumer->getKey(), 'token' => $accessToken->getToken() diff --git a/src/OAuth1/Provider/Tumblr.php b/src/OAuth1/Provider/Tumblr.php index af48a97a9..c27cca552 100644 --- a/src/OAuth1/Provider/Tumblr.php +++ b/src/OAuth1/Provider/Tumblr.php @@ -63,8 +63,6 @@ public function getName() */ public function getIdentity(AccessTokenInterface $accessToken) { - $this->consumerToken = $accessToken; - $result = $this->request( 'GET', 'user/info', diff --git a/src/OAuth1/Provider/Twitter.php b/src/OAuth1/Provider/Twitter.php index 00263e370..49b59717e 100644 --- a/src/OAuth1/Provider/Twitter.php +++ b/src/OAuth1/Provider/Twitter.php @@ -45,8 +45,6 @@ public function getName() */ public function getIdentity(AccessTokenInterface $accessToken) { - $this->consumerToken = $accessToken; - $result = $this->request( 'GET', 'account/verify_credentials.json', diff --git a/src/OpenID/AbstractProvider.php b/src/OpenID/AbstractProvider.php index bab428294..007cbc4a8 100644 --- a/src/OpenID/AbstractProvider.php +++ b/src/OpenID/AbstractProvider.php @@ -73,7 +73,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(); } diff --git a/tests/Test/Provider/ProviderMock.php b/tests/Test/Provider/ProviderMock.php index 7b4be738f..8374881cf 100644 --- a/tests/Test/Provider/ProviderMock.php +++ b/tests/Test/Provider/ProviderMock.php @@ -6,6 +6,7 @@ namespace Test\Provider; +use SocialConnect\Common\Entity\User; use SocialConnect\Provider\AbstractBaseProvider; use SocialConnect\Provider\AccessTokenInterface; @@ -17,6 +18,7 @@ class ProviderMock extends AbstractBaseProvider public function getBaseUri() { // TODO: Implement getBaseUri() method. + return ''; } /** @@ -58,6 +60,7 @@ public function makeAuthUrl(): string public function getIdentity(AccessTokenInterface $accessToken) { // TODO: Implement getIdentity() method. + return new User(); } /**