Skip to content

Commit 46eeeb0

Browse files
authored
Merge pull request #3607 from woocommerce/PCP-5180-fix-php-8-compatibility-issues-dynamic-properties-and-phpcs-configuration-phpcs
Refactor PHPCS configuration to be compatible to PHP8 (5180)
2 parents 4faef95 + 11ef14b commit 46eeeb0

File tree

231 files changed

+1298
-1091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+1298
-1091
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"container-interop/service-provider": "^0.4.0",
2121
"dhii/containers": "^0.1.0-alpha1",
2222
"inpsyde/modularity": "^1.7",
23-
"woocommerce/woocommerce-sniffs": "^0.1.0",
23+
"woocommerce/woocommerce-sniffs": "^1.0.0",
2424
"phpunit/phpunit": "^7.0 | ^8.0 | ^9.0",
2525
"brain/monkey": "^2.4",
2626
"php-stubs/wordpress-stubs": "^5.0@stable",

composer.lock

Lines changed: 254 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/ppcp-admin-notices/src/AdminNotices.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function run( ContainerInterface $c ): bool {
4949

5050
add_action(
5151
'admin_notices',
52-
function() use ( $renderer ) {
52+
function () use ( $renderer ) {
5353
$renderer->render();
5454
}
5555
);
@@ -113,11 +113,10 @@ static function () {
113113

114114
add_action(
115115
'woocommerce_init',
116-
function() {
116+
function () {
117117
if ( is_admin() && is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) {
118118
MexicoInstallmentsNote::init();
119119
}
120-
121120
}
122121
);
123122

modules/ppcp-admin-notices/src/Endpoint/MuteMessageEndpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(
5353
*
5454
* @return string
5555
*/
56-
public static function nonce() : string {
56+
public static function nonce(): string {
5757
return self::ENDPOINT;
5858
}
5959

@@ -62,7 +62,7 @@ public static function nonce() : string {
6262
*
6363
* @return void
6464
*/
65-
public function handle_request() : void {
65+
public function handle_request(): void {
6666
try {
6767
$data = $this->request_data->read_request( $this->nonce() );
6868
} catch ( RuntimeException $ex ) {

modules/ppcp-admin-notices/src/Entity/Message.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct( string $message, string $type, bool $dismissible =
6262
*
6363
* @return string
6464
*/
65-
public function message() : string {
65+
public function message(): string {
6666
return $this->message;
6767
}
6868

@@ -71,7 +71,7 @@ public function message() : string {
7171
*
7272
* @return string
7373
*/
74-
public function type() : string {
74+
public function type(): string {
7575
return $this->type;
7676
}
7777

@@ -80,7 +80,7 @@ public function type() : string {
8080
*
8181
* @return bool
8282
*/
83-
public function is_dismissible() : bool {
83+
public function is_dismissible(): bool {
8484
return $this->dismissible;
8585
}
8686

@@ -89,7 +89,7 @@ public function is_dismissible() : bool {
8989
*
9090
* @return string
9191
*/
92-
public function wrapper() : string {
92+
public function wrapper(): string {
9393
return $this->wrapper;
9494
}
9595

@@ -98,7 +98,7 @@ public function wrapper() : string {
9898
*
9999
* @return array
100100
*/
101-
public function to_array() : array {
101+
public function to_array(): array {
102102
return array(
103103
'type' => $this->type,
104104
'message' => $this->message,
@@ -114,7 +114,7 @@ public function to_array() : array {
114114
*
115115
* @return Message
116116
*/
117-
public static function from_array( array $data ) : Message {
117+
public static function from_array( array $data ): Message {
118118
return new Message(
119119
(string) ( $data['message'] ?? '' ),
120120
(string) ( $data['type'] ?? '' ),

modules/ppcp-admin-notices/src/Entity/PersistentMessage.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct( string $id, string $message, string $type, string $
4747
*
4848
* @return string
4949
*/
50-
public function id( bool $with_db_prefix = false ) : string {
50+
public function id( bool $with_db_prefix = false ): string {
5151
if ( ! $this->message_id ) {
5252
return '';
5353
}
@@ -58,7 +58,7 @@ public function id( bool $with_db_prefix = false ) : string {
5858
/**
5959
* {@inheritDoc}
6060
*/
61-
public function to_array() : array {
61+
public function to_array(): array {
6262
$data = parent::to_array();
6363
$data['id'] = $this->message_id;
6464

@@ -70,7 +70,7 @@ public function to_array() : array {
7070
*
7171
* @return PersistentMessage
7272
*/
73-
public static function from_array( array $data ) : Message {
73+
public static function from_array( array $data ): Message {
7474
return new PersistentMessage(
7575
(string) ( $data['id'] ?? '' ),
7676
(string) ( $data['message'] ?? '' ),
@@ -84,7 +84,7 @@ public static function from_array( array $data ) : Message {
8484
*
8585
* @return bool
8686
*/
87-
public function is_muted() : bool {
87+
public function is_muted(): bool {
8888
$user_id = get_current_user_id();
8989

9090
if ( ! $this->message_id || ! $user_id ) {
@@ -99,7 +99,7 @@ public function is_muted() : bool {
9999
*
100100
* @return void
101101
*/
102-
public function mute() : void {
102+
public function mute(): void {
103103
$user_id = get_current_user_id();
104104

105105
if ( $this->message_id && $user_id && ! $this->is_muted() ) {
@@ -112,7 +112,7 @@ public function mute() : void {
112112
*
113113
* @return void
114114
*/
115-
public static function clear_all() : void {
115+
public static function clear_all(): void {
116116
global $wpdb;
117117

118118
$wpdb->query(

modules/ppcp-admin-notices/src/Renderer/Renderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function render(): bool {
9595
/**
9696
* {@inheritDoc}
9797
*/
98-
public function enqueue_admin() : void {
98+
public function enqueue_admin(): void {
9999
if ( ! $this->can_mute_message ) {
100100
return;
101101
}
@@ -129,7 +129,7 @@ public function enqueue_admin() : void {
129129
*
130130
* @return array
131131
*/
132-
protected function script_data_for_admin() : array {
132+
protected function script_data_for_admin(): array {
133133
$ajax_url = admin_url( 'admin-ajax.php' );
134134

135135
return array(

modules/ppcp-admin-notices/src/Renderer/RendererInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public function render(): bool;
2626
*
2727
* @return void
2828
*/
29-
public function enqueue_admin() : void;
29+
public function enqueue_admin(): void;
3030
}

modules/ppcp-admin-notices/src/Repository/Repository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Repository implements RepositoryInterface {
2525
*
2626
* @return Message[]
2727
*/
28-
public function current_message() : array {
28+
public function current_message(): array {
2929
return array_filter(
3030
/**
3131
* Returns the list of admin messages.
@@ -34,7 +34,7 @@ public function current_message() : array {
3434
self::NOTICES_FILTER,
3535
array()
3636
),
37-
function ( $element ) : bool {
37+
function ( $element ): bool {
3838
if ( $element instanceof PersistentMessage ) {
3939
return ! $element->is_muted();
4040
}
@@ -51,7 +51,7 @@ function ( $element ) : bool {
5151
*
5252
* @return void
5353
*/
54-
public function persist( Message $message ) : void {
54+
public function persist( Message $message ): void {
5555
$persisted_notices = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array();
5656

5757
$persisted_notices[] = $message->to_array();
@@ -64,7 +64,7 @@ public function persist( Message $message ) : void {
6464
*
6565
* @return array|Message[]
6666
*/
67-
public function get_persisted_and_clear() : array {
67+
public function get_persisted_and_clear(): array {
6868
$notices = array();
6969

7070
$persisted_data = get_option( self::PERSISTED_NOTICES_OPTION ) ?: array();

0 commit comments

Comments
 (0)