Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/phpsdk_deps.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include dirname(__FILE__) . "/../lib/php/autoload.php";
include __DIR__ . "/../lib/php/autoload.php";

use SDK\{Config, Exception};

Expand Down Expand Up @@ -36,7 +36,7 @@
switch ($name) {
default:
throw new Exception("Unknown switch '$name'");
break;
break;

case "h":
case "help":
Expand Down
16 changes: 8 additions & 8 deletions bin/phpsdk_dllmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
}
}

Expand Down Expand Up @@ -85,16 +85,16 @@

$dlls = array();

for( $i = 0; $i < $zip->numFiles; $i++ ){
$stat = $zip->statIndex( $i );
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);

if (substr($stat['name'], -3) != "dll") {
continue;
}

$dlls[] = basename($stat['name']);
}

$zip->close();
unset($zip);

Expand Down
75 changes: 37 additions & 38 deletions bin/phpsdk_pgo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include dirname(__FILE__) . "/../lib/php/autoload.php";
include __DIR__ . "/../lib/php/autoload.php";

use SDK\Config;
use SDK\Exception;
Expand All @@ -21,43 +21,42 @@
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "i":
case "init":
$cmd = "init";
break;
case "ready":
$cmd = "check_init";
break;
case "t":
case "train":
$cmd = "train";
break;
case "u":
case "up":
$cmd = "up";
break;
case "d":
case "down":
$cmd = "down";
break;
case "s":
case "scenario":
$scenario = $val;
break;
case "f":
case "force":
$force = true;
break;
/* XXX This option is for now only integrated for training. It
would make sense to integrate it also with init. */
case "c":
case "cases":
$cases = explode(",", $val);
break;
case "h": case "help":
usage(0);
break;

case "i":
case "init":
$cmd = "init";
break;
case "ready":
$cmd = "check_init";
break;
case "t":
case "train":
$cmd = "train";
break;
case "u":
case "up":
$cmd = "up";
break;
case "d":
case "down":
$cmd = "down";
break;
case "s":
case "scenario":
$scenario = $val;
break;
case "f":
case "force":
$force = true;
break;
/* XXX This option is for now only integrated for training. It
would make sense to integrate it also with init. */
case "c":
case "cases":
$cases = explode(",", $val);
break;
case "h": case "help":
usage(0);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/php/autoload.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

spl_autoload_register(function($name) {
$fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "libsdk" . DIRECTORY_SEPARATOR . $name . ".php";
$fl = __DIR__ . DIRECTORY_SEPARATOR . "libsdk" . DIRECTORY_SEPARATOR . $name . ".php";

if (file_exists($fl)) {
require_once $fl;
Expand Down
4 changes: 3 additions & 1 deletion lib/php/libsdk/SDK/Build/Dependency/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SDK\Build\Dependency;

use SDK\{Config, Exception, FileOps};
use SDK\{Exception, FileOps};

class Fetcher
{
Expand All @@ -13,6 +13,7 @@ class Fetcher
protected $stability;
protected $arch;
protected $series;
protected $scheme;


public function __construct(string $host, int $port, string $scheme = "https", string $arch = NULL, string $stability = NULL, Series $series = NULL)
Expand All @@ -22,6 +23,7 @@ public function __construct(string $host, int $port, string $scheme = "https", s
$this->host = $host;
$this->port = $port;
$this->scheme = $scheme;
$this->series = $series;
}/*}}}*/

public function getSeries() : Series
Expand Down
3 changes: 2 additions & 1 deletion lib/php/libsdk/SDK/Build/Dependency/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Manager
protected $stability;
protected $arch;
protected $path;
protected $cache;
protected $series;
protected $fetcher;
protected $updatesFlag = NULL;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected function getTmpSeriesPath() : string

public function updatesAvailable() : bool
{/*{{{*/
if (!is_null($this->updatesFlag)) {
if (NULL !== $this->updatesFlag) {
return $this->updatesFlag;
}

Expand Down
1 change: 0 additions & 1 deletion lib/php/libsdk/SDK/Build/Dependency/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function setArch(string $arch) : void

public function getName() : string
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();

$file = "packages-" . Config::getCurrentBranchName() . "-{$branch_data['crt']}-{$this->arch}-{$this->stability}.txt";
Expand Down
17 changes: 8 additions & 9 deletions lib/php/libsdk/SDK/Build/PGO/Abstracts/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace SDK\Build\PGO\Abstracts;

use SDK\Build\PGO\Interfaces\Server;
use SDK\Build\PGO\PHP\CLI;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Config as SDKConfig, Exception};

abstract class PHP
{
protected $php_root;
protected $php_ext_root;
protected $opcache_file_cache;
protected $id;
protected $scenario;
protected $conf;

protected function setupPaths()
{
Expand Down Expand Up @@ -44,7 +44,7 @@ protected function createEnv() : array
$deps_root = SDKConfig::getDepsLocalPath();
foreach ($env as $k => $v) {
if (strtoupper($k) == "PATH") {
$env[$k] = "$deps_root" . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
$env[$k] = $deps_root . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
break;
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ public function getVersion(bool $short = false) : string
}
}

if (is_null($ret)) {
if (NULL === $ret) {
throw new Exception("Failed to determine the test PHP version.");
}

Expand Down Expand Up @@ -194,8 +194,8 @@ protected function getIniTplFilename()
public function exec(string $php_cmd, string $args = NULL, array $extra_env = array()) : int
{
$env = $this->createEnv();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();

$cert_path = getenv("PHP_SDK_ROOT_PATH") . "\\msys2\\usr\\ssl\\cert.pem";
$ini .= " -d curl.cainfo=$cert_path";
Expand Down Expand Up @@ -223,7 +223,7 @@ public function exec(string $php_cmd, string $args = NULL, array $extra_env = ar
$env[$k] = $v;
}

$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . "$php_cmd";
$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . $php_cmd;

$desc = array(
0 => array("file", "php://stdin", "r"),
Expand All @@ -244,4 +244,3 @@ public function getIdString(): string
. "-" . substr(md5(uniqid()), 0, 8);
}
}

5 changes: 1 addition & 4 deletions lib/php/libsdk/SDK/Build/PGO/Abstracts/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use SDK\Build\PGO\Interfaces;

class Server
abstract class Server
{
public function getName() : string
{
Expand All @@ -17,6 +17,3 @@ public function getPhp() : Interfaces\PHP
}

}



8 changes: 4 additions & 4 deletions lib/php/libsdk/SDK/Build/PGO/Abstracts/TrainingCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

namespace SDK\Build\PGO\Abstracts;

use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\FileOps;
use SDK\Build\PGO\Tool;

class TrainingCase
abstract class TrainingCase
{
use FileOps;

const TYPE_WEB = "web";
const TYPE_CLI = "cli";

protected $stat = array();
/** @var \SDK\Build\PGO\Config */
protected $conf;

public function getType() : string
{
Expand Down Expand Up @@ -148,4 +149,3 @@ public function probeUrl(string $url) : bool
return $ret;
}
}

8 changes: 3 additions & 5 deletions lib/php/libsdk/SDK/Build/PGO/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SDK\Build\PGO;

use SDK\{Config as SDKConfig, Exception};
use SDK\Exception;

class Config
{
Expand All @@ -18,7 +18,7 @@ class Config
protected $tpl_vars = array();
protected $srv = array();

public function __construct(int $mode = MODE_RUN)
public function __construct(int $mode = self::MODE_RUN)
{
if (self::MODE_CHECK_INIT == $mode) {
// XXX The check is simple right now, so this is sufficient.
Expand All @@ -40,7 +40,6 @@ public function __construct(int $mode = MODE_RUN)
$this->mode = $mode;


$base = getenv("PHP_SDK_ROOT_PATH");
if (self::MODE_INIT == $mode) {
foreach (array("nginx", "mariadb", "postgresql", "php") as $i) {
$this->importSectionFromDir($i, $this->getTplDir() . DIRECTORY_SEPARATOR . $i);
Expand Down Expand Up @@ -279,7 +278,7 @@ public function processTpl(string $s, array $additional_vars = array()) : string
public function processTplFile(string $tpl_fn, string $dst_fn, array $additional_vars = array()) : void
{
if (!file_exists($tpl_fn)) {
throw new Exception("Template file '$fn' doesn't exist.");
throw new Exception("Template file '$tpl_fn' doesn't exist.");
}

$s = file_get_contents($tpl_fn);
Expand Down Expand Up @@ -368,4 +367,3 @@ public function getSrv(?string $name = NULL)
return $ret;
}
}

Loading