I heard you can do this, that is run branch circuit conductors for lighting circuit (or whatever) through the interior of a panel to connect to a timer or other control device that is nippled into the panel.

Is this correct by code or is it just tolerated by inspectors?