Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -27,24 +27,19 @@ use App\Services\Parts\PartLotWithdrawAddHelper;
class ProjectBuildHelper
{
private PartLotWithdrawAddHelper $withdraw_add_helper;
public function __construct(PartLotWithdrawAddHelper $withdraw_add_helper)
public function __construct(private readonly PartLotWithdrawAddHelper $withdraw_add_helper)
{
$this->withdraw_add_helper = $withdraw_add_helper;
}
/**
* Returns the maximum buildable amount of the given BOM entry based on the stock of the used parts.
* This function only works for BOM entries that are associated with a part.
* @param ProjectBOMEntry $projectBOMEntry
* @return int
*/
public function getMaximumBuildableCountForBOMEntry(ProjectBOMEntry $projectBOMEntry): int
{
$part = $projectBOMEntry->getPart();
if ($part === null) {
if (!$part instanceof \App\Entity\Parts\Part) {
throw new \InvalidArgumentException('This function cannot determine the maximum buildable count for a BOM entry without a part!');
}
@ -59,8 +54,6 @@ class ProjectBuildHelper
/**
* Returns the maximum buildable amount of the given project, based on the stock of the used parts in the BOM.
* @param Project $project
* @return int
*/
public function getMaximumBuildableCount(Project $project): int
{
@ -81,9 +74,7 @@ class ProjectBuildHelper
/**
* Checks if the given project can be built with the current stock.
* This means that the maximum buildable count is greater or equal than the requested $number_of_projects
* @param Project $project
* @parm int $number_of_builds
* @return bool
*/
public function isProjectBuildable(Project $project, int $number_of_builds = 1): bool
{
@ -93,9 +84,6 @@ class ProjectBuildHelper
/**
* Check if the given BOM entry can be built with the current stock.
* This means that the maximum buildable count is greater or equal than the requested $number_of_projects
* @param ProjectBOMEntry $bom_entry
* @param int $number_of_builds
* @return bool
*/
public function isBOMEntryBuildable(ProjectBOMEntry $bom_entry, int $number_of_builds = 1): bool
{
@ -120,7 +108,7 @@ class ProjectBuildHelper
$part = $bomEntry->getPart();
//Skip BOM entries without a part (as we can not determine that)
if ($part === null) {
if (!$part instanceof \App\Entity\Parts\Part) {
continue;
}
@ -138,8 +126,6 @@ class ProjectBuildHelper
* Withdraw the parts from the stock using the given ProjectBuildRequest and create the build parts entries, if needed.
* The ProjectBuildRequest has to be validated before!!
* You have to flush changes to DB afterward
* @param ProjectBuildRequest $buildRequest
* @return void
*/
public function doBuild(ProjectBuildRequest $buildRequest): void
{