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

Update Code to newer standards, requiring php 8.1 and fix deprecations #12

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor/
.composer.lock
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7
- 8.1
- 8.2
- 8.3
- hhvm

cache:
Expand All @@ -22,8 +20,7 @@ before_script:
- composer install --dev --prefer-source

script:
- ./vendor/bin/phpunit --coverage-clover=coverage.clover
- ./vendor/bin/phpcs --standard=PSR2 src
- composer check

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.0.0

### Breaking Changes

- PHP 8.1 is now required
- All class properties and function parameters are now typed
- All functions now are properly return typed

### Fixed

- Fixed deprecation warnings of `Creation of dynamic property ... deprecated`
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ without setting anything to get sane defaults.
<?php

// Simple example
$client = Dflydev\Hawk\Client\ClientBuilder::create()
$client = \Dflydev\Hawk\Client\ClientBuilder::create()
->build()
```

Expand All @@ -37,7 +37,7 @@ $client = Dflydev\Hawk\Client\ClientBuilder::create()
<?php

// A complete example
$client = Dflydev\Hawk\Client\ClientBuilder::create()
$client = \Dflydev\Hawk\Client\ClientBuilder::create()
->setCrypto($crypto)
->setTimeProvider($timeProvider)
->setNonceProvider($nonceProvider)
Expand Down Expand Up @@ -142,14 +142,14 @@ $isAuthenticatedResponse = $client->authenticate(
<?php

// Create a set of Hawk credentials
$credentials = new Dflydev\Hawk\Credentials\Credentials(
$credentials = new \Dflydev\Hawk\Credentials\Credentials(
'afe89a3x', // shared key
'sha256', // default: sha256
'12345' // identifier, default: null
);

// Create a Hawk client
$client = Dflydev\Hawk\Client\ClientBuilder::create()
$client = \Dflydev\Hawk\Client\ClientBuilder::create()
->build();

// Create a Hawk request based on making a POST request to a specific URL
Expand Down Expand Up @@ -239,7 +239,7 @@ without setting anything but the credentials provider to get sane defaults.

$credentialsProvider = function ($id) {
if ('12345' === $id) {
return new Dflydev\Hawk\Credentials\Credentials(
return new \Dflydev\Hawk\Credentials\Credentials(
'afe89a3x', // shared key
'sha256', // default: sha256
'12345' // identifier, default: null
Expand All @@ -248,7 +248,7 @@ $credentialsProvider = function ($id) {
};

// Simple example
$server = Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
$server = \Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
->build()
```

Expand All @@ -259,7 +259,7 @@ $server = Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)

$credentialsProvider = function ($id) {
if ('12345' === $id) {
return new Dflydev\Hawk\Credentials\Credentials(
return new \Dflydev\Hawk\Credentials\Credentials(
'afe89a3x', // shared key
'sha256', // default: sha256
'12345' // identifier, default: null
Expand All @@ -268,7 +268,7 @@ $credentialsProvider = function ($id) {
};

// A complete example
$server = Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
$server = \Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
->setCrypto($crypto)
->setTimeProvider($timeProvider)
->setNonceValidator($nonceValidator)
Expand Down Expand Up @@ -307,7 +307,7 @@ try {
'hello world!'
$authorization
);
} catch(Dflydev\Hawk\Server\UnauthorizedException $e) {
} catch(\Dflydev\Hawk\Server\UnauthorizedException $e) {
// If authorization is incorrect (invalid mac, etc.) we can catch an
// unauthorized exception.
throw $e;
Expand Down Expand Up @@ -367,7 +367,7 @@ header(sprintf("%s: %s", $header->fieldName(), $header->fieldValue()));
// Create a simple credentials provider
$credentialsProvider = function ($id) {
if ('12345' === $id) {
return new Dflydev\Hawk\Credentials\Credentials(
return new \Dflydev\Hawk\Credentials\Credentials(
'afe89a3x', // shared key
'sha256', // default: sha256
'12345' // identifier, default: null
Expand All @@ -376,7 +376,7 @@ $credentialsProvider = function ($id) {
};

// Create a Hawk server
$server = Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
$server = \Dflydev\Hawk\Server\ServerBuilder::create($credentialsProvider)
->build()

// Get the authorization header for the request; it should be in the form
Expand All @@ -393,7 +393,7 @@ try {
'hello world!'
$authorization
);
} catch(Dflydev\Hawk\Server\UnauthorizedException $e) {
} catch(\Dflydev\Hawk\Server\UnauthorizedException $e) {
// If authorization is incorrect (invalid mac, etc.) we can catch an
// unauthorized exception.
throw $e;
Expand Down Expand Up @@ -487,7 +487,7 @@ A simple implementation of `CredentialsInterface`.
```php
<?php

$credentials = new Dflydev\Hawk\Credentials\Credentials(
$credentials = new \Dflydev\Hawk\Credentials\Credentials(
$key, // shared key
$algorithm, // default: sha256
$id // identifier, default: null
Expand Down
39 changes: 32 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,46 @@
}
],
"autoload": {
"psr-0": {
"Dflydev\\Hawk": "src"
"psr-4": {
"Dflydev\\Hawk\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Dflydev\\Hawk\\": "tests"
}
},
"require": {
"ircmaxell/random-lib": "^1.0@dev"
"ircmaxell/random-lib": "^1.2",
"php": "^8.1"
},
"require-dev": {
"codeclimate/php-test-reporter": "~0.1@dev",
"phpunit/phpunit": "~4.5",
"squizlabs/php_codesniffer": "~2.3"
"rector/rector": "^1.0",
"roave/security-advisories": "dev-latest",
"phpunit/phpunit": "^11.0",
"squizlabs/php_codesniffer": "^3.9",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1"
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-main": "2.0.x-dev"
}
},
"scripts": {
"check" : [
"@cs-check",
"@phpstan",
"@test"
],
"cs-check" : "phpcs --parallel=50",
"cs-fix" : "phpcbf",
"phpstan": "phpstan analyse",
"rector": [
"rector --config=rector.config.php",
"@cs-fix"
],
"test" : "phpunit"
}
}
Loading