I decided to start a new project to get into the hacklang, and after fixing some of the problems that I initially encountered when switching from php habits, I encountered the following errors:
Unbound name: str_replace Unbound name: empty
After doing some research, I found that this is due to the use of "legacy" php, which is not checked by typechecked, and will be an error with //strict .
That's fine and all, empty() was easy enough to replace, however str_replace() bit more complicated.
Is there an equivalent function that will work with //strict? Or at least something like that.
I know that I can use //decl , but I feel that this defeats the goal in my case.
Is there any way to tell which functions are implemented in the hack and which are not in the documentation, since I could not find them?
For reference (although this is not too relevant for the question itself), here is the code:
<?hh //strict class HackMarkdown { public function parse(string $content) : string { if($content===null){ throw new RuntimeException('Empty Content'); } $prepared = $this->prepare($content); } private function prepare(string $contentpre) : Vector<string>{ $contentpre = str_replace(array("\r\n","\r"),"\n",$contentpre); //probably need more in here $prepared = Vector::fromArray(explode($contentpre,"\n")); //and here return $prepared; } }
hacklang
Tiksi
source share