/** * @param string $name * @param mixed $args * @return $this * @throws \BadFunctionCallException */ protected function setter($name, $args) { if (array_key_exists($name, $this->_advancedFieldTypes)) { $type = $this->_advancedFieldTypes[$name]; if ($args[0] !== null && !$args[0] instanceof $type) { throw new \BadFunctionCallException('Argument 1 must be an object of class ' . $type); } } parent::setter($name, $args); return $this; }