diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..f7a56ff --- /dev/null +++ b/.php_cs @@ -0,0 +1,15 @@ +exclude('vendor') + ->exclude('node_modules') + ->exclude('bin') + ->in(__DIR__) +; + +return PhpCsFixer\Config::create() + ->setRules([ + 'native_function_invocation' => true, + 'native_constant_invocation' => true, + ]) + ->setFinder($finder) +; diff --git a/.svnignore b/.svnignore index 8f7beec..93fbfdb 100644 --- a/.svnignore +++ b/.svnignore @@ -8,6 +8,7 @@ .data .svnignore .wordpress-org +.php_cs Gruntfile.js LINGUAS Makefile diff --git a/includes/class-signature.php b/includes/class-signature.php index ffd5003..3dffb10 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -53,7 +53,7 @@ class Signature { $config = array( 'digest_alg' => 'sha512', 'private_key_bits' => 2048, - 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'private_key_type' => \OPENSSL_KEYTYPE_RSA, ); $key = \openssl_pkey_new( $config ); @@ -91,7 +91,7 @@ class Signature { $signed_string = "(request-target): post $path\nhost: $host\ndate: $date"; $signature = null; - \openssl_sign( $signed_string, $signature, $key, OPENSSL_ALGO_SHA256 ); + \openssl_sign( $signed_string, $signature, $key, \OPENSSL_ALGO_SHA256 ); $signature = \base64_encode( $signature ); // phpcs:ignore $key_id = \get_author_posts_url( $user_id ) . '#main-key'; diff --git a/includes/functions.php b/includes/functions.php index 60d6e3b..982d740 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -89,7 +89,7 @@ function get_webfinger_resource( $user_id ) { $user = \get_user_by( 'id', $user_id ); - return $user->user_login . '@' . \wp_parse_url( \home_url(), PHP_URL_HOST ); + return $user->user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST ); } /** @@ -253,7 +253,7 @@ function url_to_authorid( $url ) { global $wp_rewrite; // check if url hase the same host - if ( wp_parse_url( site_url(), PHP_URL_HOST ) !== wp_parse_url( $url, PHP_URL_HOST ) ) { + if ( wp_parse_url( site_url(), \PHP_URL_HOST ) !== wp_parse_url( $url, \PHP_URL_HOST ) ) { return 0; } @@ -297,7 +297,7 @@ function url_to_authorid( $url ) { */ function get_blacklist() { $blacklist = \get_option( 'activitypub_blacklist' ); - $blacklist_hosts = \explode( PHP_EOL, $blacklist ); + $blacklist_hosts = \explode( \PHP_EOL, $blacklist ); // if no values have been set, revert to the defaults if ( ! $blacklist || ! $blacklist_hosts || ! \is_array( $blacklist_hosts ) ) { diff --git a/includes/model/class-activity.php b/includes/model/class-activity.php index 470b192..4aa4107 100644 --- a/includes/model/class-activity.php +++ b/includes/model/class-activity.php @@ -69,7 +69,7 @@ class Activity { } public function to_json() { - return \wp_json_encode( $this->to_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ); + return \wp_json_encode( $this->to_array(), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT ); } public function to_simple_array() { @@ -90,6 +90,6 @@ class Activity { } public function to_simple_json() { - return \wp_json_encode( $this->to_simple_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ); + return \wp_json_encode( $this->to_simple_array(), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT ); } } diff --git a/includes/model/class-post.php b/includes/model/class-post.php index a452274..8b9fa65 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -53,7 +53,7 @@ class Post { } public function to_json() { - return \wp_json_encode( $this->to_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ); + return \wp_json_encode( $this->to_array(), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT ); } public function get_attachments() { @@ -215,7 +215,7 @@ class Post { if ( 'Article' === $this->get_object_type() ) { $title = \get_the_title( $this->post ); - return \html_entity_decode( $title, ENT_QUOTES, 'UTF-8' ); + return \html_entity_decode( $title, \ENT_QUOTES, 'UTF-8' ); } return null; @@ -271,7 +271,7 @@ class Post { $filtered_content = \apply_filters( 'the_content', $content ); $filtered_content = \apply_filters( 'activitypub_the_content', $filtered_content, $this->post ); - $decoded_content = \html_entity_decode( $filtered_content, ENT_QUOTES, 'UTF-8' ); + $decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' ); $allowed_html = \apply_filters( 'activitypub_allowed_html', '