Use of undefined constant parent - assumed 'parent' (this will throw an Error in a future version of PHP)
JamesPJ opened this issue · comments
JamesPJ commented
On PHP 7.4.6
I'm getting below error.
ErrorException
Use of undefined constant parent - assumed 'parent' (this will throw an Error in a future version of PHP)
at vendor/danhunsaker/laravel-flysystem-service/src/FlysystemManager.php:111
107| return $this->createFlysystem(new \League\Flysystem\Replicate\ReplicateAdapter($this->disk($config['master'])->getAdapter(), $this->disk($config['replica'])->getAdapter()), $config);
108| });
109| }
110|
> 111| if (class_exists('\League\Flysystem\Sftp\SftpAdapter' && !method_exists(parent, 'createSftpDriver'))) {
112| $this->extend('sftp', function ($app, $config) {
113| return $this->createFlysystem(new \League\Flysystem\Sftp\SftpAdapter($config), $config);
114| });
115| }
+17 vendor frames
18 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Danhunsaker\Laravel\Flysystem\FlysystemOtherServiceProvider))
+5 vendor frames
24 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
After changing occurrence of method_exists(parent, ....)
to method_exists(parent::class, ....)
. I was able to get it work.
Ashley Upson commented
Also fixed by changing parent
usages on lines 90 and 111 to get_parent_class($this)
.
Hennik Hunsaker commented
By skipping the function call and its associated overhead, parent::class
is the more efficient approach, so that's what I went ahead and used in the latest commit. I'll tag it in a moment.