Skip to content

Commit dba1c1d

Browse files
authored
Merge pull request #47 from UseMuffin/psalm
Fix errors reported by psalm.
2 parents 3e80ad8 + d7d5885 commit dba1c1d

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
php-version: ['7.2', '7.4']
11+
php-version: ['7.2', '8.0', '8.1']
1212
db-type: [sqlite, mysql, pgsql]
13-
name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }}
13+
prefer-lowest: ['']
14+
include:
15+
- php-version: '7.2'
16+
db-type: 'sqlite'
17+
prefer-lowest: 'prefer-lowest'
1418

1519
services:
1620
postgres:
@@ -21,17 +25,16 @@ jobs:
2125
POSTGRES_PASSWORD: postgres
2226

2327
steps:
24-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v2
2529
with:
2630
fetch-depth: 1
2731

2832
- name: Setup PHP
29-
uses: shivammathur/setup-php@v1
33+
uses: shivammathur/setup-php@v2
3034
with:
3135
php-version: ${{ matrix.php-version }}
32-
extension-csv: mbstring, intl, pdo_${{ matrix.db-type }}
36+
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
3337
coverage: pcov
34-
pecl: false
3538

3639
- name: Composer Install
3740
run: composer install
@@ -64,17 +67,16 @@ jobs:
6467
runs-on: ubuntu-18.04
6568

6669
steps:
67-
- uses: actions/checkout@v1
70+
- uses: actions/checkout@v2
6871
with:
6972
fetch-depth: 1
7073

7174
- name: Setup PHP
72-
uses: shivammathur/setup-php@v1
75+
uses: shivammathur/setup-php@v2
7376
with:
7477
php-version: '7.2'
75-
extension-csv: mbstring, intl
78+
extensions: mbstring, intl
7679
coverage: none
77-
pecl: false
7880

7981
- name: Composer Install
8082
run: composer require --dev cakephp/cakephp-codesniffer:^4.0
@@ -87,20 +89,20 @@ jobs:
8789
runs-on: ubuntu-18.04
8890

8991
steps:
90-
- uses: actions/checkout@v1
92+
- uses: actions/checkout@v2
9193
with:
9294
fetch-depth: 1
9395

9496
- name: Setup PHP
95-
uses: shivammathur/setup-php@v1
97+
uses: shivammathur/setup-php@v2
9698
with:
97-
php-version: '7.2'
99+
php-version: '8.0'
98100
extension-csv: mbstring, intl
99-
coverage: none
100-
pecl: false
101+
coverage: none,
102+
tools: vimeo/psalm:4.1
101103

102104
- name: Composer Install
103-
run: composer require --dev psalm/phar:^3.12
105+
run: composer install
104106

105107
- name: Run psalm
106-
run: vendor/bin/psalm.phar
108+
run: psalm

src/Model/Behavior/SlugBehavior.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SlugBehavior extends Behavior
5151
* - onDirty: Boolean indicating whether slug should be updated when
5252
* slug field is dirty, defaults to `false`.
5353
*
54-
* @var array
54+
* @var array<string, mixed>
5555
*/
5656
protected $_defaultConfig = [
5757
'field' => 'slug',
@@ -150,7 +150,7 @@ public function getSlugger(): SluggerInterface
150150
* @param \Muffin\Slug\SluggerInterface|string|array $slugger Sets slugger instance.
151151
* Can be SluggerInterface instance or class name or config array.
152152
* @return void
153-
* @psalm-var \Muffin\Slug\SluggerInterface|class-string|array $slugger
153+
* @psalm-param \Muffin\Slug\SluggerInterface|class-string|array $slugger
154154
*/
155155
public function setSlugger($slugger): void
156156
{
@@ -163,7 +163,7 @@ public function setSlugger($slugger): void
163163
* @param \Muffin\Slug\SluggerInterface|string|array $slugger Sets slugger instance.
164164
* Can be SluggerInterface instance or class name or config array.
165165
* @return \Muffin\Slug\SluggerInterface
166-
* @psalm-var \Muffin\Slug\SluggerInterface|class-string|array $slugger
166+
* @psalm-param \Muffin\Slug\SluggerInterface|class-string|array $slugger
167167
* @psalm-suppress MoreSpecificReturnType
168168
*/
169169
protected function _createSlugger($slugger): SluggerInterface
@@ -190,7 +190,7 @@ protected function _createSlugger($slugger): SluggerInterface
190190
/**
191191
* Returns list of event this behavior is interested in.
192192
*
193-
* @return array
193+
* @return array<string, mixed>
194194
*/
195195
public function implementedEvents(): array
196196
{

src/Slugger/CakeSlugger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public function __construct(array $config = [])
3838
* Generate slug.
3939
*
4040
* @param string $string Input string.
41-
* @param string $replacement Replacement string.
41+
* @param string $separator Replacement string.
4242
* @return string Sluggified string.
4343
*/
44-
public function slug(string $string, string $replacement = '-'): string
44+
public function slug(string $string, string $separator = '-'): string
4545
{
4646
$config = $this->config;
47-
$config['replacement'] = $replacement;
47+
$config['replacement'] = $separator;
4848
$string = Text::slug($string, $config);
4949

5050
if ($config['lowercase']) {

src/Slugger/CocurSlugger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public function __construct(array $config = [])
3939
* Generate slug.
4040
*
4141
* @param string $string Input string.
42-
* @param string $replacement Replacement string.
42+
* @param string $separator Replacement string.
4343
* @return string Sluggified string.
4444
*/
45-
public function slug(string $string, string $replacement = '-'): string
45+
public function slug(string $string, string $separator = '-'): string
4646
{
4747
$options = $this->config;
4848
$regex = $options['regex'];
4949
unset($options['regex']);
5050

51-
return Slugify::create($regex, $options)->slugify($string, $replacement);
51+
return Slugify::create($regex, $options)->slugify($string, $separator);
5252
}
5353
}

0 commit comments

Comments
 (0)