Permalink
Browse files

Some code cleanup

  • Loading branch information...
1 parent 3c47ad6 commit a01038ea69b19dc1ac8a8d2c92cb04d5eed4e7c2 @theseer committed Dec 20, 2016
Showing with 20 additions and 22 deletions.
  1. +6 −6 src/Application.php
  2. +1 −1 src/AutoloadRenderer.php
  3. +3 −5 src/CLI.php
  4. +1 −1 src/Collector.php
  5. +4 −4 src/Parser.php
  6. +3 −3 src/PharBuilder.php
  7. +1 −1 src/StaticRenderer.php
  8. +1 −1 src/Version.php
View
@@ -52,7 +52,7 @@ public function __construct(Logger $logger, Config $config, Factory $factory) {
public function run() {
$result = $this->runCollector();
if (!$result->hasUnits()) {
- throw new ApplicationException("No units were found - process aborted.", ApplicationException::NoUnitsFound);
+ throw new ApplicationException('No units were found - process aborted.', ApplicationException::NoUnitsFound);
}
if ($this->config->isCacheEnabled()) {
$this->factory->getCache()->persist($this->config->getCacheFile());
@@ -111,7 +111,7 @@ private function runSaver($code) {
$this->logger->log(
"Warning: Template used in phar mode did not contain required __HALT_COMPILER() call\n" .
"which has been added automatically. The used stub code may not work as intended.\n\n", STDERR);
- $code .= $this->config->getLineBreak() . '__HALT_COMPILER();';
+ $code .= $this->config->getLinebreak() . '__HALT_COMPILER();';
}
$pharBuilder = $this->factory->getPharBuilder();
if ($keyfile = $this->config->getPharKey()) {
@@ -130,7 +130,7 @@ private function runSaver($code) {
private function loadPharSignatureKey($keyfile) {
if (!extension_loaded('openssl')) {
- throw new ApplicationException("Extension for OpenSSL not loaded - cannot sign phar archive - process aborted.",
+ throw new ApplicationException('Extension for OpenSSL not loaded - cannot sign phar archive - process aborted.',
ApplicationException::OpenSSLError);
}
$keydata = file_get_contents($keyfile);
@@ -161,9 +161,9 @@ private function loadPharSignatureKey($keyfile) {
*/
protected function runLint($code) {
$dsp = array(
- 0 => array("pipe", "r"),
- 1 => array("pipe", "w"),
- 2 => array("pipe", "w")
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w'),
+ 2 => array('pipe', 'w')
);
$binary = $this->config->getPhp();
@@ -193,7 +193,7 @@ public function getLineBreak() {
* @throws AutoloadBuilderException
*/
public function setTimestamp($time) {
- if (!is_int($time) && !is_null($time)) {
+ if (!is_int($time) && null !== $time) {
throw new AutoloadBuilderException("'$time' is not a unix timestamp", AutoloadBuilderException::InvalidTimestamp);
}
$this->timestamp = $time;
View
@@ -38,8 +38,6 @@
namespace TheSeer\Autoload {
- use TheSeer\DirectoryScanner\DirectoryScanner;
-
/**
* CLI interface to AutoloadRenderer / StaticRenderer
*
@@ -119,7 +117,7 @@ public function run() {
break;
}
default: {
- $message = "Unexpected error in collector process: " . $e->getMessage() . "\n\nPlease report this as a bug.\n\n";
+ $message = 'Unexpected error in collector process: ' . $e->getMessage() . "\n\nPlease report this as a bug.\n\n";
}
}
$this->showVersion();
@@ -531,8 +529,8 @@ protected function setupInput() {
));
$input->argumentDefinition = new \ezcConsoleArguments();
- $input->argumentDefinition[0] = new \ezcConsoleArgument( "directory" );
- $input->argumentDefinition[0]->shorthelp = "The directory to process.";
+ $input->argumentDefinition[0] = new \ezcConsoleArgument('directory');
+ $input->argumentDefinition[0]->shorthelp = 'The directory to process.';
$input->argumentDefinition[0]->multiple = TRUE;
return $input;
View
@@ -54,7 +54,7 @@ public function processDirectory(\Iterator $sources) {
public function processFile(\SplFileInfo $file) {
try {
- $parseResult = $this->parser->parse(new SourceFile($file->getRealpath()));
+ $parseResult = $this->parser->parse(new SourceFile($file->getRealPath()));
if ($parseResult->hasRedeclarations() && !$this->tolerantMode) {
throw new CollectorException(
sprintf(
View
@@ -195,7 +195,7 @@ private function processClass($pos) {
}
default: {
throw new ParserException(sprintf(
- "Parse error while trying to process class definition (unexpected token in name)."
+ 'Parse error while trying to process class definition (unexpected token in name).'
), ParserException::ParseError
);
}
@@ -206,7 +206,7 @@ private function processClass($pos) {
}
if ($implementsFound && count($implementsList)==0) {
throw new ParserException(sprintf(
- "Parse error while trying to process class definition (extends or implements)."
+ 'Parse error while trying to process class definition (extends or implements).'
), ParserException::ParseError
);
}
@@ -259,7 +259,7 @@ private function processInterface($pos) {
private function resolveDependencyName($name) {
if ($name == '') {
throw new ParserException(sprintf(
- "Parse error while trying to process class definition (extends or implements)."
+ 'Parse error while trying to process class definition (extends or implements).'
), ParserException::ParseError
);
}
@@ -287,7 +287,7 @@ private function resolveDependencyName($name) {
private function registerUnit($name, $type) {
if ($name == '' || substr($name, -1) == '\\') {
throw new ParserException(sprintf(
- "Parse error while trying to process %s definition.",
+ 'Parse error while trying to process %s definition.',
$this->typeMap[$type]
), ParserException::ParseError
);
View
@@ -100,7 +100,7 @@ public function build($filename, $stub) {
$keyDetails = openssl_pkey_get_details($this->key);
file_put_contents($filename . '.pubkey', $keyDetails['key']);
} else {
- $phar->setSignatureAlgorithm($this->selectSignatureType($phar));
+ $phar->setSignatureAlgorithm($this->selectSignatureType());
}
$basedir = $this->basedir ? $this->basedir : $this->directories[0];
@@ -114,11 +114,11 @@ public function build($filename, $stub) {
$phar->stopBuffering();
}
- private function selectSignatureType(\Phar $phar) {
+ private function selectSignatureType() {
if ($this->signatureType !== NULL) {
return $this->supportedSignatureTypes[$this->signatureType];
}
- $supported = $phar->getSupportedSignatures();
+ $supported = \Phar::getSupportedSignatures();
foreach($this->supportedSignatureTypes as $candidate => $type) {
if (in_array($candidate, $supported)) {
return $type;
@@ -94,7 +94,7 @@ public function render($template) {
'___CREATED___' => date( $this->dateformat, $this->timestamp ? $this->timestamp : time()),
'___FILELIST___' => join( $this->linebreak . $this->indent, $entries),
'___BASEDIR___' => $baseDir,
- '___AUTOLOAD___' => uniqid('autoload')
+ '___AUTOLOAD___' => uniqid('autoload', true)
));
return str_replace(array_keys($replace), array_values($replace), $template);
View
@@ -58,7 +58,7 @@ public static function getVersion() {
}
public static function getInfoString() {
- return 'phpab ' . self::getVersion() . " - Copyright (C) 2009 - " . date('Y') . " by Arne Blankerts and Contributors";
+ return 'phpab ' . self::getVersion() . ' - Copyright (C) 2009 - ' . date('Y') . ' by Arne Blankerts and Contributors';
}
}

0 comments on commit a01038e

Please sign in to comment.