Deep Learning. An Edge Case Fix For Laravel.

Laravel PR merged 2022 12 14
When you enjoy a framework like I do in Laravel, it is fun to see your name as the latest commit at the top of the GitHub repo page.

This story begins as a conversation on phpc.social with Ben Ramsey. At first, I thought I found a bug in PHP core while working on a Laravel application. At first, I turned to report the issue on http://github.com/php/php-src. But, little did I know PHP array_merge was working as expected… reindexing numeric keys! This was an issue I found in Laravel, not PHP.

I submitted a PR to Laravel that addressed the issue by swapping array_merge for array_replace. And Taylor was very kind to merge and commit the PR.

I love it when I run into issues that stump me, like this one, because I learn the nuances of PHP, and the solutions tend to stick with me for a long time. Now I will not forget array_merge and array_replace have significant differences and will be more intentional moving forward – do not jump straight for array_merge to join arrays.

To bring the story to a close:

  1. Push through hard problems to learn deeply. I could have shrugged and taken a different route. I’m glad I did not.
  2. Reach out for help. Your insights are not robust until you ask others to help you.
  3. Do leave the solution in the dark. Take the time to contribute what you find and clear the road for others. In this case, it was a PR.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.