Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 4f81b63

Browse files
committed
Bump dependencies & fix code style
New versions of dependencies means new code style fixes.
1 parent 5926d39 commit 4f81b63

Some content is hidden

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

67 files changed

+732
-562
lines changed

app/Client/Gist.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ private function process_response( Requests_Response $response ) {
208208
if ( ! $response->success ) {
209209
// 4XX errors: client-side problems
210210
if ( $response->status_code >= 400 && $response->status_code < 500 ) {
211-
if ( $response->status_code === 401 ) {
211+
if ( 401 === $response->status_code ) {
212212
return new WP_Error(
213213
'auth_error',
214214
sprintf(
215+
/* translators: %s: Request error. */
215216
__( 'Authorization error. Message: %s', 'wp-gistpen' ),
216217
$json->message
217218
)
@@ -221,6 +222,7 @@ private function process_response( Requests_Response $response ) {
221222
return new WP_Error(
222223
'client_error',
223224
sprintf(
225+
/* translators: %s: Request error. */
224226
__( 'Error sending request. Message: %s', 'wp-gistpen' ),
225227
$json->message
226228
)

app/Database/Repository/AbstractRepository.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract class AbstractRepository implements Repository {
4040
*/
4141
public function __construct( EntityManager $em, $prefix ) {
4242
$this->prefix = $prefix;
43-
$this->em = $em;
43+
$this->em = $em;
4444
}
4545

4646
/**
@@ -68,7 +68,7 @@ protected function fill_relations( Model $model, array $params ) {
6868
$value = null;
6969

7070
switch ( $key ) {
71-
case 'blobs';
71+
case 'blobs':
7272
$value = $this->em->find_by( \Intraxia\Gistpen\Database\EntityManager::BLOB_CLASS, array_merge( $params, array(
7373
'repo_id' => $model->get_primary_id(),
7474
'post_status' => 'any',
@@ -82,7 +82,7 @@ protected function fill_relations( Model $model, array $params ) {
8282
if ( $terms ) {
8383
$term = array_pop( $terms );
8484
} else {
85-
$term = new WP_Term( new stdClass );
85+
$term = new WP_Term( new stdClass() );
8686
$term->slug = 'none';
8787
}
8888

app/Database/Repository/WordPressCustomTable.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function find( $class, $id, array $params = array() ) {
4343
return new WP_Error(
4444
'db_error',
4545
sprintf(
46+
/* translators: %s: Query error. */
4647
__( 'Query failed with error: %s', 'wp-gistpen' ),
4748
$wpdb->last_error
4849
)
@@ -105,6 +106,7 @@ public function find_by( $class, array $params = array() ) {
105106
return new WP_Error(
106107
'db_error',
107108
sprintf(
109+
/* translators: %s: Query error. */
108110
__( 'Query failed with error: %s', 'wp-gistpen' ),
109111
$wpdb->last_error
110112
)
@@ -116,7 +118,7 @@ public function find_by( $class, array $params = array() ) {
116118
$result['items'] = maybe_unserialize( $result['items'] );
117119
}
118120

119-
$model = new $class( $result );
121+
$model = new $class( $result );
120122
$model->sync_original();
121123

122124
$models = $models->add( $model );
@@ -154,6 +156,7 @@ public function create( $class, array $data = array(), array $options = array()
154156
return new WP_Error(
155157
'db_error',
156158
sprintf(
159+
/* translators: %s: Query error. */
157160
__( 'Query failed with error: %s', 'wp-gistpen' ),
158161
$wpdb->last_error
159162
)
@@ -197,6 +200,7 @@ public function persist( Model $model ) {
197200
return new WP_Error(
198201
'db_error',
199202
sprintf(
203+
/* translators: %s: Query error. */
200204
__( 'Query failed with error: %s', 'wp-gistpen' ),
201205
$wpdb->last_error
202206
)
@@ -226,6 +230,7 @@ public function delete( Model $model, $force = false ) {
226230
return new WP_Error(
227231
'db_error',
228232
sprintf(
233+
/* translators: %s: Query error. */
229234
__( 'Query failed with error: %s', 'wp-gistpen' ),
230235
$wpdb->last_error
231236
)
@@ -242,6 +247,7 @@ public function delete( Model $model, $force = false ) {
242247
return new WP_Error(
243248
'db_error',
244249
sprintf(
250+
/* translators: %s: Query error. */
245251
__( 'Query failed with error: %s', 'wp-gistpen' ),
246252
$wpdb->last_error
247253
)
@@ -313,6 +319,7 @@ private function validate_data( $class, $data ) {
313319
return new WP_Error(
314320
'invalid_data',
315321
sprintf(
322+
/* translators: %s: Run ID. */
316323
__( 'run_id %s is invalid', 'wp-gistpen' ),
317324
$data['run_id']
318325
)

app/Database/Repository/WordPressPost.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function find( $class, $id, array $params = array() ) {
4040
return new WP_Error(
4141
'invalid_data',
4242
sprintf(
43+
/* translators: %s: Post ID. */
4344
__( 'post id %s is invalid', 'wp-gistpen' ),
4445
$id
4546
)
@@ -50,6 +51,7 @@ public function find( $class, $id, array $params = array() ) {
5051
return new WP_Error(
5152
'invalid_data',
5253
sprintf(
54+
/* translators: %s: Post ID. */
5355
__( 'post id %s is invalid', 'wp-gistpen' ),
5456
$id
5557
)
@@ -65,7 +67,7 @@ public function find( $class, $id, array $params = array() ) {
6567
}
6668

6769
// @todo handle related keys specially for now.
68-
if ( in_array( $key, array( 'blobs', 'language', 'states' ) ) ) {
70+
if ( in_array( $key, array( 'blobs', 'language', 'states' ), true ) ) {
6971
continue;
7072
}
7173

@@ -123,7 +125,7 @@ public function find_by( $class, array $params = array() ) {
123125
$query_args['post_parent'] = $params['repo_id'];
124126
}
125127

126-
if ( Klass::BLOB === $class && isset( $params['repo_id'] ) ) {
128+
if ( Klass::BLOB === $class && isset( $params['repo_id'] ) ) {
127129
$query_args['post_parent'] = $params['repo_id'];
128130
}
129131

@@ -134,7 +136,7 @@ public function find_by( $class, array $params = array() ) {
134136
if ( isset( $params['gist_id'] ) ) {
135137
$query_args['meta_query'] = array(
136138
array(
137-
'key' => $this->make_meta_key( 'gist_id' ),
139+
'key' => $this->make_meta_key( 'gist_id' ),
138140
'value' => $params['gist_id'],
139141
),
140142
);
@@ -172,7 +174,7 @@ public function find_by( $class, array $params = array() ) {
172174
* @param array $options
173175
*/
174176
public function create( $class, array $data = array(), array $options = array() ) {
175-
$model = new $class;
177+
$model = new $class();
176178

177179
/**
178180
* Set aside the `blobs` key for use.
@@ -285,7 +287,7 @@ public function persist( Model $model ) {
285287
$model->set_attribute( Model::OBJECT_KEY, get_post( $result ) );
286288

287289
foreach ( $model->get_table_attributes() as $key => $value ) {
288-
if ( in_array( $key, array( 'blobs', 'language', 'repo' ) ) ) {
290+
if ( in_array( $key, array( 'blobs', 'language', 'repo' ), true ) ) {
289291
continue;
290292
}
291293

app/Database/Repository/WordPressTerm.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class WordPressTerm extends AbstractRepository {
2525
*/
2626
public function find( $class, $id, array $params = array() ) {
2727
$taxonomy = $class::get_taxonomy();
28-
$term = get_term( $id, $taxonomy );
28+
$term = get_term( $id, $taxonomy );
2929

3030
if ( ! $term ) {
3131
$term = new WP_Error( 'db_error', __( 'Error getting term', 'wp-gistpen' ) );
@@ -54,7 +54,7 @@ public function find( $class, $id, array $params = array() ) {
5454
* @param array $params
5555
*/
5656
public function find_by( $class, array $params = array() ) {
57-
$taxonomy = $class::get_taxonomy();
57+
$taxonomy = $class::get_taxonomy();
5858
$collection = new Collection( $class );
5959

6060
$query = new WP_Term_Query( array_merge( $params, array(
@@ -84,7 +84,7 @@ public function find_by( $class, array $params = array() ) {
8484
* @return Model|WP_Error
8585
*/
8686
public function create( $class, array $data = array(), array $options = array() ) {
87-
$model = new $class;
87+
$model = new $class();
8888

8989
foreach ( $data as $key => $value ) {
9090
$model->set_attribute( $key, $value );
@@ -118,7 +118,7 @@ public function create( $class, array $data = array(), array $options = array()
118118
* @return Model
119119
*/
120120
public function persist( Model $model ) {
121-
$result = $model->get_primary_id() ?
121+
$result = $model->get_primary_id() ?
122122
wp_update_term(
123123
$model->get_primary_id(),
124124
Language::get_taxonomy(),

app/Http/Filter/RepoCollection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class RepoCollection implements FilterContract {
2222
public function rules() {
2323
return array(
2424
'page' => array(
25-
'required' => false,
26-
'default' => 1,
25+
'required' => false,
26+
'default' => 1,
2727
'sanitize_callback' => array( $this, 'sanitize_page' ),
2828
),
2929
);

app/Http/Filter/RepoCreate.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public function rules() {
3232
'default' => 'draft',
3333
'sanitize_callback' => [ $this, 'sanitize_status' ],
3434
],
35-
'sync' => [
35+
'sync' => [
3636
'description' => __( 'Whether the Repo should be synced to Gist.', 'wp-gistpen' ),
3737
'required' => false,
3838
'default' => 'off',
3939
'sanitize_callback' => [ $this, 'sanitize_sync' ],
4040
],
41-
'blobs' => [
41+
'blobs' => [
4242
'description' => __( 'Individual code snippets attached to the repo.', 'wp-gistpen' ),
4343
'required' => false,
4444
'default' => [],
@@ -68,7 +68,7 @@ public function sanitize_description( $description ) {
6868
* @return string|WP_Error The status, or an error if invalid.
6969
*/
7070
public function sanitize_status( $status ) {
71-
if ( ! in_array( $status, array_keys( get_post_statuses() ) ) ) {
71+
if ( ! in_array( $status, array_keys( get_post_statuses() ), true ) ) {
7272
return $this->create_error( __( 'Param "status" must be a valid post status.', 'wp-gistpen' ) );
7373
}
7474

@@ -82,7 +82,7 @@ public function sanitize_status( $status ) {
8282
* @return string|WP_Error The sync value, or error if invalid.
8383
*/
8484
public function sanitize_sync( $sync ) {
85-
if ( ! in_array( $sync, [ 'on', 'off' ] ) ) {
85+
if ( ! in_array( $sync, [ 'on', 'off' ], true ) ) {
8686
return $this->create_error( __( 'Param "sync" must be one of: on, off.', 'wp-gistpen' ) );
8787
}
8888

@@ -125,6 +125,7 @@ public function sanitize_blobs( $blobs ) {
125125
public function sanitize_blob( $blob, $index ) {
126126
if ( ! is_array( $blob ) ) {
127127
return $this->create_error( sprintf(
128+
/* translators: %d: Blob index. */
128129
__( 'Param "blob[%d]" must be an object.', 'wp-gistpen' ),
129130
$index
130131
) );
@@ -140,6 +141,7 @@ public function sanitize_blob( $blob, $index ) {
140141
// @todo simplyify logic?
141142
) {
142143
return $this->create_error( sprintf(
144+
/* translators: %d: Blob index. */
143145
__( 'Param "blob[%d].filename" must be a non-empty string.', 'wp-gistpen' ),
144146
$index
145147
) );
@@ -150,6 +152,7 @@ public function sanitize_blob( $blob, $index ) {
150152
! is_string( $blob['code'] )
151153
) {
152154
return $this->create_error( sprintf(
155+
/* translators: %d: Blob index. */
153156
__( 'Param "blob[%d].code" must be a string.', 'wp-gistpen' ),
154157
$index
155158
) );

app/Http/Filter/RepoResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function rules() {
2323
return array(
2424
'id' => array(
2525
'required' => true,
26-
'type' => 'int',
26+
'type' => 'int',
2727
),
2828
);
2929
}

app/Http/JobsController.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function status( WP_REST_Request $request ) {
6363
return new WP_Error(
6464
'invalid_job',
6565
sprintf(
66+
/* translators: %s: Job slug. */
6667
__( 'Provided job %s is invalid.', 'wp-gistpen' ),
6768
$name
6869
),
@@ -106,6 +107,7 @@ public function dispatch( WP_REST_Request $request ) {
106107
return new WP_Error(
107108
'invalid_job',
108109
sprintf(
110+
/* translators: %s: Job slug. */
109111
__( 'Provided job %s is invalid.', 'wp-gistpen' ),
110112
$name
111113
),
@@ -146,6 +148,7 @@ public function process( WP_REST_Request $request ) {
146148
return new WP_Error(
147149
'invalid_job',
148150
sprintf(
151+
/* translators: %s: Job slug. */
149152
__( 'Provided job %s is invalid.', 'wp-gistpen' ),
150153
$name
151154
),
@@ -180,6 +183,7 @@ public function runs( WP_REST_Request $request ) {
180183
return new WP_Error(
181184
'invalid_job',
182185
sprintf(
186+
/* translators: %s: Job slug. */
183187
__( 'Provided job %s is invalid.', 'wp-gistpen' ),
184188
$name
185189
),
@@ -207,6 +211,7 @@ public function console( WP_REST_Request $request ) {
207211
return new WP_Error(
208212
'invalid_job',
209213
sprintf(
214+
/* translators: %s: Job slug. */
210215
__( 'Provided job %s is invalid.', 'wp-gistpen' ),
211216
$name
212217
),
@@ -229,7 +234,7 @@ public function console( WP_REST_Request $request ) {
229234
) );
230235

231236
return new WP_REST_Response( array(
232-
'status' => $run->status,
237+
'status' => $run->status,
233238
'messages' => $messages->serialize(),
234239
) );
235240
}

app/Http/RepoController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function index( WP_REST_Request $request ) {
4646
$collection = $this->em->find_by(
4747
Repo::class,
4848
array(
49-
'offset' => ($page - 1) * 10,
49+
'offset' => ( $page - 1 ) * 10,
5050
'with' => array(
5151
'blobs' => array(
5252
'with' => 'language',

app/Http/SearchController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function __construct( EntityManager $em ) {
3838
* @throws \Exception
3939
*/
4040
public function get( WP_REST_Request $request ) {
41-
$args = array(
41+
$args = array(
4242
'posts_per_page' => 5,
43-
'with' => 'language',
43+
'with' => 'language',
4444
);
4545
$search_term = $request->get_param( 's' );
4646

app/Http/StrictParams.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function filter_unregistered_params( $response, $handler, WP_REST_Request
4848
foreach ( $request->get_params() as $key => $value ) {
4949
if ( ! isset( $attributes['args'][ $key ] ) ) {
5050
$invalid_params[ $key ] = sprintf(
51+
/* translators: %s: Request param. */
5152
__( 'Param "%s" is not a valid request param.', 'wp-gistpen' ),
5253
$key
5354
);
@@ -56,14 +57,15 @@ public function filter_unregistered_params( $response, $handler, WP_REST_Request
5657

5758
if ( $invalid_params ) {
5859
if ( is_wp_error( $response ) ) {
59-
$data = $response->get_error_data();
60+
$data = $response->get_error_data();
6061
$invalid_params = array_merge( $data['params'], $invalid_params );
6162
}
6263

6364
return new WP_Error(
6465
'rest_invalid_param',
6566
sprintf(
66-
__( 'Invalid parameter(s): %s' ),
67+
/* translators: %s: Request params, comma-separated. */
68+
__( 'Invalid parameter(s): %s', 'wp-gistpen' ),
6769
implode( ', ', array_keys( $invalid_params ) )
6870
),
6971
array(

0 commit comments

Comments
 (0)