/** * Remove any objects we have associated with the * given file so that we can re-read it. * * @param string $cwd_relative_file_path * A file path relative to the current working directory of * the phan executable. * * @return null */ public function flushDependenciesForFile(string $cwd_relative_file_path) { // Map the relative path to a project path $file_path = File::projectRelativePathFromCWDRelativePath($cwd_relative_file_path); $code_file = $this->getFileByPath($file_path); // Flush all classes from the file foreach ($code_file->getClassFQSENList() as $fqsen) { $this->flushClassWithFQSEN($fqsen); $code_file->flushClassWithFQSEN($fqsen); } // Flush all methods from the file foreach ($code_file->getMethodFQSENList() as $fqsen) { if ($fqsen instanceof FullyQualifiedMethodName) { // Remove it from memory $this->flushMethodWithScopeAndName((string) $fqsen->getFullyQualifiedClassName(), $fqsen->getName()); } else { // Remove it from memory $this->flushMethodWithScopeAndName($fqsen->getNamespace(), $fqsen->getName()); } // Remove it from the file's depdendency list $code_file->flushMethodWithFQSEN($fqsen); } foreach ($code_file->getPropertyFQSENList() as $fqsen) { $this->flushPropertyWithScopeAndName((string) $fqsen->getFullyQualifiedClassName(), $fqsen->getName()); $code_file->flushPropertyWithFQSEN($fqsen); } foreach ($code_file->getConstantFQSENList() as $fqsen) { $this->flushConstantWithScopeAndName((string) $fqsen->getFullyQualifiedConstantName(), $fqsen->getName()); $code_file->flushConstantWithFQSEN($fqsen); } }
/** * @return string * The path of the file relative to the project * root directory */ public function getProjectRelativePath() : string { return File::projectRelativePathFromCWDRelativePath($this->file); }
/** * @return array * Get a map from column name to row values for * this instance */ public function toRow() : array { return ['file_path' => $this->file->getProjectRelativePath(), 'modification_time' => $this->file->getModificationTime()]; }