`9.0.0-beta8 (2024-04-21) <https://github.com/neos/flow-development-collection/releases/tag/9.0.0-beta8>`_
==========================================================================================================

Overview of merged pull requests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`FEATURE: introduce `UriHelper` to work with query parameters <https://github.com/neos/flow-development-collection/pull/3316>`_
-------------------------------------------------------------------------------------------------------------------------------

FYI: This pr was refactored again via https://github.com/neos/flow-development-collection/pull/3336

While working on https://github.com/neos/flow-development-collection/pull/2744 and also https://github.com/neos/neos-development-collection/issues/4552 we always came to the conclusion that the ``$queryParameters`` merging of the psr uri is limited.

This introduces a utility to do this:


```php
UriHelper::uriWithAdditionalQueryParameters($this->someUriBuilder->uriFor(...), ['q' => 'search term']);
```

and allows us to remove any $queryParam logic from the uribuilder(s)

**Upgrade instructions**


* Packages: ``Flow``

`FEATURE: Add `Flow\Route` Attribute/Annotation <https://github.com/neos/flow-development-collection/pull/3325>`_
-----------------------------------------------------------------------------------------------------------------

The ``Flow\\Route`` attribute allows to define routes directly on the affected method. This allows to avoid dealing with Routes.yaml in projects in simple cases where is sometimes is annoying to look up the exact syntax for that.

Usage:

```php
use Neos\\Flow\\Mvc\\Controller\\ActionController;
use Neos\\Flow\\Annotations as Flow;

class ExampleController extends ActionController
{
    #[Flow\\Route(uriPattern:'my/path', httpMethods: ['GET'])]
    public function someAction(): void
    {
    }

    #[Flow\\Route(uriPattern:'my/other/b-path', defaults: ['test' => 'b'])]
    #[Flow\\Route(uriPattern:'my/other/c-path', defaults: ['test' => 'c'])]
    public function otherAction(string $test): void
    {
    }
}
```

To use annotation routes packages have to register the ``AttributeRoutesProviderFactory`` in ``Neos.Flow.mvc.routes`` with Controller classNames or patterns.

Settings.yaml:
```yaml
Neos:
  Flow:
    mvc:
      routes:
        Vendor.Example.attributes:
          position: 'before Neos.Neos'
          providerFactory: \\Neos\\Flow\\Mvc\\Routing\\AttributeRoutesProviderFactory
          providerOptions:
            classNames:
              - Vendor\\Example\\Controller\\ExampleController
```

This pr also adds the general option to register ``provider`` and ``providerOptions`` in  the Setting ``Neos.Flow.mvc.routes`` which was required obviously.

The package: ``WebSupply.RouteAnnotation`` by @sorenmalling implemented similar ideas earlier.

* Resolves: `#2059 <https://github.com/neos/flow-development-collection/issues/2059>`_

**Upgrade instructions**

**Review instructions**

Alsow see: `#3324 <https://github.com/neos/flow-development-collection/issues/3324>`_resolving #2060, both solutions ideally would work hand in hand


* Packages: ``Flow``

`FEATURE: InjectConfiguration for constructor arguments <https://github.com/neos/flow-development-collection/pull/3086>`_
-------------------------------------------------------------------------------------------------------------------------

Flow now supports InjectConfiguration attributes for constructor arguments which allows for injecting configuration, such as settings, via the constructor. Compared to property injection, constructor injection results in more portable and better testable code.

* Resolves: `#3077 <https://github.com/neos/flow-development-collection/issues/3077>`_

* Packages: ``Flow``

`FEATURE: Introduce PHP 8.2 DNF type support <https://github.com/neos/flow-development-collection/pull/3328>`_
--------------------------------------------------------------------------------------------------------------

The Reflection Service now supports Disjunctive Normal Form (DNF) types for method arguments.

See: https://www.php.net/releases/8.2/en.php#dnf_types

* Resolves: `#3026 <https://github.com/neos/flow-development-collection/issues/3026>`_

* Packages: ``Flow``

`FEATURE: Separate RouteConfiguration from Router <https://github.com/neos/flow-development-collection/pull/2970>`_
-------------------------------------------------------------------------------------------------------------------

This separates the Routes configuration from the router by introducing a ``RoutesProviderInterface`` which will be used by the router implementation together with a ``ConfigurationRoutesProvider`` that implements the current configuration from Routes.yaml. 

Switching out the internal implementation of the ``RoutesProviderInterface`` can be done via Objects.yaml to add custom behaviour. But be aware that this is not covered by our api promises. All Implementations should include the routes provided by the ``ConfigurationRoutesProvider``.

This change also makes sure, that the RouteCommandController uses the current ``RoutesProviderInterface`` implementation, instead of hard coded Flow router. That ensures that all Routes available to the router are now also visible to route cli-commands.

* Fixes: `#2948 <https://github.com/neos/flow-development-collection/issues/2948>`_

**Upgrade instructions**

This change removes the methods ``getRoutes`` and ``addRoute`` from the Router that previously were mainly used in functional-tests as they were never part of the Router Interface. 

To adjust for that the existing utility ``FunctionalTestCase->registerRoute`` method has to be used instead of ``FunctionalTestCase->router->addRoute``.

The method ``Router::setRoutesConfiguration``, which was also previously used for internal testing has been removed without official replacement. You _could_ technically inject a custom routes provider to do so but be aware that this is internal behaviour.

**Review instructions**

Run the ./flow routing:list command - you will see the list as expected


* Packages: ``Flow``

`FEATURE: Consider PHP attributes in proxy method building <https://github.com/neos/flow-development-collection/pull/3265>`_
----------------------------------------------------------------------------------------------------------------------------

Added support for preserving PHP 8 attributes in generated proxy class methods. This feature enables correct argument passing from attributes to proxied methods which allows developers to use attributes instead of annotations in most cases.

* Resolves: `#3075 <https://github.com/neos/flow-development-collection/issues/3075>`_

* Packages: ``Flow``

`FEATURE: Add `Flow\InjectCache` Attribute / Annotation for property injection <https://github.com/neos/flow-development-collection/pull/3244>`_
------------------------------------------------------------------------------------------------------------------------------------------------

In many cases an ``Objects.yaml`` is created just to inject caches which can feel a bit cumbersome as one already had specified the cache in ``Caches.yaml``.

To address this the new ``@Flow\\InjectCache`` annotation allows to assign a cache frontend of a configured cache directly to a property without having to configure the ``Objects.yaml`` at all.

```php
    #[Flow\\InjectCache(identifier: 'Flow_Mvc_Routing_Resolve')]
    protected VariableFrontend $cache;
```


* Packages: ``Flow``

`FEATURE: Add more information for object arguments in debugging <https://github.com/neos/flow-development-collection/pull/3211>`_
----------------------------------------------------------------------------------------------------------------------------------

For stacktraces in exceptions and logs we now render some representation of content for objects to ease debugging with DTOs.

Specifically we will try to obtain a string representation for such an object by using either in this order:

- a string cast if __toString() is available
- json_encode if it is JsonSerializable
- json_encode on the array of public properties

For readability json_encode will be limited to the first level, also all of those string representations will be cut off after 100 characters.

If any of those options works we will also shorten the className to avoid this output becoming overly long.

Note that we use JSON_PARTIAL_OUTPUT_ON_ERROR to make sure some output is provided. This might lead to partial or weird outputs depending on the object structure, but might still provide pointers for debugging.

* Fixes: `#3165 <https://github.com/neos/flow-development-collection/issues/3165>`_

* Packages: ``Flow``

`9.0 FEATURE: Add `unique` flowQuery operation <https://github.com/neos/flow-development-collection/pull/3102>`_
----------------------------------------------------------------------------------------------------------------

This operation applies ``array_unique`` to the current flowQuery context.

While the same could previously achieved via ``Array.unique()`` the flow query operation can be placed in an operation chain without extra wrapping.

**Review instructions**

There is also a node specific implementation of the ``unique`` operation in https://github.com/neos/neos-development-collection/pull/4355

I know the php code looks oldish but the style is in line with the other flowQuery operations around. 


* Packages: ``Eel``

`FEATURE: Add `getAccessorByPath` to `Neos\Utility\Arrays` for type safe accessing of array values <https://github.com/neos/flow-development-collection/pull/3149>`_
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

The array utility allows to create a type safe accessor via ``Arrays::getAccessorByPath($arrayValue, 'your.path')``. The accessor provides the following methods that will either return the requested type or throw a ``\\UnexpectedValueException``.  

* ``int(): int``
* ``float(): float``
* ``number(): int|float``
* ``string(): string``
* ``classString(): string`` - with annotation for class-string
* ``array(): array``
* ``instanceOf(string $className): object`` - with annotation for dynamic type
* ``intOrNull(): ?int``
* ``floatOrNull(): ?float``
* ``numberOrNull(): null|int|float``
* ``stringOrNull(): ?string``
* ``classStringOrNull(): ?string`` - with annotation for class-string | null
* ``arrayOrNull(): ?array``
* ``instanceOfOrNull(string $className): ?object`` - with annotation for dynamic type | null

This will allow to write code that accesses settings via pathes without checking every level for existence still beeing type safe and accessible for static analysis.

This can be used together with settingInjection.

```php
public function injectSettings(array $settings): void
{
   $this->limit = Arrays::getAccessorByPath($settings, 'limit')->intOrNull();
}
```

* Resolves: `#3164 <https://github.com/neos/flow-development-collection/issues/3164>`_

**Review instructions**

It may look inefficient to manually throw TypeErrors that in many cases would be thrown automatically because of the declared return types. However this is not a performance issue as those are never on the happy-path and the created TypeError provides additional informations to help understand and fix problems faster.

Inspired by https://github.com/PackageFactory/extractor


* Packages: ``Flow`` ``Utility.Arrays``

`FEATURE: Exclude classes from constructor autowiring <https://github.com/neos/flow-development-collection/pull/3070>`_
-----------------------------------------------------------------------------------------------------------------------

Classes can now explicitly be excluded from constructor autowiring through a new setting.

The setting accepts an array of fully qualified class names, each class name being a regular expression. Classes of scope prototype which expect objects to be passed to their constructor are usually considered for autowiring which results in a proxy class being generated.

This option allows to exclude classes from this process. This is useful for classes like data transfer objects, read models, commands, events and value objects which usually don't rely on dependency injection.

Flow cannot reliably detect weather a prototype class depends on autowiring for constructor arguments or not. Use this option to optimize your application to avoid the small but measurable overhead of proxy generation for those kinds of classes.

Note that if there are other reasons than constructor injection which require a proxy class to be generated, the proxy class will be generated no matter what.

This change partly reverts `#3050 <https://github.com/neos/flow-development-collection/issues/3050>`_because now proxy classes _are_ generated for prototype classes by default. Otherwise a lot of existing Flow applications would not work correctly anymore.

resolves: #3049

* Packages: ``Flow``

`FEATURE: Replace self with static in proxy classes <https://github.com/neos/flow-development-collection/pull/3074>`_
---------------------------------------------------------------------------------------------------------------------

Factory methods which use code like new self() for creating a new instance are now handled correctly in proxy classes. The compiler automatically replaces "self" keywords with "static" in the rendered proxy class file to make this possible.

This implementation has not been optimized for performance.

* Resolves: `#3059 <https://github.com/neos/flow-development-collection/issues/3059>`_

* Packages: ``Flow``

`FEATURE: Support private constructors in proxy classes <https://github.com/neos/flow-development-collection/pull/3072>`_
-------------------------------------------------------------------------------------------------------------------------

Flow now can correctly build proxy classes for classes with private constructors. Previously, such classes caused errors and proxy class building had to be disabled with the ``Proxy(false)`` annotation. Now classes with private constructors can take advantage of setter and property injection and are considered for advices through the AOP framework.

* Resolves: `#3058 <https://github.com/neos/flow-development-collection/issues/3058>`_

* Packages: ``Flow``

`FEATURE: Add support for readonly classes <https://github.com/neos/flow-development-collection/pull/3051>`_
------------------------------------------------------------------------------------------------------------

Flow now respects readonly classes during proxy class building and makes sure that proxy classes are readonly as well.

resolves: #3025

* Packages: ``Flow``

`!!!BUGFIX: Make any exception handable in renderingGroups by statusCode <https://github.com/neos/flow-development-collection/pull/1514>`_
------------------------------------------------------------------------------------------------------------------------------------------

Before only exceptions that derive from FlowException could be handled with renderingGroups. This sets the status code for unknown exceptions to 500, so they will match a ``matchingStatusCodes`` configuration.
Therefore a configuration like this will now also render generic exceptions as if they were FlowExceptions with a status code of 500:
```yaml
Neos:
  Flow:
    error:
      exceptionHandler:
        renderingGroups:

          'allExceptions':
            matchingStatusCodes: [500]
            options:
              templatePathAndFilename: 'some-path'
```

Note: This is slightly breaking if you handled Flow Exceptions differently than generic exceptions. If you do want to render Flow exceptions differently then generic exceptions, the way to do this is:

```yaml
Neos:
  Flow:
    error:
      exceptionHandler:
        renderingGroups:

          'flowExceptions':
            matchingExceptionClassNames: ['FlowException']
            options:
              templatePathAndFilename: 'some-path'

          'notFound':
            matchingStatusCodes: [404]
            options:
              templatePathAndFilename: 'specific-code-path'

          'otherExceptions':
            matchingExceptionClassNames: ['Exception']
            options:
              templatePathAndFilename: 'some-other-path'
```

The first matching group will be used.

* Packages: ``Flow``

`BUGFIX: Make new object debug output more robust <https://github.com/neos/flow-development-collection/pull/3233>`_
-------------------------------------------------------------------------------------------------------------------

Unfortunately magic methods are tricky and __toString is no exception, a check if it's callable can result in true if the magic __call method is implemented but then the results of this call are completely undefined and therefore catching errors and continuing with other options is a good safeguard here.

Noticed this when I had an error in the ``Mvc\\Arguments`` implementation which declares __call.

* Packages: ``Flow``

`BUGFIX: Use correct exception class <https://github.com/neos/flow-development-collection/pull/3209>`_
------------------------------------------------------------------------------------------------------

Fix the use of an exception class that is no longer where it was.


* Packages: ``Flow``

`BUGFIX: Replacement proxy methods rendered again <https://github.com/neos/flow-development-collection/pull/3101>`_
-------------------------------------------------------------------------------------------------------------------

This fixes a bug introduced in d939e6b8 switching to laminuas-code. A proxy method can replace the full body of an existing method or even be a fully new method, in which case only ``body`` will be set in the proxy method. We still want those to be generated. This for example currently breaks the CompileStatic feature, as those methods do not get rendered anymore resulting in worse performance in Production context compared to before.

This fix renders a proxy method also when a body was set for it, but still skips it if neither pre/post nor body is set.

It also enabled CompileStatic in Testing Context so that it is testable and adds a test to make sure it works as intended.

* Fixes: `#3099 <https://github.com/neos/flow-development-collection/issues/3099>`_

* Packages: ``Flow``

`BUGFIX: Remove injected properties before serialization <https://github.com/neos/flow-development-collection/pull/3067>`_
--------------------------------------------------------------------------------------------------------------------------

This fixes a regression introduced recently which resulted in serialization errors if the object to be serialized contained properties which were previously injected.

* Resolves: `#3066 <https://github.com/neos/flow-development-collection/issues/3066>`_

* Packages: ``Flow``

`BUGFIX: Support mixed return type in proxied methods <https://github.com/neos/flow-development-collection/pull/3065>`_
-----------------------------------------------------------------------------------------------------------------------

Flow's proxy class building now supports mixed return types for methods.

This change merely adds a test which proves that the feature is working. The actual implementation was part of https://github.com/neos/flow-development-collection/issues/3042.

resolves: https://github.com/neos/flow-development-collection/issues/2899

* Packages: ``Flow``

`BUGFIX: Union types in proxy classes <https://github.com/neos/flow-development-collection/pull/3057>`_
-------------------------------------------------------------------------------------------------------

Flow's proxy class building now supports union types in method signatures.

This change merely adds a test which proves that the feature is working. The actual implementation was part of #3042.

resolves: #2941

* Packages: ``Flow``

`BUGFIX: Create serialization code for transient properties <https://github.com/neos/flow-development-collection/pull/3063>`_
-----------------------------------------------------------------------------------------------------------------------------

Due to a recent optimization, Flow was not generating ``__sleep()`` methods for classes which are not either entities or were configured with a session scope. This led to errors in classes which were using the ``@Transient`` annotation to exclude certain properties from serialization. Therefore, Flow now also generates proxy classes with ``__sleep()`` methods if the original class contains such annotations.

* Resolves: `#3062 <https://github.com/neos/flow-development-collection/issues/3062>`_

* Packages: ``Flow``

`BUGFIX: Skip proxy for optional straight values <https://github.com/neos/flow-development-collection/pull/3052>`_
------------------------------------------------------------------------------------------------------------------

When a promoted property was an optional straight value, the proxy class builder decided to create a proxy class because it could be a straight value configured in the object configuration via Objects.yaml. Flow now checks the value of the given argument and only triggers proxy class building if the argument is not null. That way, Flow will not build useless proxies for typical read models which expect a mix of objects and straight values in their constructor.

related: `#1539 <https://github.com/neos/flow-development-collection/issues/1539>`_
related: `#3049 <https://github.com/neos/flow-development-collection/issues/3049>`_

* Packages: ``Flow``

`BUGFIX: Move access to objectAccess of TemplateObjectAccessInterface into getByPath <https://github.com/neos/flow-development-collection/pull/3041>`_
------------------------------------------------------------------------------------------------------------------------------------------------------

... as accessors are not used anymore for variable provider within fluid, starting v2.8.0.

Due to the missing accessors the ``objectAccess`` of ``TemplateObjectAccessInterface`` didn't get called anymore, so the result of the ``getByPath`` method was an object of ``FusionPathProxy`` instead of an rendered string.

See: 
https://github.com/TYPO3/Fluid/compare/2.7.4...2.8.0#diff-`a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c <https://github.com/neos/flow-development-collection/commit/a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c>`_a408286f91a846e495b3c766L122
https://github.com/TYPO3/Fluid/compare/2.7.4...2.8.0#diff-`a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c <https://github.com/neos/flow-development-collection/commit/a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c>`_a408286f91a846e495b3c766L341
https://github.com/TYPO3/Fluid/compare/2.7.4...2.8.0#diff-`a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c <https://github.com/neos/flow-development-collection/commit/a0aa72aa19d9eb57cdb9a4dcd344c3706d75ae7c>`_a408286f91a846e495b3c766L312


* Packages: ``FluidAdaptor``

`!!! TASK: Refactor uri helpers <https://github.com/neos/flow-development-collection/pull/3336>`_
-------------------------------------------------------------------------------------------------

* See: `#3316 <https://github.com/neos/flow-development-collection/issues/3316>`_

**Upgrade instructions**

The following methods were removed from the ``UriHelper`` as they are obsolete and not used.
Its unlikely that the functionality is known and simple to implement yourself.
- ``\\Neos\\Flow\\Http\\Helper\\UriHelper::getUsername``
- ``\\Neos\\Flow\\Http\\Helper\\UriHelper::getPassword``
- ``\\Neos\\Flow\\Http\\Helper\\UriHelper::parseQueryIntoArguments``

The method ``\\Neos\\Flow\\Http\\Helper\\UriHelper::uriWithArguments`` was renamed to ``\\Neos\\Flow\\Http\\Helper\\UriHelper::uriWithQueryParameters`` to distinct between route values and query parameters which are not the same.
Also it will encode the query parameters after `PHP_QUERY_RFC1738 <https://www.php.net/manual/de/url.constants.php#constant.php-query-rfc1738>`_.

**Review instructions**

The pr `#3316 <https://github.com/neos/flow-development-collection/issues/3316>`_introduced a new uri helper while we already had one actually. This pr combines the two and cleans things up.

To ensure the logic of ``uriWithAdditionalQueryParameters`` is not duplicated and possibly handled elsewhere differently the helper is now also used internally by the uriConstraints.

Also the method has been renamed to better fit the previous sibling ``uriWithArguments``.

The removed methods are dead code and previously introduced once with Flow 5.1: https://github.com/neos/flow-development-collection/commit/`85408589462b7530180d3dce2858500f29f94bbe <https://github.com/neos/flow-development-collection/commit/85408589462b7530180d3dce2858500f29f94bbe>`_
As part of replacements for the old (now removed) flow Uri implementation:

``Neos\\Flow\\Http\\Uri::getUsername`` -> ``\\Neos\\Flow\\Http\\Helper\\UriHelper::getUsername``
``Neos\\Flow\\Http\\Uri::getPassword`` -> ``\\Neos\\Flow\\Http\\Helper\\UriHelper::getPassword``
``Neos\\Flow\\Http\\Uri::getArguments`` -> ``\\Neos\\Flow\\Http\\Helper\\UriHelper::parseQueryIntoArguments``

So maybe these methods _are_ known in fact and it would be a bit mean to remove them just because i felt like it and we dont use / test them?


* Packages: ``Flow``

`!!! TASK: Modernize and clean up session-related code <https://github.com/neos/flow-development-collection/pull/3330>`_
------------------------------------------------------------------------------------------------------------------------

The session-related code in Flow was updated to use modern PHP features and attributes. Classes are also declared as strict and a few minor bugs which surfaced due to type strictness were fixed along the way.

This change is breaking for anyone who implemented their own implementation of ``SessionInterface`` or ``SessionManagerInterface``because parameter and return types were added. It's very easy to solve though.

* Packages: ``Flow``

`!!! TASK: Make `QueryInterface::logicalAnd` variadic <https://github.com/neos/flow-development-collection/pull/3276>`_
-----------------------------------------------------------------------------------------------------------------------

_If_ someone implemented the ``QueryInterface``, the implementation must now use conventional variadic parameters instead of legacy ``func_get_args``

This allows phpstan to understand the code ;)

* Packages: ``Flow``

`!!! TASK: Fix `TextIterator::following` and `preceding` <https://github.com/neos/flow-development-collection/pull/3278>`_
--------------------------------------------------------------------------------------------------------------------------

Accidentally they have been typed wrongly. First in phpdoc, which is harmless and later actual types introduced in https://github.com/neos/flow-development-collection/commit/`70b671228ee4f66c54fb7fbfa390aac12b5a71c5 <https://github.com/neos/flow-development-collection/commit/70b671228ee4f66c54fb7fbfa390aac12b5a71c5>``_#diff-``947f5937b1e181a6e4ae7bb23349d22d839b073a <https://github.com/neos/flow-development-collection/commit/947f5937b1e181a6e4ae7bb23349d22d839b073a>`_07104b884c08583cc12f63df enforced that.

The tests didnt fail, because as strict types were not enabled php just cast the int's to string.

The tests, also casting when using assertEquals, didnt notice that.


This is required in preparation for https://github.com/neos/flow-development-collection/pull/3261

* Packages: ``Flow`` ``Utility.Unicode``

`!!! TASK: Introduce `TargetInterface::onPublish` callback <https://github.com/neos/flow-development-collection/pull/3229>`_
----------------------------------------------------------------------------------------------------------------------------

Currently every implementation of the ``TargetInterface::publishCollection`` should declare a second parameter: ``callable $callback = null`` which not part of the interface, but used by convention. This pattern causes trouble when using phpstan and also it’s not best practice. To improve this code and preserve the usecase partially the interface now allows to register ``onPublish`` callbacks, which should be called when ``publishCollection`` is run:

```php
interface TargetInterface
{
     // ...

     /**
      * @param \\Closure(int $iteration): void $callback Function called after each resource publishing
      */
     public function onPublish(\\Closure $callback): void;
}
```

**Upgrade instructions**

In case you are using the callback, you need to adjust the calling side:

```diff
- $fileSystemTarget->publishCollection($staticCollection, $myPublicationCallback);
+ $fileSystemTarget->onPublish($myPublicationCallback);
+ $fileSystemTarget->publishCollection($staticCollection);
```

Also note that the second parameter ``$object`` will not be passed anymore. The callback only contains the ``$iteration`` as one and only parameter.

Additionally the method ``iterate(…)`` in the ``ResourceRepository`` has been removed, replace it by iterating over the result of ``findAllIterator()`` directly.


* Packages: ``Flow``

`!!! TASK: Modernized code style in ReflectionService <https://github.com/neos/flow-development-collection/pull/2914>`_
-----------------------------------------------------------------------------------------------------------------------

Code in the reflection service was adjusted to the current code style best practices. 

The method arguments in the Reflection Service are now strictly typed. Therefore, third-party code which relied on loose types and passes invalid types, need to be adjusted. Tests in the Flow package were adjusted were necessary.

As part of the clean up, the setStatusCache() method in ReflectionService was fixed which used a wrong order of parameters in its is_callable() call.

Preparation for #2913

* Packages: ``Flow``

`!!! TASK: Require PHP 8.2 <https://github.com/neos/flow-development-collection/pull/3040>`_
--------------------------------------------------------------------------------------------

The minimum requirement for the Flow Framework, including all packages of its distribution, was raised to PHP 8.2.

* Packages: ``Flow`` ``Utility.ObjectHandling``

`TASK: Introduce internal flow package key value object <https://github.com/neos/flow-development-collection/pull/3338>`_
-------------------------------------------------------------------------------------------------------------------------

**Upgrade instructions**

**Review instructions**

The concept around the flow package key might be dated, still major parts rely on this and we could use a little strict typing around ^^

Also possible refactoring in the future to a composer key might be easier if phpstan can tell us the difference between the types instead of refactoring one string to another.


* Packages: ``Flow``

`TASK: Deprecate BaseTestCase functionalities <https://github.com/neos/flow-development-collection/pull/3309>`_
---------------------------------------------------------------------------------------------------------------

Flow has a custom extension of php unit mocks, that comes from times of typo3.
Via the accessibly proxy it allows for calling even protected methods and access of protected properties.

The usage and retrieval ``BaseTestCase::getAccessibleMock()`` has been deprecated as one should not use this for testing. It will lead to a super high coupling of the tests to the super internal implementation which makes refactoring basically impossible (without rewriting major parts of the tests).
In Neos.Neos we see this very well because we are just removing these tests and rewriting them in behat for Neos 9 :D. 

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Declare `ValueAccessor` as experimental for now <https://github.com/neos/flow-development-collection/pull/3332>`_
------------------------------------------------------------------------------------------------------------------------

The feature introduce with https://github.com/neos/flow-development-collection/pull/3149 will be marked internal and experimental for now before the stable release of Flow 9.0

my reasons for this are
- the feature is not necessary scoped to arrays so ``Neos\\Utility\\Arrays`` might not be the best location
- copy further features from https://github.com/PackageFactory/extractor especially accessing deep array structures with good exceptions: https://github.com/PackageFactory/extractor/blob/`b8a135dbd95c3a51a26787063981ce2454b81dd6 <https://github.com/neos/flow-development-collection/commit/b8a135dbd95c3a51a26787063981ce2454b81dd6>`_/src/Extractor.php#L335
    - or just take the code 1 to 1
- the naming ``ValueAccessor`` vs ``Extractor``
- ``Arrays::getAccessorByPath($array, 'path.bar')->int()`` vs ``ValueAccessor::for($array)['path']['bar']->int()``
    - im not sure about if we want to propagate the dot access pattern forever ;)
- we currently dont use the ``ValueAccessor`` ourselves in the code base and thus don't know yet if the api really makes things easier
- it doesn't support forgiving casting / access like ``stringOrIgnore``
- how to integrate this for validating configuration? https://github.com/neos/flow-development-collection/issues/3043


**Upgrade instructions**


* Packages: ``Utility.Arrays``

`TASK: Improve help text for doctrine:migrate <https://github.com/neos/flow-development-collection/pull/3268>`_
---------------------------------------------------------------------------------------------------------------

Most users probably didn't know that it is possible to use "prev" or "next" as version names for `./flow doctrine:migrate --version'. This is now documented as part of the help message and additionally the version alias "previous" is automatically converted to "prev" internally.

* Packages: ``Flow``

`TASK: Remove code related to PHP < 8.2 <https://github.com/neos/flow-development-collection/pull/3329>`_
---------------------------------------------------------------------------------------------------------

Code supporting backwards-compatibility with PHP versions earlier than 8.2 were removed, since the minimum required version for Flow is 8.2.

* Resolves: `#3085 <https://github.com/neos/flow-development-collection/issues/3085>`_

* Packages: ``Flow``

`TASK: Refactor and optimize of session data storage <https://github.com/neos/flow-development-collection/pull/3254>`_
----------------------------------------------------------------------------------------------------------------------

Before the SessionMetadata and SessionData was written with every request which caused network traffic, storage wear and also made race conditions much more likely when parallel requests changed session data. 

In total this can reduce the number of write operations on the Session caches by 80-90% removing storage and network load as those caches always are persistent and shared across clusters.

1. The improvements are on top of the Neos 9 already reducing the Flow_Session_Storage write load by not always storing the "lastVisitedNode" in the session.
2. The improvements mostly occur after sending the result "onShutdown" so this will not improve single requests but overall performance and number of parallel requests.

## 1. SessionMetadataStore / Flow_Session_MetaData

### Problem 

The session metadata (SessionId, StorageId, LastActivity .. ) is usually written at shutdown of every single request to the session metadata cache even when nothing changed. 

### Optimization 

This is optimized by the new setting ``Neos.Flow.session.updateMetadataThreshold`` that allows to configure the interval for updating the session metadata when nothing but the ``lastActivityTimestamp`` has changed. This removes lots of cache writes and avoids network traffic or storage wear. The session metadata is also converted to a single value object that combines SessionID, StorageID and lastActivityTimestamp.

## 2. SessionKeyValueStore / Flow_Session_Storage: 

### Problem

Session data is written to the Flow_Session_Storage cache once Session->putData is called. In case of flow this mostly is the Objects of scope ``@Flow\\Scope("session")`` that are stored on shutdown. Those objects are sometimes modified but during most requests nothing changes here and at the end of the request the same data is added to the cache again with another redundant cache write. 

### Optimization

The SessionDataStore optimizes this be keeping a hash of the value all previously read keys and avoids writes if the serialized content that is stored yields the same hash. That way only once session-data was actually changed the session objects are actually written to the cache. This also lessens the probability of some race conditions drastically that can occur when multiple parallel requests work on the same session.

The following redundant behavior was also removed:
- All session metadata records in the cache were previously tagged with ``session`` for iterating over them again. This is replaced by the ``retrieveAll`` method.
- The current authentication providers were always stored in the session data as ``Neos_Flow_Security_Accounts `` but were unused  
- Do we want to release this as 8.4 or 9.0? In case of 9.0 the SessionMetaData ValueObject will be adjusted to php 8.1 style.

Resolves: https://github.com/neos/flow-development-collection/issues/525

**Upgrade instructions**

**Review instructions**

Some questions during the review could be:
- Are there better ways to determine written objects are modified than comparing hashes of serialized values?: I did not find one.
- Should the comparison of written data with hashes of existing data be implemented in the cache frontend instead?: I think this would consume to much memory we have lots of cache items.


* Packages: ``Flow``

`TASK: `resource:clean` followup #1678 <https://github.com/neos/flow-development-collection/pull/3275>`_
--------------------------------------------------------------------------------------------------------

While reading the code, looking for improvement, it seems tedious that we ``getIdentifierByObject`` just to ``findByIdentifier`` a few lines later.

This happened due to a funny history of back and forth.

At first - 2014 - ``resource:clean`` was introduced looping over the PersistentResource: https://github.com/neos/flow-development-collection/commit/`8a1ce0fba6cb0bf301f971a6d7d5675e0c038d75 <https://github.com/neos/flow-development-collection/commit/8a1ce0fba6cb0bf301f971a6d7d5675e0c038d75>`_

Then - 2016 - it was decided to save the sha1 and loop over them and retrieve the asset via ``findOneBySha1``: https://github.com/neos/flow-development-collection/commit/`879fba19f93d0a8628682698e57da9f1b58ad7d4 <https://github.com/neos/flow-development-collection/commit/879fba19f93d0a8628682698e57da9f1b58ad7d4>`_

But that did not improve the situation as described in https://github.com/neos/flow-development-collection/pull/1678 and was removed again - 2019.

So in functionality we made a full round, im just here to followup on the last fix to restore the full state syntactically as it was once though of.

* Packages: ``Flow``

`TASK: *PLING PLING* phpstan level 3 <https://github.com/neos/flow-development-collection/pull/3261>`_
------------------------------------------------------------------------------------------------------

~Requires: https://github.com/neos/flow-development-collection/pull/3260~
~Requires: https://github.com/neos/flow-development-collection/pull/3217~

**Upgrade instructions**


* Packages: ``Flow`` ``Eel``

`TASK: Add type hints and minimal cleanup in object manager <https://github.com/neos/flow-development-collection/pull/3308>`_
-----------------------------------------------------------------------------------------------------------------------------

Copied from https://github.com/neos/flow-development-collection/pull/2956

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Followup ValueAccessor <https://github.com/neos/flow-development-collection/pull/3201>`_
-----------------------------------------------------------------------------------------------

followup for `#3149 <https://github.com/neos/flow-development-collection/issues/3149>`_

see https://github.com/neos/flow-development-collection/pull/3149#discussion_r1376013861

**Upgrade instructions**


* Packages: ``Flow`` ``Utility.Arrays``

`TASK: Ensure `IntegerConverter` converts DateTime to unix time stamp as int <https://github.com/neos/flow-development-collection/pull/3277>`_
----------------------------------------------------------------------------------------------------------------------------------------------

Previously the date was formatted to a unix time stamp, but in string format and not as desired as int.

This is required in preparation for https://github.com/neos/flow-development-collection/pull/3261

* Packages: ``Flow``

`TASK: Level up to phpstan 2 (Flow 9 adjustments) <https://github.com/neos/flow-development-collection/pull/3217>`_
-------------------------------------------------------------------------------------------------------------------

The upgrade to phpstan level two was introduced via https://github.com/neos/flow-development-collection/pull/3264, this holds the flow 9 specific adjustments.

Related (phpstan level 1) https://github.com/neos/flow-development-collection/pull/3216

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Fix some nullable php doc types <https://github.com/neos/flow-development-collection/pull/3260>`_
--------------------------------------------------------------------------------------------------------

I ran phpstan level 3 once on flow. And it seems we dont specifiy the nullable types correctly, but we document them in the doc string.
So i wrote a little helping script that would add the ``|null`` php doc annotation to all ``@param`` and ``@return`` types if we specify ``or NULL`` in the message. I carefully reviewed every change and made additionally some manual changes and corrected things. This is completely non breaking as only doc comments are being touched.

This will help for migrating to phpstan level 3.

**Upgrade instructions**


* Packages: ``Flow`` ``FluidAdaptor``

`TASK: Remove deprecated code <https://github.com/neos/flow-development-collection/pull/3220>`_
-----------------------------------------------------------------------------------------------

- remove deprecated ProtectedContext::whitelist
- remove deprecated Http Component legacy layer

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Change version constraints for Neos packages to self.version <https://github.com/neos/flow-development-collection/pull/3256>`_
-------------------------------------------------------------------------------------------------------------------------------------



* Packages: ``Kickstarter``

`TASK: Remove Bootstrap::MINIMUM_PHP_VERSION <https://github.com/neos/flow-development-collection/pull/3227>`_
--------------------------------------------------------------------------------------------------------------

We declare these dependencies in composer and it should not be necessary to validate them at runtime.

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Use generics via @template instead of PHPSTORM_META <https://github.com/neos/flow-development-collection/pull/3222>`_
----------------------------------------------------------------------------------------------------------------------------

Since the php universe evolved im gonna try https://github.com/neos/flow-development-collection/pull/2753 again ;)

Adds typings to:

\\Neos\\Flow\\ObjectManagement\\ObjectManagerInterface::get()

and

\\Neos\\Flow\\Core\\Bootstrap::getEarlyInstance()

by usage of the @template tag: https://phpstan.org/writing-php-code/phpdocs-basics#generics

This feature is supported by phpstorm, psalm and phpstan and also used widely in Neos 9

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Remove dead AfterInvocation related code <https://github.com/neos/flow-development-collection/pull/3219>`_
-----------------------------------------------------------------------------------------------------------------

This was never properly implemented.


* Packages: ``Flow``

`TASK: Remove persistence clone magic <https://github.com/neos/flow-development-collection/pull/3223>`_
-------------------------------------------------------------------------------------------------------

This removed the code that set ``Flow_Persistence_clone`` in entities or value objects when they were ``clone``d.

As dynamic properties are deprecated with PHP 8.2, this caused warnings and will eventually break.

Since this was (re)-introduced in Flow 2 via `90cb65827c1550e9144e9f83b9231b430c106660 <https://github.com/neos/flow-development-collection/commit/90cb65827c1550e9144e9f83b9231b430c106660>``_ to support custom backends in the geenric persistence layer of Flow, like the (now outdated) ``TYPO3.CouchDB`, we felt it is best to remove it.

**Upgrade instructions**

If you rely on this, you need to adjust your code. Chances are, if you still need this, you use the generic peristsnece layer, which is gone in Flow 7 aready (see https://github.com/neos/flow-development-collection/pull/1769 and https://github.com/neos/flow-development-collection/pull/2262). So, you have other problems to solve, anyway…


* Packages: ``Flow``

`TASK: Migrate to PHPStan (adjustments in Flow 9) <https://github.com/neos/flow-development-collection/pull/3216>`_
-------------------------------------------------------------------------------------------------------------------

With https://github.com/neos/flow-development-collection/pull/3218 PHPStan level 1 was added to the whole Flow code base and CI for Flow 8. This upmerged change needs some adjustments to pass the CI in Flow 9

- fix types in code that was introduced with Flow 9
- fix types where neos depends on it (by correcting types and adding ``never``)
- adjust unit test as ``never`` cannot be doubled (eventually this will be fixed via: https://github.com/sebastianbergmann/phpunit/issues/5048)
- fix ci and style as neos 9 followup for https://github.com/neos/flow-development-collection/pull/3218


* Packages: ``Eel`` ``Flow`` ``FluidAdaptor`` ``Kickstarter`` ``Cache``

`TASK: Carefully fix psalm types across codebase to make it green ;) <https://github.com/neos/flow-development-collection/pull/3199>`_
--------------------------------------------------------------------------------------------------------------------------------------

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Update default settings for stored throwable dumps <https://github.com/neos/flow-development-collection/pull/3213>`_
---------------------------------------------------------------------------------------------------------------------------

This updates the default settings in YAML to 30 days of dump retention and a maximum of 10.000 files.

The class properties keep their ``0`` default, so that in case the class has been extended no change is enforced.

**Review instructions**

Needs upmerge of https://github.com/neos/flow-development-collection/pull/3187


`TASK: Use new Behat `FlowBootstrapTrait` <https://github.com/neos/flow-development-collection/pull/3208>`_
-----------------------------------------------------------------------------------------------------------

Adjust to behat adjustments see https://github.com/neos/behat/pull/35

**Upgrade instructions**


* Packages: ``Flow``

`TASK: document and deprecate flows internal isolated behat tests <https://github.com/neos/flow-development-collection/pull/3173>`_
-----------------------------------------------------------------------------------------------------------------------------------

Related https://github.com/neos/flow-development-collection/issues/3170

The infrastructure is quite complex and not in relation to those two tests. That's why we declare it ready to be removed.

**Upgrade instructions**


* Packages: ``Flow``

`TASK: Support PHP never, null, false, and true as stand-alone types <https://github.com/neos/flow-development-collection/pull/3071>`_
--------------------------------------------------------------------------------------------------------------------------------------

This change adds functional tests to prove that Flow can handle PHP 8 stand-alone return types in AOP proxy class building.

Note that "null" is not supported yet by laminas-code, therefore the corresponding test is not active yet.

* Resolves: `#3027 <https://github.com/neos/flow-development-collection/issues/3027>`_

* Packages: ``Flow``

`TASK: Use Laminas Code for proxy method rendering <https://github.com/neos/flow-development-collection/pull/3064>`_
--------------------------------------------------------------------------------------------------------------------

Flow now uses laminas/laminas-code for rendering proxy methods. The Dependency Injection Proxy Class Builder was refactored and the classes ProxyConstructor and ProxyMethod were replaced by new implementations called ProxyConstructorGenerator and ProxyMethodGenerator respectively.

* Resolves: `#3042 <https://github.com/neos/flow-development-collection/issues/3042>`_

* Packages: ``Flow``

`TASK: Clean up code in AOP and ObjectManagement <https://github.com/neos/flow-development-collection/pull/3055>`_
------------------------------------------------------------------------------------------------------------------

This change contains various code clean-ups which fell off with the preparation of a new bug fix for AOP.

* Packages: ``Flow``

`TASK: Replace "adviced" by "advised" <https://github.com/neos/flow-development-collection/pull/3054>`_
-------------------------------------------------------------------------------------------------------

Fixed a good old typo everywhere in Flow by replacing all occurrences of "adviced" by "advised".

* Packages: ``Flow``

`TASK: Clean up functional tests for AOP <https://github.com/neos/flow-development-collection/pull/3053>`_
----------------------------------------------------------------------------------------------------------

This also re-activates a functional test targeting PHP 7.1 features which was disabled at some point in history.

* Packages: ``Flow``

`TASK: Only add constructor injection code if needed <https://github.com/neos/flow-development-collection/pull/3050>`_
----------------------------------------------------------------------------------------------------------------------

The proxy class builder now skips code generation for constructor injection code if the given original class is prototype, no user-defined object configuration exists and all potentially autowired constructor arguments are prototypes or simple values. This change should result in a significantly less amount of proxy classes generated in most modern Flow projects.

resolves: `#3049 <https://github.com/neos/flow-development-collection/issues/3049>`_
resolves: #1539

* Packages: ``Flow``

`TASK: Only add serialization entities code if needed <https://github.com/neos/flow-development-collection/pull/3047>`_
-----------------------------------------------------------------------------------------------------------------------

Proxy classes created by the Dependency Injection Proxy Class Builder now only contain code related to serialization and deserialization of related entities if needed.

The code is only rendered if one of the following conditions is met:

- The class is annotated with Entity
- The class is annotated with Scope("session")

Despite the previous condition, the code will not be rendered if the following condition is true:

- The class already has a __sleep() method (we assume that the developer wants to take care of serialization themself)

As part of this change, the generated code related to serialization was slightly adjusted for stricter type handling.

related: `#1539 <https://github.com/neos/flow-development-collection/issues/1539>`_

**Review instructions**

- try to find an existing application which relies on serialization of related entities, for example a Flow application which uses ORM with relations or uses entities in a session scope.
- remove all caches and then access your application in a browser using the current Flow 9 branch (without this patch)
- create a backup of the Cache/Code/Flow_Object_Classes directory
- switch to a branch with this change, remove all caches and access the application again in a browser
- use a diff tool (e.g. Kaleidoscope) to compare both cache directories to see what is now different
- check if your application still works

* Packages: ``Flow``

`Detailed log <https://github.com/neos/flow-development-collection/compare/8.3.8...9.0.0-beta8>`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
