Correct code to use php in text widget

I think this is enough, inside the widget-function of your Widget-class.

ob_start();
eval( '?>' . $html );
$html = ob_get_contents();
ob_end_clean();

Alternative use a maintenant plugin for this job, like PHP Code Widget