Hello,
Merging in-memory DOCX documents was added in phpdocx 9.5 (https://www.phpdocx.com/news/post/phpdocx-v9-5-release-notes/219), previous versions don't include this feature. Also please note that you can run a similar code but using DOCX files instead of in-memory documents if needed (or even mixing them).
Regards.