Quand on travaille de nombreuses heures sur du code, il est important de mettre toutes les chances de son coté pour se faciliter la vie. Ça commence pas l'utilisation d'une police appropriée qui évitera les confusions et améliorera la lisibilité.
Avec une mauvaise police, il y a des risques de mauvaise lecture du code, par exemple en confondant :
Les différentes polices sont testées avec l'échantillon de code suivant 1) :
public function getElementValue(array $collection, string $index): ?int { /** Comment #1 */ if (empty($collection)) { return null; } // Comment #2 foreach ($collection as $key => $element) { if ($key < $index || $key > $index) { echo 'Index does not match key', PHP_EOL; continue; } return $element->value(); } }
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789.:,;(){}[]<>|^/*!?`'“@#$%&_-+=~
àÀâÂçÇéÉèÈêÊëËîÎïÏôÔùÙûÛüÜæÆœŒ
The quick brown fox jumps over the lazy dog
== === != !== >= <= -> <=> =>
0O 1l B8 <> [] {} 2N2N2N2N
public function getElementValue(array $collection, string $index): ?int { /** Comment #1 */ if (empty($collection)) { return null; } // Comment #2 foreach ($collection as $key => $element) { if ($key < $index || $key > $index) { echo 'Index does not match key', PHP_EOL; continue; } return $element->value(); } }
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789.:,;(){}[]<>|^/*!?`'”@#$%&_-+=~
àÀâÂçÇéÉèÈêÊëËîÎïÏôÔùÙûÛüÜæÆœŒ
The quick brown fox jumps over the lazy dog
== === != !== >= <= -> <=> =>
0O 1l B8 <> [] {} 2N2N2N2N
public function getElementValue(array $collection, string $index): ?int { /** Comment #1 */ if (empty($collection)) { return null; } // Comment #2 foreach ($collection as $key => $element) { if ($key < $index || $key > $index) { echo 'Index does not match key', PHP_EOL; continue; } return $element->value(); } }
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789.:,;(){}[]<>|^/*!?`'“@#$%&_-+=~
àÀâÂçÇéÉèÈêÊëËîÎïÏôÔùÙûÛüÜæÆœŒ
The quick brown fox jumps over the lazy dog
== === != !== >= <= -> <=> =>
0O 1l B8 <> [] {} 2N2N2N2N
public function getElementValue(array $collection, string $index): ?int { /** Comment #1 */ if (empty($collection)) { return null; } // Comment #2 foreach ($collection as $key => $element) { if ($key < $index || $key > $index) { echo 'Index does not match key', PHP_EOL; continue; } return $element->value(); } }
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789.:,;(){}[]<>|^/*!?`'”@#$%&_-+=~
àÀâÂçÇéÉèÈêÊëËîÎïÏôÔùÙûÛüÜæÆœŒ
The quick brown fox jumps over the lazy dog
== === != !== >= <= -> <=> =>
0O 1l B8 <> [] {} 2N2N2N2N
public function getElementValue(array $collection, string $index): ?int { /** Comment #1 */ if (empty($collection)) { return null; } // Comment #2 foreach ($collection as $key => $element) { if ($key < $index || $key > $index) { echo 'Index does not match key', PHP_EOL; continue; } return $element->value(); } }