Skip to content

Code clean-up #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 25, 2024
6 changes: 4 additions & 2 deletions lib/php/libsdk/SDK/Build/PGO/Abstracts/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ protected function setupPaths()
}
}

abstract public function getExeFilename() : string;

/* TODO Might be improved. */
public function isDist() : bool
{
Expand Down Expand Up @@ -96,7 +98,7 @@ public function getRootDir() : string
public function getVersion(bool $short = false) : string
{
$ret = NULL;
$cli = new CLI($this->conf, $this->scenario);
$cli = new CLI($this->conf);

$out = shell_exec($cli->getExeFilename() . " -n -v");

Expand All @@ -119,7 +121,7 @@ public function getVersion(bool $short = false) : string

public function isThreadSafe() : bool
{
$cli = new CLI($this->conf, $this->scenario);
$cli = new CLI($this->conf);

$out = shell_exec($cli->getExeFilename() . " -n -v");

Expand Down
3 changes: 3 additions & 0 deletions lib/php/libsdk/SDK/Build/PGO/Abstracts/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

abstract class Server
{
protected $name;
protected $php;

public function getName() : string
{
return $this->name;
Expand Down
6 changes: 5 additions & 1 deletion lib/php/libsdk/SDK/Build/PGO/Abstracts/TrainingCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace SDK\Build\PGO\Abstracts;

use SDK\FileOps;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Tool;

abstract class TrainingCase
abstract class TrainingCase implements Interfaces\TrainingCase
{
use FileOps;

Expand All @@ -15,6 +16,9 @@ abstract class TrainingCase
protected $stat = array();
/** @var \SDK\Build\PGO\Config */
protected $conf;
protected $php;

abstract public function getName() : string;

public function getType() : string
{
Expand Down
6 changes: 2 additions & 4 deletions lib/php/libsdk/SDK/Build/PGO/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected function setupConfig($cmd)
switch ($cmd) {
default:
throw new Exception("Unknown action '{$cmd}'.");
break;
case "check_init":
$cnf = new PGOConfig(PGOConfig::MODE_CHECK_INIT);
break;
Expand Down Expand Up @@ -80,7 +79,6 @@ public function handle($force)
switch ($this->cmd) {
default:
throw new Exception("Unknown action '{$this->cmd}'.");
break;
case "init":
$lk = new Lock("pgo_init");
if (!$lk->locked()) {
Expand Down Expand Up @@ -242,7 +240,7 @@ public function up()
}
echo "\nStarting up PGO environment.\n\n";

foreach ($this->vitalizeSrv("all") as $srv) {
foreach ($this->vitalizeSrv() as $srv) {
$srv->up();
echo "\n";
}
Expand All @@ -260,7 +258,7 @@ public function down(bool $force = false)
/* XXX check it was started of course. */
echo "\nShutting down PGO environment.\n\n";

foreach ($this->vitalizeSrv("all") as $srv) {
foreach ($this->vitalizeSrv() as $srv) {
$srv->down($force);
echo "\n";
}
Expand Down
1 change: 1 addition & 0 deletions lib/php/libsdk/SDK/Build/PGO/Interfaces/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public function init() : void;
public function up() : void;
public function down(bool $force = false) : void;
public function getName() : string;
public function getPhp();
}
5 changes: 5 additions & 0 deletions lib/php/libsdk/SDK/Build/PGO/TrainingCaseIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function getHandlerFilename(string $base) : string
return $base . DIRECTORY_SEPARATOR . "TrainingCaseHandler.php";
}

#[\ReturnTypeWillChange]
public function current()
{
$base = $this->items[$this->idx];
Expand All @@ -73,21 +74,25 @@ public function current()
return $this->el;
}

#[\ReturnTypeWillChange]
public function next()
{
$this->idx++;
}

#[\ReturnTypeWillChange]
public function rewind()
{
$this->idx = 0;
}

#[\ReturnTypeWillChange]
public function valid()
{
return $this->idx < count($this->items);
}

#[\ReturnTypeWillChange]
public function key()
{
if (!is_object($this->el)) {
Expand Down
5 changes: 3 additions & 2 deletions lib/php/libsdk/SDK/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Config
protected static $depsUriScheme = "https";
protected static $depsBaseUri = "/~windows/php-sdk/deps";

/* protected static $sdkNugetFeedUrl = "http://127.0.0.1/sdk/nuget"; */
protected static $sdkNugetFeedUrl = "http://127.0.0.1/sdk/nuget"; // experimental?

protected static $knownBranches = array ();

Expand All @@ -28,7 +28,7 @@ public static function getDepsHost() : string
return self::$depsHost;
}/*}}}*/

public static function getDepsPort() : string
public static function getDepsPort() : int
{/*{{{*/
return self::$depsPort;
}/*}}}*/
Expand Down Expand Up @@ -264,6 +264,7 @@ public static function getCurrentBranchData() : array
throw new Exception("Unknown branch '$current_branch_name'");
}

$crt = null;
$cur_crt = Config::getCurrentCrtName();
if (count($branches[$current_branch_name]) > 1) {
if (NULL === $cur_crt) {
Expand Down
1 change: 1 addition & 0 deletions lib/php/libsdk/SDK/FileOps.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected function cp_or_mv(string $src, string $dst, callable $cb) : bool

if ($item->isFile()) {
if (!call_user_func($cb, $src_path, $dst_path)) {
assert(is_string($cb));
throw new Exception("Unable to $cb '$src_path' to '$dst_path'");
}
}
Expand Down