mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-18 12:23:32 +00:00
Suggestion: Adopt WordPress PHP Coding Standards (#905)
* Update phpcs rules * Automated style updates * Silence all other Warnings and Errors We'll fix them in follow ups.
This commit is contained in:
parent
f5989f0380
commit
2b5f635ba3
44 changed files with 441 additions and 446 deletions
|
@ -41,7 +41,7 @@
|
|||
"vendor/bin/phpunit"
|
||||
],
|
||||
"lint": [
|
||||
"vendor/bin/phpcs -n -q"
|
||||
"vendor/bin/phpcs"
|
||||
],
|
||||
"lint:fix": [
|
||||
"vendor/bin/phpcbf"
|
||||
|
|
|
@ -51,6 +51,7 @@ class Event extends Base_Object {
|
|||
|
||||
/**
|
||||
* Mobilizon compatible values for repliesModertaionOption.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const REPLIES_MODERATION_OPTION_TYPES = array( 'allow_all', 'closed' );
|
||||
|
@ -62,6 +63,7 @@ class Event extends Base_Object {
|
|||
|
||||
/**
|
||||
* Allowed values for ical VEVENT STATUS.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const ICAL_EVENT_STATUS_TYPES = array( 'TENTATIVE', 'CONFIRMED', 'CANCELLED' );
|
||||
|
@ -70,6 +72,7 @@ class Event extends Base_Object {
|
|||
* Default event categories.
|
||||
*
|
||||
* These values currently reflect the default set as proposed by Mobilizon to maximize interoperability.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const DEFAULT_EVENT_CATEGORIES = array(
|
||||
|
|
|
@ -152,6 +152,7 @@ class Blocks {
|
|||
|
||||
/**
|
||||
* Filter an array by a list of keys.
|
||||
*
|
||||
* @param array $array The array to filter.
|
||||
* @param array $keys The keys to keep.
|
||||
* @return array The filtered array.
|
||||
|
@ -162,6 +163,7 @@ class Blocks {
|
|||
|
||||
/**
|
||||
* Render the follow me block.
|
||||
*
|
||||
* @param array $attrs The block attributes.
|
||||
* @return string The HTML to render.
|
||||
*/
|
||||
|
|
|
@ -496,7 +496,7 @@ class Comment {
|
|||
\wp_enqueue_style(
|
||||
$handle,
|
||||
\plugins_url( 'build/remote-reply/style-index.css', __DIR__ ),
|
||||
[ 'wp-components' ],
|
||||
array( 'wp-components' ),
|
||||
$assets['version']
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ class Hashtag {
|
|||
* @return array the activity object array
|
||||
*/
|
||||
public static function filter_activity_object( $object_array ) {
|
||||
/* Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
/*
|
||||
Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
if ( ! empty( $object_array['summary'] ) ) {
|
||||
$object_array['summary'] = self::the_content( $object_array['summary'] );
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ class Link {
|
|||
* @return array the activity object array
|
||||
*/
|
||||
public static function filter_activity_object( $object_array ) {
|
||||
/* Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
/*
|
||||
Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
if ( ! empty( $object_array['summary'] ) ) {
|
||||
$object_array['summary'] = self::the_content( $object_array['summary'] );
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@ class Extra_Fields {
|
|||
|
||||
/**
|
||||
* Checks if the user is the blog user.
|
||||
*
|
||||
* @param int $user_id The user ID.
|
||||
* @return bool True if the user is the blog user, otherwise false.
|
||||
*/
|
||||
|
|
|
@ -64,7 +64,10 @@ function get_remote_metadata_by_actor( $actor, $cached = true ) {
|
|||
return new WP_Error(
|
||||
'activitypub_no_valid_actor_identifier',
|
||||
\__( 'The "actor" identifier is not valid', 'activitypub' ),
|
||||
array( 'status' => 404, 'actor' => $actor )
|
||||
array(
|
||||
'status' => 404,
|
||||
'actor' => $actor,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +80,10 @@ function get_remote_metadata_by_actor( $actor, $cached = true ) {
|
|||
return new WP_Error(
|
||||
'activitypub_no_valid_actor_identifier',
|
||||
\__( 'The "actor" identifier is not valid', 'activitypub' ),
|
||||
array( 'status' => 404, 'actor' => $actor )
|
||||
array(
|
||||
'status' => 404,
|
||||
'actor' => $actor,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,7 +106,10 @@ function get_remote_metadata_by_actor( $actor, $cached = true ) {
|
|||
$metadata = new WP_Error(
|
||||
'activitypub_no_valid_actor_url',
|
||||
\__( 'The "actor" is no valid URL', 'activitypub' ),
|
||||
array( 'status' => 400, 'actor' => $actor )
|
||||
array(
|
||||
'status' => 400,
|
||||
'actor' => $actor,
|
||||
)
|
||||
);
|
||||
return $metadata;
|
||||
}
|
||||
|
@ -118,7 +127,10 @@ function get_remote_metadata_by_actor( $actor, $cached = true ) {
|
|||
$metadata = new WP_Error(
|
||||
'activitypub_invalid_json',
|
||||
\__( 'No valid JSON data', 'activitypub' ),
|
||||
array( 'status' => 400, 'actor' => $actor )
|
||||
array(
|
||||
'status' => 400,
|
||||
'actor' => $actor,
|
||||
)
|
||||
);
|
||||
return $metadata;
|
||||
}
|
||||
|
@ -1019,7 +1031,6 @@ function custom_large_numbers( $formatted, $number, $decimals ) {
|
|||
/**
|
||||
* Registers a ActivityPub comment type.
|
||||
*
|
||||
*
|
||||
* @param string $comment_type Key for comment type.
|
||||
* @param array $args Arguments.
|
||||
*
|
||||
|
@ -1040,7 +1051,6 @@ function register_comment_type( $comment_type, $args = array() ) {
|
|||
/**
|
||||
* Fires after a ActivityPub comment type is registered.
|
||||
*
|
||||
*
|
||||
* @param string $comment_type Comment type.
|
||||
* @param array $args Arguments used to register the comment type.
|
||||
*/
|
||||
|
@ -1210,7 +1220,8 @@ function generate_post_summary( $post, $length = 500 ) {
|
|||
$content = $content[0] . ' ' . $excerpt_more;
|
||||
}
|
||||
|
||||
/* Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
/*
|
||||
Removed until this is merged: https://github.com/mastodon/mastodon/pull/28629
|
||||
return \apply_filters( 'the_excerpt', $content );
|
||||
*/
|
||||
return $content;
|
||||
|
|
|
@ -205,6 +205,7 @@ class Follower extends Actor {
|
|||
* Beware that this os deleting a Follower for ALL users!!!
|
||||
*
|
||||
* To delete only the User connection (unfollow)
|
||||
*
|
||||
* @see \Activitypub\Rest\Followers::remove_follower()
|
||||
*
|
||||
* @return void
|
||||
|
|
|
@ -295,7 +295,10 @@ class User extends Actor {
|
|||
* @return bool True if the attribute was updated, false otherwise.
|
||||
*/
|
||||
public function update_name( $value ) {
|
||||
$userdata = [ 'ID' => $this->_id, 'display_name' => $value ];
|
||||
$userdata = array(
|
||||
'ID' => $this->_id,
|
||||
'display_name' => $value,
|
||||
);
|
||||
return \wp_update_user( $userdata );
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,10 @@ class Actors {
|
|||
$url = str_replace( '{uri}', $resource, $template );
|
||||
|
||||
return new WP_REST_Response(
|
||||
array( 'url' => $url, 'template' => $template ),
|
||||
array(
|
||||
'url' => $url,
|
||||
'template' => $template,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,10 @@ class Comment {
|
|||
$url = str_replace( '{uri}', $resource, $template );
|
||||
|
||||
return new WP_REST_Response(
|
||||
array( 'url' => $url, 'template' => $template ),
|
||||
array(
|
||||
'url' => $url,
|
||||
'template' => $template,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
|
|
@ -306,6 +306,7 @@ class Post extends Base {
|
|||
|
||||
/**
|
||||
* Recursively get media IDs from blocks.
|
||||
*
|
||||
* @param array $blocks The blocks to search for media IDs
|
||||
* @param array $media The media IDs to append new IDs to
|
||||
* @param int $max_media The maximum number of media to return.
|
||||
|
|
|
@ -11,11 +11,11 @@ class Jetpack {
|
|||
if ( ! is_array( $whitelist ) ) {
|
||||
return $whitelist;
|
||||
}
|
||||
$activitypub_meta_keys = [
|
||||
$activitypub_meta_keys = array(
|
||||
'activitypub_user_id',
|
||||
'activitypub_inbox',
|
||||
'activitypub_actor_json',
|
||||
];
|
||||
);
|
||||
return \array_merge( $whitelist, $activitypub_meta_keys );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Nodeinfo {
|
|||
* Extend NodeInfo data
|
||||
*
|
||||
* @param array $nodeinfo NodeInfo data
|
||||
* @param string The NodeInfo Version
|
||||
* @param string $version The NodeInfo Version
|
||||
*
|
||||
* @return array The extended array
|
||||
*/
|
||||
|
|
79
phpcs.xml
79
phpcs.xml
|
@ -5,74 +5,39 @@
|
|||
<file>./includes/</file>
|
||||
<file>./integration/</file>
|
||||
<file>./build/</file>
|
||||
|
||||
<exclude-pattern>*\.(inc|css|js|svg)</exclude-pattern>
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/node_modules/*</exclude-pattern>
|
||||
<exclude-pattern>*.asset.php</exclude-pattern>
|
||||
|
||||
<arg value="ps"/>
|
||||
<arg name="basepath" value="."/><!-- Strip the file paths down to the relevant bit -->
|
||||
<arg name="colors"/>
|
||||
<arg name="parallel" value="50"/>
|
||||
|
||||
<rule ref="PHPCompatibility"/>
|
||||
<config name="testVersion" value="7.0-"/>
|
||||
<rule ref="PHPCompatibilityWP"/>
|
||||
<config name="minimum_supported_wp_version" value="4.7"/>
|
||||
<rule ref="WordPress-Core">
|
||||
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
|
||||
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
|
||||
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
|
||||
</rule>
|
||||
<rule ref="WordPress.Files.FileName">
|
||||
<properties>
|
||||
<property name="strict_class_file_names" value="false" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="WordPress.WP.DeprecatedFunctions" />
|
||||
<rule ref="WordPress-Extra" />
|
||||
<rule ref="WordPress.WP.I18n"/>
|
||||
|
||||
<config name="text_domain" value="activitypub,default"/>
|
||||
<arg value="ps"/>
|
||||
<arg name="parallel" value="20"/>
|
||||
<rule ref="VariableAnalysis"/>
|
||||
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable">
|
||||
<type>error</type>
|
||||
|
||||
<rule ref="WordPress">
|
||||
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
|
||||
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
||||
<exclude name="Generic.Commenting.DocComment.LongNotCapital"/>
|
||||
<exclude name="Squiz.Commenting"/>
|
||||
<exclude name="Squiz.PHP.CommentedOutCode.Found"/>
|
||||
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames"/>
|
||||
<exclude name="WordPress.Security.NonceVerification.Recommended"/>
|
||||
<exclude name="WordPress.WP.GetMetaSingle.Missing"/>
|
||||
<exclude name="WordPress.DB.PreparedSQL.NotPrepared"/>
|
||||
</rule>
|
||||
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
|
||||
<properties>
|
||||
<property name="allowUnusedCaughtExceptions" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="WordPress"/>
|
||||
<rule ref="WordPress.WP.I18n.NoHtmlWrappedStrings">
|
||||
<type>error</type>
|
||||
</rule>
|
||||
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
|
||||
<rule ref="Generic.Arrays.DisallowShortArraySyntax">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Universal.Arrays.DisallowShortArraySyntax">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Commenting">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Generic.Commenting">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="WordPress.Files.FileName">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="WordPress.WP.CapitalPDangit">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="WordPress.PHP.YodaConditions.NotYoda">
|
||||
<type>warning</type>
|
||||
</rule>
|
||||
<rule ref="WordPress.Arrays.ArrayDeclarationSpacing">
|
||||
<exclude-pattern>**/*.asset.php</exclude-pattern>
|
||||
<rule ref="VariableAnalysis">
|
||||
<exclude name="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress.WP.Capabilities">
|
||||
<properties>
|
||||
<property name="custom_capabilities" type="array">
|
||||
|
|
Loading…
Reference in a new issue