Skip to content

Commit 5bbf780

Browse files
committed
Merge remote-tracking branch 'github/lib' into lib-1.x
2 parents 5024d62 + 4151738 commit 5bbf780

File tree

9 files changed

+139
-140
lines changed

9 files changed

+139
-140
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
on:
3+
pull_request: null
4+
push:
5+
branches:
6+
- lib
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
php:
13+
- '7.4'
14+
- '8.0'
15+
- '8.1'
16+
- '8.2'
17+
18+
name: Linting - PHP ${{ matrix.php }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
coverage: none
25+
extensions: intl
26+
- run: composer install --no-progress
27+
# - run: composer codestyle
28+
- run: composer phpstan
29+
if: matrix.php == '8.1'
30+
- run: composer tests

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
22
environment:
33
php:
4-
version: '7.0.20'
4+
version: '7.4'
55
nodes:
66
analysis:
77
project_setup:

.travis.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,10 @@ matrix:
44
include:
55
- php: hhvm-3.18
66
dist: trusty
7-
- php: 5.3
8-
dist: precise
9-
- php: 5.4
10-
dist: trusty
11-
- php: 5.5
12-
dist: trusty
13-
- php: 5.6
14-
dist: xenial
15-
- php: 7.0
16-
dist: xenial
17-
- php: 7.1
18-
dist: bionic
19-
- php: 7.2
20-
dist: bionic
21-
- php: 7.3
22-
dist: bionic
237
- php: 7.4
248
dist: bionic
9+
- php: 8.0
10+
dist: bionic
2511

2612
install:
2713
- composer install --prefer-dist

Michelf/Markdown.php

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Markdown implements MarkdownInterface {
3131
*/
3232
public static function defaultTransform($text) {
3333
// Take parser class on which this function was called.
34-
$parser_class = \get_called_class();
34+
$parser_class = static::class;
3535

3636
// Try to take parser from the static parser list
3737
static $parser_list;
@@ -49,39 +49,34 @@ public static function defaultTransform($text) {
4949
/**
5050
* Configuration variables
5151
*/
52-
5352
/**
5453
* Change to ">" for HTML output.
55-
* @var string
5654
*/
57-
public $empty_element_suffix = " />";
55+
public string $empty_element_suffix = " />";
5856

5957
/**
6058
* The width of indentation of the output markup
61-
* @var int
6259
*/
63-
public $tab_width = 4;
60+
public int $tab_width = 4;
6461

6562
/**
6663
* Change to `true` to disallow markup or entities.
67-
* @var boolean
6864
*/
69-
public $no_markup = false;
70-
public $no_entities = false;
65+
public bool $no_markup = false;
66+
public bool $no_entities = false;
7167

7268

7369
/**
7470
* Change to `true` to enable line breaks on \n without two trailling spaces
7571
* @var boolean
7672
*/
77-
public $hard_wrap = false;
73+
public bool $hard_wrap = false;
7874

7975
/**
8076
* Predefined URLs and titles for reference links and images.
81-
* @var array
8277
*/
83-
public $predef_urls = array();
84-
public $predef_titles = array();
78+
public array $predef_urls = array();
79+
public array $predef_titles = array();
8580

8681
/**
8782
* Optional filter function for URLs
@@ -121,32 +116,27 @@ public static function defaultTransform($text) {
121116
* <li>List item two</li>
122117
* <li>List item three</li>
123118
* </ol>
124-
*
125-
* @var bool
126119
*/
127-
public $enhanced_ordered_list = false;
120+
public bool $enhanced_ordered_list = false;
128121

129122
/**
130123
* Parser implementation
131124
*/
132-
133125
/**
134126
* Regex to match balanced [brackets].
135127
* Needed to insert a maximum bracked depth while converting to PHP.
136-
* @var int
137128
*/
138-
protected $nested_brackets_depth = 6;
129+
protected int $nested_brackets_depth = 6;
139130
protected $nested_brackets_re;
140131

141-
protected $nested_url_parenthesis_depth = 4;
132+
protected int $nested_url_parenthesis_depth = 4;
142133
protected $nested_url_parenthesis_re;
143134

144135
/**
145136
* Table of hash values for escaped characters:
146-
* @var string
147137
*/
148-
protected $escape_chars = '\`*_{}[]()>#+-.!';
149-
protected $escape_chars_re;
138+
protected string $escape_chars = '\`*_{}[]()>#+-.!';
139+
protected string $escape_chars_re;
150140

151141
/**
152142
* Constructor function. Initialize appropriate member variables.
@@ -175,23 +165,20 @@ public function __construct() {
175165

176166
/**
177167
* Internal hashes used during transformation.
178-
* @var array
179168
*/
180-
protected $urls = array();
169+
protected array $urls = array();
181170
protected $titles = array();
182-
protected $html_hashes = array();
171+
protected array $html_hashes = array();
183172

184173
/**
185174
* Status flag to avoid invalid nesting.
186-
* @var boolean
187175
*/
188-
protected $in_anchor = false;
176+
protected bool $in_anchor = false;
189177

190178
/**
191179
* Status flag to avoid invalid nesting.
192-
* @var boolean
193180
*/
194-
protected $in_emphasis_processing = false;
181+
protected bool $in_emphasis_processing = false;
195182

196183
/**
197184
* Called before the transformation process starts to setup parser states.
@@ -263,9 +250,8 @@ public function transform($text) {
263250

264251
/**
265252
* Define the document gamut
266-
* @var array
267253
*/
268-
protected $document_gamut = array(
254+
protected array $document_gamut = array(
269255
// Strip link definitions, store in hashes.
270256
"stripLinkDefinitions" => 20,
271257
"runBasicBlockGamut" => 30,
@@ -525,9 +511,8 @@ protected function hashBlock($text) {
525511
/**
526512
* Define the block gamut - these are all the transformations that form
527513
* block-level tags like paragraphs, headers, and list items.
528-
* @var array
529514
*/
530-
protected $block_gamut = array(
515+
protected array $block_gamut = array(
531516
"doHeaders" => 10,
532517
"doHorizontalRules" => 20,
533518
"doLists" => 40,
@@ -597,9 +582,8 @@ protected function doHorizontalRules($text) {
597582
/**
598583
* These are all the transformations that occur *within* block-level
599584
* tags like paragraphs, headers, and list items.
600-
* @var array
601585
*/
602-
protected $span_gamut = array(
586+
protected array $span_gamut = array(
603587
// Process character escapes, code spans, and inline HTML
604588
// in one shot.
605589
"parseSpan" => -30,
@@ -724,7 +708,7 @@ protected function doAnchors($text) {
724708

725709
/**
726710
* Callback method to parse referenced anchors
727-
* @param string $matches
711+
* @param array $matches
728712
* @return string
729713
*/
730714
protected function _doAnchors_reference_callback($matches) {
@@ -763,7 +747,7 @@ protected function _doAnchors_reference_callback($matches) {
763747

764748
/**
765749
* Callback method to parse inline anchors
766-
* @param string $matches
750+
* @param array $matches
767751
* @return string
768752
*/
769753
protected function _doAnchors_inline_callback($matches) {
@@ -781,7 +765,7 @@ protected function _doAnchors_inline_callback($matches) {
781765
$url = $this->encodeURLAttribute($url);
782766

783767
$result = "<a href=\"$url\"";
784-
if (isset($title)) {
768+
if ($title) {
785769
$title = $this->encodeAttribute($title);
786770
$result .= " title=\"$title\"";
787771
}
@@ -1105,9 +1089,8 @@ protected function _doLists_callback($matches) {
11051089

11061090
/**
11071091
* Nesting tracker for list levels
1108-
* @var integer
11091092
*/
1110-
protected $list_level = 0;
1093+
protected int $list_level = 0;
11111094

11121095
/**
11131096
* Process the contents of a single ordered or unordered list, splitting it
@@ -1248,7 +1231,7 @@ protected function makeCodeSpan($code) {
12481231
* Define the emphasis operators with their regex matches
12491232
* @var array
12501233
*/
1251-
protected $em_relist = array(
1234+
protected array $em_relist = array(
12521235
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?![\.,:;]?\s)',
12531236
'*' => '(?<![\s*])\*(?!\*)',
12541237
'_' => '(?<![\s_])_(?!_)',
@@ -1258,7 +1241,7 @@ protected function makeCodeSpan($code) {
12581241
* Define the strong operators with their regex matches
12591242
* @var array
12601243
*/
1261-
protected $strong_relist = array(
1244+
protected array $strong_relist = array(
12621245
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?![\.,:;]?\s)',
12631246
'**' => '(?<![\s*])\*\*(?!\*)',
12641247
'__' => '(?<![\s_])__(?!_)',
@@ -1268,17 +1251,16 @@ protected function makeCodeSpan($code) {
12681251
* Define the emphasis + strong operators with their regex matches
12691252
* @var array
12701253
*/
1271-
protected $em_strong_relist = array(
1254+
protected array $em_strong_relist = array(
12721255
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?![\.,:;]?\s)',
12731256
'***' => '(?<![\s*])\*\*\*(?!\*)',
12741257
'___' => '(?<![\s_])___(?!_)',
12751258
);
12761259

12771260
/**
12781261
* Container for prepared regular expressions
1279-
* @var array
12801262
*/
1281-
protected $em_strong_prepared_relist;
1263+
protected ?array $em_strong_prepared_relist = null;
12821264

12831265
/**
12841266
* Prepare regular expressions for searching emphasis tokens in any
@@ -1826,7 +1808,7 @@ protected function outdent($text) {
18261808
/**
18271809
* String length function for detab. `_initDetab` will create a function to
18281810
* handle UTF-8 if the default function does not exist.
1829-
* @var string
1811+
* can be a string or function
18301812
*/
18311813
protected $utf8_strlen = 'mb_strlen';
18321814

@@ -1883,9 +1865,7 @@ protected function _initDetab() {
18831865
return;
18841866
}
18851867

1886-
$this->utf8_strlen = function($text) {
1887-
return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
1888-
};
1868+
$this->utf8_strlen = fn($text) => preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
18891869
}
18901870

18911871
/**

0 commit comments

Comments
 (0)