for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace mQueue\View\Helper;
use Zend_Application;
use Zend_View_Helper_Abstract;
class GoogleAnalytics extends Zend_View_Helper_Abstract
{
/**
* Returns javascript code for Google Analytics
* @param string $trackingCode
$trackingCode
string|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
* @return string
*/
public function googleAnalytics($trackingCode = null)
__construct()
if (!is_string($trackingCode)) {
global $application;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
if ($application instanceof Zend_Application) {
$trackingCode = $application->getOption('googleAnalyticsTrackingCode', null);
}
$trackingCode = trim($trackingCode);
if (!is_string($trackingCode) || empty($trackingCode)) {
return '';
$result = <<<STRING
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '$trackingCode', 'auto');
ga('send', 'pageview');
</script>
STRING;
return $result;
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.