Insphpect

This tool is currently proof-of-concept. Your feedback and evaluation is valuable in helping to improve it and ensure its reports are meaninful.

Please click here to complete a short survey to tell us what you think. It should take less than 5 minutes and help further this research project!

Transphporm\Pseudo\Nth

Detected issues

Issue Method Line number

Code

Click highlighted lines for details

<?php/* @description     Transformation Style Sheets - Revolutionising PHP templating    * * @author          Tom Butler tom@r.je                                             * * @copyright       2017 Tom Butler <tom@r.je> | https://r.je/                      * * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License * * @version         1.2                                                             */namespace Transphporm\Pseudo;use \Transphporm\Parser\Tokenizer;class Nth implements \Transphporm\Pseudo {	private $count = 0;	private $lastParentNode;	public function match($name, $args, \DomElement $element) {		if ($element->parentNode !== $this->lastParentNode) $this->count = 0;		$this->lastParentNode = $element->parentNode;		if ($name !== 'nth-child') return true;		$this->count++;		$criteria = $args[0];		if (is_callable([$this, $criteria])) return $this->$criteria($this->count);		$this->assert(is_numeric($criteria), "Argument passed to 'nth-child' must be 'odd', 'even', or of type int");		return $this->count == $criteria;	}	//TODO: Abstract assertions throughout	private function assert($condition, $error) {		if (!$condition) throw new \Exception($error);	}	private function odd($num) {		return $num % 2 === 1;	}	private function even($num) {		return $num % 2 === 0;	}}