getRepo('james','test'); $nomilestoneLabel=$repo->getLabelByName('no-milestone'); if(!$nomilestoneLabel) die ("Can't find 'no-milestone' label in repo\n"); $callback=function($issue) use ($nomilestoneLabel){ if( count($issue->getData()->milestone)==0 && !$issue->hasLabel($nomilestoneLabel) ){ $issue->addLabel( $nomilestoneLabel ); }elseif( count($issue->getData()->milestone)>0 && $issue->hasLabel($nomilestoneLabel) ){ $issue->removeLabel( $nomilestoneLabel ); } }; $repo->forIssues($callback);