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

Parameter type hint: Unparsable php code #668

Open
fernandopiovezan1 opened this issue Dec 1, 2023 · 0 comments
Open

Parameter type hint: Unparsable php code #668

fernandopiovezan1 opened this issue Dec 1, 2023 · 0 comments

Comments

@fernandopiovezan1
Copy link

Q A
Bug report? yes
Feature request? no
Library version v2.10.0
 <?php

namespace App\Traits;

use Vinkla\Hashids\Facades\Hashids;

/**
 * Trait to decode id value
 */
trait CodeDecodeId
{
    private string|int $id;

    /**
     * Set property id to use in methods inside class
     */
    public function setId(string|int $id): void
    {
        if (env('USE_HASH', true)) {
            $this->id = (int) Hashids::connection('main')->decodeHex($id);
        } else {
            $this->id = (int) $id;
        }
    }
}

I am using the following code for an integer ID to hash conversion. When validating the error Parameter type tip: CodeDecodeId.php:12: Non-parsable php code: syntax error or wrong phpdocs., I have already looked for several solutions to get around this error, but nothing I have done so far has resolved , this occurs in other classes also whether with a simple or compound parameter.
At the moment I have this validation disabled to be able to follow the project, but it would be very interesting to be able to check the typing.
This happens with ParameterTypeHint, PropertyTypeHint.

Laravel: 10.1.0
PHP: 8.2.12

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

No branches or pull requests

1 participant