Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Missing getcwd function? #29

Closed
kasperg opened this issue Sep 14, 2018 · 3 comments · Fixed by #31
Closed

Missing getcwd function? #29

kasperg opened this issue Sep 14, 2018 · 3 comments · Fixed by #31

Comments

@kasperg
Copy link
Contributor

kasperg commented Sep 14, 2018

Thanks a bunch for sharing safe. It helps me up my PHPStan level without writing to much tedious code.

One question: Is the getcwd() function missing?

I tried looking into this and the documentation seems as if it would be detected as falsy and as far as I can tell neither module nor function is explicitly declared as ignored.

Returns the current working directory on success, or FALSE on failure.

I tried running the generation but cloning the documentation fails because of timeouts 😕 .

@moufmouf
Copy link
Member

Yeah... I'm having the same problem right now. The documentation SVN seems to be down since approximately one hour. Hopefully, it will be fixed soon.

@moufmouf
Copy link
Member

Regarding getcwd, you are perfectly right, it should be detected.

Detection is done in DocPage::detectFalsyFunction:

public function detectFalsyFunction(): bool
{
$file = file_get_contents($this->path);
if (!preg_match('/::/m', $file)) {
if (preg_match('/&false;\s+on\s+error/m', $file)) {
return true;
}
if (preg_match('/&false;\s+if\s+an\s+error\s+occurred/m', $file)) {
return true;
}
if (preg_match('/&return.success;/m', $file)) {
return true;
}
if (preg_match('/&return.nullorfalse;/m', $file)) {
return true;
}
if (preg_match('/&return.falseforfailure;/m', $file)) {
return true;
}
}
return false;
}

It is really heuristic as the doc can be written in a lot of different ways.

I'll fix this for getcwd

@kasperg
Copy link
Contributor Author

kasperg commented Sep 14, 2018

I took a stab at this myself. We can continue the discussion in the PR.

@kasperg kasperg closed this as completed Sep 14, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants