Skip to content

Commit

Permalink
Merge pull request #178 from liip/fix-php83-deprecation
Browse files Browse the repository at this point in the history
Fix deprecation of dynamic assignment of class properties
  • Loading branch information
jeanmonod authored Jan 12, 2024
2 parents 8f962ac + 0d48eab commit 8036c56
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Liip/RMT/Action/CommandAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function execute()

// Prepare a callback for live output
$callback = null;
if ($this->options['live_output'] == true) {
if ($this->options['live_output']) {
$callback = function ($type, $buffer) {
$decorator = array('','');
if ($type == Process::ERR) {
Expand Down
2 changes: 1 addition & 1 deletion src/Liip/RMT/Action/FilesUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function execute()

foreach ($this->options as $option) {
$file = $option[0];
$pattern = isset($option[1]) ? $option[1] : null;
$pattern = $option[1] ?? null;

if (! file_exists($file)) {
$versionClass = new ReflectionClass($file);
Expand Down
4 changes: 2 additions & 2 deletions src/Liip/RMT/Action/VcsPublishAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getInformationRequests()
*
* @return string|null
*/
protected function getRemote()
protected function getRemote(): ?string
{
if ($this->options['ask-remote-name']) {
return Context::get('information-collector')->getValueFor('remote');
Expand All @@ -95,6 +95,6 @@ protected function getRemote()
return $this->options['remote-name'];
}

return;
return null;
}
}
1 change: 1 addition & 0 deletions src/Liip/RMT/Changelog/ChangelogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ChangelogManager
{
protected $filePath;
protected $formatter;
protected $format;

public function __construct($filePath, $format)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Liip/RMT/Command/CurrentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($input->getOption('vcs-tag')) {
$vcsTag = Context::get('version-persister')->getCurrentVersionTag();
}
if ($input->getOption('raw') == true) {
if ($input->getOption('raw')) {
$output->writeln($input->getOption('vcs-tag') ? $vcsTag : $version);
} else {
$msg = "Current release is: <green>$version</green>";
Expand Down
9 changes: 4 additions & 5 deletions src/Liip/RMT/Config/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,27 +200,26 @@ protected function findInternalClass($name, $sectionName)
}

// Guess the namespace
$namespacesByType = array(
$namespacesByType = [
'vcs' => 'Liip\RMT\VCS',
'prerequisites' => 'Liip\RMT\Prerequisite',
'pre-release-actions' => 'Liip\RMT\Action',
'post-release-actions' => 'Liip\RMT\Action',
'version-generator' => 'Liip\RMT\Version\Generator',
'version-persister' => 'Liip\RMT\Version\Persister',
);
];
$nameSpace = $namespacesByType[$classType];

// Guess the class name
// Convert from xxx-yyy-zzz to XxxYyyZzz and append suffix
$suffixByType = array(
$suffixByType = [
'vcs' => '',
'prerequisites' => '',
'pre-release-actions' => 'Action',
'post-release-actions' => 'Action',
'version-generator' => 'Generator',
'version-persister' => 'Persister',
);
$nameSpace = $namespacesByType[$classType];
];
$className = str_replace(' ', '', ucwords(str_replace('-', ' ', $name))).$suffixByType[$classType];

return $nameSpace.'\\'.$className;
Expand Down
2 changes: 1 addition & 1 deletion src/Liip/RMT/Prerequisite/TestsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function execute()
}

// Run the tests and live output with the standard output class
$timeout = isset($this->options['timeout']) ? $this->options['timeout'] : null;
$timeout = $this->options['timeout'] ?? null;
$process = $this->executeCommandInProcess($this->options['command'], $timeout);

// Break up if the result is not good
Expand Down
12 changes: 3 additions & 9 deletions src/Liip/RMT/Version/Generator/SemanticGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ public function __construct($options = array())
*/
public function generateNextVersion($currentVersion)
{
$type = isset($this->options['type']) ?
$this->options['type'] :
Context::get('information-collector')->getValueFor('type')
;
$type = $this->options['type'] ?? Context::get('information-collector')->getValueFor('type');

$label = 'none';
if (isset($this->options['allow-label']) && $this->options['allow-label'] == true) {
$label = isset($this->options['label']) ?
$this->options['label'] :
Context::get('information-collector')->getValueFor('label')
;
if (isset($this->options['allow-label']) && $this->options['allow-label']) {
$label = $this->options['label'] ?? Context::get('information-collector')->getValueFor('label');
}

// Type validation
Expand Down
5 changes: 4 additions & 1 deletion src/Liip/RMT/Version/Persister/TagValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

class TagValidator
{
public function __construct($regex, $tagPrefix = '')
protected $regex;
protected $tagPrefix;

public function __construct(string $regex, string $tagPrefix = '')
{
$this->regex = $regex;
$this->tagPrefix = $tagPrefix;
Expand Down

0 comments on commit 8036c56

Please sign in to comment.