Skip to content

Commit

Permalink
Merge pull request #44 from jweiland-net/updateUpgradeInstructions
Browse files Browse the repository at this point in the history
Update upgrade instructions
  • Loading branch information
sfroemkenjw committed Feb 20, 2023
2 parents 6ad638c + 0e01a0d commit f945e04
Show file tree
Hide file tree
Showing 36 changed files with 1,279 additions and 1,244 deletions.
48 changes: 22 additions & 26 deletions Build/.php_cs.php → Build/php-cs-fixer/config.php
@@ -1,21 +1,14 @@
<?php
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require friendsofphp/php-cs-fixer
*
* And then simply run
*
* $ ./bin/php-cs-fixer fix --config ./Build/.php_cs
*
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.

declare(strict_types=1);

/*
* This file is part of the package jweiland/yellowpages2.
*
* For more information read:
* https://www.php-fig.org/psr/psr-2/
* https://cs.sensiolabs.org
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
Expand All @@ -30,17 +23,16 @@
$finder = PhpCsFixer\Finder::create()
->name('*.php')
->exclude('.build')
->exclude('var')
->in(__DIR__);

$config = new PhpCsFixer\Config();
return $config
return (new \PhpCsFixer\Config())
->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'@PER' => true,
'header_comment' => [
'header' => $headerComment
'header' => $headerComment,
],
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
Expand All @@ -50,9 +42,11 @@
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
Expand All @@ -67,13 +61,14 @@
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
Expand All @@ -84,9 +79,10 @@
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_line_comment_style' => false,
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'whitespace_after_comma_in_array' => true
])
->setFinder($finder);
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
]);
5 changes: 0 additions & 5 deletions Classes/Domain/Model/CurrentWeather.php
Expand Up @@ -78,11 +78,6 @@ class CurrentWeather extends AbstractEntity
*/
protected $cloudsPercentage = 0;

/**
* @var string
*/
protected $serializedArray = '';

/**
* @var string
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/CurrentWeatherRepository.php
Expand Up @@ -31,7 +31,7 @@ public function findBySelection(string $selection): ?CurrentWeather
$query->equals('name', trim($selection))
)
->setOrderings([
'uid' => QueryInterface::ORDER_DESCENDING
'uid' => QueryInterface::ORDER_DESCENDING,
]);

/** @var ?CurrentWeather $currentWeather */
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Repository/DwdWarnCellRepository.php
Expand Up @@ -17,6 +17,11 @@

/**
* Repository to find warn cells by name
*
* $warnCellId looks like INT, but don't know if there are values starting with 0.
* Further the values are very huge, which can result in problems on 32bit machines.
* So keep $warnCellId to string
* @method DwdWarnCell findOneByWarnCellId(string $warnCellId);
*/
class DwdWarnCellRepository extends Repository
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/WeatherAlertRepository.php
Expand Up @@ -40,7 +40,7 @@ public function findByUserSelection(

$equalConstraintFields = [
'type' => GeneralUtility::trimExplode(',', $warningTypes),
'level' => GeneralUtility::trimExplode(',', $warningLevels)
'level' => GeneralUtility::trimExplode(',', $warningLevels),
];

$warningConstraints = ['type' => [], 'level' => []];
Expand Down
10 changes: 6 additions & 4 deletions Classes/Task/DeutscherWetterdienstTask.php
Expand Up @@ -11,6 +11,7 @@

namespace JWeiland\Weather2\Task;

use Doctrine\DBAL\DBALException;
use JWeiland\Weather2\Domain\Model\DwdWarnCell;
use JWeiland\Weather2\Domain\Model\WeatherAlert;
use JWeiland\Weather2\Domain\Repository\DwdWarnCellRepository;
Expand All @@ -21,6 +22,7 @@
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\Exception;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\CMS\Extbase\Service\CacheService;
Expand Down Expand Up @@ -89,7 +91,7 @@ class DeutscherWetterdienstTask extends AbstractTask

/**
* @return bool
* @throws \TYPO3\CMS\Extbase\Object\Exception
* @throws Exception
*/
public function execute(): bool
{
Expand Down Expand Up @@ -188,7 +190,7 @@ protected function getUidOfAlert(array $alert): int
$this->dbExtTable,
[
'comparison_hash' => $this->getComparisonHashForAlert($alert),
'pid' => $this->recordStoragePage
'pid' => $this->recordStoragePage,
]
)
->fetch();
Expand Down Expand Up @@ -221,7 +223,7 @@ protected function getWeatherAlertInstanceForAlert(
bool $isPreliminaryInformation
): WeatherAlert {
$weatherAlert = new WeatherAlert();
$weatherAlert->setPid((int)$this->recordStoragePage);
$weatherAlert->setPid($this->recordStoragePage);
$weatherAlert->setDwdWarnCell($this->getDwdWarnCell($warnCellId));
$weatherAlert->setComparisonHash($this->getComparisonHashForAlert($alert));
$weatherAlert->setPreliminaryInformation($isPreliminaryInformation);
Expand Down Expand Up @@ -264,7 +266,7 @@ protected function getDwdWarnCell(string $warnCellId): DwdWarnCell
}

/**
* @throws \Doctrine\DBAL\DBALException
* @throws DBALException
*/
protected function removeOldAlertsFromDb(): void
{
Expand Down
20 changes: 9 additions & 11 deletions Classes/Task/DeutscherWetterdienstTaskAdditionalFieldProvider.php
Expand Up @@ -50,7 +50,7 @@ class DeutscherWetterdienstTaskAdditionalFieldProvider extends AbstractAdditiona
* @var array
*/
protected $requiredFields = [
'dwd_regionSelection'
'dwd_regionSelection',
];

/**
Expand All @@ -61,7 +61,7 @@ class DeutscherWetterdienstTaskAdditionalFieldProvider extends AbstractAdditiona
protected $insertFields = [
'dwd_selectedWarnCells',
'dwd_recordStoragePage',
'dwd_clearCache'
'dwd_clearCache',
];

public function __construct(
Expand All @@ -75,10 +75,7 @@ public function __construct(
}

/**
* @param array $taskInfo
* @param DeutscherWetterdienstTask $task
* @param SchedulerModuleController $schedulerModule
* @return array
*/
public function getAdditionalFields(
array &$taskInfo,
Expand Down Expand Up @@ -112,9 +109,10 @@ public function getAdditionalFields(
);
$fieldCode = $this->addFlashMessage($flashMessage, true);
}

$additionalFields[$fieldID] = [
'code' => $fieldCode,
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:warnCells'
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:warnCells',
];

$fieldID = 'dwd_recordStoragePage';
Expand All @@ -123,14 +121,14 @@ public function getAdditionalFields(
WeatherUtility::translate('buttons.recordStoragePage', 'deutscherwetterdienst') . '</a></span></div>';
$additionalFields[$fieldID] = [
'code' => $fieldCode,
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:recordStoragePage'
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:recordStoragePage',
];

$fieldID = 'dwd_clearCache';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[' . $fieldID . ']" id="' . $fieldID . '" value="' . $taskInfo[$fieldID] . '" size="120" />';
$additionalFields[$fieldID] = [
'code' => $fieldCode,
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:clear_cache'
'label' => 'LLL:EXT:weather2/Resources/Private/Language/locallang_scheduler_deutscherwetterdienst.xlf:clear_cache',
];

return $additionalFields;
Expand All @@ -148,8 +146,8 @@ protected function initialize(): void
$popupSettings = [
'PopupWindow' => [
'width' => '800px',
'height' => '550px'
]
'height' => '550px',
],
];
$this->pageRenderer->addInlineSettingArray('Popup', $popupSettings);
$this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', (string)$this->uriBuilder->buildUriFromRoute('record_edit'));
Expand Down Expand Up @@ -209,7 +207,7 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC

if (empty($value) && in_array($fieldName, $this->requiredFields, true)) {
$isValid = false;
$this->addMessage('Field: ' . $fieldName . ' must not be empty', FlashMessage::ERROR);
$this->addMessage('Field: ' . $fieldName . ' must not be empty', AbstractMessage::ERROR);
} else {
$submittedData[$fieldName] = $value;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Task/DeutscherWetterdienstWarnCellTask.php
Expand Up @@ -64,7 +64,7 @@ protected function processResponse(ResponseInterface $response): void
'warn_cell_id' => $warnCellId,
'name' => $name,
'short_name' => $shortName,
'sign' => $sign
'sign' => $sign,
];
}
}
Expand Down
9 changes: 3 additions & 6 deletions Classes/Task/OpenWeatherMapTask.php
Expand Up @@ -115,9 +115,6 @@ class OpenWeatherMapTask extends AbstractTask
/**
* This method is the heart of the scheduler task. It will be fired if the scheduler
* gets executed
*
* @return bool
* @throws \TYPO3\CMS\Extbase\Object\Exception
*/
public function execute(): bool
{
Expand All @@ -135,7 +132,7 @@ public function execute(): bool
$this->removeOldRecordsFromDb();

$this->url = sprintf(
'http://api.openweathermap.org/data/2.5/weather?q=%s,%s&units=%s&APPID=%s',
'https://api.openweathermap.org/data/2.5/weather?q=%s,%s&units=%s&APPID=%s',
urlencode($this->city),
urlencode($this->country),
'metric',
Expand Down Expand Up @@ -198,7 +195,7 @@ private function checkResponseCode(ResponseInterface $response): bool
}

/** @var \stdClass $responseClass */
$responseClass = json_decode((string)$response->getBody());
$responseClass = json_decode((string)$response->getBody(), false);

switch ($responseClass->cod) {
case '200':
Expand Down Expand Up @@ -344,7 +341,7 @@ protected function removeOldRecordsFromDb(): void
$this->dbExtTable,
[
'pid' => $this->recordStoragePage,
'name' => $this->name
'name' => $this->name,
]
);
}
Expand Down

0 comments on commit f945e04

Please sign in to comment.