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

Reflection isDefaultValueAvailable() method seems to not work as expected #1134

Closed
pgaultier opened this issue Nov 30, 2015 · 1 comment · Fixed by #2225
Closed

Reflection isDefaultValueAvailable() method seems to not work as expected #1134

pgaultier opened this issue Nov 30, 2015 · 1 comment · Fixed by #2225
Assignees
Labels
Milestone

Comments

@pgaultier
Copy link
Contributor

pgaultier commented Nov 30, 2015

Hi,

Problem :
the reflection method isDefaultValueAvailable() return false instead of true

Example to show the problem.
I have the following class in zephir :

namespace demo;
class Test 
{
    private data;
    public function __construct(array config = [])
    {
        let this->data = config;
    }
}

code compile as expected but reflexion fail :

    $ref = new ReflectionClass('\demo\Test');
    $constructor = $ref->getConstructor();
    $params = $constructor->getParameters();
    var_dump(
        $params[0]->getName(),
        $params[0]->isOptional(),
        $params[0]->isDefaultValueAvailable()
    );

this code output :

string 'config' (length=6)
boolean true
boolean false   <- the default value flag is *not* set

Now, sample code in PHP to show what I'm really expecting
I have the following class in php

    class Test {
        private $data;
        public function __construct(array $config = [])
        {
            $this->data = $config;
        }
    }

I test it with the same code

    $ref = new ReflectionClass('Test');
    $constructor = $ref->getConstructor();
    $params = $constructor->getParameters();
    var_dump(
        $params[0]->getName(),
        $params[0]->isOptional(),
        $params[0]->isDefaultValueAvailable()
    );

and I get what I'm expecting

string 'config' (length=6)
boolean true
boolean true   <- the default value flag is set

Am'I doing something wrong in my zephir code ?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@kse300489
Copy link

Yes, because default value, generate C code when method called. I think this error cannot be resolved.

@Jeckerson Jeckerson added the bug label Apr 13, 2021
@Jeckerson Jeckerson added this to the 0.13.x milestone Apr 13, 2021
@Jeckerson Jeckerson modified the milestones: 0.13.x, 0.13.3 Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
…ULT_VALUE`

When there is default value
Jeckerson added a commit that referenced this issue Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
@Jeckerson Jeckerson self-assigned this Apr 20, 2021
@Jeckerson Jeckerson linked a pull request Apr 20, 2021 that will close this issue
3 tasks
Jeckerson added a commit that referenced this issue Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
Jeckerson added a commit that referenced this issue Apr 20, 2021
AlexNDRmac added a commit that referenced this issue Apr 21, 2021
#1134 - Fix default value detection with `Reflection`
@Jeckerson Jeckerson mentioned this issue Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants