Skip to content

Commit

Permalink
Merge pull request #3 from siebdc2/master
Browse files Browse the repository at this point in the history
PHP 8.1 compatibility
  • Loading branch information
BrentRobert authored May 19, 2022
2 parents ce17637 + 483bdce commit d3c47a3
Show file tree
Hide file tree
Showing 51 changed files with 343 additions and 81 deletions.
1 change: 0 additions & 1 deletion .github/workflows/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
fail-fast: true
matrix:
php-versions:
- "7.3"
- "7.4"
- "8.1"
dependencies:
Expand Down
12 changes: 5 additions & 7 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* PHP Coding Standards fixer configuration
*/
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
$finder = PhpCsFixer\Finder::create()
->in('./')
->name(['*.php']);

return Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setUsingCache(false)
->setRules([
'@PSR2' => true,
'no_useless_else' => true,
Expand Down Expand Up @@ -40,7 +40,5 @@
'compact_nullable_typehint' => true,
'fully_qualified_strict_types' => true,
])
->setFinder($finder)
->setRiskyAllowed(true)
->setUsingCache(false);
->setFinder($finder);

12 changes: 7 additions & 5 deletions Api/Data/TranslationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

interface TranslationInterface extends \Magento\Framework\Api\ExtensibleDataInterface
{
const STRING = 'string';
const LOCALE = 'locale';
const TRANSLATE = 'translate';
const FRONTEND = 'frontend';
const KEY_ID = 'key_id';
public const STRING = 'string';
public const LOCALE = 'locale';
public const TRANSLATE = 'translate';
public const FRONTEND = 'frontend';
public const KEY_ID = 'key_id';

/**
* @return int|null
Expand Down Expand Up @@ -68,12 +68,14 @@ public function setFrontend($frontend);

/**
* Retrieve existing extension attributes object or create a new one.
*
* @return \Phpro\Translations\Api\Data\TranslationExtensionInterface|null
*/
public function getExtensionAttributes();

/**
* Set an extension attributes object.
*
* @param \Phpro\Translations\Api\Data\TranslationExtensionInterface $extensionAttributes
* @return $this
*/
Expand Down
2 changes: 2 additions & 0 deletions Api/Data/TranslationSearchResultsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ interface TranslationSearchResultsInterface extends \Magento\Framework\Api\Searc

/**
* Get Translation list.
*
* @return \Phpro\Translations\Api\Data\TranslationInterface[]
*/
public function getItems();

/**
* Set translate list.
*
* @param \Phpro\Translations\Api\Data\TranslationInterface[] $items
* @return $this
*/
Expand Down
6 changes: 6 additions & 0 deletions Api/ExportManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@

interface ExportManagementInterface
{
/**
* Export function
*
* @param array|null $locale
* @return ExportStats
*/
public function export(?array $locale): ExportStats;
}
2 changes: 2 additions & 0 deletions Api/ImportManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface ImportManagementInterface
{
/**
* Import Magento translation CSV to the database.
*
* Example structure: "Foo","Foo value",module,Magento_Catalog
*
* @param string $filePath
Expand All @@ -20,6 +21,7 @@ public function importMagentoCsv(string $filePath, string $locale): ImportStats;

/**
* Import translation CSV (based on export) to the database.
*
* Example structure: "Bar","Bar value",en_US
*
* @param string $filePath
Expand Down
2 changes: 2 additions & 0 deletions Api/TranslationDataManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface TranslationDataManagementInterface
{
/**
* Add the translation key for all enabled locales of the Magento instance.
*
* If default translation is not set, the translation key will be used as default translation.
*
* @param string $translationKey
Expand All @@ -25,6 +26,7 @@ public function create(string $translationKey, string $translationValue, array $

/**
* Delete a translation for given translation key and locale(s).
*
* In case no locales are given, all enabled locales will be used.
*
* @param string $translationKey
Expand Down
5 changes: 5 additions & 0 deletions Api/TranslationRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface TranslationRepositoryInterface

/**
* Save Translation
*
* @param \Phpro\Translations\Api\Data\TranslationInterface $translation
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Phpro\Translations\Api\Data\TranslationInterface
Expand All @@ -20,6 +21,7 @@ public function save(

/**
* Retrieve Translation
*
* @param string $translationId
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Phpro\Translations\Api\Data\TranslationInterface
Expand All @@ -28,6 +30,7 @@ public function getById($translationId);

/**
* Retrieve Translation matching the specified criteria.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Phpro\Translations\Api\Data\TranslationSearchResultsInterface
Expand All @@ -38,6 +41,7 @@ public function getList(

/**
* Delete translation by given key and locales.
*
* @param string $translationKey
* @param array $locales
* @return bool true on success
Expand All @@ -46,6 +50,7 @@ public function deleteByTranslationKeyAndLocales(string $translationKey, array $

/**
* Delete Translation by ID
*
* @param string $translationId
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
Expand Down
2 changes: 2 additions & 0 deletions Block/Adminhtml/Translation/Edit/BackButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class BackButton extends GenericButton implements ButtonProviderInterface
{

/**
* Get data for back (reset) button
*
* @return array
*/
public function getButtonData()
Expand Down
2 changes: 2 additions & 0 deletions Block/Adminhtml/Translation/Edit/DeleteButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class DeleteButton extends GenericButton implements ButtonProviderInterface
{

/**
* Get data for back (reset) button
*
* @return array
*/
public function getButtonData()
Expand Down
3 changes: 3 additions & 0 deletions Block/Adminhtml/Translation/Edit/GenericButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

abstract class GenericButton
{
/**
* @var Context
*/
protected $context;

/**
Expand Down
2 changes: 2 additions & 0 deletions Block/Adminhtml/Translation/Edit/SaveAndContinueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SaveAndContinueButton extends GenericButton implements ButtonProviderInter
{

/**
* Get data for back (reset) button
*
* @return array
*/
public function getButtonData()
Expand Down
2 changes: 2 additions & 0 deletions Block/Adminhtml/Translation/Edit/SaveButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
{

/**
* Get data for back (reset) button
*
* @return array
*/
public function getButtonData()
Expand Down
2 changes: 2 additions & 0 deletions Block/Adminhtml/Translation/GenerateJson/SaveButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class SaveButton extends GenericButton implements ButtonProviderInterface
{

/**
* Get data for back (reset) button
*
* @return array
*/
public function getButtonData()
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

## [1.1.0] - 2022-05-18
### Added
- PHP 8.0 compatibility
- PHP 8.1 compatibility
11 changes: 9 additions & 2 deletions Console/Command/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

class Export extends Command
{
const COMMAND_NAME = 'phpro:translations:export';
const ARGUMENT_LOCALES = 'locales';
private const COMMAND_NAME = 'phpro:translations:export';
private const ARGUMENT_LOCALES = 'locales';

/**
* @var ExportManagementInterface
Expand All @@ -26,6 +26,9 @@ public function __construct(
parent::__construct();
}

/**
* Configure export command
*/
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
Expand All @@ -35,6 +38,10 @@ protected function configure(): void
parent::configure();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
try {
Expand Down
16 changes: 15 additions & 1 deletion Console/Command/GenerateFrontendTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@

class GenerateFrontendTranslations extends Command
{
const COMMAND_NAME = 'phpro:translations:generate-frontend-translations';
private const COMMAND_NAME = 'phpro:translations:generate-frontend-translations';

/**
* @var InlineTranslationsGenerator
*/
private $inlineTranslationsGenerator;

public function __construct(
Expand All @@ -24,6 +27,9 @@ public function __construct(
parent::__construct();
}

/**
* Configure frontend translations command
*/
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
Expand All @@ -32,6 +38,10 @@ protected function configure(): void
parent::configure();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
try {
Expand All @@ -55,6 +65,10 @@ protected function execute(InputInterface $input, OutputInterface $output): void
}
}

/**
* @param int $storeId
* @return InlineGenerateStatsCollection
*/
private function generatedTranslations(int $storeId): InlineGenerateStatsCollection
{
if (0 === $storeId) {
Expand Down
16 changes: 12 additions & 4 deletions Console/Command/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@

class Import extends Command
{
const COMMAND_NAME = 'phpro:translations:import';
const ARGUMENT_CSV_FILE = 'csvfile';
const ARGUMENT_LOCALE = 'locale';
const OPTION_CLEAR_CACHE = 'clear-cache';
private const COMMAND_NAME = 'phpro:translations:import';
private const ARGUMENT_CSV_FILE = 'csvfile';
private const ARGUMENT_LOCALE = 'locale';
private const OPTION_CLEAR_CACHE = 'clear-cache';

/**
* @var ImportManagementInterface
*/
private $importer;

/**
* @var Manager
*/
Expand All @@ -36,6 +37,9 @@ public function __construct(
parent::__construct();
}

/**
* Configure import command
*/
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
Expand All @@ -47,6 +51,10 @@ protected function configure(): void
parent::configure();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
try {
Expand Down
14 changes: 11 additions & 3 deletions Console/Command/ImportFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

class ImportFull extends Command
{
const COMMAND_NAME = 'phpro:translations:import-full';
const ARGUMENT_CSV_FILE = 'csvfile';
const OPTION_CLEAR_CACHE = 'clear-cache';
private const COMMAND_NAME = 'phpro:translations:import-full';
private const ARGUMENT_CSV_FILE = 'csvfile';
private const OPTION_CLEAR_CACHE = 'clear-cache';

/**
* @var ImportManagementInterface
*/
private $importer;

/**
* @var Manager
*/
Expand All @@ -35,6 +36,9 @@ public function __construct(
parent::__construct();
}

/**
* Configure import full command
*/
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
Expand All @@ -45,6 +49,10 @@ protected function configure(): void
parent::configure();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
try {
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

abstract class Translation extends Action
{
const ADMIN_RESOURCE = 'Phpro_Translations::translations';
public const ADMIN_RESOURCE = 'Phpro_Translations::translations';

/**
* Init page
Expand Down
Loading

0 comments on commit d3c47a3

Please sign in to comment.