Explorar o código

merged branch realmfoo/master (PR #1932)

Commits
-------

4f9d229 The trace argument value could be string ("*DEEP NESTED ARRAY*")
6e7439e expanded namespaces within phpdoc (special for PhpStorm)
f0a6ee5 merge from master
8519967 Calling supportsClass from vote to find out if we can vote

Discussion
----------

The trace argument of an exception can be string (*DEEP NESTED ARRAY*) but with an array type specified

It leads to the exception of a foreach loop:

Invalid argument supplied for foreach() /.../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php:103
Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
941d05b8a4

+ 4 - 1
src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php

@@ -28,10 +28,13 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
 abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
 {
     /**
-     * @var ContainerInterface
+     * @var \Symfony\Component\DependencyInjection\ContainerInterface
      */
     private $container;
 
+    /**
+     * @return \Symfony\Component\DependencyInjection\ContainerInterface
+     */
     protected function getContainer()
     {
         if (null === $this->container) {

+ 10 - 8
src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

@@ -51,7 +51,7 @@ class Controller extends ContainerAware
      * @param  array   $path       An array of path parameters
      * @param  array   $query      An array of query parameters
      *
-     * @return Response A Response instance
+     * @return \Symfony\Component\HttpFoundation\Response A Response instance
      */
     public function forward($controller, array $path = array(), array $query = array())
     {
@@ -64,7 +64,7 @@ class Controller extends ContainerAware
      * @param string  $url The URL to redirect to
      * @param integer $status The status code to use for the Response
      *
-     * @return RedirectResponse
+     * @return \Symfony\Component\HttpFoundation\RedirectResponse
      */
     public function redirect($url, $status = 302)
     {
@@ -89,9 +89,9 @@ class Controller extends ContainerAware
      *
      * @param string   $view The view name
      * @param array    $parameters An array of parameters to pass to the view
-     * @param Response $response A response instance
+     * @param \Symfony\Component\HttpFoundation\Response $response A response instance
      *
-     * @return Response A Response instance
+     * @return \Symfony\Component\HttpFoundation\Response A Response instance
      */
     public function render($view, array $parameters = array(), Response $response = null)
     {
@@ -105,6 +105,8 @@ class Controller extends ContainerAware
      *
      *     throw $this->createNotFoundException('Page not found!');
      *
+     * @param string $message
+     * @param \Exception|null $previous
      * @return NotFoundHttpException
      */
     public function createNotFoundException($message = 'Not Found', \Exception $previous = null)
@@ -119,7 +121,7 @@ class Controller extends ContainerAware
      * @param mixed $data                       The initial data for the form
      * @param array $options                    Options for the form
      *
-     * @return Form
+     * @return \Symfony\Component\Form\Form
      */
     public function createForm($type, $data = null, array $options = array())
     {
@@ -132,7 +134,7 @@ class Controller extends ContainerAware
      * @param mixed $data               The initial data for the form
      * @param array $options            Options for the form
      *
-     * @return FormBuilder
+     * @return \Symfony\Component\Form\FormBuilder
      */
     public function createFormBuilder($data = null, array $options = array())
     {
@@ -142,7 +144,7 @@ class Controller extends ContainerAware
     /**
      * Shortcut to return the request service.
      *
-     * @return Request
+     * @return \Symfony\Component\HttpFoundation\Request
      */
     public function getRequest()
     {
@@ -152,7 +154,7 @@ class Controller extends ContainerAware
     /**
      * Shortcut to return the Doctrine Registry service.
      *
-     * @return Registry
+     * @return \Symfony\Bundle\DoctrineBundle\Registry
      *
      * @throws \LogicException If DoctrineBundle is not available
      */

+ 4 - 4
src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

@@ -42,14 +42,14 @@ class CodeHelper extends Helper
      *
      * @return string
      */
-    public function formatArgsAsText($args)
+    public function formatArgsAsText(array $args)
     {
         $result = array();
         foreach ($args as $key => $item) {
             if ('object' === $item[0]) {
                 $formattedValue = sprintf("object(%s)", $item[1]);
             } elseif ('array' === $item[0]) {
-                $formattedValue = sprintf("array(%s)", $this->formatArgsAsText($item[1]));
+                $formattedValue = sprintf("array(%s)", is_array($item[1]) ? $this->formatArgsAsText($item[1]) : $item[1]);
             } elseif ('string'  === $item[0]) {
                 $formattedValue = sprintf("'%s'", $item[1]);
             } elseif ('null' === $item[0]) {
@@ -97,7 +97,7 @@ class CodeHelper extends Helper
      *
      * @return string
      */
-    public function formatArgs($args)
+    public function formatArgs(array $args)
     {
         $result = array();
         foreach ($args as $key => $item) {
@@ -106,7 +106,7 @@ class CodeHelper extends Helper
                 $short = array_pop($parts);
                 $formattedValue = sprintf("<em>object</em>(<abbr title=\"%s\">%s</abbr>)", $item[1], $short);
             } elseif ('array' === $item[0]) {
-                $formattedValue = sprintf("<em>array</em>(%s)", $this->formatArgs($item[1]));
+                $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
             } elseif ('string'  === $item[0]) {
                 $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
             } elseif ('null' === $item[0]) {

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

@@ -32,7 +32,7 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
      * @param array   $options An array of options to pass to the createKernel class
      * @param array   $server  An array of server parameters
      *
-     * @return Client A Client instance
+     * @return \Symfony\Bundle\FrameworkBundle\Client A Client instance
      */
     static protected function createClient(array $options = array(), array $server = array())
     {

+ 1 - 1
src/Symfony/Component/Console/Command/Command.php

@@ -107,7 +107,7 @@ class Command
     /**
      * Gets the application instance for this command.
      *
-     * @return Application An Application instance
+     * @return \Symfony\Component\Console\Application An Application instance
      *
      * @api
      */

+ 1 - 1
src/Symfony/Component/HttpKernel/Event/KernelEvent.php

@@ -65,7 +65,7 @@ class KernelEvent extends Event
     /**
      * Returns the request the kernel is currently processing
      *
-     * @return Symfony\Component\HttpFoundation\Request
+     * @return \Symfony\Component\HttpFoundation\Request
      *
      * @api
      */

+ 1 - 1
src/Symfony/Component/Routing/Router.php

@@ -198,7 +198,7 @@ class Router implements RouterInterface
     /**
      * Gets the UrlMatcher instance associated with this Router.
      *
-     * @return UrlMatcherInterface A UrlMatcherInterface instance
+     * @return \Symfony\Component\Routing\Matcher\UrlMatcherInterface A UrlMatcherInterface instance
      */
     public function getMatcher()
     {

+ 1 - 1
src/Symfony/Component/Security/Acl/Model/AclProviderInterface.php

@@ -33,7 +33,7 @@ interface AclProviderInterface
      * @throws AclNotFoundException when there is no ACL
      * @param ObjectIdentityInterface $oid
      * @param array $sids
-     * @return AclInterface
+     * @return \Symfony\Component\Security\Acl\Model\AclInterface
      */
     function findAcl(ObjectIdentityInterface $oid, array $sids = array());
 

+ 2 - 2
src/Symfony/Component/Security/Acl/Model/EntryInterface.php

@@ -24,7 +24,7 @@ interface EntryInterface extends \Serializable
     /**
      * The ACL this ACE is associated with.
      *
-     * @return AclInterface
+     * @return \Symfony\Component\Security\Acl\Model\AclInterface
      */
     function getAcl();
 
@@ -45,7 +45,7 @@ interface EntryInterface extends \Serializable
     /**
      * The security identity associated with this ACE
      *
-     * @return SecurityIdentityInterface
+     * @return \Symfony\Component\Security\Acl\Model\SecurityIdentityInterface
      */
     function getSecurityIdentity();
 

+ 2 - 2
src/Symfony/Component/Security/Acl/Model/MutableAclProviderInterface.php

@@ -23,8 +23,8 @@ interface MutableAclProviderInterface extends AclProviderInterface
      *
      * @throws AclAlreadyExistsException when there already is an ACL for the given
      *                                   object identity
-     * @param ObjectIdentityInterface $oid
-     * @return AclInterface
+     * @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $oid
+     * @return \Symfony\Component\Security\Acl\Model\AclInterface
      */
     function createAcl(ObjectIdentityInterface $oid);
 

+ 6 - 0
src/Symfony/Component/Security/Acl/Voter/AclVoter.php

@@ -82,6 +82,12 @@ class AclVoter implements VoterInterface
                     $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain'));
                 }
 
+                if (!$this->supportsClass($oid->getType())) {
+                    return self::ACCESS_ABSTAIN;
+                }
+
+                $sids = $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token);
+
                 return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN;
             }
             $sids = $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token);