Skip to content

Commit 3cfdc66

Browse files
authored
Merge pull request #348 from joomla-extensions/psr12
Switching to PSR-12 and updating composer dependencies
2 parents af2613f + 429006b commit 3cfdc66

35 files changed

+3778
-3821
lines changed

.drone.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ kind: pipeline
33
name: default
44

55
clone:
6-
depth: 42
76

87
steps:
98
- name: composer
10-
image: joomlaprojects/docker-tools:develop
9+
image: joomlaprojects/docker-images:php7.4
10+
volumes:
11+
- name: composer-cache
12+
path: /tmp/composer-cache
1113
commands:
1214
- composer validate --no-check-all --strict
1315
- composer install --no-progress --no-suggest
@@ -16,10 +18,15 @@ steps:
1618
image: joomlaprojects/docker-images:php7.2
1719
commands:
1820
- echo $(date)
19-
- ./administrator/components/com_patchtester/vendor/bin/phpcs --extensions=php -p --ignore=administrator/components/com_patchtester/vendor --standard=administrator/components/com_patchtester/vendor/joomla/cms-coding-standards/lib/Joomla-CMS administrator
21+
- ./administrator/components/com_patchtester/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .
2022
- echo $(date)
23+
24+
volumes:
25+
- name: composer-cache
26+
host:
27+
path: /tmp/composer-cache
2128
---
2229
kind: signature
23-
hmac: c5899584898d37d46fb70cb22487532d41719c7a836be7f67ad4ac3c2267dafa
30+
hmac: 6894a15e535673bd3eb1cf2c8ee3f9cbac4b5a6e52aa26773add3e4943f3bd86
2431

2532
...

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style end of lines and a blank line at the end of the file
7+
[*]
8+
indent_style = tab
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
14+
[*.php]
15+
indent_style = space
16+
indent_size = 4
17+
18+
[*.{js,json,scss,css,vue}]
19+
indent_style = space
20+
indent_size = 2
Lines changed: 75 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Patch testing component for the Joomla! CMS
45
*
@@ -21,88 +22,81 @@
2122
*/
2223
abstract class AbstractController
2324
{
24-
/**
25-
* The active application
26-
*
27-
* @var CMSApplication
28-
* @since 4.0.0
29-
*/
30-
protected $app;
31-
32-
/**
33-
* The object context
34-
*
35-
* @var string
36-
* @since 2.0
37-
*/
38-
protected $context;
39-
40-
/**
41-
* The default view to display
42-
*
43-
* @var string
44-
* @since 2.0
45-
*/
46-
protected $defaultView = 'pulls';
47-
48-
/**
49-
* Instantiate the controller
50-
*
51-
* @param CMSApplication $app The application object.
52-
*
53-
* @since 2.0
54-
*/
55-
public function __construct(CMSApplication $app)
56-
{
57-
$this->app = $app;
58-
59-
// Set the context for the controller
60-
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
61-
}
62-
63-
/**
64-
* Get the application object.
65-
*
66-
* @return CMSApplication
67-
*
68-
* @since 4.0.0
69-
*/
70-
public function getApplication()
71-
{
72-
return $this->app;
73-
}
74-
75-
/**
76-
* Get the input object.
77-
*
78-
* @return Input
79-
*
80-
* @since 4.0.0
81-
*/
82-
public function getInput()
83-
{
84-
return $this->app->input;
85-
}
86-
87-
/**
88-
* Sets the state for the model object
89-
*
90-
* @param AbstractModel $model Model object
91-
*
92-
* @return Registry
93-
*
94-
* @since 2.0
95-
*/
96-
protected function initializeState($model)
97-
{
98-
$state = new Registry;
25+
/**
26+
* The active application
27+
*
28+
* @var CMSApplication
29+
* @since 4.0.0
30+
*/
31+
protected $app;
32+
/**
33+
* The object context
34+
*
35+
* @var string
36+
* @since 2.0
37+
*/
38+
protected $context;
39+
/**
40+
* The default view to display
41+
*
42+
* @var string
43+
* @since 2.0
44+
*/
45+
protected $defaultView = 'pulls';
46+
/**
47+
* Instantiate the controller
48+
*
49+
* @param CMSApplication $app The application object.
50+
*
51+
* @since 2.0
52+
*/
53+
public function __construct(CMSApplication $app)
54+
{
55+
$this->app = $app;
56+
// Set the context for the controller
57+
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
58+
}
9959

100-
// Load the parameters.
101-
$params = ComponentHelper::getParams('com_patchtester');
60+
/**
61+
* Get the application object.
62+
*
63+
* @return CMSApplication
64+
*
65+
* @since 4.0.0
66+
*/
67+
public function getApplication()
68+
{
69+
return $this->app;
70+
}
10271

103-
$state->set('github_user', $params->get('org', 'joomla'));
104-
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
72+
/**
73+
* Get the input object.
74+
*
75+
* @return Input
76+
*
77+
* @since 4.0.0
78+
*/
79+
public function getInput()
80+
{
81+
return $this->app->input;
82+
}
10583

106-
return $state;
107-
}
84+
/**
85+
* Sets the state for the model object
86+
*
87+
* @param AbstractModel $model Model object
88+
*
89+
* @return Registry
90+
*
91+
* @since 2.0
92+
*/
93+
protected function initializeState($model)
94+
{
95+
$state = new Registry();
96+
// Load the parameters.
97+
$params = ComponentHelper::getParams('com_patchtester');
98+
$state->set('github_user', $params->get('org', 'joomla'));
99+
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
100+
return $state;
101+
}
108102
}
Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Patch testing component for the Joomla! CMS
45
*
@@ -13,47 +14,44 @@
1314
use Joomla\CMS\Router\Route;
1415
use PatchTester\Model\PullModel;
1516

17+
// phpcs:disable PSR1.Files.SideEffects
18+
\defined('_JEXEC') or die;
19+
// phpcs:enable PSR1.Files.SideEffects
20+
21+
1622
/**
1723
* Controller class to apply patches
1824
*
1925
* @since 2.0
2026
*/
2127
class ApplyController extends AbstractController
2228
{
23-
/**
24-
* Execute the controller.
25-
*
26-
* @return void Redirects the application
27-
*
28-
* @since 2.0
29-
*/
30-
public function execute()
31-
{
32-
try
33-
{
34-
$model = new PullModel(null, Factory::getDbo());
35-
36-
// Initialize the state for the model
37-
$model->setState($this->initializeState($model));
38-
39-
if ($model->apply($this->getInput()->getUint('pull_id')))
40-
{
41-
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
42-
}
43-
else
44-
{
45-
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
46-
}
47-
48-
$type = 'message';
49-
}
50-
catch (\Exception $e)
51-
{
52-
$msg = $e->getMessage();
53-
$type = 'error';
54-
}
55-
56-
$this->getApplication()->enqueueMessage($msg, $type);
57-
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
58-
}
29+
/**
30+
* Execute the controller.
31+
*
32+
* @return void Redirects the application
33+
*
34+
* @since 2.0
35+
*/
36+
public function execute()
37+
{
38+
try {
39+
$model = new PullModel(null, Factory::getDbo());
40+
// Initialize the state for the model
41+
$model->setState($this->initializeState($model));
42+
if ($model->apply($this->getInput()->getUint('pull_id'))) {
43+
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
44+
} else {
45+
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
46+
}
47+
48+
$type = 'message';
49+
} catch (\Exception $e) {
50+
$msg = $e->getMessage();
51+
$type = 'error';
52+
}
53+
54+
$this->getApplication()->enqueueMessage($msg, $type);
55+
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
56+
}
5957
}

0 commit comments

Comments
 (0)