Skip to content

Commit 86478a1

Browse files
committed
Fixes for build without config
1 parent a5aabdc commit 86478a1

56 files changed

Lines changed: 376 additions & 85 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/console

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use PHPCensor\Console\Application;
2424

2525
define('IS_CONSOLE', true);
2626

27+
error_reporting(-1);
28+
ini_set('display_errors', 1);
29+
2730
require_once(dirname(__DIR__) . '/bootstrap.php');
2831

2932
$application = new Application();

bootstrap.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939

4040
require_once(ROOT_DIR . 'vendor/autoload.php');
4141

42-
\PHPCensor\ErrorHandler::register();
43-
4442
if (defined('IS_CONSOLE') && IS_CONSOLE) {
4543
$loggerConfig = LoggerConfig::newFromFile(APP_DIR . "loggerconfig.php");
4644
}
@@ -66,4 +64,4 @@
6664
define('IS_CONSOLE', false);
6765
}
6866

69-
\PHPCensor\Helper\Lang::init($config);
67+
\PHPCensor\Helper\Lang::init($config, 'ru');

runtime/builds/.gitkeep

Whitespace-only changes.

src/PHPCensor/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function execute()
231231
}
232232
} catch (\Exception $ex) {
233233
$this->build->setStatus(Build::STATUS_FAILED);
234-
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
234+
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
235235
}
236236

237237
if (Build::STATUS_FAILED === $this->build->getStatus()) {

src/PHPCensor/ErrorHandler.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/PHPCensor/Logging/BuildLogger.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function logFailure($message, \Exception $exception = null)
8989
// as the exception key in the context array.
9090
if ($exception) {
9191
$context['exception'] = $exception;
92+
$context['trace'] = $exception->getTrace();
9293
}
9394

9495
$this->log("\033[0;31m" . $message . "\033[0m", LogLevel::ERROR, $context);

src/PHPCensor/Logging/LoggerConfig.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace PHPCensor\Logging;
1111

12-
use Monolog\ErrorHandler;
1312
use Monolog\Logger;
1413

1514
/**
@@ -68,7 +67,7 @@ public function getFor($name)
6867
}
6968

7069
$logger = new Logger($name, $handlers);
71-
ErrorHandler::register($logger);
70+
Handler::register($logger);
7271
$this->cache[$name] = $logger;
7372

7473
return $logger;

src/PHPCensor/Model/Build.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ protected function handleConfig(Builder $builder, $buildPath)
110110
}
111111
}
112112

113-
$yamlParser = new YamlParser();
114-
$build_config = $yamlParser->parse($build_config);
113+
// for YAML configs from files/DB
114+
if (is_string($build_config)) {
115+
$yamlParser = new YamlParser();
116+
$build_config = $yamlParser->parse($build_config);
117+
}
115118

116119
$builder->setConfigArray($build_config);
117120

@@ -159,7 +162,7 @@ protected function getZeroConfigPlugins(Builder $builder)
159162

160163
foreach (['setup', 'test', 'complete', 'success', 'failure'] as $stage) {
161164
if ($className::canExecute($stage, $builder, $this)) {
162-
$config[$stage][$className] = [
165+
$config[$stage][$className::pluginName()] = [
163166
'zero_config' => true
164167
];
165168
}

src/PHPCensor/Plugin.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,12 @@ public function getBuilder()
6767
* @return boolean
6868
*/
6969
abstract public function execute();
70+
71+
/**
72+
* @return string
73+
*/
74+
public static function pluginName()
75+
{
76+
return '';
77+
}
7078
}

src/PHPCensor/Plugin/Atoum.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ class Atoum extends Plugin
2626
protected $config;
2727
protected $directory;
2828

29+
/**
30+
* @return string
31+
*/
32+
public static function pluginName()
33+
{
34+
return 'atoum';
35+
}
36+
2937
/**
3038
* {@inheritdoc}
3139
*/

0 commit comments

Comments
 (0)