Skip to content

Commit

Permalink
Expliciting methods visibility.
Browse files Browse the repository at this point in the history
No need to keep track of line anymore, token_get_all (PHP 5.2.2) returns it.
... and fixing some grammar typos on the way.
  • Loading branch information
renan committed Apr 25, 2011
1 parent cd3529c commit 3251faf
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -103,7 +103,7 @@ class ExtractTask extends Shell {
* @return void
* @access private
*/
function execute() {
public function execute() {
if (!empty($this->params['exclude'])) {
$this->_exclude = explode(',', $this->params['exclude']);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ function execute() {
* @return void
* @access private
*/
function __extract() {
private function __extract() {
$this->out();
$this->out();
$this->out(__d('cake_console', 'Extracting...'));
Expand Down Expand Up @@ -201,7 +201,7 @@ public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(__d('cake_console', 'CakePHP Language String Extraction:'))
->addOption('app', array('help' => __d('cake_console', 'Directory where your application is located.')))
->addOption('paths', array('help' => __d('cake_console', 'Comma separted list of paths.')))
->addOption('paths', array('help' => __d('cake_console', 'Comma separated list of paths.')))
->addOption('merge', array(
'help' => __d('cake_console', 'Merge all domain strings into the default.po file.'),
'choices' => array('yes', 'no')
Expand Down Expand Up @@ -247,29 +247,19 @@ public function help() {
* @return void
* @access private
*/
function __extractTokens() {
private function __extractTokens() {
foreach ($this->__files as $file) {
$this->__file = $file;
$this->out(__d('cake_console', 'Processing %s...', $file));

$code = file_get_contents($file);
$allTokens = token_get_all($code);
$this->__tokens = array();
$lineNumber = 1;

$this->__tokens = array();
foreach ($allTokens as $token) {
if ((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] != T_INLINE_HTML))) {
if (is_array($token)) {
$token[] = $lineNumber;
}
if (!is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) {
$this->__tokens[] = $token;
}

if (is_array($token)) {
$lineNumber += count(explode("\n", $token[1])) - 1;
} else {
$lineNumber += count(explode("\n", $token)) - 1;
}
}
unset($allTokens);
$this->__parse('__', array('singular'));
Expand All @@ -290,7 +280,7 @@ function __extractTokens() {
* @return void
* @access private
*/
function __parse($functionName, $map) {
private function __parse($functionName, $map) {
$count = 0;
$tokenCount = count($this->__tokens);

Expand Down Expand Up @@ -337,7 +327,7 @@ function __parse($functionName, $map) {
* @return void
* @access private
*/
function __buildFiles() {
private function __buildFiles() {
foreach ($this->__strings as $domain => $strings) {
foreach ($strings as $string => $files) {
$occurrences = array();
Expand Down Expand Up @@ -372,7 +362,7 @@ function __buildFiles() {
* @return void
* @access private
*/
function __store($domain, $header, $sentence) {
private function __store($domain, $header, $sentence) {
if (!isset($this->__storage[$domain])) {
$this->__storage[$domain] = array();
}
Expand All @@ -389,7 +379,7 @@ function __store($domain, $header, $sentence) {
* @return void
* @access private
*/
function __writeFiles() {
private function __writeFiles() {
$overwriteAll = false;
foreach ($this->__storage as $domain => $sentences) {
$output = $this->__writeHeader();
Expand Down Expand Up @@ -425,7 +415,7 @@ function __writeFiles() {
* @return string Translation template header
* @access private
*/
function __writeHeader() {
private function __writeHeader() {
$output = "# LANGUAGE translation of CakePHP Application\n";
$output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
$output .= "#\n";
Expand All @@ -452,7 +442,7 @@ function __writeHeader() {
* @return array Strings extracted
* @access private
*/
function __getStrings(&$position, $target) {
private function __getStrings(&$position, $target) {
$strings = array();
while (count($strings) < $target && ($this->__tokens[$position] == ',' || $this->__tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) {
if ($this->__tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->__tokens[$position+1] == '.') {
Expand All @@ -473,13 +463,13 @@ function __getStrings(&$position, $target) {
}

/**
* Format a string to be added as a translateable string
* Format a string to be added as a translatable string
*
* @param string $string String to format
* @return string Formatted string
* @access private
*/
function __formatString($string) {
private function __formatString($string) {
$quote = substr($string, 0, 1);
$string = substr($string, 1, -1);
if ($quote == '"') {
Expand All @@ -501,7 +491,7 @@ function __formatString($string) {
* @return void
* @access private
*/
function __markerError($file, $line, $marker, $count) {
private function __markerError($file, $line, $marker, $count) {
$this->out(__d('cake_console', "Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
$count += 2;
$tokenCount = count($this->__tokens);
Expand All @@ -526,12 +516,12 @@ function __markerError($file, $line, $marker, $count) {
}

/**
* Search files that may contain translateable strings
* Search files that may contain translatable strings
*
* @return void
* @access private
*/
function __searchFiles() {
private function __searchFiles() {
$pattern = false;
if (!empty($this->_exclude)) {
$pattern = '/[\/\\\\]' . implode('|', $this->_exclude) . '[\/\\\\]/';
Expand Down

0 comments on commit 3251faf

Please sign in to comment.