You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: resources/posts/2023/2023-12-28-3-signs-your-project-is-becoming-legacy-arrays-creep.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -75,17 +75,18 @@ After 2 hours of digging into code, we learn that:
75
75
* in another `array<string|null>`
76
76
* and in another `array<string|false>`
77
77
78
-
You want to quit such a project, right? There is a way out.
78
+
You want to quit such a project, right? Wait, there is another a way out.
79
79
80
80
<br>
81
81
82
82
You might be thinking, "Let's refactor the array to collections." It is also a way, but it takes more energy, more studying, and most importantly - much more than 1 line.
83
83
84
-
Our job is to deliver for a reasonable price, so I always aim for cost-effective solutions.
84
+
**Our job is to deliver for a reasonable price, so I always aim for cost-effective solutions.**
85
+
85
86
86
87
## The Single Line
87
88
88
-
I learned the following approach from a friend of mine about 10 years ago, way before PHP 7.0 with type declarations was released. Simple but effective.
89
+
I learned the following approach from a [friend of mine](https://www.outofdark.com/) about 10 years ago, way before PHP 7.0 with type declarations was released. Simple but effective.
89
90
90
91
**Validate with assert**. I don't mean the native `assert()` native function that is often disabled in php config. I mean assert PHP package, like `webmozart/assert`, that fails hard with an exception not correct:
91
92
@@ -99,9 +100,9 @@ public function __construct(array $codes)
99
100
}
100
101
```
101
102
102
-
They used this approach 10 years and I was thinking "lol, what an anxious approach to coding, they're so afraid they have to check everything".
103
+
They used this approach 10 years ago and I was thinking "lol, what an anxious approach to coding, they're so afraid they have to check everything".
103
104
104
-
Little did I know, nowadays, with similar projects, **I'm the one who checks everything because I have to manually verify the exact type of each variable. Those guys are already working on the 20th project and keep delivering.
105
+
Little did I know, nowadays, with similar projects, **I'm the one who checks everything because I have to manually verify the exact type of each variable**. Those guys are already working on the 20th project and keep delivering.
105
106
106
107
This takes about **half of our focus while working with projects** in [Rector upgrade team](https://getrector.com/hire-team) projects.
0 commit comments