Skip to content

Commit

Permalink
Sync with Contributte standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Nov 15, 2018
1 parent b41faa0 commit 63ae45c
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 87 deletions.
20 changes: 5 additions & 15 deletions .editorconfig
@@ -1,26 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

# Top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true

# JS / PHP
[*.{js,php,phpt}]
charset = utf-8
indent_style = tab
indent_size = 4

# NEON
[*.neon]
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
indent_size = tab
tab_width = 4

# Composer, NPM, Travis, BitbucketPipelines
[{composer.json,package.json,.travis.yml,bitbucket-pipelines.yml}]
[{*.json,*.yml,*.md}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
@@ -0,0 +1,10 @@
# Not archived
.docs export-ignore
tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
README.md export-ignore
ruleset.xml export-ignore
5 changes: 2 additions & 3 deletions .gitignore
Expand Up @@ -6,6 +6,5 @@
/composer.lock

# Tests
/tests/*.log
/tests/tmp
/tests/coverage.html
/temp
/coverage.xml
39 changes: 23 additions & 16 deletions .travis.yml
@@ -1,19 +1,24 @@
language: php
php:
- 7.1
- 7.2
- 7.1
- 7.2
- 7.3

before_install:
# turn off XDebug
# Turn off XDebug
- phpenv config-rm xdebug.ini || return 0

install:
# Composer
- travis_retry composer install --no-progress --prefer-dist

script:
# Nette/Tester
- composer run-script tester
# Tests
- composer run-script tests

after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done

jobs:
include:
Expand All @@ -22,34 +27,36 @@ jobs:
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script tester
- composer run-script tests

- stage: Quality Assurance
php: 7.1
script:
- composer run-script qa

- stage: Phpstan
php: 7.1
script:
- composer run-script phpstan-install
- composer run-script phpstan

- stage: Test Coverage
if: branch = master AND type = push
php: 7.1
script:
- composer run-script coverage
after_script:
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- php coveralls.phar --verbose --config tests/.coveralls.yml
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
- php php-coveralls.phar --verbose --config tests/.coveralls.yml

- stage: Phpstan
- stage: Outdated Dependencies
if: branch = master AND type = cron
php: 7.1
script:
- composer run-script phpstan-install
- composer run-script phpstan
- composer outdated --direct --strict

allow_failures:
- stage: Test Coverage
- stage: Phpstan

after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done

sudo: false

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -7,10 +7,10 @@ Ultra easy-to-use Facebook wrapper for [`Nette Framework`](https://github.com/ne
[![Build Status](https://img.shields.io/travis/contributte/facebook.svg?style=flat-square)](https://travis-ci.org/contributte/facebook)
[![Code coverage](https://img.shields.io/coveralls/contributte/facebook.svg?style=flat-square)](https://coveralls.io/r/contributte/facebook)
[![Licence](https://img.shields.io/packagist/l/contributte/facebook.svg?style=flat-square)](https://packagist.org/packages/contributte/facebook)

[![Downloads this Month](https://img.shields.io/packagist/dm/contributte/facebook.svg?style=flat-square)](https://packagist.org/packages/contributte/facebook)
[![Downloads total](https://img.shields.io/packagist/dt/contributte/facebook.svg?style=flat-square)](https://packagist.org/packages/contributte/facebook)
[![Latest stable](https://img.shields.io/packagist/v/contributte/facebook.svg?style=flat-square)](https://packagist.org/packages/contributte/facebook)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)

## Discussion / Help

Expand Down Expand Up @@ -54,7 +54,7 @@ composer require contributte/facebook
<a href="https://github.com/Vody105">Filip Šuška</a>
</td>
</tr>
<tbody>
</tbody>
</table>

-----
Expand Down
18 changes: 10 additions & 8 deletions composer.json
Expand Up @@ -17,12 +17,12 @@
"require": {
"php": ">= 7.1",
"facebook/graph-sdk": "^5.6",
"nette/http": "^2.4"
"nette/http": "~2.4"
},
"require-dev": {
"ninjify/qa": "^0.6.0",
"ninjify/qa": "^0.8.0",
"ninjify/nunjuck": "^0.2.0",
"nette/di": "^2.4.10"
"nette/di": "~2.4.10"
},
"autoload": {
"psr-4": {
Expand All @@ -34,19 +34,21 @@
"linter src tests",
"codesniffer src tests"
],
"tester": [
"tests": [
"tester -s -p php --colors 1 -C tests/cases"
],
"coverage": [
"tester -s -p php --colors 1 -C -d extension=xdebug.so --coverage ./coverage.xml --coverage-src ./src tests/cases"
"tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/cases"
],
"phpstan-install": [
"mkdir -p temp/phpstan",
"composer require -d temp/phpstan phpstan/phpstan:0.8.5",
"composer require -d temp/phpstan phpstan/phpstan-nette:0.8.3"
"composer require -d temp/phpstan phpstan/phpstan:^0.10",
"composer require -d temp/phpstan phpstan/phpstan-deprecation-rules:^0.10",
"composer require -d temp/phpstan phpstan/phpstan-nette:^0.10",
"composer require -d temp/phpstan phpstan/phpstan-strict-rules:^0.10"
],
"phpstan": [
"temp/phpstan/vendor/bin/phpstan analyse -l 1 -c phpstan.neon src"
"temp/phpstan/vendor/bin/phpstan analyse -l max -c phpstan.neon src"
]
}
}
4 changes: 2 additions & 2 deletions phpstan.neon
@@ -1,5 +1,5 @@
includes:
- temp/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- temp/phpstan/vendor/phpstan/phpstan-nette/extension.neon
- temp/phpstan/vendor/phpstan/phpstan-nette/rules.neon

parameters:
- temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
13 changes: 4 additions & 9 deletions ruleset.xml
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<ruleset name="Contributte">
<!-- Extending rulesets -->
<rule ref="vendor/ninjify/coding-standard/ruleset.xml"/>
<!-- My rules -->
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>

<!-- Specific rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
Expand All @@ -11,12 +12,6 @@
"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants">
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions">
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions.NonFullyQualified"/>
</rule>

<!-- Exclude folders -->
<exclude-pattern>/tests/tmp</exclude-pattern>
Expand Down
13 changes: 5 additions & 8 deletions src/DI/Nette/FacebookExtension.php
Expand Up @@ -10,22 +10,19 @@

/**
* Class FacebookExtension
*
* @author Filip Suska <vody105@gmail.com>
*/
class FacebookExtension extends CompilerExtension
{

/** @var string[] */
/** @var mixed[] */
private $defaults = [
'appId' => NULL,
'appSecret' => NULL,
'defaultGraphVersion' => NULL,
'appId' => null,
'appSecret' => null,
'defaultGraphVersion' => null,
'persistentDataHandler' => 'session',
];

/**
* @return void
* @throws AssertionException
*/
public function loadConfiguration(): void
Expand All @@ -44,7 +41,7 @@ public function loadConfiguration(): void
];

// Facebook has its own default value for default_graph_version
if ($config['defaultGraphVersion'] !== NULL) {
if ($config['defaultGraphVersion'] !== null) {
$appData['default_graph_version'] = $config['defaultGraphVersion'];
}

Expand Down
2 changes: 0 additions & 2 deletions src/Exceptions/FacebookLoginException.php
Expand Up @@ -6,8 +6,6 @@

/**
* Class FacebookException
*
* @author Filip Suska <vody105@gmail.com>
*/
class FacebookLoginException extends RuntimeException
{
Expand Down
4 changes: 0 additions & 4 deletions src/FacebookFactory.php
Expand Up @@ -8,8 +8,6 @@

/**
* Class FacebookFactory
*
* @author Filip Suska <vody105@gmail.com>
*/
class FacebookFactory
{
Expand All @@ -22,7 +20,6 @@ class FacebookFactory

/**
* @param string[] $config
* @param Session $session
*/
public function __construct(array $config, Session $session)
{
Expand All @@ -31,7 +28,6 @@ public function __construct(array $config, Session $session)
}

/**
* @return Facebook
* @throws FacebookSDKException
*/
public function create(): Facebook
Expand Down
16 changes: 2 additions & 14 deletions src/FacebookLogin.php
Expand Up @@ -11,8 +11,6 @@

/**
* Class LoginService
*
* @author Filip Suska <vody105@gmail.com>
*/
class FacebookLogin
{
Expand All @@ -21,7 +19,6 @@ class FacebookLogin
private $facebook;

/**
* @param Facebook $facebook
* @throws FacebookSDKException
*/
public function __construct(Facebook $facebook)
Expand All @@ -32,12 +29,9 @@ public function __construct(Facebook $facebook)
/**
* Creates Response that redirects person to FB for authorization and back
*
* @param string $redirectUrl
* @param string[] $permissions
* @param string|null $stateParam
* @return string
*/
public function getLoginUrl(string $redirectUrl, array $permissions = ['public_profile'], ?string $stateParam = NULL): string
public function getLoginUrl(string $redirectUrl, array $permissions = ['public_profile'], ?string $stateParam = null): string
{
// Create redirect URL with econea return URL
$helper = $this->facebook->getRedirectLoginHelper();
Expand All @@ -55,7 +49,6 @@ public function getLoginUrl(string $redirectUrl, array $permissions = ['public_p
/**
* Gets access token from fb for queried user
*
* @return AccessToken
* @throws FacebookLoginException
*/
public function getAccessToken(): AccessToken
Expand All @@ -68,7 +61,7 @@ public function getAccessToken(): AccessToken

// Failed to get accessToken
if (!isset($accessToken)) {
if ($helper->getError()) {
if ($helper->getError() !== null) {
throw new FacebookLoginException($helper->getError());
} else {
throw new FacebookLoginException('Facebook: Bad request.');
Expand All @@ -84,7 +77,6 @@ public function getAccessToken(): AccessToken
}

/**
* @return AccessToken
* @throws FacebookLoginException
*/
public function getAccessTokenFromCookie(): AccessToken
Expand All @@ -106,9 +98,7 @@ public function getAccessTokenFromCookie(): AccessToken
}

/**
* @param string $accessToken
* @param string[] $fields
* @return GraphUser
*/
public function getMe(string $accessToken, array $fields): GraphUser
{
Expand All @@ -122,8 +112,6 @@ public function getMe(string $accessToken, array $fields): GraphUser
}

/**
* @param AccessToken $accessToken
* @return AccessToken
* @throws FacebookSDKException
*/
private function getLongLifeValidatedToken(AccessToken $accessToken): AccessToken
Expand Down
File renamed without changes.

0 comments on commit 63ae45c

Please sign in to comment.