<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Nette Framework forum : Development of Nette Framework : Discussion on development : Please test Nette DI 3.3.0-RC1</title>
<link>https://forum.nette.org/en</link>
<description>Nette Framework forum</description>
<language>en</language>
<docs>http://backend.userland.com/rss</docs>
<item>
	<title>Please test Nette DI 3.3.0-RC1 (Discussion on development)</title>
	<dc:creator>David Grudl</dc:creator>
	<link>https://forum.nette.org/en/36995#p229152</link>
	<guid isPermaLink="false">229152@http://forum.nette.org/en</guid>
	<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I&apos;d like to ask you to test &lt;strong&gt;nette/di 3.3.0-RC1&lt;/strong&gt;. It&apos;s a big
release: I&apos;ve rewritten a large part of the compiler, extensions got a new phase
system, and the configuration gained a few things I think you&apos;ll like. I&apos;ll
cover the new features in a blog post; here the point is to find out whether
everything still works for you after upgrading.&lt;/p&gt;

&lt;p&gt;The rewrite is mainly about this: service definitions used to describe
everything with a single &lt;code&gt;Statement&lt;/code&gt; class, whether it was creating
an object, calling a method, reading a property, or a function like
&lt;code&gt;not()&lt;/code&gt;. Now each kind of expression has its own class
(&lt;code&gt;Instantiation&lt;/code&gt;, &lt;code&gt;Call&lt;/code&gt;, &lt;code&gt;PropertyAccess&lt;/code&gt;,
&lt;code&gt;PartialCall&lt;/code&gt; …) with the common parent
&lt;code&gt;Nette\DI\Expression&lt;/code&gt;, and knows how to resolve its own type and
generate its own code. For backward compatibility most of them still extend
&lt;code&gt;Statement&lt;/code&gt;, so code that checks &lt;code&gt;instanceof Statement&lt;/code&gt;
works as before.&lt;/p&gt;

&lt;pre
class=&quot;language-bash&quot;&gt;&lt;code&gt;composer require nette/di:^3.3.0-RC1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It requires PHP 8.3 or newer. It works with the current nette/bootstrap
3.3.1, so you don&apos;t need to change anything else. If you also want to try the
new parameter features (see below), add &lt;strong&gt;nette/bootstrap
3.3.2-RC1&lt;/strong&gt;:&lt;/p&gt;

&lt;pre
class=&quot;language-bash&quot;&gt;&lt;code&gt;composer require nette/bootstrap:^3.3.2-RC1&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;How to test&lt;/h4&gt;

&lt;p&gt;Just delete &lt;code&gt;temp/cache&lt;/code&gt;, run the application and ideally your
tests too. If the container builds and the app runs without new exceptions or
deprecation notices, you&apos;re done. I&apos;m most interested in applications with lots
of third-party extensions, because those reach into the compiler internals, and
that&apos;s where most of the changes are.&lt;/p&gt;

&lt;h4&gt;What might break&lt;/h4&gt;

&lt;p&gt;Things earlier versions only reported as deprecated now throw an exception.
The service type is no longer read from the &lt;code&gt;@return&lt;/code&gt; annotation of a
factory method; declare a native return type.&lt;/p&gt;

&lt;p&gt;For extension authors:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;extensions now do their work in methods marked with the &lt;code&gt;#[Hook]&lt;/code&gt;
	attribute, which attach to compilation phases and replace
	&lt;code&gt;loadConfiguration()&lt;/code&gt;, &lt;code&gt;beforeCompile()&lt;/code&gt; and
	&lt;code&gt;afterCompile()&lt;/code&gt; (see the &lt;a
	href=&quot;https://doc.nette.org/en/dependency-injection/extensions#toc-extension-lifecycle&quot;&gt;documentation&lt;/a&gt;
	and the thread &lt;a href=&quot;https://forum.nette.org/en/36918&quot;&gt;New Phase System for
	Extensions&lt;/a&gt;); the old methods are deprecated, but &lt;strong&gt;of course&lt;/strong&gt;
	they keep working unchanged&lt;/li&gt;

	&lt;li&gt;the built-in extensions (&lt;code&gt;DIExtension&lt;/code&gt;,
	&lt;code&gt;InjectExtension&lt;/code&gt;, &lt;code&gt;SearchExtension&lt;/code&gt;,
	&lt;code&gt;DecoratorExtension&lt;/code&gt;, &lt;code&gt;ParametersExtension&lt;/code&gt;) now do their
	work in &lt;code&gt;#[Hook]&lt;/code&gt; methods, so if you extend one and call e.g.
	&lt;code&gt;parent::beforeCompile()&lt;/code&gt;, nothing happens&lt;/li&gt;

	&lt;li&gt;&lt;code&gt;ServiceDefinition::getCreator()&lt;/code&gt; and &lt;code&gt;getFactory()&lt;/code&gt;
	now declare &lt;code&gt;Nette\DI\Expression&lt;/code&gt; as their return type instead of
	&lt;code&gt;Statement&lt;/code&gt;. In practice they still return a &lt;code&gt;Statement&lt;/code&gt;;
	the only exception is a service written as &lt;code&gt;create: foo(...)&lt;/code&gt;, which
	gives you a &lt;code&gt;PartialCall&lt;/code&gt; that doesn&apos;t extend
	&lt;code&gt;Statement&lt;/code&gt;.&lt;/li&gt;

	&lt;li&gt;&lt;code&gt;Resolver&lt;/code&gt;, &lt;code&gt;PhpGenerator&lt;/code&gt;, &lt;code&gt;Autowiring&lt;/code&gt;
	and &lt;code&gt;DependencyChecker&lt;/code&gt; moved to the &lt;code&gt;Nette\DI\Compiler&lt;/code&gt;
	namespace, &lt;code&gt;Reference&lt;/code&gt; to &lt;code&gt;Nette\DI\Expressions&lt;/code&gt;; the old
	names still work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full list is in the &lt;a
href=&quot;https://doc.nette.org/en/dependency-injection/upgrading#toc-upgrading-to-version-3-3&quot;&gt;upgrade
guide&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;What to look forward to&lt;/h4&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Hooks for extensions:&lt;/strong&gt; instead of three fixed methods, any
	method marked with &lt;code&gt;#[Hook(Phase::Register)]&lt;/code&gt; does the work, and each
	extension declares its own order with &lt;code&gt;before&lt;/code&gt;
	and &lt;code&gt;after&lt;/code&gt;.&lt;/li&gt;

	&lt;li&gt;&lt;strong&gt;Spreading an array into arguments&lt;/strong&gt; with &lt;code&gt;...()&lt;/code&gt;,
	just like &lt;code&gt;...$array&lt;/code&gt; in PHP: &lt;code&gt;- PDO(...(%pdoArgs%))&lt;/code&gt;&lt;/li&gt;

	&lt;li&gt;&lt;strong&gt;Dynamic parameters without a separate method:&lt;/strong&gt; wrap a value
	in &lt;code&gt;Nette\DI\DynamicValue&lt;/code&gt;, pass it to &lt;code&gt;addParameters()&lt;/code&gt;,
	and it won&apos;t be compiled into the container (with nette/bootstrap
	3.3.2-RC1).&lt;/li&gt;

	&lt;li&gt;&lt;strong&gt;Passwords and API keys:&lt;/strong&gt; a file loaded with
	&lt;code&gt;addSecrets()&lt;/code&gt; never ends up in the generated container in
	&lt;code&gt;temp&lt;/code&gt; (with nette/bootstrap 3.3.2-RC1).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A blog post with the details is coming, but you can read all about it in the
documentation today: &lt;a
href=&quot;https://doc.nette.org/en/dependency-injection/extensions#toc-extension-lifecycle&quot;&gt;Extension
Lifecycle&lt;/a&gt;, &lt;a
href=&quot;https://doc.nette.org/en/application/bootstrapping#toc-dynamic-parameters&quot;&gt;Dynamic
Parameters&lt;/a&gt; and &lt;a
href=&quot;https://doc.nette.org/en/application/bootstrapping#toc-passwords-and-api-keys&quot;&gt;Passwords
and API Keys&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If something stops working or you run into an unexpected exception or
deprecation notice, please let me know. Thanks!&lt;/p&gt;
</description>
	<pubDate>Thu, 03 Dec 2026 07:42:12 +0100</pubDate>
</item>
</channel>
</rss>
