<?php declare(strict_types=1); namespace League\Flysystem\PhpseclibV2; use phpseclib\Net\SFTP; /** * @internal This is only used for testing purposes. * * @deprecated The "League\Flysystem\PhpseclibV2\SftpStub" class is deprecated since Flysystem 3.0, use "League\Flysystem\PhpseclibV3\SftpStub" instead. */ class SftpStub extends SFTP { /** * @var array<string,bool> */ private $tripWires = []; public function failOnChmod(string $filename): void { $key = $this->formatTripKey('chmod', $filename); $this->tripWires[$key] = true; } /** * @param int $mode * @param string $filename * @param bool $recursive * * @return bool|mixed */ public function chmod($mode, $filename, $recursive = false) { $key = $this->formatTripKey('chmod', $filename); $shouldTrip = $this->tripWires[$key] ?? false; if ($shouldTrip) { unset($this->tripWires[$key]); return false; } return parent::chmod($mode, $filename, $recursive); } public function failOnPut(string $filename): void { $key = $this->formatTripKey('put', $filename); $this->tripWires[$key] = true; } /** * @param string $remote_file * @param resource|string $data * @param int $mode * @param int $start * @param int $local_start * @param null $progressCallback * * @return bool */ public function put( $remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1, $progressCallback = null ) { $key = $this->formatTripKey('put', $remote_file); $shouldTrip = $this->tripWires[$key] ?? false; if ($shouldTrip) { return false; } return parent::put($remote_file, $data, $mode, $start, $local_start, $progressCallback); } /** * @param array<int,mixed> $arguments * * @return string */ private function formatTripKey(...$arguments): string { $key = ''; foreach ($arguments as $argument) { $key .= var_export($argument, true); } return $key; } public function reset(): void { $this->tripWires = []; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.github | Folder | 0755 |
|
|
.gitattributes | File | 150 B | 0644 |
|
ConnectionProvider.php | File | 375 B | 0644 |
|
ConnectivityChecker.php | File | 388 B | 0644 |
|
FixatedConnectivityChecker.php | File | 880 B | 0644 |
|
README.md | File | 462 B | 0644 |
|
SftpAdapter.php | File | 12.08 KB | 0644 |
|
SftpAdapterTest.php | File | 6.03 KB | 0644 |
|
SftpConnectionProvider.php | File | 6.16 KB | 0644 |
|
SftpConnectionProviderTest.php | File | 6.69 KB | 0644 |
|
SftpStub.php | File | 2.43 KB | 0644 |
|
SimpleConnectivityChecker.php | File | 490 B | 0644 |
|
StubSftpConnectionProvider.php | File | 1.3 KB | 0644 |
|
UnableToAuthenticate.php | File | 932 B | 0644 |
|
UnableToConnectToSftpHost.php | File | 618 B | 0644 |
|
UnableToEstablishAuthenticityOfHost.php | File | 717 B | 0644 |
|
UnableToLoadPrivateKey.php | File | 568 B | 0644 |
|
composer.json | File | 670 B | 0644 |
|