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

Update BaseStringHelper.php #20099

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update BaseStringHelper.php #20099

wants to merge 1 commit into from

Conversation

spzgy
Copy link

@spzgy spzgy commented Jan 9, 2024

Exception 'TypeError' with message 'count(): Argument #1 ($value) must be of type Countable|array, bool given'

Q A
Is bugfix? ✔️/❌
New feature? ✔️/❌
Breaks BC? ✔️/❌
Fixed issues

Exception 'TypeError' with message 'count(): Argument yiisoft#1 ($value) must be of type Countable|array, bool given'
Copy link

what-the-diff bot commented Jan 9, 2024

PR Summary

  • Enhancement to the Word Counting Method
    In the base string helper module, a modification has been introduced to the method responsible for counting words. A new variable has been incorporated to capture the result of a function that splits the input text. After this split operation, there's now an extra layer of verification to ensure the result is valid before proceeding to count the words, thus avoiding potential errors or inaccuracies in the word count.

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (b46e267) 48.02% compared to head (b63ba54) 48.02%.

Files Patch % Lines
framework/helpers/BaseStringHelper.php 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20099   +/-   ##
=======================================
  Coverage   48.02%   48.02%           
=======================================
  Files         445      445           
  Lines       43889    43892    +3     
=======================================
+ Hits        21077    21079    +2     
- Misses      22812    22813    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@samdark samdark added type:test pr:request for unit tests Unit tests are needed. and removed type:test labels Jan 9, 2024
@samdark
Copy link
Member

samdark commented Jan 9, 2024

Looks alright 👍 Would you please add a unit test and a line for CHANGELOG?

@rob006
Copy link
Contributor

rob006 commented Jan 9, 2024

AFAIK preg_split() returns false only if you pass invalid input or regex. In countWords() regex is hardcoded, so input must be a problem - for what value (and what scenario) you get this error?

@Webkadabra
Copy link

Please, reject and close this PR. Author has no idea what he is doing. The variable he is trying to run count() on is a string. If anything, a string type could be added, not a count() on a STRING.

Why end it on the array then? What if it is not an arra,y and not a string? What if I have some words in binary? Please, looks for troubles elsewhere, REJECT THIS PR.

@Webkadabra
Copy link

Looks alright 👍 Would you please add a unit test and a line for CHANGELOG?

this is nonsense PR, seriously

@Webkadabra
Copy link

@spzgy you're adding array methods to a STRING HELPER class. Do you keep your milk out on a porch, and your cat is inside a freezer? What are you doing, my man?

@schmunk42
Copy link
Contributor

AFAIK preg_split() returns false only if you pass invalid input or regex. In countWords() regex is hardcoded, so input must be a problem - for what value (and what scenario) you get this error?

@spzgy As @rob006 mentioned: Please provide an example for the error you get and which PHP version are you using.

Related: https://stackoverflow.com/a/59335626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:request for unit tests Unit tests are needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants