Hello,
Please check the following sample included in phpdocx 9.5 and newer releases: examples/Core/addShape/sample_2.php. In this sample you can find how to add text contents into a shape. The following code adds a roundrect shape with a text content:
$txtboxContent = new WordFragment($docx);
$runs = array();
$runs[] = array('text' => 'This text is normal.');
$runs[] = array('text' => ' And this text is red.', 'color' => 'FF0000');
$txtboxContent->addText($runs);
$options = array(
'width' => 60,
'height' => 60,
'strokecolor' => '#ff00ff',
'strokeweight' => '3',
'fillcolor' => '#ffff00',
'position' => 'absolute',
'marginLeft' => 10,
'marginTop' => -5,
'arcsize' => 0.2,
'textContent' => $txtboxContent,
);
$docx->addShape('roundrect', $options);
Regards.