Strict comparison here and https://github.com/symfony/symfony/pull/9442/files#diff-e88ad8ede40599bea0592b1113c4452cR490 will be better.
Moreover substr($dir, -1) is a more common way maybe more powerful, no? (Or stripos/strrev)