<?php declare(strict_types=1); namespace League\Flysystem\PhpseclibV3; use phpseclib3\Net\SFTP; /** * @internal This is only used for testing purposes. */ class SftpStub extends SFTP { /** * @var array<string,bool> */ private array $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 | 192 B | 0644 |
|
ConnectivityChecker.php | File | 203 B | 0644 |
|
FixatedConnectivityChecker.php | File | 681 B | 0644 |
|
README.md | File | 314 B | 0644 |
|
SftpAdapter.php | File | 11.68 KB | 0644 |
|
SftpAdapterTest.php | File | 6.05 KB | 0644 |
|
SftpConnectionProvider.php | File | 5.67 KB | 0644 |
|
SftpConnectionProviderTest.php | File | 11.57 KB | 0644 |
|
SftpStub.php | File | 2.28 KB | 0644 |
|
SimpleConnectivityChecker.php | File | 293 B | 0644 |
|
StubSftpConnectionProvider.php | File | 783 B | 0644 |
|
UnableToAuthenticate.php | File | 744 B | 0644 |
|
UnableToConnectToSftpHost.php | File | 420 B | 0644 |
|
UnableToEstablishAuthenticityOfHost.php | File | 499 B | 0644 |
|
UnableToLoadPrivateKey.php | File | 376 B | 0644 |
|
composer.json | File | 628 B | 0644 |
|