Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubs for Acl #148

Merged
merged 1 commit into from Apr 19, 2021
Merged

Add stubs for Acl #148

merged 1 commit into from Apr 19, 2021

Conversation

VincentLanglet
Copy link
Contributor

No description provided.

@VincentLanglet
Copy link
Contributor Author

Hi @ondrejmirtes, any idea about this error ?

PHPStan Symfony Framework extensions and rules > phpstan:


In StubPhpDocProvider.php line 150:
                   
  Internal error.  
                   

analyse [--paths-file PATHS-FILE] [-c|--configuration CONFIGURATION] [-l|--level LEVEL] [--no-progress] [--debug] [-a|--autoload-file AUTOLOAD-FILE] [--error-format ERROR-FORMAT] [--generate-baseline [GENERATE-BASELINE]] [--memory-limit MEMORY-LIMIT] [--xdebug] [--fix] [--watch] [--pro] [--] [<paths>...]

@ondrejmirtes
Copy link
Member

AclProviderInterface.stub contains a parse error: https://phpstan.org/r/5b9d1718-66c8-40e6-8c0b-d9363de991f7

@@ -0,0 +1,16 @@
<?php
Copy link
Contributor

@mhujer mhujer Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a space in the beginning of the line which causes the error 😄

Suggested change
<?php
<?php

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With PHPStan's dev-master, the experience is a bit nicer:

------ --------------------------------------------------------------------------------------------
  Line   stubs/Symfony/Component/Security/Acl/Model/AclProviderInterface.stub
 ------ --------------------------------------------------------------------------------------------
  3      Namespace declaration statement has to be the very first statement in the script on line 3
  3      Namespace declaration statement has to be the very first statement in the script on line 3
  3      Namespace declaration statement has to be the very first statement in the script on line 3
  3      Namespace declaration statement has to be the very first statement in the script on line 3
 ------ --------------------------------------------------------------------------------------------

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoah, nice catch

@VincentLanglet
Copy link
Contributor Author

This seems to be ready now :)

@ondrejmirtes ondrejmirtes merged commit 69d0cbf into phpstan:master Apr 19, 2021
@ondrejmirtes
Copy link
Member

Thank you!

@VincentLanglet VincentLanglet deleted the aclStub branch April 19, 2021 21:57
@VincentLanglet
Copy link
Contributor Author

I'm not sure the stub is working as expected. @ondrejmirtes

The following PR is failing:
sonata-project/SonataAdminBundle#7095

    /**
     * @var MutableAclProviderInterface
     */
    protected $aclProvider;

    public function getObjectAcl(ObjectIdentityInterface $objectIdentity)
    {
        try {
            return $this->aclProvider->findAcl($objectIdentity);
        } catch (AclNotFoundException $e) {
            return null;
        }
    }

is throwing an error

Method                                                                 
         Sonata\AdminBundle\Security\Handler\AclSecurityHandler::getObjectAcl(  
         ) should return                                                        
         Symfony\Component\Security\Acl\Model\MutableAclInterface|null but      
         returns Symfony\Component\Security\Acl\Model\AclInterface.

even if the stub is

    /**
     * @phpstan-param array<SecurityIdentityInterface> $sids
     * @phpstan-return MutableAclInterface
     */
    public function findAcl(ObjectIdentityInterface $oid, array $sids = []);

@ondrejmirtes
Copy link
Member

@VincentLanglet Please open an issue.

@VincentLanglet
Copy link
Contributor Author

Done #149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants