for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Pheanstalk\Structure;
use Doctrine\Common\Collections\ArrayCollection;
class Job
{
/** @var ArrayCollection[Task] */
ArrayCollection[Task]
1
private $tasks;
/**
* Job constructor.
*
* @param ArrayCollection[Task] $tasks
*/
public function __construct(ArrayCollection $tasks)
$this->setTasks($tasks);
}
* @return ArrayCollection
public function getTasks(): ArrayCollection
return $this->tasks;
* @param ArrayCollection $tasks
* @return Job
public function setTasks(ArrayCollection $tasks): Job
$this->tasks = $tasks->filter(function(Task $task) {
$task
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$this->tasks = $tasks->filter(function(/** @scrutinizer ignore-unused */ Task $task) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return true;
});
return $this;
* @param Task $task
public function addTask(Task $task): Job
$this->tasks[] = $task;
public function removeTask(Task $task): Job
$this->tasks->removeElement($task);
* @return \DOMDocument
* @throws \ReflectionException
public function getXml()
$dom = new \DOMDocument("1.0", "utf-8");
$root = $dom->createElement("job");
$tasks = $dom->createElement("tasks");
/** @var Task $task */
foreach ($this->getTasks() as $task) {
$taskItem = $dom->createElement("task");
$taskItem
$taskNode = $task->getXml()->getElementsByTagName('task')->item(0);
$tasks->appendChild($dom->importNode($taskNode, true));
$root->appendChild($tasks);
$dom->appendChild($root);
return $dom;