|
@@ -108,7 +108,7 @@ discard block |
|
|
block discarded – undo |
|
108
|
108
|
foreach ( $this->tests as $key => $array ) { |
|
109
|
109
|
// The cheatsheets are still compatible with PHP < 5.3, so there is no way round this. |
|
110
|
110
|
// phpcs:ignore PHPCompatibility.PHP.DeprecatedFunctions.create_functionDeprecated,WordPress.PHP.RestrictedPHPFunctions.create_function_create_function,Generic.PHP.NoSilencedErrors.Discouraged |
|
111
|
|
- $this->tests[ $key ]['test'] = @create_function( $array['arg'], $array['function'] ); |
|
|
111
|
+ $this->tests[$key]['test'] = @create_function( $array['arg'], $array['function'] ); |
|
112
|
112
|
} |
|
113
|
113
|
} |
|
114
|
114
|
|
|
@@ -129,8 +129,8 @@ discard block |
|
|
block discarded – undo |
|
129
|
129
|
function merge_tests( $overload_tests ) { |
|
130
|
130
|
|
|
131
|
131
|
foreach ( $overload_tests as $key => $array ) { |
|
132
|
|
- if ( isset( $this->tests[ $key ], $this->tests[ $key ]['function'], $array['function'] ) ) { |
|
133
|
|
- $this->tests[ $key ]['function'] = $array['function']; |
|
|
132
|
+ if ( isset( $this->tests[$key], $this->tests[$key]['function'], $array['function'] ) ) { |
|
|
133
|
+ $this->tests[$key]['function'] = $array['function']; |
|
134
|
134
|
} |
|
135
|
135
|
} |
|
136
|
136
|
} |
|
@@ -144,8 +144,8 @@ discard block |
|
|
block discarded – undo |
|
144
|
144
|
* @return string |
|
145
|
145
|
*/ |
|
146
|
146
|
function get_tab_title( $tab ) { |
|
147
|
|
- if ( isset( $this->test_groups[ $tab ]['title'] ) && is_string( $this->test_groups[ $tab ]['title'] ) && $this->test_groups[ $tab ]['title'] !== '' ) { |
|
148
|
|
- return $this->test_groups[ $tab ]['title']; |
|
|
147
|
+ if ( isset( $this->test_groups[$tab]['title'] ) && is_string( $this->test_groups[$tab]['title'] ) && $this->test_groups[$tab]['title'] !== '' ) { |
|
|
148
|
+ return $this->test_groups[$tab]['title']; |
|
149
|
149
|
} |
|
150
|
150
|
else { |
|
151
|
151
|
return ''; |
|
@@ -192,7 +192,7 @@ discard block |
|
|
block discarded – undo |
|
192
|
192
|
*/ |
|
193
|
193
|
function get_test_group( $test_group = null ) { |
|
194
|
194
|
$key = key( $this->test_groups ); // Set the first test group as the default if no test group given. |
|
195
|
|
- if ( isset( $test_group, $this->test_groups[ $test_group ] ) ) { |
|
|
195
|
+ if ( isset( $test_group, $this->test_groups[$test_group] ) ) { |
|
196
|
196
|
$key = $test_group; |
|
197
|
197
|
} |
|
198
|
198
|
return $key; |
|
@@ -228,8 +228,8 @@ discard block |
|
|
block discarded – undo |
|
228
|
228
|
$this->test_legend = $legend_array; |
|
229
|
229
|
|
|
230
|
230
|
// Merge test group specific variables into the test array. |
|
231
|
|
- if ( isset( $extra_variables[ $test_group ] ) && $extra_variables[ $test_group ] !== array() ) { |
|
232
|
|
- $this->test_data = array_merge( $this->test_data, $extra_variables[ $test_group ] ); |
|
|
231
|
+ if ( isset( $extra_variables[$test_group] ) && $extra_variables[$test_group] !== array() ) { |
|
|
232
|
+ $this->test_data = array_merge( $this->test_data, $extra_variables[$test_group] ); |
|
233
|
233
|
} |
|
234
|
234
|
|
|
235
|
235
|
$keys = array_keys( $this->test_data ); |
|
@@ -302,11 +302,11 @@ discard block |
|
|
block discarded – undo |
|
302
|
302
|
); |
|
303
|
303
|
|
|
304
|
304
|
foreach ( $clean_this as $key => $function ) { |
|
305
|
|
- if ( isset( $GLOBALS['test_array'], $GLOBALS['test_array'][ $key ] ) && is_resource( $GLOBALS['test_array'][ $key ] ) ) { |
|
306
|
|
- $function( $GLOBALS['test_array'][ $key ] ); |
|
|
305
|
+ if ( isset( $GLOBALS['test_array'], $GLOBALS['test_array'][$key] ) && is_resource( $GLOBALS['test_array'][$key] ) ) { |
|
|
306
|
+ $function( $GLOBALS['test_array'][$key] ); |
|
307
|
307
|
} |
|
308
|
|
- if ( isset( $this->test_data, $this->test_data[ $key ] ) && is_resource( $this->test_data[ $key ] ) ) { |
|
309
|
|
- $function( $this->test_data[ $key ] ); |
|
|
308
|
+ if ( isset( $this->test_data, $this->test_data[$key] ) && is_resource( $this->test_data[$key] ) ) { |
|
|
309
|
+ $function( $this->test_data[$key] ); |
|
310
|
310
|
} |
|
311
|
311
|
} |
|
312
|
312
|
} |
|
@@ -369,15 +369,15 @@ discard block |
|
|
block discarded – undo |
|
369
|
369
|
*/ |
|
370
|
370
|
function print_table( $test_group ) { |
|
371
|
371
|
|
|
372
|
|
- if ( isset( $this->test_groups[ $test_group ] ) ) { |
|
|
372
|
+ if ( isset( $this->test_groups[$test_group] ) ) { |
|
373
|
373
|
$GLOBALS['encountered_errors'] = array(); |
|
374
|
374
|
|
|
375
|
375
|
echo ' |
|
376
|
376
|
<div id="', $test_group, '">'; |
|
377
|
377
|
|
|
378
|
|
- if ( isset( $this->test_groups[ $test_group ]['urls'] ) && ( is_array( $this->test_groups[ $test_group ]['urls'] ) && count( $this->test_groups[ $test_group ]['urls'] ) > 0 ) ) { |
|
|
378
|
+ if ( isset( $this->test_groups[$test_group]['urls'] ) && ( is_array( $this->test_groups[$test_group]['urls'] ) && count( $this->test_groups[$test_group]['urls'] ) > 0 ) ) { |
|
379
|
379
|
echo '<p>References:</p><ul>'; |
|
380
|
|
- foreach ( $this->test_groups[ $test_group ]['urls'] as $url ) { |
|
|
380
|
+ foreach ( $this->test_groups[$test_group]['urls'] as $url ) { |
|
381
|
381
|
printf( '<li><a href="%1$s" target="_blank">%1$s</a></li>', $url ); |
|
382
|
382
|
} |
|
383
|
383
|
unset( $url ); |
|
@@ -390,9 +390,9 @@ discard block |
|
|
block discarded – undo |
|
390
|
390
|
$last_key = null; |
|
391
|
391
|
|
|
392
|
392
|
foreach ( $this->test_data_keys as $key ) { |
|
393
|
|
- $value = $this->test_data[ $key ]; |
|
|
393
|
+ $value = $this->test_data[$key]; |
|
394
|
394
|
$legend = ''; |
|
395
|
|
- if ( isset( $this->test_legend[ $key ] ) ) { |
|
|
395
|
+ if ( isset( $this->test_legend[$key] ) ) { |
|
396
|
396
|
$legend = '<sup class="fright"><a href="#var-legend-' . $key . '">†' . $key . '</a></sup>'; |
|
397
|
397
|
} |
|
398
|
398
|
|
|
@@ -403,7 +403,7 @@ discard block |
|
|
block discarded – undo |
|
403
|
403
|
$class[] = 'new-var-type'; |
|
404
|
404
|
$last_key = $type; |
|
405
|
405
|
} |
|
406
|
|
- if ( isset( $this->test_groups[ $test_group ]['target'] ) && $this->test_groups[ $test_group ]['target'] === $type ) { |
|
|
406
|
+ if ( isset( $this->test_groups[$test_group]['target'] ) && $this->test_groups[$test_group]['target'] === $type ) { |
|
407
|
407
|
$class[] = 'target'; |
|
408
|
408
|
} |
|
409
|
409
|
|
|
@@ -465,15 +465,15 @@ discard block |
|
|
block discarded – undo |
|
465
|
465
|
<tr> |
|
466
|
466
|
' . $group_label; |
|
467
|
467
|
|
|
468
|
|
- foreach ( $this->test_groups[ $test_group ]['tests'] as $test ) { |
|
|
468
|
+ foreach ( $this->test_groups[$test_group]['tests'] as $test ) { |
|
469
|
469
|
$class = $this->get_table_header_cell_class( $test_group, $test ); |
|
470
|
|
- $tooltip = ( isset( $this->tests[ $test ]['tooltip'] ) ? ' title="' . htmlspecialchars( $this->tests[ $test ]['tooltip'], ENT_QUOTES, 'UTF-8' ) . '"' : '' ); |
|
|
470
|
+ $tooltip = ( isset( $this->tests[$test]['tooltip'] ) ? ' title="' . htmlspecialchars( $this->tests[$test]['tooltip'], ENT_QUOTES, 'UTF-8' ) . '"' : '' ); |
|
471
|
471
|
|
|
472
|
472
|
$html .= ' |
|
473
|
473
|
<th' . $class . '>' . |
|
474
|
|
- ( ( isset( $this->tests[ $test ]['url'] ) && $this->tests[ $test ]['url'] !== '' ) ? '<a href="' . $this->tests[ $test ]['url'] . '" target="_blank"' . $tooltip . '>' : '' ) . |
|
475
|
|
- $this->tests[ $test ]['title'] . |
|
476
|
|
- ( ( isset( $this->tests[ $test ]['url'] ) && $this->tests[ $test ]['url'] !== '' ) ? '</a>' : '' ); |
|
|
474
|
+ ( ( isset( $this->tests[$test]['url'] ) && $this->tests[$test]['url'] !== '' ) ? '<a href="' . $this->tests[$test]['url'] . '" target="_blank"' . $tooltip . '>' : '' ) . |
|
|
475
|
+ $this->tests[$test]['title'] . |
|
|
476
|
+ ( ( isset( $this->tests[$test]['url'] ) && $this->tests[$test]['url'] !== '' ) ? '</a>' : '' ); |
|
477
|
477
|
|
|
478
|
478
|
|
|
479
|
479
|
$html .= $this->get_table_header_note_indicators( $test, $test_group ); |
|
@@ -498,11 +498,11 @@ discard block |
|
|
block discarded – undo |
|
498
|
498
|
* @return string |
|
499
|
499
|
*/ |
|
500
|
500
|
function get_table_header_group_label( $test_group ) { |
|
501
|
|
- if ( isset( $this->test_groups[ $test_group ]['book_url'] ) && $this->test_groups[ $test_group ]['book_url'] !== '' ) { |
|
502
|
|
- $group_label = '<th class="label-col"><a href="' . $this->test_groups[ $test_group ]['book_url'] . '" target="_blank">' . $this->test_groups[ $test_group ]['title'] . '</a></th>'; |
|
|
501
|
+ if ( isset( $this->test_groups[$test_group]['book_url'] ) && $this->test_groups[$test_group]['book_url'] !== '' ) { |
|
|
502
|
+ $group_label = '<th class="label-col"><a href="' . $this->test_groups[$test_group]['book_url'] . '" target="_blank">' . $this->test_groups[$test_group]['title'] . '</a></th>'; |
|
503
|
503
|
} |
|
504
|
504
|
else { |
|
505
|
|
- $group_label = '<th class="label-col">' . $this->test_groups[ $test_group ]['title'] . '</th>'; |
|
|
505
|
+ $group_label = '<th class="label-col">' . $this->test_groups[$test_group]['title'] . '</th>'; |
|
506
|
506
|
} |
|
507
|
507
|
|
|
508
|
508
|
return $group_label; |
|
@@ -520,12 +520,12 @@ discard block |
|
|
block discarded – undo |
|
520
|
520
|
function get_table_header_note_indicators( $test, $test_group ) { |
|
521
|
521
|
$notes = ''; |
|
522
|
522
|
|
|
523
|
|
- if ( isset( $this->tests[ $test ]['notes'] ) && ( is_array( $this->tests[ $test ]['notes'] ) && count( $this->tests[ $test ]['notes'] ) > 0 ) ) { |
|
|
523
|
+ if ( isset( $this->tests[$test]['notes'] ) && ( is_array( $this->tests[$test]['notes'] ) && count( $this->tests[$test]['notes'] ) > 0 ) ) { |
|
524
|
524
|
|
|
525
|
|
- $this->table_notes = array_merge( $this->table_notes, $this->tests[ $test ]['notes'] ); |
|
|
525
|
+ $this->table_notes = array_merge( $this->table_notes, $this->tests[$test]['notes'] ); |
|
526
|
526
|
$this->table_notes = array_unique( $this->table_notes ); |
|
527
|
527
|
|
|
528
|
|
- foreach ( $this->tests[ $test ]['notes'] as $note ) { |
|
|
528
|
+ foreach ( $this->tests[$test]['notes'] as $note ) { |
|
529
|
529
|
$note_id = array_search( $note, $this->table_notes, true ); |
|
530
|
530
|
if ( $note_id !== false ) { |
|
531
|
531
|
$notes .= ' <sup><a href="#' . $test_group . '-note' . ( $note_id + 1 ) . '">‡' . ( $note_id + 1 ) . '</a></sup>'; |
|
@@ -548,7 +548,7 @@ discard block |
|
|
block discarded – undo |
|
548
|
548
|
$class = array(); |
|
549
|
549
|
|
|
550
|
550
|
foreach ( $this->table_header_class_map as $group_key => $classname ) { |
|
551
|
|
- if ( isset( $this->test_groups[ $test_group ][ $group_key ] ) && in_array( $test, $this->test_groups[ $test_group ][ $group_key ], true ) ) { |
|
|
551
|
+ if ( isset( $this->test_groups[$test_group][$group_key] ) && in_array( $test, $this->test_groups[$test_group][$group_key], true ) ) { |
|
552
|
552
|
$class[] = $classname; |
|
553
|
553
|
} |
|
554
|
554
|
} |
|
@@ -585,7 +585,7 @@ discard block |
|
|
block discarded – undo |
|
585
|
585
|
*/ |
|
586
|
586
|
function print_row_cells( $value, $test_group ) { |
|
587
|
587
|
|
|
588
|
|
- foreach ( $this->test_groups[ $test_group ]['tests'] as $key => $test ) { |
|
|
588
|
+ foreach ( $this->test_groups[$test_group]['tests'] as $key => $test ) { |
|
589
|
589
|
$GLOBALS['has_error'] = array(); |
|
590
|
590
|
|
|
591
|
591
|
$class = $this->get_table_row_cell_class( $test_group, $test ); |
|
@@ -594,7 +594,7 @@ discard block |
|
|
block discarded – undo |
|
594
|
594
|
<td' . $class . '>'; |
|
595
|
595
|
|
|
596
|
596
|
$val = $this->generate_value( $value ); |
|
597
|
|
- $this->tests[ $test ]['test']( $val ); |
|
|
597
|
+ $this->tests[$test]['test']( $val ); |
|
598
|
598
|
$this->print_row_cell_error_refs(); |
|
599
|
599
|
|
|
600
|
600
|
echo ' </td>'; |
|
@@ -615,13 +615,13 @@ discard block |
|
|
block discarded – undo |
|
615
|
615
|
*/ |
|
616
|
616
|
function get_table_row_cell_class( $test_group, $test ) { |
|
617
|
617
|
$class = array( $test ); |
|
618
|
|
- if ( in_array( $test, $this->test_groups[ $test_group ]['best'], true ) ) { |
|
|
618
|
+ if ( in_array( $test, $this->test_groups[$test_group]['best'], true ) ) { |
|
619
|
619
|
$class[] = 'best'; |
|
620
|
620
|
} |
|
621
|
|
- else if ( in_array( $test, $this->test_groups[ $test_group ]['good'], true ) ) { |
|
|
621
|
+ else if ( in_array( $test, $this->test_groups[$test_group]['good'], true ) ) { |
|
622
|
622
|
$class[] = 'good'; |
|
623
|
623
|
} |
|
624
|
|
- if ( in_array( $test, $this->test_groups[ $test_group ]['break_at'], true ) ) { |
|
|
624
|
+ if ( in_array( $test, $this->test_groups[$test_group]['break_at'], true ) ) { |
|
625
|
625
|
$class[] = 'end'; |
|
626
|
626
|
} |
|
627
|
627
|
|