lekoala /
silverstripe-encrypt
| 1 | <?php |
||
| 2 | |||
| 3 | namespace LeKoala\Encrypt; |
||
| 4 | |||
| 5 | use Exception; |
||
| 6 | use SilverStripe\Assets\File; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @mixin \LeKoala\Encrypt\EncryptedDBFile |
||
| 10 | * @property bool $Encrypted |
||
| 11 | * @method bool encryptFileIfNeeded() |
||
| 12 | */ |
||
| 13 | class EncryptedFile extends File |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @return void |
||
| 17 | */ |
||
| 18 | protected function onBeforeWrite() |
||
| 19 | { |
||
| 20 | parent::onBeforeWrite(); |
||
| 21 | try { |
||
| 22 | $this->encryptFileIfNeeded(false); |
||
|
0 ignored issues
–
show
|
|||
| 23 | } catch (Exception $ex) { |
||
| 24 | $this->Encrypted = false; |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $path |
||
| 30 | * @param ?string $filename |
||
| 31 | * @param ?string $hash |
||
| 32 | * @param ?string $variant |
||
| 33 | * @param array<mixed> $config |
||
| 34 | * @return array<mixed> |
||
| 35 | */ |
||
| 36 | public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []) |
||
| 37 | { |
||
| 38 | $this->Encrypted = false; |
||
| 39 | return parent::setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param resource $stream |
||
| 44 | * @param string $filename |
||
| 45 | * @param ?string $hash |
||
| 46 | * @param ?string $variant |
||
| 47 | * @param array<mixed> $config |
||
| 48 | * @return array<mixed> |
||
| 49 | */ |
||
| 50 | public function setFromStream($stream, $filename, $hash = null, $variant = null, $config = []) |
||
| 51 | { |
||
| 52 | $this->Encrypted = false; |
||
| 53 | return parent::setFromStream($stream, $filename, $hash = null, $variant = null, $config = []); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $data |
||
| 58 | * @param string $filename |
||
| 59 | * @param ?string $hash |
||
| 60 | * @param ?string $variant |
||
| 61 | * @param array<mixed> $config |
||
| 62 | * @return array<mixed> |
||
| 63 | */ |
||
| 64 | public function setFromString($data, $filename, $hash = null, $variant = null, $config = []) |
||
| 65 | { |
||
| 66 | $this->Encrypted = false; |
||
| 67 | return parent::setFromString($data, $filename, $hash = null, $variant = null, $config = []); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.