Skip to content

Commit

Permalink
Various updates for new admin and site packages, and some phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cviebrock committed Oct 30, 2024
1 parent 5529589 commit 185aa78
Show file tree
Hide file tree
Showing 115 changed files with 244 additions and 286 deletions.
7 changes: 0 additions & 7 deletions Store/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,6 @@ public static function init()

SiteViewFactory::addPath('Store/views');

if (class_exists('Blorg')) {
SiteViewFactory::registerView(
'post-search',
'StoreBlorgPostSearchView'
);
}

self::$is_initialized = true;
}

Expand Down
7 changes: 4 additions & 3 deletions Store/StoreArticlePageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(SiteApplication $app)
// }}}
// {{{ protected function isVisible()

protected function isVisible(SiteArticle $article, $source)
protected function isVisible(SiteArticle $article, $source): bool
{
$region = $this->app->getRegion();
$sql = sprintf('select count(id) from EnabledArticleView
Expand All @@ -51,7 +51,8 @@ protected function isVisible(SiteArticle $article, $source)
protected function getNotVisiblePage(
SiteArticle $article,
SiteLayout $layout
) {
): SitePage
{
$page = new SitePage($this->app, $layout);
$page = $this->decorate($page, 'StoreArticleNotVisiblePage');
$page->setArticle($article);
Expand All @@ -69,7 +70,7 @@ protected function getNotVisiblePage(
* @return SiteArticle the specified article or null if no such article
* exists.
*/
protected function getArticle($path)
protected function getArticle($path): SiteArticle
{
$article = parent::getArticle($path);
$article->setRegion($this->app->getRegion());
Expand Down
2 changes: 2 additions & 0 deletions Store/StoreCartLightbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class StoreCartLightbox extends SwatControl
*/
protected $app;

private ?StoreCartProcessor $processor = null;

/**
* @var SwatUI
*/
Expand Down
2 changes: 2 additions & 0 deletions Store/StoreItemsView.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class StoreItemsView extends SwatControl

protected $has_description = false;

protected string $source;

/**
* @var boolean
*/
Expand Down
2 changes: 1 addition & 1 deletion Store/StorePageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(SiteApplication $app)
// }}}
// {{{ public function resolvePage()

public function resolvePage($source, SiteLayout $layout = null)
public function resolvePage($source, SiteLayout $layout = null): SiteAbstractPage
{
$layout = ($layout === null) ? $this->resolveLayout($source) : $layout;

Expand Down
6 changes: 3 additions & 3 deletions Store/StorePayPalPaymentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function __construct(array $parameters = array())

$valid_modes = array('live', 'sandbox');
if (!in_array($parameters['mode'], $valid_modes)) {
throw new StoreException('Mode "'.$mode.'" is not valid for '.
throw new StoreException('Mode "'.$parameters['mode'].'" is not valid for '.
'the PayPal payment provider.');
}

Expand Down Expand Up @@ -830,7 +830,7 @@ public function formatString($string, $max_length = 0)

// truncate to max_length
if ($max_length > 0) {
$string = mb_mb_substr($string, 0, $max_length);
$string = mb_substr($string, 0, $max_length);
}

return $string;
Expand Down Expand Up @@ -1475,7 +1475,7 @@ protected function getCreditCardType(StoreOrderPaymentMethod $payment_method)
break;

default:
throw new StorePaymentException('Unsupported card type in order.');
throw new StorePaymentCardTypeException('Unsupported card type in order.');
}

return $type;
Expand Down
7 changes: 4 additions & 3 deletions Store/StoreShipmentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ class StoreShipmentMethod
/**
* An approximation of how long it takes to ship items with this method.
*
* @return DateInterval the approximate time it will take to deliver a
* shipment using this method.
* @return ?DateInterval the approximate time it will take to deliver a
* shipment using this method, or null.
*/
public function getTimeToDeliver($address)
public function getTimeToDeliver($address): ?DateInterval
{
return null;
}

// }}}
Expand Down
24 changes: 11 additions & 13 deletions Store/StoreStatusList.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ abstract class StoreStatusList extends SwatObject implements Iterator, Countable

/**
* Index value used to implement the iterator interface for this list
*
* @var integer
*/
private $current_index = 0;
private int $current_index = 0;

// }}}
// {{{ protected properties
Expand Down Expand Up @@ -97,7 +95,7 @@ public function getByShortname($shortname)
*
* @return mixed the current status.
*/
public function current()
public function current(): mixed
{
return $this->statuses[$this->current_index];
}
Expand All @@ -108,9 +106,9 @@ public function current()
/**
* Returns the key of the current status
*
* @return integer the key of the current status
* @return int the key of the current status
*/
public function key()
public function key(): int
{
return $this->current_index;
}
Expand All @@ -121,7 +119,7 @@ public function key()
/**
* Moves forward to the next status
*/
public function next()
public function next(): void
{
$this->current_index++;
}
Expand All @@ -143,7 +141,7 @@ public function prev()
/**
* Rewinds this iterator to the first status
*/
public function rewind()
public function rewind(): void
{
$this->current_index = 0;
}
Expand All @@ -154,10 +152,10 @@ public function rewind()
/**
* Checks is there is a current status after calls to rewind() and next()
*
* @return boolean true if there is a current status and false if there
* is not.
* @return bool true if there is a current status and false if there
* is not.
*/
public function valid()
public function valid(): bool
{
return isset($this->statuses[$this->current_index]);
}
Expand All @@ -170,9 +168,9 @@ public function valid()
*
* This satisfies the Countable interface.
*
* @return integer the number of statuses in this list.
* @return int the number of statuses in this list.
*/
public function count()
public function count(): int
{
return count($this->statuses);
}
Expand Down
2 changes: 2 additions & 0 deletions Store/StoreVoucherRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class StoreVoucherRow extends StoreTotalRow
{
// {{{ public function __construct()

protected SwatButton $remove_button;

public function __construct()
{
parent::__construct();
Expand Down
2 changes: 1 addition & 1 deletion Store/StoreXMLRPCServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(SiteApplication $app)
// }}}
// {{{ protected function getPageMap()

protected function getPageMap()
protected function getPageMap(): array
{
return array(
'search-panel' => 'StoreSearchPanelServer',
Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Account/AddressDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StoreAccountAddressDelete extends AdminDBDelete
// process phase
// {{{ protected function processDBData()

protected function processDBData()
protected function processDBData(): void
{
parent::processDBData();

Expand Down
4 changes: 2 additions & 2 deletions Store/admin/components/Account/AddressEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function getCountry()
// }}}
// {{{ protected function saveDBData()

protected function saveDBData()
protected function saveDBData(): void
{
$values = $this->getUIValues();

Expand Down Expand Up @@ -263,7 +263,7 @@ protected function getUIValues()
// }}}
// {{{ protected function validate()

protected function validate()
protected function validate(): void
{
$provstate = $this->ui->getWidget('provstate');
$country = $this->ui->getWidget('country');
Expand Down
9 changes: 5 additions & 4 deletions Store/admin/components/Account/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function setTimeZone()
// }}}
// {{{ protected function getTableModel()

protected function getTableModel(SwatView $view)
protected function getTableModel(SwatView $view): ?SwatTableModel
{
switch ($view->id) {
case 'orders_view':
Expand All @@ -115,12 +115,13 @@ protected function getTableModel(SwatView $view)
case 'payment_methods_view':
return $this->getPaymentMethodsTableModel($view);
}
return null;
}

// }}}
// {{{ protected function getOrdersTableModel()

protected function getOrdersTableModel(SwatTableView $view)
protected function getOrdersTableModel(SwatTableView $view): SwatDBDefaultRecordsetWrapper
{
$sql = 'select Orders.id,
Orders.account as account_id,
Expand All @@ -143,7 +144,7 @@ protected function getOrdersTableModel(SwatTableView $view)
// }}}
// {{{ protected function getAddressesTableModel()

protected function getAddressesTableModel(SwatTableView $view)
protected function getAddressesTableModel(SwatTableView $view): SwatTableStore
{
$account = $this->getAccount();
$billing_id = $account->getInternalValue('default_billing_address');
Expand All @@ -167,7 +168,7 @@ protected function getAddressesTableModel(SwatTableView $view)
// }}}
// {{{ protected function getPaymentMethodsTableModel()

protected function getPaymentMethodsTableModel(SwatTableView $view)
protected function getPaymentMethodsTableModel(SwatTableView $view): SwatTableStore
{
$wrapper = SwatDBClassMap::get('StoreAccountPaymentMethodWrapper');

Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Account/PaymentMethodDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StoreAccountPaymentMethodDelete extends AdminDBDelete
// process phase
// {{{ protected function processDBData()

protected function processDBData()
protected function processDBData(): void
{
parent::processDBData();

Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Account/PaymentMethodEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function getPaymentMethod()
// process phase
// {{{ protected function saveDBData()

protected function saveDBData()
protected function saveDBData(): void
{
$payment_method = $this->getPaymentMethod();
$payment_method->payment_type =
Expand Down
4 changes: 2 additions & 2 deletions Store/admin/components/Ad/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function getUiXml()
// build phase
// {{{ protected function getTableModel()

protected function getTableModel(SwatView $view)
protected function getTableModel(SwatView $view): ?SwatTableModel
{
switch ($view->id) {
case 'orders_view':
Expand All @@ -48,7 +48,7 @@ protected function getTableModel(SwatView $view)
// }}}
// {{{ protected function getOrdersTableModel()

protected function getOrdersTableModel()
protected function getOrdersTableModel(): SwatTableStore
{
$regions = $this->queryRegions();
$this->appendRegionColumns($regions);
Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Ad/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function getUiXml()
// build phase
// {{{ protected function getTableModel()

protected function getTableModel(SwatView $view)
protected function getTableModel(SwatView $view): SwatDBDefaultRecordsetWrapper
{
$sql = sprintf('select Ad.*,
coalesce(OrderCountByAdView.order_count, 0) as order_count,
Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Article/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function getUiXml()
// process phase
// {{{ protected function saveDBData()

protected function saveDBData()
protected function saveDBData(): void
{
parent::saveDBData();

Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Attribute/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StoreAttributeDelete extends AdminDBDelete
// process phase
// {{{ protected function processDBData()

protected function processDBData()
protected function processDBData(): void
{
parent::processDBData();

Expand Down
4 changes: 2 additions & 2 deletions Store/admin/components/Attribute/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getUiXml()
// process phase
// {{{ protected function validate()

protected function validate()
protected function validate(): void
{
$shortname = $this->ui->getWidget('shortname');

Expand All @@ -97,7 +97,7 @@ protected function validate()

// {{{ protected function saveDBData()

protected function saveDBData()
protected function saveDBData(): void
{
$this->updateAttribute();
$this->attribute->save();
Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/Attribute/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function processActions(SwatView $view, SwatActions $actions)
// build phase
// {{{ protected function getTableModel()

protected function getTableModel(SwatView $view)
protected function getTableModel(SwatView $view): SwatTableStore
{
$sql = sprintf('select Attribute.*
from Attribute
Expand Down
2 changes: 1 addition & 1 deletion Store/admin/components/AttributeType/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StoreAttributeTypeDelete extends AdminDBDelete
// process phase
// {{{ protected function processDBData()

protected function processDBData()
protected function processDBData(): void
{
parent::processDBData();

Expand Down
4 changes: 2 additions & 2 deletions Store/admin/components/AttributeType/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function initAttributeType()
// process phase
// {{{ protected function validate()

protected function validate()
protected function validate(): void
{
$shortname = $this->ui->getWidget('shortname');

Expand All @@ -74,7 +74,7 @@ protected function validate()
// }}}
// {{{ protected function saveDBData()

protected function saveDBData()
protected function saveDBData(): void
{
$this->updateAttributeType();
$this->attribute_type->save();
Expand Down
Loading

0 comments on commit 185aa78

Please sign in to comment.