Skip to content

Commit

Permalink
Fix errors reported by psalm.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 27, 2021
1 parent 3e80ad8 commit d7d5885
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4']
php-version: ['7.2', '8.0', '8.1']
db-type: [sqlite, mysql, pgsql]
name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }}
prefer-lowest: ['']
include:
- php-version: '7.2'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'

services:
postgres:
Expand All @@ -21,17 +25,16 @@ jobs:
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extension-csv: mbstring, intl, pdo_${{ matrix.db-type }}
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
coverage: pcov
pecl: false

- name: Composer Install
run: composer install
Expand Down Expand Up @@ -64,17 +67,16 @@ jobs:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
extension-csv: mbstring, intl
extensions: mbstring, intl
coverage: none
pecl: false

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

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
php-version: '8.0'
extension-csv: mbstring, intl
coverage: none
pecl: false
coverage: none,
tools: vimeo/psalm:4.1

- name: Composer Install
run: composer require --dev psalm/phar:^3.12
run: composer install

- name: Run psalm
run: vendor/bin/psalm.phar
run: psalm
8 changes: 4 additions & 4 deletions src/Model/Behavior/SlugBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SlugBehavior extends Behavior
* - onDirty: Boolean indicating whether slug should be updated when
* slug field is dirty, defaults to `false`.
*
* @var array
* @var array<string, mixed>
*/
protected $_defaultConfig = [
'field' => 'slug',
Expand Down Expand Up @@ -150,7 +150,7 @@ public function getSlugger(): SluggerInterface
* @param \Muffin\Slug\SluggerInterface|string|array $slugger Sets slugger instance.
* Can be SluggerInterface instance or class name or config array.
* @return void
* @psalm-var \Muffin\Slug\SluggerInterface|class-string|array $slugger
* @psalm-param \Muffin\Slug\SluggerInterface|class-string|array $slugger
*/
public function setSlugger($slugger): void
{
Expand All @@ -163,7 +163,7 @@ public function setSlugger($slugger): void
* @param \Muffin\Slug\SluggerInterface|string|array $slugger Sets slugger instance.
* Can be SluggerInterface instance or class name or config array.
* @return \Muffin\Slug\SluggerInterface
* @psalm-var \Muffin\Slug\SluggerInterface|class-string|array $slugger
* @psalm-param \Muffin\Slug\SluggerInterface|class-string|array $slugger
* @psalm-suppress MoreSpecificReturnType
*/
protected function _createSlugger($slugger): SluggerInterface
Expand All @@ -190,7 +190,7 @@ protected function _createSlugger($slugger): SluggerInterface
/**
* Returns list of event this behavior is interested in.
*
* @return array
* @return array<string, mixed>
*/
public function implementedEvents(): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Slugger/CakeSlugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public function __construct(array $config = [])
* Generate slug.
*
* @param string $string Input string.
* @param string $replacement Replacement string.
* @param string $separator Replacement string.
* @return string Sluggified string.
*/
public function slug(string $string, string $replacement = '-'): string
public function slug(string $string, string $separator = '-'): string
{
$config = $this->config;
$config['replacement'] = $replacement;
$config['replacement'] = $separator;
$string = Text::slug($string, $config);

if ($config['lowercase']) {
Expand Down
6 changes: 3 additions & 3 deletions src/Slugger/CocurSlugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public function __construct(array $config = [])
* Generate slug.
*
* @param string $string Input string.
* @param string $replacement Replacement string.
* @param string $separator Replacement string.
* @return string Sluggified string.
*/
public function slug(string $string, string $replacement = '-'): string
public function slug(string $string, string $separator = '-'): string
{
$options = $this->config;
$regex = $options['regex'];
unset($options['regex']);

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

0 comments on commit d7d5885

Please sign in to comment.