Skip to content

refactor: reduce_multiples() and fix user guide#9099

Merged
kenjis merged 8 commits into
codeigniter4:developfrom
kenjis:refactor-reduce_multiples
Aug 2, 2024
Merged

refactor: reduce_multiples() and fix user guide#9099
kenjis merged 8 commits into
codeigniter4:developfrom
kenjis:refactor-reduce_multiples

Conversation

@kenjis

@kenjis kenjis commented Aug 2, 2024

Copy link
Copy Markdown
Member

Description

  • refactor to suppress PHPStan error (false positive)
  • fix user guide
  • refactor test code
 ------ ------------------------------------------------------------------- 
  Line   system/Helpers/text_helper.php                                     
 ------ ------------------------------------------------------------------- 
  529    Regex pattern is invalid: Compilation failed: quantifier does not  
         follow a repeatable item at offset 5 in pattern: #.*{2,}#          
         🪪  regexp.pattern                                                 
 ------ ------------------------------------------------------------------- 

https://github.com/codeigniter4/CodeIgniter4/actions/runs/10208178324/job/28244217081

But the pattern is #,{2,}# by default:

function reduce_multiples(string $str, string $character = ',', bool $trim = false): string
{
$str = preg_replace('#' . preg_quote($character, '#') . '{2,}#', $character, $str);

I sent a bug report: phpstan/phpstan#11432

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the refactor Pull requests that refactor code label Aug 2, 2024

@paulbalandan paulbalandan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a bug in PHPStan.

@kenjis kenjis merged commit 82dbd91 into codeigniter4:develop Aug 2, 2024
@kenjis kenjis deleted the refactor-reduce_multiples branch August 2, 2024 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants