Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: reduce_multiples() and fix user guide #9099

Merged
merged 8 commits into from
Aug 2, 2024

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Aug 2, 2024

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
Copy link
Member

@paulbalandan paulbalandan left a comment

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
42 checks passed
@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