PHP/Xdebug Nesting level error -


yes looked @ previous questions in topic , still not able solve problem. tried ini_set('xdebug.max_nesting_level', 5000); in script , still im getting error. show i'm doing , and resolution.

basically running test data database.

include 'testsettings.php';  //get config $conf = config::getinstance('sendcsv.php'); $conf->getconfig();  $formatter = new formattercontext(new csvformatter($conf)); $formatter->formatloads(null); 

the complain comes when call `$formatter->formatloads(null);

so here formattercontext()

class formattercontext {     private $strategy;      public function __construct(iformatter $formater)     {         $this->strategy = $formater;     }      public function formatloads()     {         return $this->formatloads();     } } 

the interface:

abstract class iformatter {     private $config;     private $formatted;     private $filemaps;     private $filerows;      abstract public function formatloads($loads);      public function __construct(config $conf)     {         $this->filemaps = $conf->__get('filemaps');         $this->filerows = $conf->__get('filerows');     } } 

the strategy:

class csvformatter extends iformatter {       public function formatloads($loads)     {         echo "hello world!\n";     } } 

now don't know doing wrong here. first time have encounter error. beyond nesting level = 5000 have not tried, think @ point wrong. thanks

arg! silly me... in context class i'm calling context formatload() instead of strategy. ooops!

the context class should like:

class formattercontext {     private $strategy;      public function __construct(iformatter $formater)     {         $this->strategy = $formater;     }      public function formatloads()     {         // return $this->formatloads();         return $this->strategy->formatloads();     } } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -