Call to a member function addEagerConstraints() on null Call to a member function addEagerConstraints() on null public function xxx() { return yyy; } 加上 return 就行了