Skip to content

Commit cb2967f

Browse files
committed
Add phpstan baseline for 3.x-dev and fix errors
1 parent a76d9d4 commit cb2967f

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

phpstan-baseline.neon

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
parameters:
2+
excludePaths:
3+
analyse:
4+
- src/phputf8/*
5+
ignoreErrors:
6+
-
7+
message: "#^Call to deprecated method rules\\(\\) of class Doctrine\\\\Common\\\\Inflector\\\\Inflector\\.$#"
8+
count: 1
9+
path: src/Inflector.php
10+
11+
-
12+
message: """
13+
#^Call to deprecated method toPlural\\(\\) of class Joomla\\\\String\\\\Inflector\\:
14+
3\\.0 Use Doctrine\\\\Common\\\\Inflector\\\\Inflector\\:\\:pluralize\\(\\) instead\\.$#
15+
"""
16+
count: 1
17+
path: src/Inflector.php
18+
19+
-
20+
message: """
21+
#^Call to deprecated method toSingular\\(\\) of class Joomla\\\\String\\\\Inflector\\:
22+
3\\.0 Use Doctrine\\\\Common\\\\Inflector\\\\Inflector\\:\\:singularize\\(\\) instead\\.$#
23+
"""
24+
count: 2
25+
path: src/Inflector.php
26+
27+
-
28+
message: "#^Class Joomla\\\\String\\\\Inflector extends deprecated class Doctrine\\\\Common\\\\Inflector\\\\Inflector\\.$#"
29+
count: 1
30+
path: src/Inflector.php
31+
32+
-
33+
message: "#^Method Joomla\\\\String\\\\Inflector\\:\\:getInstance\\(\\) should return static\\(Joomla\\\\String\\\\Inflector\\) but returns Joomla\\\\String\\\\Inflector\\.$#"
34+
count: 1
35+
path: src/Inflector.php
36+
37+
-
38+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
39+
count: 2
40+
path: src/Inflector.php

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
includes:
33
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
4+
- phpstan-baseline.neon
45

56
parameters:
67
level: 5

src/StringHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function increment($string, $style = 'default', $n = 0)
7474

7575
// Check if we are incrementing an existing pattern, or appending a new one.
7676
if (preg_match($rxSearch, $string, $matches)) {
77-
$n = empty($n) ? ($matches[1] + 1) : $n;
77+
$n = empty($n) ? (1 + (int) $matches[1]) : $n;
7878
$string = preg_replace($rxReplace, sprintf($oldFormat, $n), $string);
7979
} else {
8080
$n = empty($n) ? 2 : $n;
@@ -338,7 +338,7 @@ public static function strcasecmp($str1, $str2, $locale = false)
338338
}
339339

340340
// Get current locale
341-
$locale0 = setlocale(LC_COLLATE, 0);
341+
$locale0 = setlocale(LC_COLLATE, '0');
342342

343343
if (!$locale = setlocale(LC_COLLATE, $locale)) {
344344
$locale = $locale0;
@@ -384,7 +384,7 @@ public static function strcmp($str1, $str2, $locale = false)
384384
{
385385
if ($locale) {
386386
// Get current locale
387-
$locale0 = setlocale(LC_COLLATE, 0);
387+
$locale0 = setlocale(LC_COLLATE, '0');
388388

389389
if (!$locale = setlocale(LC_COLLATE, $locale)) {
390390
$locale = $locale0;

src/phputf8/stristr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Note: requires utf8_strtolower
1212
* @param string
1313
* @param string
14-
* @return int
14+
* @return string|boolean
1515
* @see http://www.php.net/strcasecmp
1616
* @see utf8_strtolower
1717
* @package utf8

0 commit comments

Comments
 (0)