for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SocialLinks\Metas;
use SocialLinks\Page;
use ArrayObject;
/**
* Base class extended by all metas.
*/
abstract class MetaBase extends ArrayObject
{
protected $page;
protected $prefix;
protected $characterLimits = [];
* Constructor.
*
* @param Page $page
public function __construct(Page $page)
$this->page = $page;
$this->generateTags();
}
* Generate all tags.
* @return array
abstract protected function generateTags();
* {@inheritdoc}
public function addMeta($name, $content)
$content = $this->filterAttribute($name, $content);
$this[$name] = '<meta name="'.$this->prefix.static::escape($name).'" content="'.static::escape($content).'">';
public function addLink($rel, $href)
$this[$rel] = '<link rel="'.$this->prefix.static::escape($rel).'" href="'.static::escape($href).'">';
* Escapes the value of an attribute.
* @param string $value
* @return string
protected static function escape($value)
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
* Filters attribute values to trim by length
$value
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
protected function filterAttribute($name, $content)
$limit = isset($this->characterLimits[$name]) ? $this->characterLimits[$name] : null;
if($limit && strlen($content) > $limit)
$content = substr($content, 0, $limit - 3).'...';
return $content;
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.