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 support for phpstan/phpdoc-parser 2 #386

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

xabbuh
Copy link
Contributor

@xabbuh xabbuh commented Nov 7, 2024

No description provided.

Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your help to upgrade, I think we should accept the issues in the pipeline by adding the phpstan errors to the baseline. And add the missing symbol to the composer-require-checker config.

Let me know if you need any help with that.

['lines' => true, 'indexes' => true],
true
);
if (class_exists(ParserConfig::class)) {
Copy link
Member

Choose a reason for hiding this comment

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

please add class_exists as a use function class_exists this will fix the codestyle issue in the pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaapio Could you retrigger the build? I hope I caught everything. :)

@jaapio
Copy link
Member

jaapio commented Nov 11, 2024

Thanks a lot, I will take care of the last code style issue, don't worry about that one. :-)

@jaapio jaapio merged commit 5763b5b into phpDocumentor:5.x Nov 12, 2024
23 of 25 checks passed
@xabbuh xabbuh deleted the phpstan-phpdoc-parser-2 branch November 12, 2024 11:22
@PhilETaylor
Copy link

so.......

Symfony 7.1 stable project.... composer update... BANG 💣

composer why phpdocumentor/reflection-docblock

philetaylor/maintain.myjoomla.com dev-master requires  phpdocumentor/reflection-docblock (5.5.1)
symfony/framework-bundle          v7.1.6     conflicts phpdocumentor/reflection-docblock (<3.2.2)
symfony/mime                      v7.1.6     conflicts phpdocumentor/reflection-docblock (<3.2.2)
symfony/property-info             v7.1.6     conflicts phpdocumentor/reflection-docblock (<5.2)
symfony/serializer                v7.1.6     conflicts phpdocumentor/reflection-docblock (<3.2.2)
symfony/twig-bridge               v7.1.6     conflicts phpdocumentor/reflection-docblock (<3.2.2)
web-auth/webauthn-symfony-bundle  4.9.1      requires  phpdocumentor/reflection-docblock (^5.3)
composer update 


Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "7.1.*"
Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading phpdocumentor/reflection-docblock (5.5.1 => 5.6.0)
  - Upgrading phpstan/phpdoc-parser (1.33.0 => 2.0.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Upgrading phpstan/phpdoc-parser (1.33.0 => 2.0.0): Extracting archive
  - Upgrading phpdocumentor/reflection-docblock (5.5.1 => 5.6.0): Extracting archive
Generating autoload files
!!  ArgumentCountError {#29260
!!    #message: "Too few arguments to function PHPStan\PhpDocParser\Lexer\Lexer::__construct(), 0 passed in /Users/phil/Sites/manage.mysites.guru/vendor/symfony/type-info/TypeResolver/StringTypeResolver.php on line 66 and exactly 1 expected"
!!    #code: 0
!!    #file: "./vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php"
!!    #line: 102
!!    trace: {
!!      ./vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php:102 { …}
!!      ./vendor/symfony/type-info/TypeResolver/StringTypeResolver.php:66 { …}
!!      ./vendor/symfony/type-info/TypeResolver/TypeResolver.php:71 { …}
!!      ./vendor/symfony/type-info/TypeResolver/TypeResolver.php:66 { …}
!!      ./vendor/symfony/property-info/Extractor/ReflectionExtractor.php:102 { …}
!!      ./var/build/Container3zDfNAT/App_KernelDevDebugContainer.php:2634 {
!!        Container3zDfNAT\App_KernelDevDebugContainer::Container3zDfNAT\{closure}
!!        › yield 0 => ($container->privates['property_info.serializer_extractor'] ?? $container->load('getPropertyInfo_SerializerExtractorService'));
!!        › yield 1 => ($container->privates['property_info.reflection_extractor'] ??= new \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor());
!!        › yield 2 => ($container->privates['doctrine.orm.default_entity_manager.property_info_extractor'] ?? $container->load('getDoctrine_Orm_DefaultEntityManager_PropertyInfoExtractorService'));
!!      }
!!      ./vendor/symfony/property-info/PropertyInfoExtractor.php:92 { …}
!!      ./vendor/symfony/property-info/PropertyInfoExtractor.php:43 { …}
!!      ./vendor/symfony/validator/Mapping/Loader/PropertyInfoLoader.php:51 { …}
!!      ./vendor/symfony/validator/Mapping/Loader/LoaderChain.php:48 { …}
!!      ./vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php:96 { …}
!!      ./vendor/symfony/framework-bundle/CacheWarmer/ValidatorCacheWarmer.php:51 { …}
!!      ./vendor/symfony/framework-bundle/CacheWarmer/AbstractPhpFileCacheWarmer.php:41 { …}
!!      ./vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:96 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:542 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:740 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:120 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:177 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:69 { …}
!!      ./vendor/symfony/console/Application.php:167 { …}
!!      ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 { …}
!!      ./vendor/autoload_runtime.php:29 { …}
!!      ./bin/console:23 { …}
!!    }

ScreenShot-2024-11-12-13 04 57

Its cool, I just pegged the old version for now until I understand whats going on here...

    "phpstan/phpdoc-parser": "1.33.0",
    "phpdocumentor/reflection-docblock":"5.5.1"

Not looking for support, just thought it was imporant to note that a straight composer update broken me and made me cry... more coffee needed. Hugs needed. haha.

@PhilETaylor
Copy link

PhilETaylor commented Nov 12, 2024

Coffee cup filled...

I note that symfony/type-info is the problem here. I see you already have submitted the changes symfony/type-info@51535dd but they are not released yet. also symfony/property-info at symfony/property-info@4d77ab2

Hope that helps the next person coming here :) and @fabpot might release a new version soon of symfony/type-info and symfony/property-info.

for today I have switched to

 "symfony/type-info": "7.1.x-dev",
 "symfony/property-info": "7.1.x-dev"

@xabbuh
Copy link
Contributor Author

xabbuh commented Nov 12, 2024

Yes, the next Symfony patch releases will indeed be compatible with phpstan/phpdoc-parser 2. By the way, you can also opt to explicitly require version 1 of it if you don't want to update to non-tagged Symfony releases at the moment.

@PhilETaylor
Copy link

Its all cool... appreciate your work. Could not find a way to send you money though, consider enabling GitHub sponsors! :)

@lyrixx
Copy link

lyrixx commented Nov 12, 2024

Hello, thanks for the patch

but the new release breaks APIP:

I have no name! /app/server/backend composer u                                                                                                                                                                    
Loading composer repositories with package information                                                                                                                                                            
Updating dependencies                                                                                                                                                                                             
Lock file operations: 0 installs, 2 updates, 0 removals                                                                                                                                                           
  - Upgrading phpdocumentor/reflection-docblock (5.5.1 => 5.6.0)                                                                                                                                                  
  - Upgrading phpstan/phpdoc-parser (1.33.0 => 2.0.0)                                                                                                                                                             
Writing lock file                                                                                                                                                                                                 
Installing dependencies from lock file (including require-dev)                                                                                                                                                    
Package operations: 0 installs, 2 updates, 0 removals                                                                                                                                                             
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.                                                                                                       
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.                                                                       
Installing 'unzip' or '7z' (21.01+) may remediate them.                                                                                                                                                           
  - Downloading phpstan/phpdoc-parser (2.0.0)                                                                                                                                                                     
  - Downloading phpdocumentor/reflection-docblock (5.6.0)                                                                                                                                                         
  - Upgrading phpstan/phpdoc-parser (1.33.0 => 2.0.0): Extracting archive
  - Upgrading phpdocumentor/reflection-docblock (5.5.1 => 5.6.0): Extracting archive
Generating autoload files
148 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> rm -rf var/cache/*
> mkdir -p web/assets/images
> bin/console assets:install web --relative
ArgumentCountError {#20079
  #message: "Too few arguments to function PHPStan\PhpDocParser\Parser\ConstExprParser::__construct(), 0 passed in /app/server/backend/vendor/api-platform/core/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php on line 62 and exactly 1 expected"
  #code: 0
  #file: "./vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php"
  #line: 18
  trace: {
    ./vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php:18 { …}
    ./vendor/api-platform/core/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php:62 { …}
    ./var/cache/dev/ContainerT2bhKAf/AppKernelDevDebugContainer.php:30847 {
      ContainerT2bhKAf\AppKernelDevDebugContainer::getApiPlatform_Metadata_Resource_MetadataCollectionFactory_CachedService($container)^
      › 
      ›     return $container->privates['api_platform.metadata.resource.metadata_collection_factory.cached'] = new \ApiPlatform\Metadata\Resource\Factory\CachedResourceMetadataCollectionFactory(($container->privates['api_platform.cache.metadata.resource_collection'] ?? self::getApiPlatform_Cache_Metadata_ResourceCollectionService($container)), new \ApiPlatform\Doctrine\Orm\Metadata\Resource\DoctrineOrmResourceCollectionMetadataFactory($c, new \ApiPlatform\Symfony\Messenger\Metadata\MessengerResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\PhpDocResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\AlternateUriResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\FiltersResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\FormatsResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\InputOutputResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\OperationNameResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\LinkResourceMetadataCollectionFactory($e, new \ApiPlatform\Metadata\Resource\Factory\MainControllerResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\UriTemplateResourceMetadataCollectionFactory($e, new \ApiPlatform\Metadata\Operation\DashPathSegmentNameGenerator(new \ApiPlatform\Metadata\Util\Inflector(true)), new \ApiPlatform\Metadata\Resource\Factory\BackedEnumResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\NotExposedOperationResourceMetadataCollectionFactory($e, new \ApiPlatform\Metadata\Resource\Factory\ExtractorResourceMetadataCollectionFactory(($container->privates['api_platform.metadata.resource_extractor.yaml'] ??= new \ApiPlatform\Metadata\Extractor\YamlResourceExtractor([], $container)), new \ApiPlatform\Metadata\Resource\Factory\ConcernsResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\ExtractorResourceMetadataCollectionFactory(($container->privates['api_platform.metadata.resource_extractor.xml'] ??= new \ApiPlatform\Metadata\Extractor\XmlResourceExtractor([], $container)), new \ApiPlatform\Metadata\Resource\Factory\ParameterResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\DeprecationResourceMetadataCollectionFactory(new \ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory(NULL, $f, $container->parameters['api_platform.defaults'], false)), ($container->privates['api_platform.filter_locator'] ?? self::getApiPlatform_FilterLocatorService($container))), $container->parameters['api_platform.defaults'], $f, false)), $container->parameters['api_platform.defaults'], $f, false)))), true)))), $container->parameters['api_platform.formats'], $container->parameters['api_platform.patch_formats'], $container->parameters['api_platform.error_formats'])))))));
      › }
    }

@xabbuh
Copy link
Contributor Author

xabbuh commented Nov 12, 2024

@lyrixx see api-platform/core#6789

@jaapio
Copy link
Member

jaapio commented Nov 12, 2024

I think the problem is api-platform relies on a specific version but does not enforce it directly? Otherwise composer would have blocked the install.

@xabbuh
Copy link
Contributor Author

xabbuh commented Nov 12, 2024

Yes, that's indeed the cause. API Platform does not restrict the installation of phpstan/phpdoc-parser to a particular version, but the code assumes that the signatures are the ones from version 1.

@ro0NL ro0NL mentioned this pull request Nov 12, 2024
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.

4 participants