Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up phpstan version and fix reported errors. #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tests export-ignore
.scrutinizer.yml export-ignore
phpunit.xml.dist export-ignore
phpmd.xml.dist export-ignore
phpstan.neon export-ignore
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
with:
php-version: '7.4'
coverage: none
tools: cs2pr
tools: cs2pr, phpstan:1.6

- name: Composer Install
run: composer install
Expand All @@ -68,4 +68,4 @@ jobs:

- name: Run phpstan
if: success() || failure()
run: vendor/bin/phpstan.phar analyse src/ tests/ --no-progress --level 2
run: phpstan
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"require-dev": {
"squizlabs/php_codesniffer": "^3.3.2",
"phpunit/phpunit": "^7.5",
"socialconnect/http-client": "^1.0",
"phpstan/phpstan-shim": "^0.11.12"
"socialconnect/http-client": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 5
paths:
- src/
4 changes: 1 addition & 3 deletions src/OAuth1/Provider/Atlassian.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 0 additions & 2 deletions src/OAuth1/Provider/Px500.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public function getName()
*/
public function getIdentity(AccessTokenInterface $accessToken)
{
$this->consumerToken = $accessToken;

$result = $this->request(
'GET',
'users',
Expand Down
2 changes: 0 additions & 2 deletions src/OAuth1/Provider/Trello.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public function getName()
*/
public function getIdentity(AccessTokenInterface $accessToken)
{
$this->consumerToken = $accessToken;

$parameters = [
'key' => $this->consumer->getKey(),
'token' => $accessToken->getToken()
Expand Down
2 changes: 0 additions & 2 deletions src/OAuth1/Provider/Tumblr.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public function getName()
*/
public function getIdentity(AccessTokenInterface $accessToken)
{
$this->consumerToken = $accessToken;

$result = $this->request(
'GET',
'user/info',
Expand Down
2 changes: 0 additions & 2 deletions src/OAuth1/Provider/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function getName()
*/
public function getIdentity(AccessTokenInterface $accessToken)
{
$this->consumerToken = $accessToken;

$result = $this->request(
'GET',
'account/verify_credentials.json',
Expand Down
1 change: 1 addition & 0 deletions src/OAuth1/Signature/MethodRSASHA1.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function getName()
public function buildSignature(string $signatureBase, Consumer $consumer, Token $token)
{
$certificate = openssl_pkey_get_private('file://' . $this->privateKey);
/** @phpstan-ignore-next-line */
$privateKeyId = openssl_pkey_get_private($certificate);

$signature = null;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenID/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/AbstractBaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ protected function createRequest(string $method, string $uri, array $query, arra
$contentLength = mb_strlen($payloadAsString);

$request = $request
->withHeader('Content-Length', $contentLength)
->withHeader('Content-Length', (string)$contentLength)
->withHeader('Content-Type', 'application/x-www-form-urlencoded')
;

Expand Down
3 changes: 3 additions & 0 deletions tests/Test/Provider/ProviderMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Test\Provider;

use SocialConnect\Common\Entity\User;
use SocialConnect\Provider\AbstractBaseProvider;
use SocialConnect\Provider\AccessTokenInterface;

Expand All @@ -17,6 +18,7 @@ class ProviderMock extends AbstractBaseProvider
public function getBaseUri()
{
// TODO: Implement getBaseUri() method.
return '';
}

/**
Expand Down Expand Up @@ -58,6 +60,7 @@ public function makeAuthUrl(): string
public function getIdentity(AccessTokenInterface $accessToken)
{
// TODO: Implement getIdentity() method.
return new User();
}

/**
Expand Down