當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Reference::isStrict方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\Reference::isStrict方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reference::isStrict方法的具體用法?PHP Reference::isStrict怎麽用?PHP Reference::isStrict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\Reference的用法示例。


在下文中一共展示了Reference::isStrict方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateScope

 protected function validateScope(Reference $reference, Definition $definition = null)
 {
     if (ContainerInterface::SCOPE_PROTOTYPE === $this->currentScope) {
         return;
     }
     if (!$reference->isStrict()) {
         return;
     }
     if (null === $definition) {
         return;
     }
     if ($this->currentScope === ($scope = $definition->getScope())) {
         return;
     }
     $id = (string) $reference;
     if (in_array($scope, $this->currentScopeChildren, true)) {
         throw new \RuntimeException(sprintf('Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. ' . 'Generally, it is safer to either move "%s" to scope "%s" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "%s" each time it is needed. ' . 'In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.', $this->currentId, $id, $this->currentId, $scope, $id));
     }
     if (!in_array($scope, $this->currentScopeAncestors, true)) {
         throw new \RuntimeException(sprintf('Cross-Scope Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. ' . 'This service might not be available consistently. Generally, it is safer to either move the definition "%s" to scope "%s", or ' . 'declare "%s" as a child scope of "%s". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.', $this->currentId, $id, $this->currentId, $scope, $this->currentScope, $scope));
     }
 }
開發者ID:faridos,項目名稱:ServerGroveLiveChat,代碼行數:22,代碼來源:CheckReferenceValidityPass.php

示例2: validateScope

 /**
  * Validates the scope of a single Reference.
  *
  * @param Reference  $reference
  * @param Definition $definition
  *
  * @throws ScopeWideningInjectionException when the definition references a service of a narrower scope
  * @throws ScopeCrossingInjectionException when the definition references a service of another scope hierarchy
  */
 private function validateScope(Reference $reference, Definition $definition = null)
 {
     if (ContainerInterface::SCOPE_PROTOTYPE === $this->currentScope) {
         return;
     }
     if (!$reference->isStrict()) {
         return;
     }
     if (null === $definition) {
         return;
     }
     if ($this->currentScope === ($scope = $definition->getScope())) {
         return;
     }
     $id = (string) $reference;
     if (in_array($scope, $this->currentScopeChildren, true)) {
         throw new ScopeWideningInjectionException($this->currentId, $this->currentScope, $id, $scope);
     }
     if (!in_array($scope, $this->currentScopeAncestors, true)) {
         throw new ScopeCrossingInjectionException($this->currentId, $this->currentScope, $id, $scope);
     }
 }
開發者ID:neteasy-work,項目名稱:hkgbf_crm,代碼行數:31,代碼來源:CheckReferenceValidityPass.php


注:本文中的Symfony\Component\DependencyInjection\Reference::isStrict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。