Skip to content

Commit

Permalink
Merge pull request #9319 from mickaelandrieu/phpdocs
Browse files Browse the repository at this point in the history
Phpdocs
  • Loading branch information
mickaelandrieu committed Jul 15, 2018
2 parents 3874c2c + 6044234 commit 087ee2a
Show file tree
Hide file tree
Showing 28 changed files with 466 additions and 36 deletions.
31 changes: 30 additions & 1 deletion src/Adapter/Addons/AddonsDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,29 @@
*/
class AddonsDataProvider implements AddonsInterface
{
/**
* @var bool
*/
protected static $is_addons_up = true;

/**
* @var ApiClient
*/
private $marketplaceClient;

/**
* @var ModuleZipManager
*/
private $zipManager;

/**
* @var PhpEncryption
*/
private $encryption;

/**
* @var string the cache directory location
*/
public $cacheDir;

public function __construct(ApiClient $apiClient, ModuleZipManager $zipManager)
Expand All @@ -58,6 +73,12 @@ public function __construct(ApiClient $apiClient, ModuleZipManager $zipManager)
$this->encryption = new PhpEncryption(_NEW_COOKIE_KEY_);
}

/**
* @param $module_id
*
* @return bool
* @throws Exception
*/
public function downloadModule($module_id)
{
$params = array(
Expand Down Expand Up @@ -85,7 +106,11 @@ public function downloadModule($module_id)
}
}

/** Does this function should be in a User related class ? **/
/**
* @return bool
*
* @todo Does this function should be in a User related class ?
*/
public function isAddonsAuthenticated()
{
$request = Request::createFromGlobals();
Expand Down Expand Up @@ -161,6 +186,10 @@ public function request($action, $params = array())
}
}

/**
* @return array
* @throws Exception
*/
protected function getAddonsCredentials()
{
$request = Request::createFromGlobals();
Expand Down
11 changes: 9 additions & 2 deletions src/Adapter/Admin/AbstractAdminQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ abstract class AbstractAdminQueryBuilder
const FILTERING_EQUAL_NUMERIC = '= %s';
const FILTERING_EQUAL_STRING = '= \'%s\'';

/**
* @var string|null
*/
private $lastCompiledSql = null;

final private function compileSqlWhere(array $whereArray)
/**
* @param array $whereArray
* @return mixed|string
*/
private function compileSqlWhere(array $whereArray)
{
$operator = 'AND';
$s = array();
Expand All @@ -65,7 +72,7 @@ final private function compileSqlWhere(array $whereArray)
/**
* Compiles a SQL query (SELECT), from a group of associative arrays.
*
* @see PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider::getCatalogProductList() for an example.
* @see \PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider::getCatalogProductList() for an example.
*
* Format example for $table:
* $table = array(
Expand Down
15 changes: 9 additions & 6 deletions src/Adapter/Admin/PagePreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
*/
class PagePreference implements AdminPagePreferenceInterface
{
/**
* @var SessionInterface
*/
private $session;

public function __construct(SessionInterface $session)
Expand All @@ -54,8 +57,8 @@ public function __construct(SessionInterface $session)
}
}

/* (non-PHPdoc)
* @see \PrestaShopCoreAdminBundle\TransitionalBehavior\AdminPagePreferenceInterface::getTemporaryShouldUseLegacyPage()
/**
* {@inheritdoc}
*/
public function getTemporaryShouldUseLegacyPage($page)
{
Expand All @@ -66,8 +69,8 @@ public function getTemporaryShouldUseLegacyPage($page)
return ($this->session->has('should_use_legacy_page_for_'.$page) && $this->session->get('should_use_legacy_page_for_'.$page, 0) == 1);
}

/* (non-PHPdoc)
* @see \PrestaShopCoreAdminBundle\TransitionalBehavior\AdminPagePreferenceInterface::setTemporaryShouldUseLegacyPage()
/**
* {@inheritdoc}
*/
public function setTemporaryShouldUseLegacyPage($page, $useLegacy)
{
Expand All @@ -82,8 +85,8 @@ public function setTemporaryShouldUseLegacyPage($page, $useLegacy)
}
}

/* (non-PHPdoc)
* @see \PrestaShopCoreAdminBundle\TransitionalBehavior\AdminPagePreferenceInterface::getTemporaryShouldAllowUseLegacyPage()
/**
* {@inheritdoc}
*/
public function getTemporaryShouldAllowUseLegacyPage($page = null)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Adapter/Admin/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function __construct(LegacyContext $legacyContext, Router $router)
$this->router = $router;
}

/* (non-PHPdoc)
* @see \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate()
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
Expand Down Expand Up @@ -109,16 +109,16 @@ final public function getLegacyOptions($routeName, $parameters = array())
return array($legacyController, $legacyParameters);
}

/* (non-PHPdoc)
* @see \Symfony\Component\Routing\RequestContextAwareInterface::setContext()
/**
* {@inheritdoc}
*/
public function setContext(RequestContext $context)
{
throw new LogicException('Cannot use this UrlGeneratorInterface implementation with a Symfony context. Please call AdminUrlGeneratorFactory::forLegacy() to reach the right instance.');
}

/* (non-PHPdoc)
* @see \Symfony\Component\Routing\RequestContextAwareInterface::getContext()
/**
* {@inheritdoc}
*/
public function getContext()
{
Expand Down
14 changes: 14 additions & 0 deletions src/Adapter/Assets/AssetUrlGeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,24 @@

trait AssetUrlGeneratorTrait
{
/**
* @var string
*/
protected $fqdn;

/**
* @param string $fullPath
* @return string
*/
protected function getUriFromPath($fullPath)
{
return str_replace($this->configuration->get('_PS_ROOT_DIR_'), rtrim($this->configuration->get('__PS_BASE_URI__'), '/'), $fullPath);
}

/**
* @param string $fullUri
* @return string
*/
protected function getPathFromUri($fullUri)
{
if ('' !== ($trimmedUri = rtrim($this->configuration->get('__PS_BASE_URI__'), '/'))) {
Expand All @@ -47,6 +58,9 @@ protected function getPathFromUri($fullUri)
return $this->configuration->get('_PS_ROOT_DIR_').$fullUri;
}

/**
* @return string
*/
protected function getFQDN()
{
if (is_null($this->fqdn)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace PrestaShop\PrestaShop\Adapter\Attribute;

use Context;
use Symfony\Component\Translation\TranslatorInterface;
use Validate;
use Product;
use SpecificPriceRule;
Expand All @@ -41,6 +42,9 @@
*/
class AdminAttributeGeneratorControllerWrapper
{
/**
* @var TranslatorInterface
*/
private $translator;

public function __construct()
Expand Down
12 changes: 12 additions & 0 deletions src/Adapter/BestSales/BestSalesProductSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@

class BestSalesProductSearchProvider implements ProductSearchProviderInterface
{
/**
* @var TranslatorInterface
*/
private $translator;

/**
* @var SortOrderFactory
*/
private $sortOrderFactory;

public function __construct(
Expand All @@ -49,6 +56,11 @@ public function __construct(
$this->sortOrderFactory = new SortOrderFactory($this->translator);
}

/**
* @param ProductSearchContext $context
* @param ProductSearchQuery $query
* @return ProductSearchResult
*/
public function runQuery(
ProductSearchContext $context,
ProductSearchQuery $query
Expand Down
40 changes: 40 additions & 0 deletions src/Adapter/Cart/CartPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,41 @@
use Cart;
use Product;
use Configuration;
use Symfony\Component\Translation\TranslatorInterface;
use TaxConfiguration;
use CartRule;
use Tools;
use Hook;

/**
* This class is used to render the PHP and Javascript representations of Customer Cart
* in Front Office.
*/
class CartPresenter implements PresenterInterface
{
/**
* @var PriceFormatter
*/
private $priceFormatter;

/**
* @var \Link
*/
private $link;

/**
* @var TranslatorInterface
*/
private $translator;

/**
* @var ImageRetriever
*/
private $imageRetriever;

/**
* @var TaxConfiguration
*/
private $taxConfiguration;

public function __construct()
Expand All @@ -60,11 +84,18 @@ public function __construct()
$this->taxConfiguration = new TaxConfiguration();
}

/**
* @return bool|mixed
*/
private function includeTaxes()
{
return $this->taxConfiguration->includeTaxes();
}

/**
* @param array $rawProduct
* @return array
*/
private function presentProduct(array $rawProduct)
{
$settings = new ProductPresentationSettings();
Expand Down Expand Up @@ -149,6 +180,11 @@ private function presentProduct(array $rawProduct)
);
}

/**
* @param array $products
* @param Cart $cart
* @return array
*/
public function addCustomizedData(array $products, Cart $cart)
{
return array_map(function (array $product) use ($cart) {
Expand Down Expand Up @@ -436,6 +472,10 @@ function ($voucher) {
);
}

/**
* @param Cart $cart
* @return array
*/
private function getTemplateVarVouchers(Cart $cart)
{
$cartVouchers = $cart->getCartRules();
Expand Down
8 changes: 8 additions & 0 deletions src/Adapter/Category/CategoryDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
class CategoryDataProvider
{
/**
* @var int
*/
private $languageId;

/** @var array the list of existing active categories until root */
Expand Down Expand Up @@ -251,6 +254,11 @@ public function getAjaxCategories($query, $limit, $nameAsBreadCrumb = false)
return $results;
}

/**
* @param int|null $idLang
* @param Shop|null $shop
* @return Category
*/
public function getRootCategory($idLang = null, Shop $shop = null)
{
return Category::getRootCategory($idLang, $shop);
Expand Down
16 changes: 16 additions & 0 deletions src/Adapter/Category/CategoryProductSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
use Symfony\Component\Translation\TranslatorInterface;
use Category;

/**
* Responsible of getting products for specific category
*/
class CategoryProductSearchProvider implements ProductSearchProviderInterface
{
private $translator;
Expand All @@ -50,6 +53,13 @@ public function __construct(
$this->sortOrderFactory = new SortOrderFactory($this->translator);
}

/**
* @param ProductSearchContext $context
* @param ProductSearchQuery $query
* @param string $type
* @return array|false|int
* @throws \PrestaShopDatabaseException
*/
private function getProductsOrCount(
ProductSearchContext $context,
ProductSearchQuery $query,
Expand Down Expand Up @@ -79,6 +89,12 @@ private function getProductsOrCount(
}
}

/**
* @param ProductSearchContext $context
* @param ProductSearchQuery $query
* @return ProductSearchResult
* @throws \PrestaShopDatabaseException
*/
public function runQuery(
ProductSearchContext $context,
ProductSearchQuery $query
Expand Down

0 comments on commit 087ee2a

Please sign in to comment.