Skip to content

Commit

Permalink
Deprecate getter,setter and protected methods in RenameUpload
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Thole <[email protected]>
  • Loading branch information
marcelthole committed Jan 9, 2025
1 parent 9b32ba7 commit 5bdd310
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
53 changes: 53 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@
<DeprecatedClass>
<code><![CDATA[Compress]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[Decompress]]></code>
</DeprecatedInterface>
<PossiblyNullArgument>
<code><![CDATA[$value]]></code>
</PossiblyNullArgument>
Expand Down Expand Up @@ -593,6 +596,7 @@
<code><![CDATA[AbstractFilter]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[Encrypt]]></code>
<code><![CDATA[Encrypt\EncryptionAlgorithmInterface]]></code>
</DeprecatedInterface>
<DocblockTypeContradiction>
Expand Down Expand Up @@ -836,6 +840,9 @@
<code><![CDATA[Filter\Decrypt]]></code>
<code><![CDATA[parent::filter($content)]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[Decrypt]]></code>
</DeprecatedInterface>
<DocblockTypeContradiction>
<code><![CDATA[! is_scalar($value) && ! is_array($value)]]></code>
</DocblockTypeContradiction>
Expand Down Expand Up @@ -894,6 +901,9 @@
<code><![CDATA[Filter\Encrypt]]></code>
<code><![CDATA[parent::filter($content)]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[Encrypt]]></code>
</DeprecatedInterface>
<DocblockTypeContradiction>
<code><![CDATA[! is_scalar($value) && ! is_array($value)]]></code>
</DocblockTypeContradiction>
Expand Down Expand Up @@ -1017,6 +1027,27 @@
<DeprecatedClass>
<code><![CDATA[AbstractFilter]]></code>
</DeprecatedClass>
<DeprecatedMethod>
<code><![CDATA[applyRandomToFilename]]></code>
<code><![CDATA[checkFileExists]]></code>
<code><![CDATA[checkFileExists]]></code>
<code><![CDATA[checkFileExists]]></code>
<code><![CDATA[getFinalTarget]]></code>
<code><![CDATA[getFinalTarget]]></code>
<code><![CDATA[getFinalTarget]]></code>
<code><![CDATA[getOverwrite]]></code>
<code><![CDATA[getRandomize]]></code>
<code><![CDATA[getRandomize]]></code>
<code><![CDATA[getStreamFactory]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getUploadFileFactory]]></code>
<code><![CDATA[getUseUploadExtension]]></code>
<code><![CDATA[getUseUploadExtension]]></code>
<code><![CDATA[getUseUploadName]]></code>
<code><![CDATA[moveUploadedFile]]></code>
<code><![CDATA[moveUploadedFile]]></code>
<code><![CDATA[setTarget]]></code>
</DeprecatedMethod>
<DocblockTypeContradiction>
<code><![CDATA[$target === null]]></code>
<code><![CDATA[is_string($target)]]></code>
Expand Down Expand Up @@ -2080,6 +2111,28 @@
</PossiblyUnusedMethod>
</file>
<file src="test/File/RenameUploadTest.php">
<DeprecatedMethod>
<code><![CDATA[getOverwrite]]></code>
<code><![CDATA[getOverwrite]]></code>
<code><![CDATA[getOverwrite]]></code>
<code><![CDATA[getRandomize]]></code>
<code><![CDATA[getRandomize]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getUseUploadName]]></code>
<code><![CDATA[getUseUploadName]]></code>
<code><![CDATA[setStreamFactory]]></code>
<code><![CDATA[setUploadFileFactory]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[1234]]></code>
</InvalidArgument>
Expand Down
36 changes: 36 additions & 0 deletions src/File/RenameUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function __construct($targetOrOptions = [])
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param StreamFactoryInterface $factory Factory to use to produce a PSR-7
* stream with which to seed a PSR-7 UploadedFileInterface.
* @return self
Expand All @@ -91,6 +93,8 @@ public function setStreamFactory(StreamFactoryInterface $factory)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return null|StreamFactoryInterface
*/
public function getStreamFactory()
Expand All @@ -99,6 +103,8 @@ public function getStreamFactory()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param string $target Target file path or directory
* @return self
*/
Expand All @@ -114,6 +120,8 @@ public function setTarget($target)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return string Target file path or directory
*/
public function getTarget()
Expand All @@ -122,6 +130,8 @@ public function getTarget()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param UploadedFileFactoryInterface $factory Factory to use to produce
* filtered PSR-7 UploadedFileInterface instances.
* @return self
Expand All @@ -133,6 +143,8 @@ public function setUploadFileFactory(UploadedFileFactoryInterface $factory)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return null|UploadedFileFactoryInterface
*/
public function getUploadFileFactory()
Expand All @@ -141,6 +153,8 @@ public function getUploadFileFactory()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param bool $flag When true, this filter will use the $_FILES['name']
* as the target filename.
* Otherwise, it uses the default 'target' rules.
Expand All @@ -153,6 +167,8 @@ public function setUseUploadName($flag = true)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return bool
*/
public function getUseUploadName()
Expand All @@ -161,6 +177,8 @@ public function getUseUploadName()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param bool $flag When true, this filter will use the original file
* extension for the target filename
* @return self
Expand All @@ -172,6 +190,8 @@ public function setUseUploadExtension($flag = true)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return bool
*/
public function getUseUploadExtension()
Expand All @@ -180,6 +200,8 @@ public function getUseUploadExtension()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param bool $flag Shall existing files be overwritten?
* @return self
*/
Expand All @@ -190,6 +212,8 @@ public function setOverwrite($flag = true)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return bool
*/
public function getOverwrite()
Expand All @@ -198,6 +222,8 @@ public function getOverwrite()
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @param bool $flag Shall target files have a random postfix attached?
* @return self
*/
Expand All @@ -208,6 +234,8 @@ public function setRandomize($flag = true)
}

/**
* @deprecated Since 2.41.0. This method will be removed in 3.0 without replacement
*
* @return bool
*/
public function getRandomize()
Expand Down Expand Up @@ -251,6 +279,8 @@ public function filter($value)
}

/**
* @deprecated This method will be inaccessible in 3.0 once this class is marked final
*
* @param string $sourceFile Source file path
* @param string $targetFile Target file path
* @throws Exception\RuntimeException
Expand All @@ -273,6 +303,8 @@ protected function moveUploadedFile($sourceFile, $targetFile)
}

/**
* @deprecated This method will be inaccessible in 3.0 once this class is marked final
*
* @param string $targetFile Target file path
* @return void
* @throws Exception\InvalidArgumentException
Expand All @@ -293,6 +325,8 @@ protected function checkFileExists($targetFile)
}

/**
* @deprecated This method will be inaccessible in 3.0 once this class is marked final
*
* @param string $source
* @param string|null $clientFileName
* @return string
Expand Down Expand Up @@ -340,6 +374,8 @@ protected function getFinalTarget($source, $clientFileName)
}

/**
* @deprecated This method will be inaccessible in 3.0 once this class is marked final
*
* @param string $source
* @param string $filename
* @return string
Expand Down

0 comments on commit 5bdd310

Please sign in to comment.