Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Throw a NotImplementedError in PHP?

Tags:

exception

php

Is there a kind of NotImplementedError in PHP?

I want to add these to some stub-methods and interfaces, so as to warn classes that extend me, they still have work to do. Or is this achieved differently in PHP?

like image 555
berkes Avatar asked Nov 11 '11 10:11

berkes


1 Answers

PHP does not have a built-in NotImplementedException however you're welcome to create your own. I suppose BadMethodCallException comes close which would be a decent candidate for extension

class NotImplementedException extends BadMethodCallException {} 

... and in your method

public function notImplementedMethod() {     throw new NotImplementedException(); } 

You can also very simply do something like this

throw new Exception('Not implemented'); 
like image 111
Phil Avatar answered Sep 24 '22 22:09

Phil