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

ReflectionClass#isInstantiable() should report false for private constructors #411

Closed
UFOMelkor opened this issue Mar 22, 2018 · 1 comment

Comments

@UFOMelkor
Copy link

Looks like the current implementation of isInstantiable is not compatible with the reflection extension:

<?php
declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';

use Roave\BetterReflection\BetterReflection;

class ClassWithPrivateConstructor
{
    private function __construct()
    {
    }
}

$betterReflector = (new BetterReflection())->classReflector();
var_dump((new ReflectionClass(ClassWithPrivateConstructor::class))->isInstantiable());
var_dump($betterReflector->reflect(ClassWithPrivateConstructor::class)->isInstantiable());

outputs

bool(false)
bool(true)
@kukulich
Copy link
Collaborator

Fixed in #412

@asgrim asgrim added this to the 2.1.0 milestone Mar 22, 2018
@asgrim asgrim closed this as completed Mar 22, 2018
@asgrim asgrim self-assigned this Mar 22, 2018
@Ocramius Ocramius modified the milestones: 2.1.0, 3.0.0 May 10, 2018
@Ocramius Ocramius changed the title IsInstantiable and private constructors ReflectionClass#isInstantiable() should report false for private constructors May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants