Hello,
Adding custom tags or attributes to a DOCX will return a corrupted DOCX. The best approach to accomplish that task is getting DOCX contents using getDocxPathQueryInfo and query the style file. A heading content has always a w:outlineLvl tag in the w:pPr tag in the document content or in the style file.
The next release of phpdocx will include a new method to query styles.
Regards.