Skip to content

Commit

Permalink
Merge pull request #55 from sergeyz/patch-1
Browse files Browse the repository at this point in the history
Fix bootstrap
  • Loading branch information
Gianluca Arbezzano committed Jun 23, 2015
2 parents 2c687f6 + b7f474c commit 18239d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
19 changes: 11 additions & 8 deletions PHPCtags.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ private function struct($node, $reset=FALSE, $parent=array())
$this->struct($subNode, FALSE, array('namespace' => $name));
}
} elseif ($node instanceof PHPParser_Node_Expr_Assign) {
if (is_string($node->var->name)) {
if (isset($node->var->name) && is_string($node->var->name)) {
$kind = 'v';
$node = $node->var;
$name = $node->name;
$line = $node->getLine();
}
} elseif ($node instanceof PHPParser_Node_Expr_AssignRef) {
if (is_string($node->var->name)) {
if (isset($node->var->name) && is_string($node->var->name)) {
$kind = 'v';
$node = $node->var;
$name = $node->name;
Expand Down Expand Up @@ -389,7 +389,7 @@ private function full_render() {
// Save all tag information to a file for faster updates if a cache file was specified.
if (isset($this->cachefile)) {
file_put_contents($this->cachefile, serialize($this->tagdata));
if ($this->mOptions['v']) {
if ($this->mOptions['V']) {
echo "Saved cache file.".PHP_EOL;
}
}
Expand All @@ -416,7 +416,7 @@ public function export()
$end = microtime(true);

if ($this->mOptions['V']) {
echo "It tooks ".($end-$start)." seconds.".PHP_EOL;
echo PHP_EOL."It took ".($end-$start)." seconds.".PHP_EOL;
}

return $content;
Expand All @@ -426,7 +426,7 @@ private function process($file)
{
// Load the tag md5 data to skip unchanged files.
if (!isset($this->tagdata) && isset($this->cachefile) && file_exists(realpath($this->cachefile))) {
if ($this->mOptions['v']) {
if ($this->mOptions['V']) {
echo "Loaded cache file.".PHP_EOL;
}
$this->tagdata = unserialize(file_get_contents(realpath($this->cachefile)));
Expand Down Expand Up @@ -469,10 +469,11 @@ private function process($file)

private function process_single_file($filename)
{
if ($this->mOptions['v'] && $this->filecount > 1 && $this->filecount % 64 == 0) {
if ($this->mOptions['V'] && $this->filecount > 1 && $this->filecount % 64 == 0) {
echo " ".$this->filecount." files".PHP_EOL;
}
$this->filecount++;
$startfile = microtime(true);

$this->setMFile((string) $filename);
$file = file_get_contents($this->mFile);
Expand All @@ -487,12 +488,14 @@ private function process_single_file($filename)
}

$struct = $this->struct($this->mParser->parse($file), TRUE);
$finishfile = microtime(true);
$this->mLines[$this->mFile] = $this->render($struct);
$finishmerge = microtime(true);
$this->tagdata[$this->mFile][$md5] = $this->mLines[$this->mFile];
if ($this->mOptions['debug']) {
echo "Parse: ".($finishfile - $startfile).", Merge: ".($finishmerge-$finishfile)."; (".$this->filecount.")".$this->mFile.PHP_EOL;
} else if ($this->mOptions['v']) {
echo "U";
} else if ($this->mOptions['V']) {
echo ".";
}
}

Expand Down
21 changes: 9 additions & 12 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@
-o Alternative for -f.
-R Equivalent to --recurse.
-u Equivalent to --sort=no.
<<<<<<< HEAD
-v Equivalent to --verbose.
-V Equivalent to --version.
=======
-V Equivalent to --verbose.
>>>>>>> a86869b... Fixed issues based on @mr-russ's PR.
--append=[yes|no]
Should tags should be appended to existing tag file [no]?
--debug
Expand All @@ -80,13 +75,9 @@
Recurse into directories supplied on command line [no].
--sort=[yes|no|foldcase]
Should tags be sorted (optionally ignoring case) [yes]?.
<<<<<<< HEAD
--Version
=======
--verbose=[yes|no]
Enable verbose messages describing actions on each source file.
--version
>>>>>>> a86869b... Fixed issues based on @mr-russ's PR.
Print version identifier to standard output.
EOF;

Expand All @@ -103,20 +94,26 @@
}
while ($key = array_pop($argv_)) unset($argv[$key]);

// option -V is an alternative to --verbose
// option -v is an alternative to --verbose
if (isset($options['V'])) {
$options['verbose'] = 'yes';
}

if (isset($options['verbose'])) {
if ($options['verbose'] === FALSE || yes_or_no($options['verbose']) == 'yes') {
$options['V'] = 'yes';
$options['V'] = true;
} else if (yes_or_no($options['verbose']) != 'no') {
die('phpctags: Invalid value for "verbose" option'.PHP_EOL);
} else {
$options['V'] = false;
}
} else {
$options['V'] = false;
}

if (!isset($options['debug'])) {
if (isset($options['debug'])) {
$options['debug'] = true;
} else {
error_reporting(0);
}

Expand Down

0 comments on commit 18239d0

Please sign in to comment.