Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with latest Nette #3

Closed
jtojnar opened this issue Feb 25, 2024 · 11 comments
Closed

Incompatible with latest Nette #3

jtojnar opened this issue Feb 25, 2024 · 11 comments

Comments

@jtojnar
Copy link
Collaborator

jtojnar commented Feb 25, 2024

nette/application 3.2.0 changed order of arguments in nette/application@bb8f93c. That one is trivial to fix but there are other issues as well.

Is this project still maintained? Would you accept pull requests to fix it?

@jtojnar jtojnar changed the title Inconmpatible with latest Nette Incompatible with latest Nette Feb 25, 2024
@jtojnar
Copy link
Collaborator Author

jtojnar commented Feb 25, 2024

I opened a PR (#4) that fixes the failures but there are still several deprecations:

Deprecated: Creation of dynamic property Codeception\Lib\Generator\Actions::$di is deprecated in /home/jtojnar/Projects/webchemistry-testing-helpers/vendor/codeception/codeception/src/Codeception/Lib/Generator/Actions.php on line 62

Deprecated: Creation of dynamic property Codeception\Lib\Generator\Actions::$moduleContainer is deprecated in /home/jtojnar/Projects/webchemistry-testing-helpers/vendor/codeception/codeception/src/Codeception/Lib/Generator/Actions.php on line 64

Acceptance Tests (0) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DEPRECATION: 'settings: bootstrap: _bootstrap.php' option is deprecated! Replace it with: 'bootstrap: _bootstrap.php' (not under settings section). See: https://codeception.com/docs/reference/Configuration
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2x DEPRECATION: Nette\Application\UI\Form::getValues(true) is deprecated, use getValues('array'). /home/jtojnar/Projects/webchemistry-testing-helpers/vendor/nette/forms/src/Forms/Container.php:125

I can fix those as well (probably by updating Codeception). And I can switch CI to GitHub actions if you want.

@jtojnar
Copy link
Collaborator Author

jtojnar commented Feb 29, 2024

@MartkCz Any opinion on this?

@MartkCz
Copy link
Contributor

MartkCz commented Feb 29, 2024

I'm not using this package anymore. I'll merge your pr and release a new version. Feel free to update the dependency.

@jtojnar
Copy link
Collaborator Author

jtojnar commented Feb 29, 2024

Thanks. Will probably want to fix the warnings as well before then.

Are you okay with breaking the API (as below) or do you want a deprecation first?

commit 12e2b2ee321dbf6f3c92800332901b6c8dcd8616
Author: Jan Tojnar <[email protected]>
Date:   Thu Feb 29 19:39:00 2024 +0100

    FormResponse: Fix deprecation
    
    nette/forms 3.2.0 deprecated the boolean argument, let’s drop it:
    https://github.com/nette/forms/commit/0a812bd6e70aba54c6e563aef4d77bd4388607ae
    
    Also let’s use the `Array` constant introduced in nette/forms 3.1.12:
    https://github.com/nette/forms/commit/0be7b3d5971113515e9020cf53453e74f02a46a1

diff --git a/src/Components/Responses/FormResponse.php b/src/Components/Responses/FormResponse.php
index f806422..35c0746 100644
--- a/src/Components/Responses/FormResponse.php
+++ b/src/Components/Responses/FormResponse.php
@@ -3,7 +3,7 @@
 namespace WebChemistry\Testing\Components\Responses;
 
 use Nette\Application\UI\Form;
-use Nette\Utils\ArrayHash;
+use Nette\Forms\Container;
 
 /**
  * @property-read Form $form
@@ -44,11 +44,11 @@ class FormResponse extends BaseResponse {
 	}
 
 	/**
-	 * @param bool $asArray
-	 * @return array|ArrayHash
+	 * Returns the values submitted by the form.
+	 * @param  Control[]|null  $controls
 	 */
-	public function getValues(bool $asArray = true) {
-		return $this->getForm()->getValues($asArray);
+	public function getValues(string|object|null $returnType = null, ?array $controls = null): object|array {
+		return $this->getForm()->getValues($returnType, $controls);
 	}
 
 	/**
@@ -56,7 +56,7 @@ class FormResponse extends BaseResponse {
 	 * @return mixed
 	 */
 	public function getValue(string $path) {
-		$values = $this->getValues(true);
+		$values = $this->getValues(Container::Array);
 		foreach (explode('.', $path) as $item) {
 			$values = $values[$item];
 		}
diff --git a/composer.json b/composer.json
index f7fb241..14dc64e 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,7 @@
 	"require-dev": {
 		"codeception/codeception": "~4.1",
 		"nette/application": "^3.2",
-		"nette/forms": "^3.0",
+		"nette/forms": "^3.1.12",
 		"latte/latte": "^2.9",
 		"codeception/module-asserts": "^1.3"
 	},

@MartkCz
Copy link
Contributor

MartkCz commented Feb 29, 2024

Is it ready for release?

@jtojnar
Copy link
Collaborator Author

jtojnar commented Feb 29, 2024

One more thing #7

@jtojnar
Copy link
Collaborator Author

jtojnar commented Mar 1, 2024

Looks like we actually used a different default than nette/forms so the deprecation fix caused a BC break:

a9776b4#diff-619c18463d859978e51257d25f93c4fbf7117d95a0067d5b2a2e1c144362d565R50

Will want something like the following:

--- a/src/Components/Responses/FormResponse.php
+++ b/src/Components/Responses/FormResponse.php
@@ -47,7 +47,7 @@ class FormResponse extends BaseResponse {
 	 * Returns the values submitted by the form.
 	 * @param  Control[]|null  $controls
 	 */
-	public function getValues(string|object|null $returnType = null, ?array $controls = null): object|array {
+	public function getValues(string|object $returnType = Container::Array, ?array $controls = null): object|array {
 		return $this->getForm()->getValues($returnType, $controls);
 	}
 

@MartkCz
Copy link
Contributor

MartkCz commented Mar 2, 2024

I give you rights, I get lost in it :) this will be faster

@jtojnar
Copy link
Collaborator Author

jtojnar commented Mar 2, 2024

Thanks. Will try to finish it up and then then make a release?

@MartkCz
Copy link
Contributor

MartkCz commented Mar 2, 2024

Yes, major version, please.

@jtojnar
Copy link
Collaborator Author

jtojnar commented Mar 3, 2024

@jtojnar jtojnar closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants