Throw a NotImplementedError in PHP?

PhpException

Php Problem Overview


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?

Php Solutions


Solution 1 - Php

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');

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionberkesView Question on Stackoverflow
Solution 1 - PhpPhilView Answer on Stackoverflow