Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

PHP: count sys_get_temp_dir, getmypid, get_current_user and php_uname as environment reads (#1478)

Hashem Alkhanaizi47d5302d73c9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbf654f9..e4f0a4a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+- PHP: `sys_get_temp_dir()`, `getmypid()`, `getmyuid()`, `get_current_user()` and `php_uname()`
+ count as reading the environment, as `getcwd()` and `gethostname()` do, so `bridge` keeps a
+ function that calls one in PHP and `analyze` lists it under "State outside the arguments" (#1448).
- Go: `os.Getpid()`, `os.Getppid()`, `os.Getuid()` and `os.Getgid()` count as reading the
environment, and `time.Until()` as reading the clock, the mirror of `time.Since()`, so `bridge`
keeps a function that calls one in Go and `analyze` counts it (#1455).
diff --git a/src/lang/effects.rs b/src/lang/effects.rs
index d4f75530..3ae21e9a 100644
--- a/src/lang/effects.rs
+++ b/src/lang/effects.rs
@@ -205,7 +205,18 @@ fn environment(lang: Lang) -> &'static [&'static str] {
"Process.uid",
"Gem.user_home",
],
- Lang::Php => &["getenv(", "$_ENV", "$_SERVER", "getcwd(", "gethostname("],
+ Lang::Php => &[
+ "getenv(",
+ "$_ENV",
+ "$_SERVER",
+ "getcwd(",
+ "gethostname(",
+ "sys_get_temp_dir(",
+ "getmypid(",
+ "getmyuid(",
+ "get_current_user(",
+ "php_uname(",
+ ],
Lang::Csharp => &[
"Environment.GetEnvironmentVariable",
"Environment.CurrentDirectory",
@@ -1735,6 +1746,11 @@ mod tests {
(Lang::Ruby, "def self.f(x)\n File.join(Dir.tmpdir, x)\nend"),
(Lang::Ruby, "def self.f(x)\n Socket.gethostname + x\nend"),
(Lang::Php, "function f($x) { return getenv('HOME') . $x; }"),
+ (
+ Lang::Php,
+ "function f($x) { return sys_get_temp_dir() . $x; }",
+ ),
+ (Lang::Php, "function f($x) { return getmypid() . $x; }"),
(Lang::Powershell, "function F { param($X) $env:HOME + $X }"),
(
Lang::C,