本文整理汇总了PHP中PEAR_ErrorStack::push方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_ErrorStack::push方法的具体用法?PHP PEAR_ErrorStack::push怎么用?PHP PEAR_ErrorStack::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_ErrorStack
的用法示例。
在下文中一共展示了PEAR_ErrorStack::push方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* vérifie qu'un objet DocInfos correspond à ce type de document
* @param object $docinfos
* @return boolean true si le document correspond au type
*/
function check($docinfos)
{
$res = array();
if (!$this->id) {
return false;
}
/* On vérifie que l'accroche est correcte */
if ($this->accroche && $docinfos->accroche == '') {
$this->errors->push(OW_NO_ABSTRACT, 'error');
}
/* Nombre total de classements dans $docinfos */
$nb = 0;
/* On compte le nombre d'entrées dans $docinfos pour chaque critère
qui se trouve dans $this->max ou $this->min. On calcule au passage
également le nombre total d'entrées. */
$compte = array();
foreach (array_unique(array_merge(array_keys($this->max), array_keys($this->min))) as $critere) {
$nb += $compte[$critere] = isset($docinfos->classement[$critere]) ? count($docinfos->classement[$critere]) : 0;
}
/* On vérifie que le nombre de classement pour chaque critère est dans
le bon intervalle */
foreach (array_keys($this->max) as $critere) {
/* Il n'y a pas de maximum si $this->max[$critere] est négatif */
if ($this->max[$critere] >= 0 && $compte[$critere] > $this->max[$critere]) {
$this->errors->push(OW_TOO_MANY_SUBJECTS, 'error', array('criterion' => $critere, 'limit' => $this->max[$critere]));
}
}
foreach (array_keys($this->min) as $critere) {
if ($compte[$critere] < $this->min[$critere]) {
$this->errors->push(OW_TOO_FEW_SUBJECTS, 'error', array('criterion' => $critere, 'limit' => $this->min[$critere]));
}
}
/* Le nombre total de classements est-il compris entre les
deux valeurs imposées ? */
if ($nb > $this->total_max) {
$this->errors->push(OW_TOO_MANY_SUBJECTS, 'error', array('limit' => $this->total_max));
}
if ($nb < $this->total_min) {
$this->errors->push(OW_TOO_FEW_SUBJECTS, 'error', array('limit' => $this->total_min));
}
return !$this->errors->hasErrors();
}
示例2: array
/**
* Validation warning. Does not mark the object contents invalid.
* @param error code
* @param array error information
* @access private
*/
function _validateWarning($code, $params = array())
{
$this->_stack->push($code, 'warning', $params, false, false, debug_backtrace());
}
示例3: analyzeSourceCode
/**
* Analyze the source code of the given PHP file
*
* @param string Filename of the PHP file
* @param boolean whether to analyze $file as the file contents
* @return mixed
*/
function analyzeSourceCode($file, $string = false)
{
if (!function_exists("token_get_all")) {
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file), 'Parser error: token_get_all() function must exist to analyze source code, PHP may have been compiled with --disable-tokenizer');
return false;
}
if (!defined('T_DOC_COMMENT')) {
define('T_DOC_COMMENT', T_COMMENT);
}
if (!defined('T_INTERFACE')) {
define('T_INTERFACE', -1);
}
if (!defined('T_IMPLEMENTS')) {
define('T_IMPLEMENTS', -1);
}
if ($string) {
$contents = $file;
} else {
if (!($fp = @fopen($file, "r"))) {
return false;
}
fclose($fp);
$contents = file_get_contents($file);
}
// Silence this function so we can catch PHP Warnings and show our own custom message
$tokens = @token_get_all($contents);
if (isset($php_errormsg)) {
if (isset($this->_stack)) {
$pn = $this->_pf->getPackage();
$this->_stack->push(__FUNCTION__, 'warning', array('file' => $file, 'package' => $pn), 'in %file%: Could not process file for unkown reasons,' . ' possibly a PHP parse error in %file% from %package%');
}
}
/*
for ($i = 0; $i < sizeof($tokens); $i++) {
@list($token, $data) = $tokens[$i];
if (is_string($token)) {
var_dump($token);
} else {
print token_name($token) . ' ';
var_dump(rtrim($data));
}
}
*/
$look_for = 0;
$paren_level = 0;
$bracket_level = 0;
$brace_level = 0;
$lastphpdoc = '';
$current_class = '';
$current_interface = '';
$current_class_level = -1;
$current_function = '';
$current_function_level = -1;
$declared_classes = array();
$declared_interfaces = array();
$declared_functions = array();
$declared_methods = array();
$used_classes = array();
$used_functions = array();
$extends = array();
$implements = array();
$nodeps = array();
$inquote = false;
$interface = false;
for ($i = 0; $i < sizeof($tokens); $i++) {
if (is_array($tokens[$i])) {
list($token, $data) = $tokens[$i];
} else {
$token = $tokens[$i];
$data = '';
}
if ($inquote) {
if ($token != '"' && $token != T_END_HEREDOC) {
continue;
} else {
$inquote = false;
continue;
}
}
switch ($token) {
case T_WHITESPACE:
continue;
case ';':
if ($interface) {
$current_function = '';
$current_function_level = -1;
}
break;
case '"':
case T_START_HEREDOC:
$inquote = true;
break;
case T_CURLY_OPEN:
//.........这里部分代码省略.........
示例4: updateProperty
/**
* Updates the properties of the containers from the original source.
*
* @param bool if the auth container should be updated
* @param bool if the perm container should be updated
* @return bool true on success and false on failure
*
* @access public
*/
function updateProperty($auth, $perm = null, $accountId = 0)
{
if (!is_a($this->_auth, 'LiveUser_Auth_Common')) {
$this->stack->push(LIVEUSER_ERROR, 'error', array(), 'Cannot update container if no auth container instance is available');
return false;
}
if ($auth && !$this->_auth->readUserData(null, null, $this->_auth->getProperty('auth_user_id'), $accountId)) {
return false;
}
if (is_null($perm)) {
$perm = is_a($this->_perm, 'LiveUser_Perm_Simple');
}
if ($perm) {
if (!is_a($this->_perm, 'LiveUser_Perm_Simple')) {
$this->stack->push(LIVEUSER_ERROR, 'error', array(), 'Cannot update container if no perm container instance is available');
return false;
}
if (!$this->_perm->mapUser($this->_auth->getProperty('auth_user_id'), $this->_auth->containerName)) {
return false;
}
}
$this->_freeze();
return true;
}
示例5: array
/**
* Validation warning. Does not mark the object contents invalid.
* @param error code
* @param array error information
* @access private
*/
function _validateWarning($code, $params = array())
{
$this->_stack->push($code, 'warning', $params);
}
示例6: array
function _missingFile($file)
{
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file), 'package.xml 1.0 file "%file%" is not present in <contents>');
}
示例7: array
/**
* Finds and gets full userinfo by filtering inside the auth container
*
* @param array auth params (as for getUsers() from the auth container
* @return array|bool Array with userinfo if found on success or false otherwise
*
* @access private
*/
function _getUsersByAuth($authParams = array())
{
if (!is_object($this->auth) || !is_object($this->perm)) {
$this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Perm and/or Auth container not set.'));
return false;
}
$first = $authParams['select'] == 'row';
$authUsers = $this->auth->getUsers($authParams);
if (!$authUsers) {
return $authUsers;
}
if ($first) {
$authUsers = array($authUsers);
}
$users = array();
foreach ($authUsers as $authData) {
$permParams = array('filters' => array('auth_user_id' => $authData['auth_user_id'], 'auth_container_name' => $this->authContainerName), 'select' => 'row');
$permData = $this->perm->getUsers($permParams);
if (!$permData) {
continue;
}
if ($first) {
return LiveUser::arrayMergeClobber($authData, $permData);
}
$users[] = LiveUser::arrayMergeClobber($authData, $permData);
}
return $users;
}
示例8: analyzeSourceCode
//.........这里部分代码省略.........
break;
case T_CURLY_OPEN:
case T_DOLLAR_OPEN_CURLY_BRACES:
case '{':
$brace_level++;
continue 2;
case '}':
$brace_level--;
if ($current_class_level == $brace_level) {
$current_class = '';
$current_class_level = -1;
}
if ($current_function_level == $brace_level) {
$current_function = '';
$current_function_level = -1;
}
continue 2;
case '[':
$bracket_level++;
continue 2;
case ']':
$bracket_level--;
continue 2;
case '(':
$paren_level++;
continue 2;
case ')':
$paren_level--;
continue 2;
case T_INTERFACE:
$interface = true;
case T_CLASS:
if ($current_class_level != -1 || $current_function_level != -1) {
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file), 'Parser error: invalid PHP found in file "%file%"');
return false;
}
case T_FUNCTION:
case T_NEW:
case T_EXTENDS:
case T_IMPLEMENTS:
$look_for = $token;
continue 2;
case T_STRING:
if (version_compare(zend_version(), '2.0', '<')) {
if (in_array(strtolower($data), array('public', 'private', 'protected', 'abstract', 'interface', 'implements', 'clone', 'throw'))) {
$this->_stack->push(__FUNCTION__, 'warning', array(), 'Error, PHP5 token encountered, analysis should be in PHP5');
}
}
if ($look_for == T_CLASS) {
$current_class = $data;
$current_class_level = $brace_level;
$declared_classes[] = $current_class;
} elseif ($look_for == T_INTERFACE) {
$current_interface = $data;
$current_class_level = $brace_level;
$declared_interfaces[] = $current_interface;
} elseif ($look_for == T_IMPLEMENTS) {
$implements[$current_class] = $data;
} elseif ($look_for == T_EXTENDS) {
$extends[$current_class] = $data;
} elseif ($look_for == T_FUNCTION) {
if ($current_class) {
$current_function = "{$current_class}::{$data}";
$declared_methods[$current_class][] = $data;
} elseif ($current_interface) {
$current_function = "{$current_interface}::{$data}";
示例9: readUserData
/**
* Reads user data from the given data source
* If only $handle is given, it will read the data
* from the first user with that handle and return
* true on success.
* If $handle and $passwd are given, it will try to
* find the first user with both handle and password
* matching and return true on success (this allows
* multiple users having the same handle but different
* passwords - yep, some people want this).
* if only an auth_user_id is passed it will try to read the data based on the id
* If no match is found, false is being returned.
*
* Again, this does nothing in the base class. The
* described functionality must be implemented in a
* subclass overriding this method.
*
* @param string user handle
* @param string user password
* @param bool|int if the user data should be read using the auth user id
* @return bool true on success or false on failure
*
* @access public
*/
function readUserData($handle = '', $passwd = '', $auth_user_id = false)
{
$this->stack->push(LIVEUSER_ERROR_NOT_SUPPORTED, 'exception', array('feature' => 'readUserData'));
return false;
}
示例10: init
/**
* Load and initialize the storage container.
*
* @param array Array with the configuration
* @return bool true on success or false on failure
*
* @access public
*/
function init(&$conf)
{
if (!array_key_exists('storage', $conf)) {
$this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Missing storage configuration array'));
return false;
}
if (is_array($conf)) {
$keys = array_keys($conf);
foreach ($keys as $key) {
if (isset($this->{$key})) {
$this->{$key} =& $conf[$key];
}
}
}
$this->_storage =& LiveUser::storageFactory($conf['storage']);
if ($this->_storage === false) {
end($conf['storage']);
$key = key($conf['storage']);
$this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate perm storage container: ' . $key));
return false;
}
return true;
}
示例11: array
function _repackageErrorStack($err)
{
$this->errors->push(17, 'error', array(), false, $err);
return PEAR_ERRORSTACK_IGNORE;
}
示例12: setPearinstallerDep
/**
* @param string minimum allowed PEAR installer version
* @param string maximum allowed PEAR installer version
* @param string recommended PEAR installer version
* @param array incompatible version of the PEAR installer
*/
function setPearinstallerDep($min, $max = false, $recommended = false, $exclude = false)
{
$this->_isValid = 0;
$dep = array('min' => $min);
if ($max) {
$dep['max'] = $max;
}
if ($recommended) {
$dep['recommended'] = $recommended;
}
if ($exclude) {
if (count($exclude) == 1) {
$exclude = $exclude[0];
}
$dep['exclude'] = $exclude;
}
if (isset($this->_packageInfo['dependencies']['required']['pearinstaller'])) {
$this->_stack->push(__FUNCTION__, 'warning', array('dep' => $this->_packageInfo['dependencies']['required']['pearinstaller']), 'warning: PEAR Installer dependency already exists, overwriting');
unset($this->_packageInfo['dependencies']['required']['pearinstaller']);
}
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep, array('dependencies' => array('providesextension', 'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'), 'required' => array('optional', 'group'), 'pearinstaller' => array('package', 'subpackage', 'extension', 'os', 'arch')));
}
示例13: updateProperty
/**
* updates the properties of the containers from the original source
*
* @param boolean $auth if the auth container should be updated
* @param boolean $perm if the perm container should be updated
* @return boolean
*
* @access public
*/
function updateProperty($auth, $perm = null)
{
if (!is_a($this->_auth, 'LiveUser_Auth_Common')) {
$this->_stack->push(LIVEUSER_ERROR, 'error', array(), 'Cannot update container if no auth container instance is available');
return false;
}
if ($auth && !$this->_auth->readUserData('', '', true)) {
return false;
}
if (is_null($perm)) {
$perm = is_a($this->_perm, 'LiveUser_Perm_Simple');
}
if ($perm) {
if (!is_a($this->_perm, 'LiveUser_Perm_Simple')) {
$this->_stack->push(LIVEUSER_ERROR, 'error', array(), 'Cannot update container if no perm container instance is available');
return false;
}
if (!$this->_perm->mapUser($this->_auth->getProperty('auth_user_id'), $this->_auth->backendArrayIndex)) {
return false;
}
}
return true;
}