Skip to content

Commit

Permalink
chore: updating code style (#1150)
Browse files Browse the repository at this point in the history
* chore: updating code style
* chore: removing rector
  • Loading branch information
gustavs-gutmanis authored Mar 19, 2024
1 parent 40987cd commit dd78841
Show file tree
Hide file tree
Showing 88 changed files with 193 additions and 353 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
])
->setRiskyAllowed(true)
->setFinder($finder)
->setCacheFile(__DIR__.'/.php-cs-fixer.cache')
;
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9.3.0",
"friendsofphp/php-cs-fixer": "^v3.14.4",
"brainmaestro/composer-git-hooks": "^2.8",
"craftcms/rector": "dev-main"
"friendsofphp/php-cs-fixer": "^v3.52.0",
"brainmaestro/composer-git-hooks": "^2.8"
},
"autoload": {
"psr-4": {
Expand Down
280 changes: 60 additions & 220 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function normalize(): array
return $this->toArray();
}

public function toArray(self $optionCollection = null): array
public function toArray(?self $optionCollection = null): array
{
$options = [];

Expand All @@ -90,7 +90,7 @@ public function toArray(self $optionCollection = null): array
return $options;
}

public function toTwigArray(self $optionCollection = null): array
public function toTwigArray(?self $optionCollection = null): array
{
$options = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Attributes/Property/Input/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
?string $label = null,
?string $instructions = null,
?int $order = null,
array $value = null,
?array $value = null,
?int $width = null,
public null|array|OptionCollection|string $options = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
?string $label = null,
?string $instructions = null,
?int $order = null,
array $value = null,
?array $value = null,
?int $width = null,
public null|array|string|TabularDataConfiguration $configuration = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SessionBag implements \JsonSerializable
/** @var array */
private $attributes;

public function __construct(int $formId, array $properties = [], array $attributes = [], Carbon $lastUpdate = null)
public function __construct(int $formId, array $properties = [], array $attributes = [], ?Carbon $lastUpdate = null)
{
$this->formId = $formId;
$this->properties = $properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PayloadStorage implements FormContextStorageInterface

private ?string $secret;

public function __construct(string $secret = null)
public function __construct(?string $secret = null)
{
$this->secret = $secret;

Expand Down Expand Up @@ -128,7 +128,7 @@ private function getPostedPayload(): ?string
return $payload ? htmlspecialchars($payload) : null;
}

private function getDecryptedBag(Form $form, string $payload = null)
private function getDecryptedBag(Form $form, ?string $payload = null)
{
if (null === $payload) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function (SurveyPreferencesRecord $preference) {
];
}

protected function put(int|string $id = null): null|array|object
protected function put(null|int|string $id = null): null|array|object
{
PermissionHelper::requirePermission(SurveysBundle::PERMISSION_REPORTS_MANAGE);
$request = $this->request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class SurveySettingsController extends Controller
{
public function __construct($id, $module, $config = [], private FieldTypesProvider $fieldTypesProvider)
public function __construct($id, $module, $config, private FieldTypesProvider $fieldTypesProvider)
{
parent::__construct($id, $module, $config);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Bundles/Form/Types/Surveys/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#[Type('Surveys & Polls')]
class Survey extends Form
{
public function getSurveyResults(FieldInterface $field = null): null|FieldTotals|FormTotals
public function getSurveyResults(?FieldInterface $field = null): null|FieldTotals|FormTotals
{
$totalsProvider = \Craft::$container->get(TotalsProvider::class);
$formTotals = $totalsProvider->get($this);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Bundles/GraphQL/Types/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function parseValue(mixed $value): mixed
return $value;
}

public function parseLiteral(mixed $valueNode, array $variables = null): mixed
public function parseLiteral(mixed $valueNode, ?array $variables = null): mixed
{
return $valueNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NotificationsProvider
{
public function __construct(private PropertyProvider $propertyProvider) {}

public function getByForm(Form $form = null): array
public function getByForm(?Form $form = null): array
{
/** @var FormNotificationRecord[] $records */
$records = FormNotificationRecord::find()
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Elements/SpamSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getCpEditUrl(): ?string
return $this->getIsEditable() ? UrlHelper::cpUrl('freeform/spam/'.$this->id) : false;
}

protected static function defineActions(string $source = null): array
protected static function defineActions(?string $source = null): array
{
if ('*' === $source) {
$message = Freeform::t('Are you sure you want to delete all submissions?');
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin/src/Elements/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public function getFieldCollection(): FieldCollection
return $this->fieldCollection;
}

protected static function defineSources(string $context = null): array
protected static function defineSources(?string $context = null): array
{
static $sources;

Expand Down Expand Up @@ -620,7 +620,7 @@ protected static function defineDefaultTableAttributes(string $source): array
];
}

protected static function defineActions(string $source = null): array
protected static function defineActions(?string $source = null): array
{
if ('*' === $source) {
$message = Freeform::t('Are you sure you want to delete all submissions?');
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Events/Forms/PageJumpEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getJumpToIndex(): ?int
return $this->jumpToIndex;
}

public function setJumpToIndex(int $jumpToIndex = null): void
public function setJumpToIndex(?int $jumpToIndex = null): void
{
$totalPages = \count($this->getForm()->getLayout()->getPages());

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Events/Forms/ReturnUrlEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getReturnUrl(): ?string
return $this->returnUrl;
}

public function setReturnUrl(string $returnUrl = null): self
public function setReturnUrl(?string $returnUrl = null): self
{
$this->returnUrl = $returnUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function addToNav(string $handle, $value): self
return $this;
}

public function addSubnavItem(string $handle, string $label, string $url, string $afterHandle = null, ?array $extraOptions = null): self
public function addSubnavItem(string $handle, string $label, string $url, ?string $afterHandle = null, ?array $extraOptions = null): self
{
$item = [
'label' => $label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getNavigation(): array
return $this->navigation;
}

public function addHeader(string $handle, string $title, string $afterHandle = null): self
public function addHeader(string $handle, string $title, ?string $afterHandle = null): self
{
$item = ['heading' => $title];

Expand All @@ -38,7 +38,7 @@ public function addHeader(string $handle, string $title, string $afterHandle = n
return $this;
}

public function addNavigationItem(string $handle, string $title, string $afterHandle = null): self
public function addNavigationItem(string $handle, string $title, ?string $afterHandle = null): self
{
$item = ['title' => $title];

Expand All @@ -47,7 +47,7 @@ public function addNavigationItem(string $handle, string $title, string $afterHa
return $this;
}

private function insertItem(string $handle, array $item, string $afterHandle = null)
private function insertItem(string $handle, array $item, ?string $afterHandle = null)
{
if (null !== $afterHandle && isset($this->navigation[$afterHandle])) {
$modifiedArray = [];
Expand Down
18 changes: 9 additions & 9 deletions packages/plugin/src/Fields/AbstractField.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function setValue(mixed $value): FieldInterface
* Render the complete set of HTML for this field
* That includes the Label, Input and Error messages.
*/
final public function render(array $parameters = null): Markup
final public function render(?array $parameters = null): Markup
{
$this->setParameters($parameters);

Expand Down Expand Up @@ -237,7 +237,7 @@ final public function render(array $parameters = null): Markup
return $this->renderRaw($output);
}

final public function renderContainerOpeningTag(array $parameters = null): Markup
final public function renderContainerOpeningTag(?array $parameters = null): Markup
{
$this->setParameters($parameters);
Event::trigger($this, self::EVENT_RENDER_CONTAINER, new FieldRenderEvent($this));
Expand All @@ -253,15 +253,15 @@ final public function renderContainerClosingTag(): Markup
/**
* Render the Label HTML.
*/
final public function renderLabel(array $parameters = null): Markup
final public function renderLabel(?array $parameters = null): Markup
{
$this->setParameters($parameters);
Event::trigger($this, self::EVENT_RENDER_LABEL, new FieldRenderEvent($this));

return $this->renderRaw($this->getLabelHtml());
}

public function renderInstructions(array $parameters = null): Markup
public function renderInstructions(?array $parameters = null): Markup
{
$this->setParameters($parameters);
Event::trigger($this, self::EVENT_RENDER_INSTRUCTIONS, new FieldRenderEvent($this));
Expand All @@ -272,7 +272,7 @@ public function renderInstructions(array $parameters = null): Markup
/**
* Render the Input HTML.
*/
final public function renderInput(array $parameters = null): Markup
final public function renderInput(?array $parameters = null): Markup
{
$this->setParameters($parameters);
Event::trigger($this, self::EVENT_RENDER_INPUT, new FieldRenderEvent($this));
Expand All @@ -283,7 +283,7 @@ final public function renderInput(array $parameters = null): Markup
/**
* Outputs the HTML of errors.
*/
final public function renderErrors(array $parameters = null): Markup
final public function renderErrors(?array $parameters = null): Markup
{
$this->setParameters($parameters);
Event::trigger($this, self::EVENT_RENDER_ERRORS, new FieldRenderEvent($this));
Expand Down Expand Up @@ -332,7 +332,7 @@ public function hasErrors(): bool
/**
* @return $this
*/
public function addErrors(array $errors = null): self
public function addErrors(?array $errors = null): self
{
if (empty($errors)) {
return $this;
Expand Down Expand Up @@ -510,7 +510,7 @@ public function includeInGqlSchema(): bool
return true;
}

public function setParameters(array $parameters = null): void
public function setParameters(?array $parameters = null): void
{
if (!\is_array($parameters)) {
return;
Expand Down Expand Up @@ -690,7 +690,7 @@ protected function onAfterInputHtml(): string
/**
* An alias method for translator.
*/
protected function translate(string $string = null, array $variables = []): string
protected function translate(?string $string = null, array $variables = []): string
{
return null === $string ? '' : Freeform::t($string, $variables);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Fields/FieldInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getContentGqlMutationArgumentType(): array|Type;

public function includeInGqlSchema(): bool;

public function setParameters(array $parameters = null): void;
public function setParameters(?array $parameters = null): void;

public function getAttributes(): FieldAttributesCollection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function getLocale(): ?string
return $this->locale;
}

public function getGeneratedMinDate(string $format = null): ?string
public function getGeneratedMinDate(?string $format = null): ?string
{
if (!$this->minDate) {
return null;
Expand All @@ -275,7 +275,7 @@ public function getGeneratedMinDate(string $format = null): ?string
return date($format ?? 'Y-m-d', strtotime($this->minDate));
}

public function getGeneratedMaxDate(string $format = null): ?string
public function getGeneratedMaxDate(?string $format = null): ?string
{
if (!$this->maxDate) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class OptionsConfiguration implements OptionsConfigurationInterface
private string $typeClass;
private array $properties;

public function __construct(array $config = [], PropertyProvider $propertyProvider)
public function __construct(array $config, PropertyProvider $propertyProvider)
{
$this->emptyOption = $config['emptyOption'] ?? null;
$this->typeClass = $config['typeClass'] ?? '';
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin/src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,14 @@ public function persistState(): void
Event::trigger(self::class, self::EVENT_PERSIST_STATE, new PersistStateEvent($this));
}

public function registerContext(array $renderProperties = null): void
public function registerContext(?array $renderProperties = null): void
{
$this->setProperties($renderProperties);

Event::trigger(self::class, self::EVENT_REGISTER_CONTEXT, new RegisterContextEvent($this));
}

public function render(array $renderProperties = null): ?Markup
public function render(?array $renderProperties = null): ?Markup
{
$this->setProperties($renderProperties);
$formTemplate = $this->getProperties()->get(
Expand All @@ -602,7 +602,7 @@ public function render(array $renderProperties = null): ?Markup
return $this->getFormHandler()->renderFormTemplate($this, $formTemplate);
}

public function renderTag(array $renderProperties = null): Markup
public function renderTag(?array $renderProperties = null): Markup
{
$this->registerContext($renderProperties);

Expand Down Expand Up @@ -680,7 +680,7 @@ public function getRelations(): Relations
return new Relations($this->getProperties()->get(self::DATA_RELATIONS));
}

public function setProperties(array $properties = null): self
public function setProperties(?array $properties = null): self
{
$event = new SetPropertiesEvent($this, $properties ?? []);
Event::trigger(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Form/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Settings
#[Ignore]
private PropertyAccessor $accessor;

public function __construct(array $settings = [], PropertyProvider $propertyProvider)
public function __construct(array $settings, PropertyProvider $propertyProvider)
{
$this->behavior = new BehaviorSettings();
$this->general = new GeneralSettings();
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Freeform.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static function editions(): array
];
}

public static function t(string $message, array $params = [], string $language = null): string
public static function t(string $message, array $params = [], ?string $language = null): string
{
return \Craft::t(self::TRANSLATION_CATEGORY, $message, $params, $language);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CallbackController extends BaseStripeController
public function __construct(
$id,
$module,
$config = [],
$config,
private IsolatedTwig $isolatedTwig,
private StripeCallbackService $callbackService,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PaymentIntentsController extends BaseStripeController
public function __construct(
$id,
$module,
$config = [],
$config,
private IsolatedTwig $isolatedTwig,
private StripeCustomerService $customerService,
private StripePriceService $amountService,
Expand Down
Loading

0 comments on commit dd78841

Please sign in to comment.