Coder Social home page Coder Social logo

reflection's People

Contributors

benmorel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

reflection's Issues

use of object instead of string

in this example:

use Brick\Reflection\ImportResolver;

$class = new ReflectionClass(App\Test::class);
$resolver = new ImportResolver($class);

echo $resolver->resolve('\Some\FQCN\Class'); // Some\FQCN\Class
echo $resolver->resolve('Something'); // App\Something
echo $resolver->resolve('Something\Else'); // App\Something\Else
echo $resolver->resolve('Bar'); // Foo\Bar
echo $resolver->resolve('Bar\tender'); // Foo\Bar\tender
echo $resolver->resolve('Alias'); // Foo\Bar\Baz
echo $resolver->resolve('Alias\ooka'); // Foo\Bar\Baz\ooka

you are using a string of the declared class: App\Test::clas

Can you extend your class to parse objects in which the instance of a class is stored?

$class = new ReflectionClass($classObject);

Bug in exportFunction when parameter has no type

When parameter has no type, the exportFunction method assigns a nullable sign on the parameter.
Example:

public function offsetGetForModifying($offset)

is exported as:

public function offsetGetForModifying(?$offset)

To resolve the issue, you should move the verification for nullable parameters, so this verification is placed inside the verification for the parameter type:

Before my proposed modification:
// File: ReflectionTools.php(324)

if ($parameter->allowsNull() && ! $parameter->isDefaultValueAvailable()) {
    $result .= '?';
}

if (null !== $type = $parameter->getType()) {
    if (! $type->isBuiltin()) {
        $result .= '\\';
    }

    $result .= $type->getName() . ' ';
}

After my proposed modification:
// File: ReflectionTools.php(324)

if (null !== $type = $parameter->getType()) {
    if ($parameter->allowsNull() && ! $parameter->isDefaultValueAvailable()) {
        $result .= '?';
    }

    if (! $type->isBuiltin()) {
        $result .= '\\';
    }

    $result .= $type->getName() . ' ';
}

I hope I made myself clear with my not-so-good English. But if you have any doubts, we could talk more.
And I thank you for the great tool you made, it saved me hours of development of a function to export a ReflectionFunction signature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.