Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'cs/remove-underscores' of https://github.com/arse/zf2 i…
Browse files Browse the repository at this point in the history
…nto feature/protected-underscores

Conflicts:
	library/Zend/Console/Getopt.php
  • Loading branch information
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 344 deletions.
36 changes: 18 additions & 18 deletions src/Storage/AbstractStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class AbstractStorage implements
* class capabilities with default values
* @var array
*/
protected $_has = array('uniqueid' => true,
protected $has = array('uniqueid' => true,
'delete' => false,
'create' => false,
'top' => false,
Expand All @@ -39,19 +39,19 @@ abstract class AbstractStorage implements
* current iteration position
* @var int
*/
protected $_iterationPos = 0;
protected $iterationPos = 0;

/**
* maximum iteration position (= message count)
* @var null|int
*/
protected $_iterationMax = null;
protected $iterationMax = null;

/**
* used message class, change it in an extended class to extend the returned message class
* @var string
*/
protected $_messageClass = 'Zend\Mail\Storage\Message';
protected $messageClass = 'Zend\Mail\Storage\Message';

/**
* Getter for has-properties. The standard has properties
Expand All @@ -70,7 +70,7 @@ public function __get($var)
{
if (strpos($var, 'has') === 0) {
$var = strtolower(substr($var, 3));
return isset($this->_has[$var]) ? $this->_has[$var] : null;
return isset($this->has[$var]) ? $this->has[$var] : null;
}

throw new Exception\InvalidArgumentException($var . ' not found');
Expand All @@ -84,7 +84,7 @@ public function __get($var)
*/
public function getCapabilities()
{
return $this->_has;
return $this->has;
}


Expand Down Expand Up @@ -271,8 +271,8 @@ public function offsetUnset($id)
*/
public function rewind()
{
$this->_iterationMax = $this->countMessages();
$this->_iterationPos = 1;
$this->iterationMax = $this->countMessages();
$this->iterationPos = 1;
}


Expand All @@ -283,7 +283,7 @@ public function rewind()
*/
public function current()
{
return $this->getMessage($this->_iterationPos);
return $this->getMessage($this->iterationPos);
}


Expand All @@ -294,7 +294,7 @@ public function current()
*/
public function key()
{
return $this->_iterationPos;
return $this->iterationPos;
}


Expand All @@ -303,7 +303,7 @@ public function key()
*/
public function next()
{
++$this->_iterationPos;
++$this->iterationPos;
}


Expand All @@ -314,10 +314,10 @@ public function next()
*/
public function valid()
{
if ($this->_iterationMax === null) {
$this->_iterationMax = $this->countMessages();
if ($this->iterationMax === null) {
$this->iterationMax = $this->countMessages();
}
return $this->_iterationPos && $this->_iterationPos <= $this->_iterationMax;
return $this->iterationPos && $this->iterationPos <= $this->iterationMax;
}


Expand All @@ -329,14 +329,14 @@ public function valid()
*/
public function seek($pos)
{
if ($this->_iterationMax === null) {
$this->_iterationMax = $this->countMessages();
if ($this->iterationMax === null) {
$this->iterationMax = $this->countMessages();
}

if ($pos > $this->_iterationMax) {
if ($pos > $this->iterationMax) {
throw new Exception\OutOfBoundsException('this position does not exist');
}
$this->_iterationPos = $pos;
$this->iterationPos = $pos;
}

}
56 changes: 28 additions & 28 deletions src/Storage/Folder/Maildir.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ class Maildir extends Storage\Maildir implements FolderInterface
* root folder for folder structure
* @var \Zend\Mail\Storage\Folder
*/
protected $_rootFolder;
protected $rootFolder;

/**
* rootdir of folder structure
* @var string
*/
protected $_rootdir;
protected $rootdir;

/**
* name of current folder
* @var string
*/
protected $_currentFolder;
protected $currentFolder;

/**
* delim char for subfolders
* @var string
*/
protected $_delim;
protected $delim;

/**
* Create instance with parameters
Expand All @@ -65,31 +65,31 @@ public function __construct($params)
throw new Exception\InvalidArgumentException('no valid dirname given in params');
}

$this->_rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->rootdir = rtrim($params->dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

$this->_delim = isset($params->delim) ? $params->delim : '.';
$this->delim = isset($params->delim) ? $params->delim : '.';

$this->_buildFolderTree();
$this->selectFolder(!empty($params->folder) ? $params->folder : 'INBOX');
$this->_has['top'] = true;
$this->_has['flags'] = true;
$this->has['top'] = true;
$this->has['flags'] = true;
}

/**
* find all subfolders and mbox files for folder structure
*
* Result is save in \Zend\Mail\Storage\Folder instances with the root in $this->_rootFolder.
* Result is save in \Zend\Mail\Storage\Folder instances with the root in $this->rootFolder.
* $parentFolder and $parentGlobalName are only used internally for recursion.
*
* @throws \Zend\Mail\Storage\Exception\RuntimeException
*/
protected function _buildFolderTree()
{
$this->_rootFolder = new Storage\Folder('/', '/', false);
$this->_rootFolder->INBOX = new Storage\Folder('INBOX', 'INBOX', true);
$this->rootFolder = new Storage\Folder('/', '/', false);
$this->rootFolder->INBOX = new Storage\Folder('INBOX', 'INBOX', true);

ErrorHandler::start(E_WARNING);
$dh = opendir($this->_rootdir);
$dh = opendir($this->rootdir);
ErrorHandler::stop();
if (!$dh) {
throw new Exception\RuntimeException("can't read folders in maildir");
Expand All @@ -103,7 +103,7 @@ protected function _buildFolderTree()
continue;
}

if ($this->_isMaildir($this->_rootdir . $entry)) {
if ($this->_isMaildir($this->rootdir . $entry)) {
$dirs[] = $entry;
}
}
Expand All @@ -112,18 +112,18 @@ protected function _buildFolderTree()
sort($dirs);
$stack = array(null);
$folderStack = array(null);
$parentFolder = $this->_rootFolder;
$parentFolder = $this->rootFolder;
$parent = '.';

foreach ($dirs as $dir) {
do {
if (strpos($dir, $parent) === 0) {
$local = substr($dir, strlen($parent));
if (strpos($local, $this->_delim) !== false) {
if (strpos($local, $this->delim) !== false) {
throw new Exception\RuntimeException('error while reading maildir');
}
array_push($stack, $parent);
$parent = $dir . $this->_delim;
$parent = $dir . $this->delim;
$folder = new Storage\Folder($local, substr($dir, 1), true);
$parentFolder->$local = $folder;
array_push($folderStack, $parentFolder);
Expand All @@ -150,27 +150,27 @@ protected function _buildFolderTree()
public function getFolders($rootFolder = null)
{
if (!$rootFolder || $rootFolder == 'INBOX') {
return $this->_rootFolder;
return $this->rootFolder;
}

// rootdir is same as INBOX in maildir
if (strpos($rootFolder, 'INBOX' . $this->_delim) === 0) {
if (strpos($rootFolder, 'INBOX' . $this->delim) === 0) {
$rootFolder = substr($rootFolder, 6);
}
$currentFolder = $this->_rootFolder;
$subname = trim($rootFolder, $this->_delim);
$currentFolder = $this->rootFolder;
$subname = trim($rootFolder, $this->delim);

while ($currentFolder) {
ErrorHandler::start(E_NOTICE);
list($entry, $subname) = explode($this->_delim, $subname, 2);
list($entry, $subname) = explode($this->delim, $subname, 2);
ErrorHandler::stop();
$currentFolder = $currentFolder->$entry;
if (!$subname) {
break;
}
}

if ($currentFolder->getGlobalName() != rtrim($rootFolder, $this->_delim)) {
if ($currentFolder->getGlobalName() != rtrim($rootFolder, $this->delim)) {
throw new Exception\InvalidArgumentException("folder $rootFolder not found");
}
return $currentFolder;
Expand All @@ -186,20 +186,20 @@ public function getFolders($rootFolder = null)
*/
public function selectFolder($globalName)
{
$this->_currentFolder = (string)$globalName;
$this->currentFolder = (string)$globalName;

// getting folder from folder tree for validation
$folder = $this->getFolders($this->_currentFolder);
$folder = $this->getFolders($this->currentFolder);

try {
$this->_openMaildir($this->_rootdir . '.' . $folder->getGlobalName());
$this->_openMaildir($this->rootdir . '.' . $folder->getGlobalName());
} catch(Exception\ExceptionInterface $e) {
// check what went wrong
if (!$folder->isSelectable()) {
throw new Exception\RuntimeException("{$this->_currentFolder} is not selectable", 0, $e);
throw new Exception\RuntimeException("{$this->currentFolder} is not selectable", 0, $e);
}
// seems like file has vanished; rebuilding folder tree - but it's still an exception
$this->_buildFolderTree($this->_rootdir);
$this->_buildFolderTree($this->rootdir);
throw new Exception\RuntimeException('seems like the maildir has vanished, I\'ve rebuild the ' .
'folder tree, search for an other folder and try again', 0, $e);
}
Expand All @@ -212,6 +212,6 @@ public function selectFolder($globalName)
*/
public function getCurrentFolder()
{
return $this->_currentFolder;
return $this->currentFolder;
}
}
Loading

0 comments on commit c1bc89d

Please sign in to comment.