This code has an error on line 23 (should return int, not string).
https://psalm.dev/r/aa26301af0
Removing the mixed return type fixes the issue: https://psalm.dev/r/6bf5cdea8a.
Regression occurred in #8926.
Commit da001c4 is the last one, when Psalm reports the problem (correct behavior).