Skip to content

Commit b8d4cee

Browse files
Support newer PHP versions
1 parent fd04b27 commit b8d4cee

17 files changed

+400
-357
lines changed

.gitattributes

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# Path-based git attributes
2-
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3-
4-
# Ignore all test and documentation with "export-ignore".
5-
/.gitattributes export-ignore
6-
/.gitignore export-ignore
7-
/.travis.yml export-ignore
8-
/phpunit.xml.dist export-ignore
9-
/tests export-ignore
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.php-cs-fixer.dist.php export-ignore
4+
/.travis.yml export-ignore
5+
/phpunit.xml.dist export-ignore
6+
/tests export-ignore

.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [Nyholm, GrahamCampbell]
2+
tidelift: "packagist/guzzlehttp/oauth-subscriber"

.github/stale.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
daysUntilStale: 120
2+
daysUntilClose: 14
3+
exemptLabels:
4+
- lifecycle/keep-open
5+
- lifecycle/ready-for-merge
6+
# Label to use when marking an issue as stale
7+
staleLabel: lifecycle/stale
8+
# Comment to post when marking an issue as stale. Set to `false` to disable
9+
markComment: >
10+
This issue has been automatically marked as stale because it has not had
11+
recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you
12+
for your contributions.
13+
# Comment to post when closing a stale issue. Set to `false` to disable
14+
closeComment: false

.github/workflows/ci.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
pull_request:
7+
8+
jobs:
9+
build-lowest-version:
10+
name: Build lowest version
11+
runs-on: ubuntu-22.04
12+
13+
steps:
14+
- name: Set up PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '7.2'
18+
ini-values: error_reporting=E_ALL
19+
coverage: 'none'
20+
extensions: mbstring
21+
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Install dependencies
26+
run: composer update --no-interaction --prefer-stable --prefer-lowest --no-progress
27+
28+
- name: Run tests
29+
run: make test
30+
31+
build:
32+
name: Build
33+
runs-on: ubuntu-22.04
34+
strategy:
35+
max-parallel: 10
36+
matrix:
37+
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
38+
39+
steps:
40+
- name: Set up PHP
41+
uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: ${{ matrix.php }}
44+
ini-values: error_reporting=E_ALL
45+
coverage: 'none'
46+
extensions: mbstring
47+
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Install dependencies
52+
run: composer update --no-interaction --no-progress
53+
54+
- name: Run tests
55+
run: make test

.github/workflows/static.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
php-cs-fixer:
13+
name: PHP-CS-Fixer
14+
runs-on: ubuntu-22.04
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '7.4'
24+
coverage: none
25+
extensions: mbstring
26+
27+
- name: Download dependencies
28+
run: composer update --no-interaction --no-progress
29+
30+
- name: Download PHP CS Fixer
31+
run: composer bin php-cs-fixer update --no-interaction --no-progress
32+
33+
- name: Execute PHP CS Fixer
34+
run: vendor/bin/php-cs-fixer fix --diff --dry-run

.gitignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.idea
2-
.DS_STORE
3-
coverage
4-
phpunit.xml
1+
.php-cs-fixer.php
2+
.php-cs-fixer.cache
3+
.phpunit.result.cache
4+
build
55
composer.lock
6-
vendor/
6+
vendor
7+
phpunit.xml

.php-cs-fixer.dist.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$config = (new PhpCsFixer\Config())
4+
->setRiskyAllowed(true)
5+
->setRules([
6+
'@PHP71Migration:risky' => true,
7+
'@PHPUnit75Migration:risky' => true,
8+
'@PSR12:risky' => true,
9+
'@Symfony' => true,
10+
'global_namespace_import' => false,
11+
'no_superfluous_phpdoc_tags' => [
12+
'allow_mixed' => true,
13+
],
14+
'phpdoc_annotation_without_dot' => false,
15+
'phpdoc_summary' => false,
16+
'phpdoc_to_comment' => false,
17+
'single_line_throw' => false,
18+
'yoda_style' => false,
19+
])
20+
->setFinder(
21+
PhpCsFixer\Finder::create()
22+
->in(__DIR__.'/src')
23+
->in(__DIR__.'/tests')
24+
->name('*.php')
25+
)
26+
;
27+
28+
return $config;

.travis.yml

-35
This file was deleted.

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 0.7.0 - UPCOMING
4+
5+
* Dropped support for HHVM and PHP <7.2.5
6+
* Added support for PHP 8.1, 8.2, 8.3, 8.4
7+
38
## 0.6.0 - 2021-07-13
49

510
* Added support for `guzzlehttp/psr7:^2.0`

LICENSE

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling <[email protected]>
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Michael Dowling <[email protected]>
4+
Copyright (c) 2020 Graham Campbell <[email protected]>
25

36
Permission is hereby granted, free of charge, to any person obtaining a copy
47
of this software and associated documentation files (the "Software"), to deal

README.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Guzzle OAuth Subscriber
2+
3+
Signs HTTP requests using OAuth 1.0. Requests are signed using a
4+
consumer key, consumer secret, OAuth token, and OAuth secret.
5+
6+
This version only works with Guzzle 7.9 and up!
7+
8+
## Installing
9+
10+
This project can be installed using Composer. Add the following to your
11+
`composer.json`:
12+
13+
```json
14+
{
15+
"require": {
16+
"guzzlehttp/oauth-subscriber": "^0.7"
17+
}
18+
}
19+
```
20+
21+
## Using the Subscriber
22+
23+
Here's an example showing how to send an authenticated request to the
24+
Twitter REST API:
25+
26+
```php
27+
use GuzzleHttp\Client;
28+
use GuzzleHttp\HandlerStack;
29+
use GuzzleHttp\Subscriber\Oauth\Oauth1;
30+
31+
$stack = HandlerStack::create();
32+
33+
$middleware = new Oauth1([
34+
'consumer_key' => 'my_key',
35+
'consumer_secret' => 'my_secret',
36+
'token' => 'my_token',
37+
'token_secret' => 'my_token_secret',
38+
]);
39+
$stack->push($middleware);
40+
41+
$client = new Client([
42+
'base_uri' => 'https://api.twitter.com/1.1/',
43+
'handler' => $stack,
44+
]);
45+
46+
// Set the "auth" request option to "oauth" to sign using oauth
47+
$res = $client->get('statuses/home_timeline.json', ['auth' => 'oauth']);
48+
```
49+
50+
You can set the `auth` request option to `oauth` for all requests sent
51+
by the client by extending the array you feed to `new Client` with auth
52+
=> oauth.
53+
54+
```php
55+
use GuzzleHttp\Client;
56+
use GuzzleHttp\HandlerStack;
57+
use GuzzleHttp\Subscriber\Oauth\Oauth1;
58+
59+
$stack = HandlerStack::create();
60+
61+
$middleware = new Oauth1([
62+
'consumer_key' => 'my_key',
63+
'consumer_secret' => 'my_secret',
64+
'token' => 'my_token',
65+
'token_secret' => 'my_token_secret',
66+
]);
67+
$stack->push($middleware);
68+
69+
$client = new Client([
70+
'base_uri' => 'https://api.twitter.com/1.1/',
71+
'handler' => $stack,
72+
'auth' => 'oauth',
73+
]);
74+
75+
// Now you don't need to add the auth parameter
76+
$res = $client->get('statuses/home_timeline.json');
77+
```
78+
79+
You can set the `token` and `token_secret` options to an empty string to
80+
use two-legged OAuth.
81+
82+
## Using the RSA-SH1 signature method
83+
84+
```php
85+
use GuzzleHttp\Subscriber\Oauth\Oauth1;
86+
87+
$stack = HandlerStack::create();
88+
89+
$middleware = new Oauth1([
90+
'consumer_key' => 'my_key',
91+
'consumer_secret' => 'my_secret',
92+
'private_key_file' => 'my_path_to_private_key_file',
93+
'private_key_passphrase' => 'my_passphrase',
94+
'signature_method' => Oauth1::SIGNATURE_METHOD_RSA,
95+
]);
96+
$stack->push($middleware);
97+
98+
$client = new Client([
99+
'handler' => $stack,
100+
]);
101+
102+
$response = $client->get('https://httpbin.org/', ['auth' => 'oauth']);
103+
```

0 commit comments

Comments
 (0)