Skip to content

Commit

Permalink
Implement RequireNumericLiteralSeparator rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Jan 9, 2023
1 parent 789970c commit 3c12226
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions includes/Integrations/Jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function filter_admin_ajax_response( $data, $attachment ) {

if ( $metadata && isset( $metadata['videopress']['duration'], $data['media_details'] ) && \is_array( $data['media_details'] ) ) {
$data['media_details']['length_formatted'] = $this->format_milliseconds( $metadata['videopress']['duration'] );
$data['media_details']['length'] = (int) floor( $metadata['videopress']['duration'] / 1000 );
$data['media_details']['length'] = (int) floor( $metadata['videopress']['duration'] / 1_000 );
}

if ( $metadata && isset( $data['url'], $metadata['videopress']['file_url_base']['https'], $metadata['videopress']['files']['hd']['mp4'] ) ) {
Expand Down Expand Up @@ -316,7 +316,7 @@ public function filter_rest_api_response( WP_REST_Response $response, WP_Post $p

if ( $metadata && isset( $metadata['videopress']['duration'], $data['media_details'] ) && \is_array( $data['media_details'] ) ) {
$data['media_details']['length_formatted'] = $this->format_milliseconds( $metadata['videopress']['duration'] );
$data['media_details']['length'] = (int) floor( $metadata['videopress']['duration'] / 1000 );
$data['media_details']['length'] = (int) floor( $metadata['videopress']['duration'] / 1_000 );
}

if ( $metadata && isset( $data['source_url'], $metadata['videopress']['file_url_base']['https'], $metadata['videopress']['files']['hd']['mp4'] ) ) {
Expand Down Expand Up @@ -346,7 +346,7 @@ public function filter_rest_api_response( WP_REST_Response $response, WP_Post $p
* @param int $milliseconds Milliseconds to converted to minutes and seconds.
*/
protected function format_milliseconds( $milliseconds ): string {
$seconds = floor( $milliseconds / 1000 );
$seconds = floor( $milliseconds / 1_000 );

if ( $seconds >= 1 ) {
$minutes = floor( $seconds / 60 );
Expand Down
2 changes: 1 addition & 1 deletion includes/Media/Image_Sizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Image_Sizes extends Service_Base {
/**
* The image dimensions for media library thumbnails.
*/
public const STORY_THUMBNAIL_IMAGE_DIMENSIONS = [ 150, 9999 ];
public const STORY_THUMBNAIL_IMAGE_DIMENSIONS = [ 150, 9_999 ];

/**
* The image size for the publisher logo.
Expand Down
2 changes: 1 addition & 1 deletion includes/REST_API/Embed_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function get_proxy_item( $request ) {
}

$args = [
'limit_response_size' => 153600, // 150 KB.
'limit_response_size' => 15_3600, // 150 KB.
'timeout' => 7, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
];

Expand Down
4 changes: 2 additions & 2 deletions includes/REST_API/Hotlinking_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private function proxy_url_curl( string $url, array $args ): void {

rewind( $this->stream_handle );
while ( ! feof( $this->stream_handle ) ) {
echo fread( $this->stream_handle, 1024 * 1024 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions.file_system_read_fread
echo fread( $this->stream_handle, 1_024 * 1_024 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions.file_system_read_fread
}

fclose( $this->stream_handle );
Expand Down Expand Up @@ -699,7 +699,7 @@ private function validate_url( string $url ) {
}

/** This filter is documented in wp-includes/http.php */
$allowed_ports = apply_filters( 'http_allowed_safe_ports', [ 80, 443, 8080 ], $host, $url );
$allowed_ports = apply_filters( 'http_allowed_safe_ports', [ 80, 443, 8_080 ], $host, $url );
if (
! isset( $parsed_url['port'] ) ||
( \is_array( $allowed_ports ) && \in_array( $parsed_url['port'], $allowed_ports, true ) )
Expand Down
2 changes: 1 addition & 1 deletion includes/REST_API/Link_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function parse_link( $request ) {
}

$args = [
'limit_response_size' => 153600, // 150 KB.
'limit_response_size' => 15_3600, // 150 KB.
'timeout' => 7, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
];

Expand Down
6 changes: 6 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator">
<properties>
<property name="minDigitsAfterDecimalPoint" value="5" />
</properties>
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- Disallows grouped use declarations. -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<!-- Disallows leading backslash in use statement. -->
Expand Down

0 comments on commit 3c12226

Please sign in to comment.