More codestyle

Signed-off-by: Roland Dalmulder <contact@rolandd.com>
This commit is contained in:
Roland Dalmulder 2023-08-25 22:48:31 +02:00
parent 8b0f33e99e
commit aeb58bebef
No known key found for this signature in database
GPG Key ID: 6D30CD38749A5B9E
2 changed files with 20 additions and 15 deletions

View File

@ -14,7 +14,8 @@ use Joomla\Registry\Registry;
*/
trait GithubCredentialsTrait
{
protected function getCredentials(): Registry {
protected function getCredentials(): Registry
{
$state = new Registry();
$params = ComponentHelper::getParams('com_patchtester');
$state->set('github_user', $params->get('org', 'joomla'));

View File

@ -183,7 +183,8 @@ class PullModel extends BaseDatabaseModel
$result = null;
}
if ($result === null
if (
$result === null
|| ($result->getStatusCode() !== 200
&& $result->getStatusCode() !== 310)
) {
@ -262,7 +263,8 @@ class PullModel extends BaseDatabaseModel
if (file_exists($tempPath . '/' . $file)) {
// Create directories if they don't exist until file
if (!file_exists(JPATH_ROOT . '/' . $filePath)
if (
!file_exists(JPATH_ROOT . '/' . $filePath)
|| !is_dir(
JPATH_ROOT . '/' . $filePath
)
@ -323,7 +325,9 @@ class PullModel extends BaseDatabaseModel
Text::sprintf(
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
$exception->getMessage()
), $exception->getCode(), $exception
),
$exception->getCode(),
$exception
);
}
@ -349,7 +353,9 @@ class PullModel extends BaseDatabaseModel
Text::sprintf(
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
$exception->getMessage()
), $exception->getCode(), $exception
),
$exception->getCode(),
$exception
);
}
@ -384,10 +390,7 @@ class PullModel extends BaseDatabaseModel
array_walk(
$composerFiles,
static function ($composerFile) use (&$filesToCheck, $path) {
if (file_exists(
$path . '/libraries/vendor/composer/' . $composerFile
) === false
) {
if (file_exists($path . '/libraries/vendor/composer/' . $composerFile) === false) {
return;
}
@ -401,20 +404,20 @@ class PullModel extends BaseDatabaseModel
$autoload,
$match
);
if (!$resultMatch) {
return;
}
// Check if the class is already defined
$autoloadClass = '\Composer\Autoload\ComposerStaticInit'
. $match[1];
$autoloadClass = '\Composer\Autoload\ComposerStaticInit' . $match[1];
if (class_exists($autoloadClass)) {
return;
}
require_once $path
. '/libraries/vendor/composer/autoload_static.php';
// Get all the files
require_once $path . '/libraries/vendor/composer/autoload_static.php';
$files = $autoloadClass::$files;
$filesToCheck = array_merge($filesToCheck, $files);
} else {
@ -434,13 +437,14 @@ class PullModel extends BaseDatabaseModel
* @param array $files The list of files to check
* @param string $path The path where the temporary patch resides
*
* @return boolean True if all files exist | False otherwise.
* @return bool True if all files exist | False otherwise.
*
* @since 4.0.0
*/
private function checkFilesExist(array $files, string $path): bool
{
$path = Path::clean($path);
foreach ($files as $file) {
if (is_array($file)) {
$this->checkFilesExist($file, $path);