brick / reflection Goto Github PK
View Code? Open in Web Editor NEWLow-level tools to extend PHP reflection capabilities
License: MIT License
Low-level tools to extend PHP reflection capabilities
License: MIT License
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.
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);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.