-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[PHP] Upgrade php-cs-fixer to 2.12, enables PHP >= 7.2 support #769
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
<?php | ||
|
||
return Symfony\CS\Config::create() | ||
->level(Symfony\CS\FixerInterface::PSR2_LEVEL) | ||
return PhpCsFixer\Config::create() | ||
->setUsingCache(true) | ||
->fixers( | ||
[ | ||
'ordered_use', | ||
'phpdoc_order', | ||
'short_array_syntax', | ||
'strict', | ||
'strict_param' | ||
] | ||
) | ||
->finder( | ||
Symfony\CS\Finder\DefaultFinder::create() | ||
->in(__DIR__) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_order' => true, | ||
'array_syntax' => [ 'syntax' => 'short' ], | ||
'strict_comparison' => true, | ||
'strict_param' => true, | ||
'no_trailing_whitespace' => false, | ||
'no_trailing_whitespace_in_comment' => false, | ||
'braces' => false, | ||
'single_blank_line_at_eof' => false, | ||
'blank_line_after_namespace' => false, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('test') | ||
->exclude('tests') | ||
->in(__DIR__) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/client/petstore-security-test/php/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.1.1-SNAPSHOT | ||
3.2.1-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
return PhpCsFixer\Config::create() | ||
->setUsingCache(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_order' => true, | ||
'array_syntax' => [ 'syntax' => 'short' ], | ||
'strict_comparison' => true, | ||
'strict_param' => true, | ||
'no_trailing_whitespace' => false, | ||
'no_trailing_whitespace_in_comment' => false, | ||
'braces' => false, | ||
'single_blank_line_at_eof' => false, | ||
'blank_line_after_namespace' => false, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('test') | ||
->exclude('tests') | ||
->in(__DIR__) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: php | ||
sudo: false | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
before_install: "composer install" | ||
script: "vendor/bin/phpunit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# OpenAPIClient-php | ||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- | ||
|
||
This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: | ||
|
||
- API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r | ||
- Build package: org.openapitools.codegen.languages.PhpClientCodegen | ||
|
||
## Requirements | ||
|
||
PHP 5.5 and later | ||
|
||
## Installation & Usage | ||
### Composer | ||
|
||
To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: | ||
|
||
``` | ||
{ | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" | ||
} | ||
], | ||
"require": { | ||
"GIT_USER_ID/GIT_REPO_ID": "*@dev" | ||
} | ||
} | ||
``` | ||
|
||
Then run `composer install` | ||
|
||
### Manual Installation | ||
|
||
Download the files and include `autoload.php`: | ||
|
||
```php | ||
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php'); | ||
``` | ||
|
||
## Tests | ||
|
||
To run the unit tests: | ||
|
||
``` | ||
composer install | ||
./vendor/bin/phpunit | ||
``` | ||
|
||
## Getting Started | ||
|
||
Please follow the [installation procedure](#installation--usage) and then run the following: | ||
|
||
```php | ||
<?php | ||
require_once(__DIR__ . '/vendor/autoload.php'); | ||
|
||
$apiInstance = new OpenAPI\Client\Api\FakeApi( | ||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. | ||
// This is optional, `GuzzleHttp\Client` will be used as default. | ||
new GuzzleHttp\Client() | ||
); | ||
$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE | | ||
|
||
try { | ||
$apiInstance->testCodeInjectEndRnNR($unknown_base_type); | ||
} catch (Exception $e) { | ||
echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; | ||
} | ||
|
||
?> | ||
``` | ||
|
||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*FakeApi* | [**testCodeInjectEndRnNR**](docs/Api/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
|
||
## Documentation For Models | ||
|
||
- [ModelReturn](docs/Model/ModelReturn.md) | ||
|
||
|
||
## Documentation For Authorization | ||
|
||
|
||
## api_key | ||
|
||
- **Type**: API key | ||
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r | ||
- **Location**: HTTP header | ||
|
||
## petstore_auth | ||
|
||
- **Type**: OAuth | ||
- **Flow**: implicit | ||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog | ||
- **Scopes**: | ||
- **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r | ||
- **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
|
||
## Author | ||
|
||
[email protected] *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "GIT_USER_ID/GIT_REPO_ID", | ||
"description": "", | ||
"keywords": [ | ||
"openapitools", | ||
"openapi-generator", | ||
"php", | ||
"sdk", | ||
"rest", | ||
"api" | ||
], | ||
"homepage": "http://openapi-generator.tech", | ||
"license": "proprietary", | ||
"authors": [ | ||
{ | ||
"name": "OpenAPI-Generator contributors", | ||
"homepage": "https://openapi-generator.tech" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5", | ||
"ext-curl": "*", | ||
"ext-json": "*", | ||
"ext-mbstring": "*", | ||
"guzzlehttp/guzzle": "^6.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^4.8", | ||
"squizlabs/php_codesniffer": "~2.6", | ||
"friendsofphp/php-cs-fixer": "~2.12" | ||
}, | ||
"autoload": { | ||
"psr-4": { "OpenAPI\\Client\\" : "lib/" } | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { "OpenAPI\\Client\\" : "test/" } | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
samples/client/petstore-security-test/php/docs/Api/FakeApi.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# OpenAPI\Client\FakeApi | ||
|
||
All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**testCodeInjectEndRnNR**](FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
|
||
# **testCodeInjectEndRnNR** | ||
> testCodeInjectEndRnNR($unknown_base_type) | ||
|
||
To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | ||
|
||
### Example | ||
```php | ||
<?php | ||
require_once(__DIR__ . '/vendor/autoload.php'); | ||
|
||
$apiInstance = new OpenAPI\Client\Api\FakeApi( | ||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. | ||
// This is optional, `GuzzleHttp\Client` will be used as default. | ||
new GuzzleHttp\Client() | ||
); | ||
$unknown_base_type = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE | | ||
|
||
try { | ||
$apiInstance->testCodeInjectEndRnNR($unknown_base_type); | ||
} catch (Exception $e) { | ||
echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
``` | ||
|
||
### Parameters | ||
|
||
Name | Type | Description | Notes | ||
------------- | ------------- | ------------- | ------------- | ||
**unknown_base_type** | [**\OpenAPI\Client\Model\UNKNOWN_BASE_TYPE**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] | ||
|
||
### Return type | ||
|
||
void (empty response body) | ||
|
||
### Authorization | ||
|
||
No authorization required | ||
|
||
### HTTP request headers | ||
|
||
- **Content-Type**: application/json, *_/ \" =end -- | ||
- **Accept**: Not defined | ||
|
||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) | ||
|
10 changes: 10 additions & 0 deletions
10
samples/client/petstore-security-test/php/docs/Model/ModelReturn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ModelReturn | ||
|
||
## Properties | ||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**return** | **int** | property description *_/ ' \" =end -- \\r\\n \\n \\r | [optional] | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ | ||
# | ||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" | ||
|
||
git_user_id=$1 | ||
git_repo_id=$2 | ||
release_note=$3 | ||
|
||
if [ "$git_user_id" = "" ]; then | ||
git_user_id="GIT_USER_ID" | ||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" | ||
fi | ||
|
||
if [ "$git_repo_id" = "" ]; then | ||
git_repo_id="GIT_REPO_ID" | ||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" | ||
fi | ||
|
||
if [ "$release_note" = "" ]; then | ||
release_note="Minor update" | ||
echo "[INFO] No command line input provided. Set \$release_note to $release_note" | ||
fi | ||
|
||
# Initialize the local directory as a Git repository | ||
git init | ||
|
||
# Adds the files in the local repository and stages them for commit. | ||
git add . | ||
|
||
# Commits the tracked changes and prepares them to be pushed to a remote repository. | ||
git commit -m "$release_note" | ||
|
||
# Sets the new remote | ||
git_remote=`git remote` | ||
if [ "$git_remote" = "" ]; then # git remote not defined | ||
|
||
if [ "$GIT_TOKEN" = "" ]; then | ||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." | ||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git | ||
else | ||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git | ||
fi | ||
|
||
fi | ||
|
||
git pull origin master | ||
|
||
# Pushes (Forces) the changes in the local repository up to the remote repository | ||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" | ||
git push origin master 2>&1 | grep -v 'To https' | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain, please, how this change is related to
phpcs
fixer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php-cs-fixer
raises astrict-param
warning for in_array calls where the$strict
parameter is false (which is the default). Passing true ensures we use strict comparison, i.e. value + type checking.From my reading of the code I couldn't see any reason why we would need loose comparisons, especially since they can result in weird behaviour as documented here and here.