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

Bug Fix: Prevent Count Error in tln_skipspace Method #1911

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

GabrielBragaGit
Copy link
Contributor

Description

Fixed a potential type error when checking for whitespace in email parsing.

Details

  • Modified tln_skipspace method to handle string inputs safely
  • Prevents "count() must be of type Countable|array" error
  • Maintains original logic of skipping whitespace

Code Change

// Before
if (count($matches[1])) {
    $count = strlen($matches[1]);
    $offset += $count;
}

// After
if (!empty($matches[1])) {
    $count = strlen($matches[1]);
    $offset += $count;
}

Rationale

  • Original code assumed $matches[1] would always be an array
  • New implementation checks for non-empty value before processing
  • Improves error handling and type safety

#### Description
Fixed a potential type error when checking for whitespace in email parsing.

#### Details
- Modified `tln_skipspace` method to handle string inputs safely
- Prevents "count() must be of type Countable|array" error
- Maintains original logic of skipping whitespace

#### Code Change
```php
// Before
if (count($matches[1])) {
    $count = strlen($matches[1]);
    $offset += $count;
}

// After
if (!empty($matches[1])) {
    $count = strlen($matches[1]);
    $offset += $count;
}
```

### Rationale

- Original code assumed $matches[1] would always be an array
- New implementation checks for non-empty value before processing
- Improves error handling and type safety
Add space after the exclamation mark (!) before empty() function call to improve code readability and maintain consistent code style standards.
@amit-webkul amit-webkul removed their assignment Jan 2, 2025
@devansh-webkul devansh-webkul merged commit 6db6ba5 into krayin:2.0 Jan 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants