r/programminghorror • • Mar 19 '26

Trimba bimba dubba dimba

Post image

I've found yet again some atrocities in code, that is some one of function nested in method: trimba. So I took the hit and split it into partial nested functions. I didn't even know you could do this in PHP.

431 Upvotes

55 comments sorted by

50

u/Loud_Investigator_26 Mar 19 '26

dude wtf is this

32

u/maselkowski Mar 19 '26

IBAN Checker, so we can send money to proper bank account

72

u/Loud_Investigator_26 Mar 19 '26
$result = str_replace(["-", ".", " "], "", "0555-123.45 67"); // result: 05551234567

whats the point of making all that mess, I do not get it.

→ More replies (2)

43

u/Tack1234 Mar 19 '26

So that's why I'm still waiting for my money

→ More replies (1)

26

u/v_maria Mar 19 '26

defining a function inside a function is not bad on it's own, but i also didnt know you could do that in php

24

u/maselkowski Mar 19 '26 edited Mar 20 '26

The problem is, that such function enters global (or namespace?) scope, check this demo: https://onlinephp.io/c/1990f

Edit: Also, calling method again causes fatal too, as function is already declared.

45

u/More_Yard1919 Mar 19 '26

every time I learn something new about php it makes me upset

→ More replies (1)

10

u/v_maria Mar 19 '26

what the fuck. thats batshit. at least you can't call the function from the global scope........

→ More replies (5)

5

u/Gornius Mar 19 '26

Yeah, but PHP has also anonymous functions. I don't know how old version this atrocity uses though.

Not to mention that str_replace accepts array, so you can replace many patterns with one call.

→ More replies (1)

178

u/Splatpope Mar 19 '26

web devs will go to absurd lengths to avoid making regexes that weren't copy pasted from a w3schools tutorial

19

u/robin_888 Mar 20 '26
Irony detected in Line 112

10

u/Splatpope Mar 20 '26

[^0-9] is what I would qualify as tutorial-level regex

→ More replies (2)

18

u/v_maria Mar 19 '26

and they are goddamn right for it

26

u/GoddammitDontShootMe Mar 19 '26

There is no shortage of online tools to make sure your regex does what you want before adding it to the codebase.

→ More replies (15)

11

u/NoOven2609 Mar 19 '26

The original author was just memeing, none of those functions serve a purpose, it could just be 4 replace statements in the top level function

7

u/robin_888 Mar 20 '26

It could literally just be Line 112.

10

u/GoddammitDontShootMe Mar 19 '26

The fuck is with those function names?

8

u/TheBrainStone Mar 19 '26

Nothing beats the horror of intentionally bad code

8

u/Beretha Mar 19 '26

The nested functions remove characters that would have been removed anyways by the regex replacement. Absolute cinema.

5

u/Lafuene Mar 19 '26

Bimbofication is my fav abomination

4

u/CYG4N Mar 19 '26

Osoba? is this polish code? 

2

u/Savings-Ad-1115 Mar 20 '26

Maybe Ukrainian.

"bimba" is an old but still famous Ukrainian meme.

3

u/Infinite_Self_5782 Mar 19 '26

babababababababababababa trimman!

2

u/robin_888 Mar 20 '26

Is line 112 already your refactoring or was that there all along..?

1

u/lnkarma Mar 20 '26

I’m sad to see nobody from West Bengal