当前位置: 首页>>代码示例>>PHP>>正文


PHP assert函数代码示例

本文整理汇总了PHP中assert函数的典型用法代码示例。如果您正苦于以下问题:PHP assert函数的具体用法?PHP assert怎么用?PHP assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: arborize

 public static function arborize($tokens, $config, $context)
 {
     $definition = $config->getHTMLDefinition();
     $parent = new HTMLPurifier_Token_Start($definition->info_parent);
     $stack = array($parent->toNode());
     foreach ($tokens as $token) {
         $token->skip = null;
         // [MUT]
         $token->carryover = null;
         // [MUT]
         if ($token instanceof HTMLPurifier_Token_End) {
             $token->start = null;
             // [MUT]
             $r = array_pop($stack);
             assert($r->name === $token->name);
             assert(empty($token->attr));
             $r->endCol = $token->col;
             $r->endLine = $token->line;
             $r->endArmor = $token->armor;
             continue;
         }
         $node = $token->toNode();
         $stack[count($stack) - 1]->children[] = $node;
         if ($token instanceof HTMLPurifier_Token_Start) {
             $stack[] = $node;
         }
     }
     assert(count($stack) == 1);
     return $stack[0];
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:30,代码来源:Arborize.php

示例2: __construct

 public function __construct($username, $krbpwd)
 {
     assert($username != null);
     assert($krbpwd != null);
     $this->username = $username;
     $this->krbpwd = $krbpwd;
 }
开发者ID:BGCX067,项目名称:fajr-svn-to-git,代码行数:7,代码来源:CosignPasswordLogin.php

示例3: handleElement

 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of Representation objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     // Create the data object
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->newDataObject();
     $representation->setSubmissionId($submission->getId());
     // Handle metadata in subelements.  Look for the 'name' and 'seq' elements.
     // All other elements are handled by subclasses.
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'name':
                     $representation->setName($n->textContent, $n->getAttribute('locale'));
                     break;
                 case 'seq':
                     $representation->setSeq($n->textContent);
                     break;
             }
         }
     }
     return $representation;
     // database insert is handled by sub class.
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:32,代码来源:NativeXmlRepresentationFilter.inc.php

示例4: actionSubscribeContacts

 public function actionSubscribeContacts($marketingListId, $id, $type, $page = 1, $subscribedCount = 0, $skippedCount = 0)
 {
     assert('$type === "contact" || $type === "report"');
     if (!in_array($type, array('contact', 'report'))) {
         throw new NotSupportedException();
     }
     $contactIds = array((int) $id);
     if ($type === 'report') {
         $attributeName = null;
         $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('reportResultsListPageSize', get_class($this->getModule()));
         $reportDataProvider = MarketingListMembersUtil::makeReportDataProviderAndResolveAttributeName($id, $pageSize, $attributeName);
         $contactIds = MarketingListMembersUtil::getContactIdsByReportDataProviderAndAttributeName($reportDataProvider, $attributeName);
         $pageCount = $reportDataProvider->getPagination()->getPageCount();
         $subscriberInformation = $this->addNewSubscribers($marketingListId, $contactIds);
         if ($pageCount == $page || $pageCount == 0) {
             $subscriberInformation = array('subscribedCount' => $subscribedCount + $subscriberInformation['subscribedCount'], 'skippedCount' => $skippedCount + $subscriberInformation['skippedCount']);
             $message = $this->renderCompleteMessageBySubscriberInformation($subscriberInformation);
             echo CJSON::encode(array('message' => $message, 'type' => 'message'));
         } else {
             $percentageComplete = round($page / $pageCount, 2) * 100 . ' %';
             $message = Zurmo::t('MarketingListsModule', 'Processing: {percentageComplete} complete', array('{percentageComplete}' => $percentageComplete));
             echo CJSON::encode(array('message' => $message, 'type' => 'message', 'nextPage' => $page + 1, 'subscribedCount' => $subscribedCount + $subscriberInformation['subscribedCount'], 'skippedCount' => $skippedCount + $subscriberInformation['skippedCount']));
         }
     } else {
         $subscriberInformation = $this->addNewSubscribers($marketingListId, $contactIds, MarketingListMember::SCENARIO_MANUAL_CHANGE);
         $message = $this->renderCompleteMessageBySubscriberInformation($subscriberInformation);
         echo CJSON::encode(array('message' => $message, 'type' => 'message'));
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:29,代码来源:DefaultPortletController.php

示例5: getTemplateVarsFromRowColumn

 /**
  * This implementation assumes an element that is a
  * Filter. It will display the filter name and information
  * about filter parameters (if any).
  * @see GridCellProvider::getTemplateVarsFromRowColumn()
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn(&$row, $column)
 {
     $filter =& $row->getData();
     assert(is_a($filter, 'Filter'));
     switch ($column->getId()) {
         case 'settings':
             $label = '';
             foreach ($filter->getSettings() as $filterSetting) {
                 $settingData = $filter->getData($filterSetting->getName());
                 if (is_a($filterSetting, 'BooleanFilterSetting')) {
                     if ($settingData) {
                         if (!empty($label)) {
                             $label .= ' | ';
                         }
                         $label .= __($filterSetting->getDisplayName());
                     }
                 } else {
                     if (!empty($settingData)) {
                         if (!empty($label)) {
                             $label .= ' | ';
                         }
                         $label .= __($filterSetting->getDisplayName()) . ': ' . $settingData;
                     }
                 }
             }
             break;
         default:
             $label = $filter->getData($column->getId());
     }
     return array('label' => $label);
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:40,代码来源:FilterGridCellProvider.inc.php

示例6: dataObjectEffect

 /**
  * @see DataObjectRequiredPolicy::dataObjectEffect()
  */
 function dataObjectEffect()
 {
     $reviewId = (int) $this->getDataObjectId();
     if (!$reviewId) {
         return AUTHORIZATION_DENY;
     }
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewAssignment = $reviewAssignmentDao->getById($reviewId);
     if (!is_a($reviewAssignment, 'ReviewAssignment')) {
         return AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment actually belongs to the
     // authorized submission.
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     assert(is_a($submission, 'Submission'));
     if ($reviewAssignment->getSubmissionId() != $submission->getId()) {
         AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment is for this workflow stage
     $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
     if ($reviewAssignment->getStageId() != $stageId) {
         return AUTHORIZATION_DENY;
     }
     // Save the review Assignment to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment);
     return AUTHORIZATION_PERMIT;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:31,代码来源:ReviewAssignmentRequiredPolicy.inc.php

示例7: formatElement

 /**
  * Format XML for single DC element.
  * @param $propertyName string
  * @param $value array
  * @param $multilingual boolean optional
  */
 function formatElement($propertyName, $values, $multilingual = false)
 {
     if (!is_array($values)) {
         $values = array($values);
     }
     // Translate the property name to XML syntax.
     $openingElement = str_replace(array('[@', ']'), array(' ', ''), $propertyName);
     $closingElement = String::regexp_replace('/\\[@.*/', '', $propertyName);
     // Create the actual XML entry.
     $response = '';
     foreach ($values as $key => $value) {
         if ($multilingual) {
             $key = str_replace('_', '-', $key);
             assert(is_array($value));
             foreach ($value as $subValue) {
                 if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) {
                     $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
                 } else {
                     $response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
                 }
             }
         } else {
             assert(is_scalar($value));
             $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "</{$closingElement}>\n";
         }
     }
     return $response;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:34,代码来源:PKPOAIMetadataFormat_DC.inc.php

示例8: bGenBrief

 public function bGenBrief($sDest, $sBriefTag)
 {
     $sBriefTag = trim($sBriefTag, '.');
     if (0 == strlen($sBriefTag)) {
         return true;
     }
     list($type, $brief) = explode('.', $sBriefTag, 2);
     assert(isset($this->_aBriefConf[$type][$brief]));
     $master = Ko_Tool_Singleton::OInstance('SaeStorage')->read($this->_sDomain, $sDest);
     if (false === $master) {
         return false;
     }
     $sExt = pathinfo($sDest, PATHINFO_EXTENSION);
     $method = $this->_aBriefConf[$type][$brief]['crop'] ? 'VCrop' : 'VResize';
     $slave = Ko_Tool_Image::$method($master, '1.' . $sExt, $this->_aBriefConf[$type][$brief]['width'], $this->_aBriefConf[$type][$brief]['height'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB);
     if (false === $slave) {
         return false;
     }
     list($name, $ext) = explode('.', $sDest, 2);
     $ret = Ko_Tool_Singleton::OInstance('SaeStorage')->write($this->_sDomain, $name . '.' . $sBriefTag . '.' . $ext, $slave);
     if (false === $ret) {
         return false;
     }
     return true;
 }
开发者ID:firaga,项目名称:operation,代码行数:25,代码来源:SaeStorage.php

示例9: process

 /**
  * Apply this filter to the request.
  *
  * @param array &$request  The current request
  */
 public function process(&$request)
 {
     assert('is_array($request)');
     assert('array_key_exists("Attributes", $request)');
     $attributes =& $request['Attributes'];
     if (!isset($attributes[$this->scopeAttribute])) {
         return;
     }
     if (!isset($attributes[$this->sourceAttribute])) {
         return;
     }
     if (!isset($attributes[$this->targetAttribute])) {
         $attributes[$this->targetAttribute] = array();
     }
     foreach ($attributes[$this->scopeAttribute] as $scope) {
         if (strpos($scope, '@') !== FALSE) {
             $scope = explode('@', $scope, 2);
             $scope = $scope[1];
         }
         foreach ($attributes[$this->sourceAttribute] as $value) {
             $value = $value . '@' . $scope;
             if (in_array($value, $attributes[$this->targetAttribute], TRUE)) {
                 /* Already present. */
                 continue;
             }
             $attributes[$this->targetAttribute][] = $value;
         }
     }
 }
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:34,代码来源:ScopeAttribute.php

示例10: resolve

 /**
  * Resolves the class name of a <code>ProviderData</code> child based on the
  * <code>providerId</code> property in the <code>$data</code> object.
  *
  * @param $className the parent class name (should be <code>ProviderData</code>)
  * @param $data the received data object to inspect
  * @param array $options should contain <code>(PropertyBasedClassNameResolver::PROPERTY_ID => ProviderData::PROVIDER_ID)</code> entry
  * @return the <code>ProviderData</code> sub class name according to the given value for <code>ProviderData::PROVIDER_ID</code>
  */
 public function resolve($className, $data, array $options = array())
 {
     assert($className == Stormpath::PROVIDER_DATA, '$className arg should be ' . Stormpath::PROVIDER_DATA);
     if (isset($options[DefaultClassNameResolver::PROPERTY_ID])) {
         $propertyId = $options[DefaultClassNameResolver::PROPERTY_ID];
         $arrData = json_decode(json_encode($data), true);
         if (isset($arrData[$propertyId])) {
             $propertyValue = $arrData[$propertyId];
             switch ($propertyValue) {
                 case GoogleProviderData::PROVIDER_ID:
                     return Stormpath::GOOGLE_PROVIDER_DATA;
                 case FacebookProviderData::PROVIDER_ID:
                     return Stormpath::FACEBOOK_PROVIDER_DATA;
                 case GithubProviderData::PROVIDER_ID:
                     return Stormpath::GITHUB_PROVIDER_DATA;
                 case LinkedInProviderData::PROVIDER_ID:
                     return Stormpath::LINKEDIN_PROVIDER_DATA;
                 default:
                     throw new \InvalidArgumentException('Could not find className for providerId ' . $propertyValue);
             }
         } else {
             throw new \InvalidArgumentException('Property ' . $propertyId . ' is not defined in $data object');
         }
     } else {
         throw new \InvalidArgumentException('Required key ' . DefaultClassNameResolver::PROPERTY_ID . ' not found in $options array');
     }
 }
开发者ID:InfinityCCS,项目名称:stormpath-sdk-php,代码行数:36,代码来源:ProviderDataClassNameResolver.php

示例11: getTypeByModelUsingValidator

 public static function getTypeByModelUsingValidator($model, $attributeName)
 {
     assert('$model instanceof RedBeanModel || $model instanceof ModelForm ||
                 $model instanceof ConfigurableMetadataModel');
     assert('is_string($attributeName) && $attributeName != ""');
     $validators = $model->getValidators($attributeName);
     foreach ($validators as $validator) {
         switch (get_class($validator)) {
             case 'CBooleanValidator':
                 return 'CheckBox';
             case 'CEmailValidator':
                 return 'Email';
             case 'RedBeanModelTypeValidator':
             case 'TypeValidator':
                 switch ($validator->type) {
                     case 'date':
                         return 'Date';
                     case 'datetime':
                         return 'DateTime';
                     case 'integer':
                         return 'Integer';
                     case 'float':
                         return 'Decimal';
                     case 'time':
                         return 'Time';
                     case 'array':
                         throw new NotSupportedException();
                 }
                 break;
             case 'CUrlValidator':
                 return 'Url';
         }
     }
     return null;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:35,代码来源:ModelAttributeToMixedTypeUtil.php

示例12: getTemplateVarsFromRowColumn

 /**
  * Extracts variables for a given column from a data element
  * so that they may be assigned to template before rendering.
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn($row, $column)
 {
     $element = $row->getData();
     $columnId = $column->getId();
     assert(is_a($element, 'ReviewForm') && !empty($columnId));
     switch ($columnId) {
         case 'name':
             $label = $element->getLocalizedTitle();
             return array('label' => $label);
             break;
         case 'inReview':
             $label = $element->getIncompleteCount();
             return array('label' => $label);
             break;
         case 'completed':
             $label = $element->getCompleteCount();
             return array('label' => $label);
             break;
         case 'active':
             $selected = $element->getActive();
             return array('selected' => $selected);
             break;
         default:
             break;
     }
 }
开发者ID:selwyntcy,项目名称:pkp-lib,代码行数:33,代码来源:ReviewFormGridCellProvider.inc.php

示例13: getListView

 /**
  * @param   string $moduleName
  * @param   bool $forceEmptyResults
  * Return an empty listView
  * @return  View
  */
 public function getListView($moduleName, $forceEmptyResults = false)
 {
     assert('is_string($moduleName)');
     $pageSize = $this->pageSize;
     $module = Yii::app()->findModule($moduleName);
     $searchFormClassName = $module::getGlobalSearchFormClassName();
     $modelClassName = $module::getPrimaryModelName();
     $model = new $modelClassName(false);
     $searchForm = new $searchFormClassName($model);
     $sanitizedSearchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $this->term);
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $this->user->id, $sanitizedSearchAttributes);
     $listViewClassName = $module::getPluralCamelCasedName() . 'ForMixedModelsSearchListView';
     $sortAttribute = SearchUtil::resolveSortAttributeFromGetArray($modelClassName);
     $sortDescending = SearchUtil::resolveSortDescendingFromGetArray($modelClassName);
     if ($forceEmptyResults) {
         $dataProviderClass = 'EmptyRedBeanModelDataProvider';
         $emptyText = '';
     } else {
         $dataProviderClass = 'RedBeanModelDataProvider';
         $emptyText = null;
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(false), $modelClassName, $dataProviderClass, $sortAttribute, $sortDescending, $pageSize, $module->getStateMetadataAdapterClassName());
     $listView = new $listViewClassName('default', $module->getId(), $modelClassName, $dataProvider, GetUtil::resolveSelectedIdsFromGet(), '-' . $moduleName, array('route' => '', 'class' => 'SimpleListLinkPager', 'firstPageLabel' => '<span>first</span>', 'prevPageLabel' => '<span>previous</span>', 'nextPageLabel' => '<span>next</span>', 'lastPageLabel' => '<span>last</span>'));
     $listView->setRowsAreSelectable(false);
     $listView->setEmptyText($emptyText);
     return $listView;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:33,代码来源:MixedModelsSearchResultsDataCollection.php

示例14: sanitycheck_hook_cron

/**
 * Hook to run a cron job.
 *
 * @param array &$croninfo  Output
 */
function sanitycheck_hook_cron(&$croninfo)
{
    assert('is_array($croninfo)');
    assert('array_key_exists("summary", $croninfo)');
    assert('array_key_exists("tag", $croninfo)');
    SimpleSAML_Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
    try {
        $sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
        $cronTag = $sconfig->getString('cron_tag', NULL);
        if ($cronTag === NULL || $cronTag !== $croninfo['tag']) {
            return;
        }
        $info = array();
        $errors = array();
        $hookinfo = array('info' => &$info, 'errors' => &$errors);
        SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
        if (count($errors) > 0) {
            foreach ($errors as $err) {
                $croninfo['summary'][] = 'Sanitycheck error: ' . $err;
            }
        }
    } catch (Exception $e) {
        $croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
    }
}
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:30,代码来源:hook_cron.php

示例15: initialize

 /**
  * @copydoc PKPHandler::initialize()
  */
 function initialize($request)
 {
     parent::initialize($request);
     // Load user-related translations.
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_APP_MANAGER);
     // Basic grid configuration.
     $this->setTitle('grid.user.currentUsers');
     // Grid actions.
     $router = $request->getRouter();
     $pluginName = $request->getUserVar('pluginName');
     assert(!empty($pluginName));
     $this->_pluginName = $pluginName;
     $dispatcher = $request->getDispatcher();
     $url = $dispatcher->url($request, ROUTE_PAGE, null, 'manager', 'importexport', array('plugin', $pluginName, 'exportAllUsers'));
     $this->addAction(new LinkAction('exportAllUsers', new RedirectConfirmationModal(__('grid.users.confirmExportAllUsers'), null, $url), __('grid.action.exportAllUsers'), 'export_users'));
     //
     // Grid columns.
     //
     // First Name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('firstName', 'user.firstName', null, null, $cellProvider));
     // Last Name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('lastName', 'user.lastName', null, null, $cellProvider));
     // User name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('username', 'user.username', null, null, $cellProvider));
     // Email.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('email', 'user.email', null, null, $cellProvider));
 }
开发者ID:relaciones-internacionales-journal,项目名称:pkp-lib,代码行数:34,代码来源:ExportableUsersGridHandler.inc.php


注:本文中的assert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。