Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#2083] Better fix for issue, and CS cleanup
Browse files Browse the repository at this point in the history
- Revert to previous constructor behavior, but instead have doWrite() call
  getFirePhp() to lazy-load the bridge instance.
- Do not import classes from a subnamespace of the current namespace
- trailing whitespace
  • Loading branch information
weierophinney committed Aug 2, 2012
1 parent c38c873 commit b28a056
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions src/Writer/FirePhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use FirePHP as FirePHPService;
use Zend\Log\Formatter\FirePhp as FirePhpFormatter;
use Zend\Log\Logger;
use Zend\Log\Writer\FirePhp\FirePhpBridge;
use Zend\Log\Writer\FirePhp\FirePhpInterface;

/**
* @category Zend
Expand All @@ -26,19 +24,19 @@ class FirePhp extends AbstractWriter
/**
* A FirePhpInterface instance that is used to log messages to.
*
* @var FirePhpInterface
* @var FirePhp\FirePhpInterface
*/
protected $firephp;

/**
* Initializes a new instance of this class.
*
* @param null|FirePhpInterface $instance An instance of FirePhpInterface
* @param null|FirePhp\FirePhpInterface $instance An instance of FirePhpInterface
* that should be used for logging
*/
public function __construct(FirePhpInterface $instance = null)
public function __construct(FirePhp\FirePhpInterface $instance = null)
{
$this->firephp = $instance === null ? $this->getFirePhp() : $instance;
$this->firephp = $instance;
$this->formatter = new FirePhpFormatter();
}

Expand All @@ -50,7 +48,9 @@ public function __construct(FirePhpInterface $instance = null)
*/
protected function doWrite(array $event)
{
if (!$this->firephp->getEnabled()) {
$firephp = $this->getFirePhp();

if (!$firephp->getEnabled()) {
return;
}

Expand All @@ -61,50 +61,50 @@ protected function doWrite(array $event)
case Logger::ALERT:
case Logger::CRIT:
case Logger::ERR:
$this->firephp->error($line);
$firephp->error($line);
break;
case Logger::WARN:
$this->firephp->warn($line);
$firephp->warn($line);
break;
case Logger::NOTICE:
case Logger::INFO:
$this->firephp->info($line);
$firephp->info($line);
break;
case Logger::DEBUG:
$this->firephp->trace($line);
$firephp->trace($line);
break;
default:
$this->firephp->log($line);
$firephp->log($line);
break;
}
}

/**
* Gets the FirePhpInterface instance that is used for logging.
*
* @return FirePhpInterface
* @return FirePhp\FirePhpInterface
*/
public function getFirePhp()
{
// Remember: class names in strings are absolute; thus the class_exists
// here references the canonical name for the FirePHP class
if (!$this->firephp instanceof FirePhpInterface
if (!$this->firephp instanceof FirePhp\FirePhpInterface
&& class_exists('FirePHP')
) {
// FirePHPService is an alias for FirePHP; otherwise the class
// names would clash in this file on this line.
$this->setFirePhp(new FirePhpBridge(new FirePHPService()));
$this->setFirePhp(new FirePhp\FirePhpBridge(new FirePHPService()));
}
return $this->firephp;
}

/**
* Sets the FirePhpInterface instance that is used for logging.
*
* @param FirePhpInterface $instance A FirePhpInterface instance to set.
* @param FirePhp\FirePhpInterface $instance A FirePhpInterface instance to set.
* @return FirePhp
*/
public function setFirePhp(FirePhpInterface $instance)
public function setFirePhp(FirePhp\FirePhpInterface $instance)
{
$this->firephp = $instance;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/FirePhp/FirePhpBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FirePhpBridge implements FirePhpInterface
{
/**
* FirePHP instance
*
*
* @var FirePHP
*/
protected $firephp;
Expand Down

0 comments on commit b28a056

Please sign in to comment.