@samdark's suggestion. Extracted from https://github.com/yiisoft/hydrator/pull/90#discussion_r1704574760.