kdyby / autowired Goto Github PK
View Code? Open in Web Editor NEWSyntax sugar for working with services in Nette Framework
Home Page: https://packagist.org/packages/kdyby/autowired
License: Other
Syntax sugar for working with services in Nette Framework
Home Page: https://packagist.org/packages/kdyby/autowired
License: Other
I tried to write a trait with its own dependencies and for laziness I used the @autowire
annotation in that trait. Turns out it only works with fully-qualified @var
annotation but not with use statements.
The reason is that if the property was declared in a trait, ReflectionProperty::getDeclaringClass()
returns the class that uses the trait, not the trait itself. Because of that the use statements are read from wrong file.
More information about the topic as well as possible solution is here: http://mouf-php.com/blog/php_reflection_api_traits
Should I send a PR using the solution from the article above or are you against such solution?
Could you please create stable tags for Nette 2.2 version that contains 1723f8f?
And maybe for 2.1 too? :-)
nette/*
to absolute minimumHaving @var \Nette\Localization\ITranslator|\App\Translator
leads to a weird exception Class "Nette\Localization\ITranslator|\App\Translator" was not found
.
I would like to ask you what are the differences between Kdyby/Autowired
and @inject
annotation used in Nette. To me it looks like Kdyby/Autowired
was created before @inject
annotation was impemented into Nette so it is "useless" now.
Only differences I can see is that you can't @inject
into protected methods (which is more or less just semantic approach) and that there is some "magic" with component factories in Kdyby/Autowired
which I don't clearly understand.
I would appreciate your help here, @hosiplan :-) Thank you for your time.
Hi,
is there any reason why to limit usage only for Components:
if (! $this instanceof Nette\Application\UI\Component) {
throw new MemberAccessException('Trait ' . __TRAIT__ . ' can be used only in descendants of ' . Nette\Application\UI\Component::class . '.');
}
?
I'm using it (successfully) also in Symfony Console Commands.
Thank you for your opinion.
Argument 1 passed to App\Presenters\Base::validateProperty() must be an instance of Nette\Reflection\Property, instance of ReflectionProperty given, called in ..../vendor/kdyby/autowired/src/Kdyby/Autowired/AutowireProperties.php on line 78
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.