MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / php_appended_path

Method php_appended_path

codegraph-kernel/src/php.rs:1032–1050  ·  view source on GitHub ↗

phpAppendedPath (#3298): the path string literals (and `DIRECTORY_SEPARATOR`, read as `/`) append to a directory. It starts with `/`, doesn't end with one, and has no empty segment; None when anything else is appended.

(&self, tail: &[Node<'t>])

Source from the content-addressed store, hash-verified

1030 /// with `/`, doesn't end with one, and has no empty segment; None when
1031 /// anything else is appended.
1032 fn php_appended_path(&self, tail: &[Node<'t>]) -> Option<String> {
1033 let mut rest = String::new();
1034 for part in tail {
1035 if let Some(literal) = self.php_literal_text(*part) {
1036 rest.push_str(literal);
1037 continue;
1038 }
1039 let text = self.text(*part);
1040 if text.strip_prefix('\\').unwrap_or(text) == "DIRECTORY_SEPARATOR" {
1041 rest.push('/');
1042 } else {
1043 return None;
1044 }
1045 }
1046 if !rest.starts_with('/') || rest.ends_with('/') {
1047 return None;
1048 }
1049 rest.split('/').skip(1).all(|seg| !seg.is_empty()).then_some(rest)
1050 }
1051
1052 /// phpDirectoryIncludePath (#3298): `__DIR__ . '/inc/a.php'`,
1053 /// `dirname(__FILE__) . DIRECTORY_SEPARATOR . 'a.php'` — a path appended

Callers 1

Calls 4

php_literal_textMethod · 0.80
pushMethod · 0.80
textMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected