/** * @param File $file * @param Report $report */ public function process(File $file, Report $report) { $collection = Collection::createFromString($file->getContent()->get()); $invalidProperties = InvalidPropertyFinder::find($collection); if (count($invalidProperties) === 0) { return; } foreach ($invalidProperties as $property) { $variable = $property->getVariable(); $report->addMessage($file, $this, 'Invalid property. Redundant NULL value for the property: ' . $variable->getValue(), $variable->getLine()); } }
/** * @param File $file * @param Report $report */ public function process(File $file, Report $report) { $collection = Collection::createFromString($file->getContent()->get()); $invalidProperties = InvalidPropertyFinder::find($collection); if (count($invalidProperties) === 0) { return; } foreach ($invalidProperties as $property) { $report->addMessage($file, $this, 'Replace redundant NULL value', $property->getVariable()->getLine()); foreach ($property->getTokensToReplace() as $token) { $token->remove(); } } $file->getContent()->set($collection->assemble()); }