Skip to content

Commit 6b8195e

Browse files
authored
Merge pull request #96 from microsoftgraph/dev
Release 2.0.0-RC7
2 parents bb61bcd + eb0d71b commit 6b8195e

34 files changed

+569
-277
lines changed

.github/workflows/pr-validation.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ defaults:
1818
jobs:
1919
validate-pull-request:
2020
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
php-versions: ['7.4', '8.0', '8.1', '8.2']
2124
steps:
22-
- uses: actions/checkout@v3.3.0
25+
- uses: actions/checkout@v3.5.2
2326
with:
2427
submodules: 'true'
2528
- name: Setup PHP and Xdebug for Code Coverage report
2629
uses: shivammathur/setup-php@v2
2730
with:
28-
php-version: '7.4'
31+
php-version: ${{ matrix.php-versions }}
2932
coverage: xdebug
3033
- name: Validate composer file
3134
run: |
@@ -34,8 +37,15 @@ jobs:
3437
run: |
3538
composer install
3639
- name: Run tests
37-
run : |
38-
vendor/bin/phpunit --coverage-text
40+
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
41+
- name: Fix code coverage paths
42+
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
43+
- name: SonarCloud Scan
44+
if: ${{ matrix.php-versions == '8.0' }}
45+
uses: SonarSource/sonarcloud-github-action@master
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3949
- name: Run static analysis
4050
run: |
4151
vendor/bin/phpstan analyse --memory-limit=500M --error-format=github

.github/workflows/tag-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
create-tag:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v3.3.0
21+
- uses: actions/checkout@v3.5.2
2222

2323
- name: Get SDK version and set environment variable
2424
run: |

.github/workflows/update-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run-php-documentor:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3.3.0
18+
- uses: actions/checkout@v3.5.2
1919
with:
2020
ref: ${{ github.ref }}
2121

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Get started with the Microsoft Graph Core SDK for PHP
22

33
[![Latest Stable Version](https://poser.pugx.org/microsoft/microsoft-graph-core/version)](https://packagist.org/packages/microsoft/microsoft-graph-core)
4+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=microsoftgraph_msgraph-sdk-php-core&metric=coverage)](https://sonarcloud.io/dashboard?id=microsoftgraph_msgraph-sdk-php-core)
45

56
## Install the Core Library
67
To install the `microsoft-graph-core` library with Composer, either run `composer require microsoft/microsoft-graph-core`, or edit your `composer.json` file:
78
```
89
{
910
"require": {
10-
"microsoft/microsoft-graph-core": "^2.0.0-RC4"
11+
"microsoft/microsoft-graph-core": "^2.0.0-RC7"
1112
}
1213
}
1314
```

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
],
1414
"require": {
1515
"php": "^8.0 || ^7.4",
16-
"microsoft/kiota-authentication-phpleague": "^0.4.0",
17-
"microsoft/kiota-http-guzzle": "^0.4.0",
18-
"microsoft/kiota-serialization-json": "^0.3.0",
19-
"microsoft/kiota-serialization-text": "^0.3.0",
20-
"microsoft/kiota-abstractions": "^0.4.0",
16+
"microsoft/kiota-authentication-phpleague": "^0.6.0",
17+
"microsoft/kiota-http-guzzle": "^0.6.0",
18+
"microsoft/kiota-serialization-json": "^0.4.0",
19+
"microsoft/kiota-serialization-text": "^0.5.0",
2120
"php-http/httplug": "^2.2",
2221
"php-http/guzzle7-adapter": "^1.0",
2322
"ext-json": "*"

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 3
2+
level: 9
33
polluteScopeWithAlwaysIterableForeach: false
44
polluteScopeWithLoopInitialAssignments: false
55
paths:

sonar-project.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sonar.projectKey=microsoftgraph_msgraph-sdk-php-core
2+
sonar.organization=microsoftgraph2
3+
sonar.php.coverage.reportPaths=coverage.xml
4+
sonar.sources=src/
5+
sonar.tests=tests/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved.
4+
* Licensed under the MIT License. See License in the project root
5+
* for license information.
6+
*/
7+
8+
9+
namespace Microsoft\Graph\Core\Authentication;
10+
11+
12+
use Microsoft\Kiota\Authentication\Oauth\TokenRequestContext;
13+
use Microsoft\Kiota\Authentication\PhpLeagueAccessTokenProvider;
14+
15+
/**
16+
* Class GraphPhpLeagueAccessTokenProvider
17+
*
18+
* Fetches an access token using the PHP League OAuth 2.0 client library while setting default Graph allowed hosts
19+
*
20+
* @package Microsoft\Graph\Core\Authentication
21+
* @copyright 2023 Microsoft Corporation
22+
* @license https://opensource.org/licenses/MIT MIT License
23+
* @link https://developer.microsoft.com/graph
24+
*/
25+
class GraphPhpLeagueAccessTokenProvider extends PhpLeagueAccessTokenProvider
26+
{
27+
/**
28+
* @param TokenRequestContext $tokenRequestContext
29+
* @param array<string> $scopes if left empty, it's set to ["https://[graph national cloud host]/.default"] scope
30+
*/
31+
public function __construct(TokenRequestContext $tokenRequestContext, array $scopes = [])
32+
{
33+
$allowedHosts = ["graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de",
34+
"microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com"];
35+
parent::__construct($tokenRequestContext, $scopes, $allowedHosts);
36+
}
37+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved.
4+
* Licensed under the MIT License. See License in the project root
5+
* for license information.
6+
*/
7+
8+
9+
namespace Microsoft\Graph\Core\Authentication;
10+
11+
use Microsoft\Kiota\Abstractions\Authentication\BaseBearerTokenAuthenticationProvider;
12+
use Microsoft\Kiota\Authentication\Oauth\TokenRequestContext;
13+
14+
/**
15+
* Class GraphPhpLeagueAuthenticationProvider
16+
* @package Microsoft\Graph\Core\Authentication
17+
* @copyright 2023 Microsoft Corporation
18+
* @license https://opensource.org/licenses/MIT MIT License
19+
* @link https://developer.microsoft.com/graph
20+
*/
21+
class GraphPhpLeagueAuthenticationProvider extends BaseBearerTokenAuthenticationProvider
22+
{
23+
/**
24+
* @param TokenRequestContext $tokenRequestContext
25+
* @param array<string> $scopes defaults to ["https://[graph national cloud host]/.default"] scope
26+
*/
27+
public function __construct(TokenRequestContext $tokenRequestContext, array $scopes = [])
28+
{
29+
$accessTokenProvider = new GraphPhpLeagueAccessTokenProvider($tokenRequestContext, $scopes);
30+
parent::__construct($accessTokenProvider);
31+
}
32+
}

src/BaseGraphRequestAdapter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
class BaseGraphRequestAdapter extends GuzzleRequestAdapter
2929
{
3030
/**
31+
* @param GraphTelemetryOption $telemetryOption
3132
* @param AuthenticationProvider|null $authenticationProvider
32-
* @param GraphTelemetryOption|null $telemetryOption
3333
* @param ParseNodeFactory|null $parseNodeFactory
3434
* @param SerializationWriterFactory|null $serializationWriterFactory
3535
* @param Client|null $guzzleClient
3636
*/
37-
public function __construct(?AuthenticationProvider $authenticationProvider = null, ?GraphTelemetryOption $telemetryOption = null, ?ParseNodeFactory $parseNodeFactory = null, ?SerializationWriterFactory $serializationWriterFactory = null, ?Client $guzzleClient = null)
37+
public function __construct(GraphTelemetryOption $telemetryOption,
38+
?AuthenticationProvider $authenticationProvider = null,
39+
?ParseNodeFactory $parseNodeFactory = null,
40+
?SerializationWriterFactory $serializationWriterFactory = null,
41+
?Client $guzzleClient = null)
3842
{
3943
$authenticationProvider = ($authenticationProvider) ?? new AnonymousAuthenticationProvider();
4044
$guzzleClient = ($guzzleClient) ?? GraphClientFactory::setTelemetryOption($telemetryOption)::create();

0 commit comments

Comments
 (0)