可捕获的致命错误:参数1传递给CorenlpAdapter :: getOutput()

I get the following error:

Catchable fatal error: Argument 1 passed to CorenlpAdapter::getOutput() must be an instance of string, string given, called in /Library/WebServer/Documents/website/php-stanford-corenlp-adapter/index.php on line 22 and defined in /Library/WebServer/Documents/website/php-stanford-corenlp-adapter/src/CoreNLP/CorenlpAdapter.php on line 95

index.php 21 and 22 contain:

$text1 = 'I will meet Mary in New York at 10pm';
$coreNLP->getOutput($text1);

corenlpAdapter.php lines 95 and onwards contain:

public function getOutput(string $text){

    if(ONLINE_API){
        // run the text through the public API
        $this->getServerOutputOnline($text);
    } else{
        // run the text through Java CoreNLP
        $this->getServerOutput($text);
    }

    // cache result
    $this->serverMemory[] = $this->serverOutput;

    if(empty($this->serverOutput)){
        echo '** ERROR: No output from the CoreNLP Server **<br />
            - Check if the CoreNLP server is running. Start the CoreNLP server if necessary<br />
            - Check if the port you are using (probably port 9000) is not blocked by another program<br />';
        die;
    }

    /**
     * create trees
     */
    $sentences = $this->serverOutput['sentences'];
    foreach($this->serverOutput['sentences'] as $sentence){
        $tree           = $this->getTreeWithTokens($sentence); // gets one tree
        $this->trees[]  = $tree; // collect all trees
    }

    /**
     * add OpenIE data
     */
    $this->addOpenIE();

    // to get the trees just call $coreNLP->trees in the main program
    return;
}

Why exactly am I getting this error when text1 is a string?

public function getOutput($text){
  .
  .
  .
}

I am the original author of this class. As you can see, the function getOutput looks like this:

public function getOutput(string $text){
...
} 

Change that to:

public function getOutput($text){
...
} 

The function tries to enforce that the input is string. The original code should work. However, it seems that in your case, PHP thinks "string" is not actually a string. Maybe the coding environment (the IDE) you are using uses the wrong character set? Or maybe you copy-pasted the code from HTML into the IDE or something like that. Thus whilst it says "string" on the screen, it's not actually a string to PHP.

If you are sure the input is a string, you can safely change the code like above. The class should then work normally.