We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -45,24 +45,24 @@ |
||
45 | 45 | * @param Settings $settings Required. |
46 | 46 | * @param bool $is_title Optional. Default false. |
47 | 47 | */ |
48 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
49 | - if ( empty( $settings['smartDiacritics'] ) ) { |
|
48 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
49 | + if (empty($settings['smartDiacritics'])) { |
|
50 | 50 | return; // abort. |
51 | 51 | } |
52 | 52 | |
53 | - if ( ! empty( $settings['diacriticReplacement'] ) && |
|
54 | - ! empty( $settings['diacriticReplacement']['patterns'] ) && |
|
55 | - ! empty( $settings['diacriticReplacement']['replacements'] ) ) { |
|
53 | + if ( ! empty($settings['diacriticReplacement']) && |
|
54 | + ! empty($settings['diacriticReplacement']['patterns']) && |
|
55 | + ! empty($settings['diacriticReplacement']['replacements'])) { |
|
56 | 56 | |
57 | 57 | // Uses "word" => "replacement" pairs from an array to make fast preg_* replacements. |
58 | 58 | $replacements = $settings['diacriticReplacement']['replacements']; |
59 | - $textnode->data = preg_replace_callback( $settings['diacriticReplacement']['patterns'], function( $match ) use ( $replacements ) { |
|
60 | - if ( isset( $replacements[ $match[0] ] ) ) { |
|
61 | - return $replacements[ $match[0] ]; |
|
59 | + $textnode->data = preg_replace_callback($settings['diacriticReplacement']['patterns'], function($match) use ($replacements) { |
|
60 | + if (isset($replacements[$match[0]])) { |
|
61 | + return $replacements[$match[0]]; |
|
62 | 62 | } else { |
63 | 63 | return $match[0]; |
64 | 64 | } |
65 | - }, $textnode->data ); |
|
65 | + }, $textnode->data); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param bool $feed_compatible Optional. Default false. |
53 | 53 | */ |
54 | - public function __construct( $feed_compatible = false ) { |
|
54 | + public function __construct($feed_compatible = false) { |
|
55 | 55 | $this->feed_compatible = $feed_compatible; |
56 | 56 | } |
57 | 57 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - abstract public function apply( \DOMText $textnode, Settings $settings, $is_title = false ); |
|
67 | + abstract public function apply(\DOMText $textnode, Settings $settings, $is_title = false); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Determines whether the fix should be applied to (RSS) feeds. |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return string The string without `$prev_char` and `$next_char`. |
88 | 88 | */ |
89 | - protected static function remove_adjacent_characters( $string, $prev_char = '', $next_char = '' ) { |
|
89 | + protected static function remove_adjacent_characters($string, $prev_char = '', $next_char = '') { |
|
90 | 90 | // Use the most efficient string functions. |
91 | - $func = Strings::functions( $string ); |
|
91 | + $func = Strings::functions($string); |
|
92 | 92 | |
93 | 93 | // Remove previous character. |
94 | - if ( '' !== $prev_char ) { |
|
95 | - $string = $func['substr']( $string, 1, $func['strlen']( $string ) ); |
|
94 | + if ('' !== $prev_char) { |
|
95 | + $string = $func['substr']($string, 1, $func['strlen']($string)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Remove next character. |
99 | - if ( '' !== $next_char ) { |
|
100 | - $string = $func['substr']( $string, 0, $func['strlen']( $string ) - 1 ); |
|
99 | + if ('' !== $next_char) { |
|
100 | + $string = $func['substr']($string, 0, $func['strlen']($string) - 1); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | return $string; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * @param string $css_class HTML class used in markup. |
54 | 54 | * @param bool $feed_compatible Optional. Default false. |
55 | 55 | */ |
56 | - public function __construct( $css_class, $feed_compatible = false ) { |
|
57 | - parent::__construct( self::REGEX, self::SETTINGS_SWITCH, $css_class, $feed_compatible ); |
|
56 | + public function __construct($css_class, $feed_compatible = false) { |
|
57 | + parent::__construct(self::REGEX, self::SETTINGS_SWITCH, $css_class, $feed_compatible); |
|
58 | 58 | } |
59 | 59 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param string $settings_switch On/off switch for fix. |
70 | 70 | * @param bool $feed_compatible Optional. Default false. |
71 | 71 | */ |
72 | - public function __construct( $regex, $replacement, $settings_switch, $feed_compatible = false ) { |
|
73 | - parent::__construct( $feed_compatible ); |
|
72 | + public function __construct($regex, $replacement, $settings_switch, $feed_compatible = false) { |
|
73 | + parent::__construct($feed_compatible); |
|
74 | 74 | |
75 | 75 | $this->regex = $regex; |
76 | 76 | $this->settings_switch = $settings_switch; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | * @param Settings $settings Required. |
85 | 85 | * @param bool $is_title Optional. Default false. |
86 | 86 | */ |
87 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
88 | - if ( empty( $settings[ $this->settings_switch ] ) ) { |
|
87 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
88 | + if (empty($settings[$this->settings_switch])) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $textnode->data = preg_replace( $this->regex, $this->replacement, $textnode->data ); |
|
92 | + $textnode->data = preg_replace($this->regex, $this->replacement, $textnode->data); |
|
93 | 93 | } |
94 | 94 | } |
@@ -49,22 +49,22 @@ |
||
49 | 49 | * @param Settings $settings Required. |
50 | 50 | * @param bool $is_title Optional. Default false. |
51 | 51 | */ |
52 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
53 | - if ( empty( $settings['smartMarks'] ) ) { |
|
52 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
53 | + if (empty($settings['smartMarks'])) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Escape usage of "501(c)(1...29)" (US non-profit). |
58 | - $textnode->data = preg_replace( self::ESCAPE_501C, '$1' . RE::ESCAPE_MARKER . '$2' . RE::ESCAPE_MARKER . '$3', $textnode->data ); |
|
58 | + $textnode->data = preg_replace(self::ESCAPE_501C, '$1' . RE::ESCAPE_MARKER . '$2' . RE::ESCAPE_MARKER . '$3', $textnode->data); |
|
59 | 59 | |
60 | 60 | // Replace marks. |
61 | - $textnode->data = str_replace( [ '(c)', '(C)' ], U::COPYRIGHT, $textnode->data ); |
|
62 | - $textnode->data = str_replace( [ '(r)', '(R)' ], U::REGISTERED_MARK, $textnode->data ); |
|
63 | - $textnode->data = str_replace( [ '(p)', '(P)' ], U::SOUND_COPY_MARK, $textnode->data ); |
|
64 | - $textnode->data = str_replace( [ '(sm)', '(SM)' ], U::SERVICE_MARK, $textnode->data ); |
|
65 | - $textnode->data = str_replace( [ '(tm)', '(TM)' ], U::TRADE_MARK, $textnode->data ); |
|
61 | + $textnode->data = str_replace(['(c)', '(C)'], U::COPYRIGHT, $textnode->data); |
|
62 | + $textnode->data = str_replace(['(r)', '(R)'], U::REGISTERED_MARK, $textnode->data); |
|
63 | + $textnode->data = str_replace(['(p)', '(P)'], U::SOUND_COPY_MARK, $textnode->data); |
|
64 | + $textnode->data = str_replace(['(sm)', '(SM)'], U::SERVICE_MARK, $textnode->data); |
|
65 | + $textnode->data = str_replace(['(tm)', '(TM)'], U::TRADE_MARK, $textnode->data); |
|
66 | 66 | |
67 | 67 | // Un-escape escaped sequences. |
68 | - $textnode->data = str_replace( RE::ESCAPE_MARKER, '', $textnode->data ); |
|
68 | + $textnode->data = str_replace(RE::ESCAPE_MARKER, '', $textnode->data); |
|
69 | 69 | } |
70 | 70 | } |
@@ -40,7 +40,6 @@ |
||
40 | 40 | |
41 | 41 | /** |
42 | 42 | * The setting string used to enable/disable the fix (e.g. 'styleAmpersands'). |
43 | - |
|
44 | 43 | * @var string |
45 | 44 | */ |
46 | 45 | protected $settings_switch; |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param string $css_class HTML class used in markup. |
70 | 70 | * @param bool $feed_compatible Optional. Default false. |
71 | 71 | */ |
72 | - public function __construct( $regex, $settings_switch, $css_class, $feed_compatible = false ) { |
|
73 | - parent::__construct( $css_class, $feed_compatible ); |
|
72 | + public function __construct($regex, $settings_switch, $css_class, $feed_compatible = false) { |
|
73 | + parent::__construct($css_class, $feed_compatible); |
|
74 | 74 | |
75 | 75 | $this->regex = $regex; |
76 | 76 | $this->settings_switch = $settings_switch; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | * @param Settings $settings Required. |
85 | 85 | * @param bool $is_title Optional. Default false. |
86 | 86 | */ |
87 | - public function apply_internal( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
88 | - if ( empty( $settings[ $this->settings_switch ] ) ) { |
|
87 | + public function apply_internal(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
88 | + if (empty($settings[$this->settings_switch])) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $textnode->data = preg_replace( $this->regex, '<span class="' . $this->css_class . '">$1</span>', $textnode->data ); |
|
92 | + $textnode->data = preg_replace($this->regex, '<span class="' . $this->css_class . '">$1</span>', $textnode->data); |
|
93 | 93 | } |
94 | 94 | } |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | * @param Settings $settings Required. |
104 | 104 | * @param bool $is_title Optional. Default false. |
105 | 105 | */ |
106 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
107 | - if ( empty( $settings['dashSpacing'] ) ) { |
|
106 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
107 | + if (empty($settings['dashSpacing'])) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Various special characters and regular expressions. |
112 | 112 | $s = $settings->dash_style(); |
113 | 113 | |
114 | - if ( $s != $this->cached_dash_style ) { |
|
115 | - $this->update_dash_spacing_regex( $s->parenthetical_dash(), $s->parenthetical_space(), $s->interval_dash(), $s->interval_space() ); |
|
114 | + if ($s != $this->cached_dash_style) { |
|
115 | + $this->update_dash_spacing_regex($s->parenthetical_dash(), $s->parenthetical_space(), $s->interval_dash(), $s->interval_space()); |
|
116 | 116 | $this->cached_dash_style = $s; |
117 | 117 | } |
118 | 118 | |
119 | - $textnode->data = preg_replace( self::EM_DASH_SPACING, $this->em_dash_replacement, $textnode->data ); |
|
120 | - $textnode->data = preg_replace( $this->parenthetical_dash_spacing, $this->parenthetical_dash_replacement, $textnode->data ); |
|
121 | - $textnode->data = preg_replace( $this->interval_dash_spacing, $this->interval_dash_replacement, $textnode->data ); |
|
119 | + $textnode->data = preg_replace(self::EM_DASH_SPACING, $this->em_dash_replacement, $textnode->data); |
|
120 | + $textnode->data = preg_replace($this->parenthetical_dash_spacing, $this->parenthetical_dash_replacement, $textnode->data); |
|
121 | + $textnode->data = preg_replace($this->interval_dash_spacing, $this->interval_dash_replacement, $textnode->data); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $interval The dash character used for interval dashes. |
130 | 130 | * @param string $interval_space The space character used around interval dashes. |
131 | 131 | */ |
132 | - private function update_dash_spacing_regex( $parenthetical, $parenthetical_space, $interval, $interval_space ) { |
|
132 | + private function update_dash_spacing_regex($parenthetical, $parenthetical_space, $interval, $interval_space) { |
|
133 | 133 | $this->parenthetical_dash_spacing = "/ |
134 | 134 | (?: |
135 | 135 | \s |
@@ -53,23 +53,23 @@ |
||
53 | 53 | * @param Settings $settings Required. |
54 | 54 | * @param bool $is_title Optional. Default false. |
55 | 55 | */ |
56 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
57 | - if ( empty( $settings['spaceCollapse'] ) ) { |
|
56 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
57 | + if (empty($settings['spaceCollapse'])) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Normal spacing. |
62 | - $textnode->data = preg_replace( self::COLLAPSE_NORMAL_SPACES, ' ', $textnode->data ); |
|
62 | + $textnode->data = preg_replace(self::COLLAPSE_NORMAL_SPACES, ' ', $textnode->data); |
|
63 | 63 | |
64 | 64 | // Non-breakable space get's priority. If non-breakable space exists in a string of spaces, it collapses to a single non-breakable space. |
65 | - $textnode->data = preg_replace( self::COLLAPSE_NON_BREAKABLE_SPACES, U::NO_BREAK_SPACE, $textnode->data ); |
|
65 | + $textnode->data = preg_replace(self::COLLAPSE_NON_BREAKABLE_SPACES, U::NO_BREAK_SPACE, $textnode->data); |
|
66 | 66 | |
67 | 67 | // For any other spaceing, replace with the first occurance of an unusual space character. |
68 | - $textnode->data = preg_replace( self::COLLAPSE_OTHER_SPACES, '$1', $textnode->data ); |
|
68 | + $textnode->data = preg_replace(self::COLLAPSE_OTHER_SPACES, '$1', $textnode->data); |
|
69 | 69 | |
70 | 70 | // Remove all spacing at beginning of block level elements. |
71 | - if ( '' === DOM::get_prev_chr( $textnode ) ) { // we have the first text in a block level element. |
|
72 | - $textnode->data = preg_replace( self::COLLAPSE_SPACES_AT_START_OF_BLOCK, '', $textnode->data ); |
|
71 | + if ('' === DOM::get_prev_chr($textnode)) { // we have the first text in a block level element. |
|
72 | + $textnode->data = preg_replace(self::COLLAPSE_SPACES_AT_START_OF_BLOCK, '', $textnode->data); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -46,12 +46,12 @@ |
||
46 | 46 | * @param Settings $settings Required. |
47 | 47 | * @param bool $is_title Optional. Default false. |
48 | 48 | */ |
49 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
50 | - if ( empty( $settings['smartEllipses'] ) ) { |
|
49 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
50 | + if (empty($settings['smartEllipses'])) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - $textnode->data = str_replace( [ '....', '. . . .' ], '.' . U::ELLIPSIS, $textnode->data ); |
|
55 | - $textnode->data = str_replace( [ '...', '. . .' ], U::ELLIPSIS, $textnode->data ); |
|
54 | + $textnode->data = str_replace(['....', '. . . .'], '.' . U::ELLIPSIS, $textnode->data); |
|
55 | + $textnode->data = str_replace(['...', '. . .'], U::ELLIPSIS, $textnode->data); |
|
56 | 56 | } |
57 | 57 | } |