Skip to content

Commit

Permalink
Merge pull request #145 from woocommerce/24-03/phpcs-develop
Browse files Browse the repository at this point in the history
PHPCS Develop
  • Loading branch information
Luc45 authored Mar 13, 2024
2 parents 9e18d1a + 644f67d commit 11c5429
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 26 deletions.
6 changes: 6 additions & 0 deletions src/.phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>

<!-- WPCS 3 -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped"/>
<exclude name="Universal.ControlStructures.DisallowLonelyIf.Found"/>
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>

<!-- Ignored until this is answered: https://github.com/squizlabs/PHP_CodeSniffer/issues/3570 -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>

Expand Down
4 changes: 3 additions & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"QIT_CLI\\": "src/"
Expand All @@ -31,7 +33,7 @@
"phpunit/phpunit": "^8",
"phpstan/phpstan": "^1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"wp-coding-standards/wpcs": "^2.3",
"wp-coding-standards/wpcs": "dev-develop",
"phpcompatibility/php-compatibility": "^9",
"spatie/phpunit-snapshot-assertions": "^3.0"
}
Expand Down
223 changes: 204 additions & 19 deletions src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function get( string $key, bool $ignore_expiration = false ) {
}

if ( $ignore_expiration === false && time() > $c['expire'] ) {
$deleted ++;
++$deleted;
unset( $this->cache[ $k ] );
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/src/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function request(): string {
curl_close( $curl );

if ( ! in_array( $response_status_code, $this->expected_status_codes, true ) ) {
if ( $proxied && $body === false ) {
if ( $proxied && $result === false ) {
$body = sprintf( 'Is the Automattic Proxy running and accessible through %s?', Config::get_proxy_url() );
}

Expand All @@ -273,7 +273,7 @@ public function request(): string {

if ( $response_status_code === 429 ) {
if ( $this->retry_429 > 0 ) {
$this->retry_429 --;
--$this->retry_429;
$sleep_seconds = $this->wait_after_429( $headers );
App::make( Output::class )->writeln( sprintf( '<comment>Request failed... Waiting %d seconds and retrying (429 Too many Requests)</comment>', $sleep_seconds ) );

Expand All @@ -282,7 +282,7 @@ public function request(): string {
}
} else {
if ( $this->retry > 0 ) {
$this->retry --;
--$this->retry;
App::make( Output::class )->writeln( sprintf( '<comment>Request failed... Retrying (HTTP Status Code %s) %s</comment>', $response_status_code, $error_message ) );

// Between 1 and 5s.
Expand Down
2 changes: 1 addition & 1 deletion src/src/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function upload_build( int $woo_extension_id, string $extension_slug, str
$progress_bar->start();

while ( ! feof( $file ) ) {
$current_chunk ++;
++$current_chunk;

$r = $this->request_builder
->with_url( get_manager_url() . '/wp-json/cd/v1/upload-build' )
Expand Down
2 changes: 1 addition & 1 deletion src/src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getDefaultCommands() {
if ( in_array( '--json', $GLOBALS['argv'], true ) ) {
class QIT_JSON_Filter extends \php_user_filter {
public function filter( $in, $out, &$consumed, $closing ): int {
while ( $bucket = stream_bucket_make_writeable( $in ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( $bucket = stream_bucket_make_writeable( $in ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition,Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
if ( ! is_null( json_decode( $bucket->data ) ) ) {
$consumed += $bucket->datalen;
stream_bucket_append( $out, $bucket );
Expand Down

0 comments on commit 11c5429

Please sign in to comment.