I am using Flysystem\CSV to create a CSV and I'm running into the following problem with my code:
namespace App;
use League\Csv\Writer;
class Example
{
public function writeToCsv()
{
$csv = Writer::createFromFileObject(new \SplTempFileObject);
}
}
As per this example.
I've checked that SplTempFileObject
is being instantiated properly, and it is.
Yet there is an exception being thrown by AbstractCsv
.
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/exampleuser/vendor/league/csv/src/AbstractCsv.php on line 210
That line has the following return statement:
/**
* Return a new {@link Writer} instance from a {@link AbstractCsv} object
*
* @param string $open_mode the file open mode flag
*
* @return Writer
*/
public function newWriter($open_mode = 'r+')
{
return $this->newInstance(Writer::class, $open_mode);
}
I've double-checked that the package is installed correctly and it is.
PHP version 5.4.45
.
The problem is that ::class
name resolution is not available in 5.4. Which has come in with 5.5