Skip to content

Bump to type-resolver 2.0 #722

@Bloemendaal

Description

@Bloemendaal

Hi!

I'm experiencing this issue: phpDocumentor/TypeResolver#180 and it seems to be resolved in version 2.0. I have a docblock at a param for a class that is generic, but is not a collection. Since the type resolver expects it to be a collection, the Symfony object normaliser throws an error because the types won't match. I've been debugging this issue for hours now and I don't really see an option in my current code except removing this docblock and ignoring the phpstan errors...

Do you expect to release this soon? And if so, do you expect it to be a major bump? Because spatie/laravel-data depends on the package v6.

Example:

<?php

/**
 * @template T of MyInterface
 */
class MyGenericClass
{
    /**
     * @param T $myValue
     */
    public function __construct(
        protected readonly MyInterface $myValue,
    ) {}
}

And then the place that gets serialized, in my case an event in spatie/laravel-event-sourcing

<?php

use Spatie\EventSourcing\StoredEvents\ShouldBeStored;

class MyEvent extends ShouldBeStored
{
    /**
     * @param MyGenericClass<MyImplementedInterface> $myEventValue
     */
    public function __construct(
        public readonly MyGenericClass $myEventValue,
    ) {}
}

It'll now say that the expectedType is MyImplementedInterface[], which is incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions