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

Modernization: Replace Deprecated each() Function in tln_tagprint #1912

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from

Conversation

GabrielBragaGit
Copy link

Description

Updated tln_tagprint method to use modern PHP iteration syntax, removing deprecated each() function.

Details

  • Replaced each() with foreach loop
  • Simplified array population method
  • Maintained original method logic
  • Ensures compatibility with PHP 7.2+ and PHP 8.0+

Code Change

// Before
while ([$attname, $attvalue] = each($attary)) {
    array_push($atts, "$attname=$attvalue");
}

// After
foreach ($attary as $attname => $attvalue) {
    $atts[] = "$attname=$attvalue";
}

Rationale

  • each() function is deprecated and removed in newer PHP versions
  • foreach provides a more modern and readable way to iterate arrays
  • $atts[] is a more concise way to add elements to an array compared to array_push()
  • Improves code maintainability and compatibility

#### Description
Updated `tln_tagprint` method to use modern PHP iteration syntax, removing deprecated `each()` function.

#### Details
- Replaced `each()` with `foreach` loop
- Simplified array population method
- Maintained original method logic
- Ensures compatibility with PHP 7.2+ and PHP 8.0+

#### Code Change
```php
// Before
while ([$attname, $attvalue] = each($attary)) {
    array_push($atts, "$attname=$attvalue");
}

// After
foreach ($attary as $attname => $attvalue) {
    $atts[] = "$attname=$attvalue";
}
```

### Rationale

- #each() function is deprecated and removed in newer PHP versions
- #foreach provides a more modern and readable way to iterate arrays
- #$atts[] is a more concise way to add elements to an array compared to #array_push()
- Improves code maintainability and compatibility
amit-webkul
amit-webkul previously approved these changes Dec 31, 2024
Restore the original array construction format while replacing deprecated each() function:
- Maintain array_push() instead of using array[] syntax
- Keep the exact same string format for attributes
- Ensure compatibility with PHP 8.2 and 8.3
Copy link
Author

@GabrielBragaGit GabrielBragaGit left a comment

Choose a reason for hiding this comment

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

Restore the original array construction format while replacing deprecated each() function:

  • Maintain array_push() instead of using array[] syntax
  • Keep the exact same string format for attributes
  • Ensure compatibility with PHP 8.2 and 8.3

@amit-webkul amit-webkul removed their assignment Jan 2, 2025
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.

2 participants