The images created secondarily from the original source (FROM scratch as php-dev COPY --from=php-base . /) do not inherit the environment variables from the base. The file structure is the same, but other Docker set items such as ENV and ENTRYPOINT are not inherited.
ENV specifically causes an issue with compiling xdebug (or other php extensions) because the script for it expects PHP_INI_DIR=/usr/local/etc/php to exist.