Apparently trimImage
leaves the image in a crop mode where the geometry of the canvas is different from that of the actual image.
When the arc is applied it uses the 'wrong' geometry, i.e. that of the uncropped image, which produces the unwanted effect of the text going off the image.
The way to fix this is to reset the geometry for the image through the Imagick function setImagePage
which is called repage in the Image Magick manual i.e.
<?php
$draw = new ImagickDraw();
$draw->setFont('Arial.ttf');
$draw->setFontSize(20);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
$draw->setFillColor('#ff0000');
$textOnly = new Imagick();
$textOnly->newImage(500, 100, "blue");
$textOnly->setImageFormat('png');
$textOnly->annotateImage($draw, 30, 40, 0, 'Your Text Here');
$textOnly->trimImage(0);
$textOnly->setImagePage($textOnly->getimageWidth(), $textOnly->getimageheight(), 0, 0);
$distort = array( 180 );
$textOnly->setImageVirtualPixelMethod( Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$textOnly->setImageMatte( TRUE );
$textOnly->distortImage(Imagick::DISTORTION_ARC, $distort, FALSE);
$textOnly->setformat('png');
header("Content-Type: image/png");
echo $textOnly->getimageblob();
produces an image: