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

Error: Call to protected Yiisoft\Validator\Rule::__construct() from context 'App\Blog\Post\PostForm' #311

Closed
rossaddison opened this issue Jun 12, 2021 · 1 comment
Labels

Comments

@rossaddison
Copy link
Contributor

What steps will reproduce the problem? Add a Post

What is the expected result? Add a Post

What do you get instead? Above error

Error can be avoided by removing getRules function in the PostForm. but then there will be no validation available. ****

Additional info

Q A
Version 12-June-2021
PHP version 7.4.9
Operating system Windows 10 mySql 5.7.31

Stack Trace
Error: Call to protected Yiisoft\Validator\Rule::__construct() from context 'App\Blog\Post\PostForm' in C:\wamp64\www\yii3-1206\src\Blog\Post\PostForm.php:40
Stack trace:
#0 C:\wamp64\www\yii3-1206\vendor\yiisoft\validator\src\Validator.php(36): App\Blog\Post\PostForm->getRules()
#1 C:\wamp64\www\yii3-1206\src\Blog\Post\PostController.php(58): Yiisoft\Validator\Validator->validate(Object(App\Blog\Post\PostForm))
#2 [internal function]: App\Blog\Post\PostController->add(Object(HttpSoft\Message\ServerRequest), Object(Yiisoft\Validator\Validator), Object(App\Handler\NotFoundHandler))
#3 C:\wamp64\www\yii3-1206\vendor\yiisoft\injector\src\Injector.php(66): ReflectionFunction->invokeArgs(Array)
#4 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareFactory.php(89): Yiisoft\Injector\Injector->invoke(Object(Closure), Array)
#5 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): class@anonymous->process(Object(HttpSoft\Message\ServerRequest), Object(App\Handler\NotFoundHandler))
#6 C:\wamp64\www\yii3-1206\vendor\yiisoft\auth\src\Middleware\Authentication.php(57): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#7 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\Auth\Middleware\Authentication->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#8 C:\wamp64\www\yii3-1206\vendor\yiisoft\data-response\src\Middleware\FormatDataResponse.php(25): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#9 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\DataResponse\Middleware\FormatDataResponse->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#10 C:\wamp64\www\yii3-1206\vendor\yiisoft\csrf\src\CsrfMiddleware.php(50): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#11 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\Csrf\CsrfMiddleware->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#12 C:\wamp64\www\yii3-1206\vendor\yiisoft\yii-debug-api\src\Middleware\DebugHeaders.php(31): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#13 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\Yii\Debug\Api\Middleware\DebugHeaders->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#14 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(54): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#15 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareDispatcher.php(49): Yiisoft\Middleware\Dispatcher\MiddlewareStack->handle(Object(HttpSoft\Message\ServerRequest))
#16 C:\wamp64\www\yii3-1206\vendor\yiisoft\router\src\MatchingResult.php(81): Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher->dispatch(Object(HttpSoft\Message\ServerRequest), Object(App\Handler\NotFoundHandler))
#17 C:\wamp64\www\yii3-1206\vendor\yiisoft\router\src\Middleware\Router.php(46): Yiisoft\Router\MatchingResult->process(Object(HttpSoft\Message\ServerRequest), Object(App\Handler\NotFoundHandler))
#18 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\Router\Middleware\Router->process(Object(HttpSoft\Message\ServerRequest), Object(App\Handler\NotFoundHandler))
#19 C:\wamp64\www\yii3-1206\vendor\yiisoft\session\src\SessionMiddleware.php(36): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#20 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\Session\SessionMiddleware->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#21 C:\wamp64\www\yii3-1206\vendor\yiisoft\error-handler\src\Middleware\ErrorCatcher.php(135): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#22 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(100): Yiisoft\ErrorHandler\Middleware\ErrorCatcher->process(Object(HttpSoft\Message\ServerRequest), Object(class@anonymous))
#23 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareStack.php(54): class@anonymous->handle(Object(HttpSoft\Message\ServerRequest))
#24 C:\wamp64\www\yii3-1206\vendor\yiisoft\middleware-dispatcher\src\MiddlewareDispatcher.php(49): Yiisoft\Middleware\Dispatcher\MiddlewareStack->handle(Object(HttpSoft\Message\ServerRequest))
#25 C:\wamp64\www\yii3-1206\vendor\yiisoft\yii-web\src\Application.php(60): Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher->dispatch(Object(HttpSoft\Message\ServerRequest), Object(App\Handler\NotFoundHandler))
#26 C:\wamp64\www\yii3-1206\src\ApplicationRunner.php(75): Yiisoft\Yii\Web\Application->handle(Object(HttpSoft\Message\ServerRequest))
#27 C:\wamp64\www\yii3-1206\public\index.php(24): App\ApplicationRunner->run()
#28 {main}

@vjik vjik added the type:bug Bug label Jun 12, 2021
@vjik vjik mentioned this issue Jun 12, 2021
vjik added a commit that referenced this issue Jun 12, 2021
@vjik
Copy link
Member

vjik commented Jun 12, 2021

Fixed. Thank you for report!

@vjik vjik closed this as completed Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants