We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -74,40 +74,40 @@ discard block |
||
74 | 74 | * @param Settings $settings Required. |
75 | 75 | * @param bool $is_title Optional. Default false. |
76 | 76 | */ |
77 | - public function apply( \DOMText $textnode, Settings $settings, $is_title = false ) { |
|
77 | + public function apply(\DOMText $textnode, Settings $settings, $is_title = false) { |
|
78 | 78 | // Intervening inline tags may interfere with widow identification, but that is a sacrifice of using the parser. |
79 | 79 | // Intervening tags will only interfere if they separate the widow from previous or preceding whitespace. |
80 | - if ( empty( $settings['dewidow'] ) || empty( $settings['dewidowMaxPull'] ) || empty( $settings['dewidowMaxLength'] ) ) { |
|
80 | + if (empty($settings['dewidow']) || empty($settings['dewidowMaxPull']) || empty($settings['dewidowMaxLength'])) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - if ( '' === DOM::get_next_chr( $textnode ) ) { |
|
84 | + if ('' === DOM::get_next_chr($textnode)) { |
|
85 | 85 | // We have the last type "text" child of a block level element. |
86 | - $textnode->data = preg_replace_callback( self::REGEX, function( array $widow ) use ( $settings ) { |
|
87 | - $func = Strings::functions( $widow[0] ); |
|
86 | + $textnode->data = preg_replace_callback(self::REGEX, function(array $widow) use ($settings) { |
|
87 | + $func = Strings::functions($widow[0]); |
|
88 | 88 | |
89 | 89 | // If we are here, we know that widows are being protected in some fashion |
90 | 90 | // with that, we will assert that widows should never be hyphenated or wrapped |
91 | 91 | // as such, we will strip soft hyphens and zero-width-spaces. |
92 | - $widow['widow'] = str_replace( U::ZERO_WIDTH_SPACE, '', $widow['widow'] ); |
|
93 | - $widow['widow'] = str_replace( U::SOFT_HYPHEN, '', $widow['widow'] ); |
|
94 | - $widow['trailing'] = preg_replace( "/\s+/{$func['u']}", U::NO_BREAK_SPACE, $widow['trailing'] ); |
|
95 | - $widow['trailing'] = str_replace( U::ZERO_WIDTH_SPACE, '', $widow['trailing'] ); |
|
96 | - $widow['trailing'] = str_replace( U::SOFT_HYPHEN, '', $widow['trailing'] ); |
|
92 | + $widow['widow'] = str_replace(U::ZERO_WIDTH_SPACE, '', $widow['widow']); |
|
93 | + $widow['widow'] = str_replace(U::SOFT_HYPHEN, '', $widow['widow']); |
|
94 | + $widow['trailing'] = preg_replace("/\s+/{$func['u']}", U::NO_BREAK_SPACE, $widow['trailing']); |
|
95 | + $widow['trailing'] = str_replace(U::ZERO_WIDTH_SPACE, '', $widow['trailing']); |
|
96 | + $widow['trailing'] = str_replace(U::SOFT_HYPHEN, '', $widow['trailing']); |
|
97 | 97 | |
98 | 98 | // Eject if widows neighbor is proceeded by a no break space (the pulled text would be too long). |
99 | - if ( '' === $widow['space_before'] || strstr( U::NO_BREAK_SPACE, $widow['space_before'] ) ) { |
|
99 | + if ('' === $widow['space_before'] || strstr(U::NO_BREAK_SPACE, $widow['space_before'])) { |
|
100 | 100 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Eject if widows neighbor length exceeds the max allowed or widow length exceeds max allowed. |
104 | - if ( $func['strlen']( $widow['neighbor'] ) > $settings['dewidowMaxPull'] || |
|
105 | - $func['strlen']( $widow['widow'] ) > $settings['dewidowMaxLength'] ) { |
|
104 | + if ($func['strlen']($widow['neighbor']) > $settings['dewidowMaxPull'] || |
|
105 | + $func['strlen']($widow['widow']) > $settings['dewidowMaxLength']) { |
|
106 | 106 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Never replace thin and hair spaces with . |
110 | - switch ( $widow['space_between'] ) { |
|
110 | + switch ($widow['space_between']) { |
|
111 | 111 | case U::THIN_SPACE: |
112 | 112 | case U::HAIR_SPACE: |
113 | 113 | return $widow['space_before'] . $widow['neighbor'] . $widow['space_between'] . $widow['widow'] . $widow['trailing']; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | // Let's protect some widows! |
117 | 117 | return $widow['space_before'] . $widow['neighbor'] . U::NO_BREAK_SPACE . $widow['widow'] . $widow['trailing']; |
118 | - }, $textnode->data ); |
|
118 | + }, $textnode->data); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |