/** * Visits a function node. * * @param PHP_Depend_Code_Function $node The current function node. * * @return void * @see PHP_Depend_VisitorI::visitFunction() */ public function visitFunction(PHP_Depend_Code_Function $node) { if ($node->getSourceFile()->getFileName() === null) { return; } $this->_apply(new PHP_PMD_Node_Function($node)); }
/** * Visits a function node. * * @param PHP_Depend_Code_Function $function The current function node. * * @return void * @see PHP_Depend_VisitorI::visitFunction() */ public function visitFunction(PHP_Depend_Code_Function $function) { // First visit function file $function->getSourceFile()->accept($this); $fileXml = end($this->_xmlStack); $document = $fileXml->ownerDocument; $functionXml = $document->createElement('function'); $functionXml->setAttribute('name', $function->getName()); $this->_appendMetrics($functionXml, $function); $fileXml->appendChild($functionXml); // Update file element @functions count $fileXml->setAttribute('functions', 1 + $fileXml->getAttribute('functions')); // Remove xml file element array_pop($this->_xmlStack); }
/** * Tests that build interface updates the source file information for null * values. * * @return void */ public function testSetSourceFileInformationForNullValue() { $item = new PHP_Depend_Code_Function('func'); $file = new PHP_Depend_Code_File(__FILE__); $this->assertNull($item->getSourceFile()); $item->setSourceFile($file); $this->assertSame($file, $item->getSourceFile()); }