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

Bug: The system/View/Cell.php on return $instance->{$method}(); #8121

Closed
MohammedNuru opened this issue Oct 29, 2023 · 8 comments
Closed

Bug: The system/View/Cell.php on return $instance->{$method}(); #8121

MohammedNuru opened this issue Oct 29, 2023 · 8 comments

Comments

@MohammedNuru
Copy link

MohammedNuru commented Oct 29, 2023

PHP Version

8.1

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

apache

Database

MySQL

What happened?

File: system/View/Cell.php

the return method under or line 231.
return $instance->{$method}();
well this result in an error saying to few argument sent or not. but I have fixed it by writing it like.
return $instance->{$method}($params);

was this thing a bug or my mistake to correct it?
now seems working fine...

Steps to Reproduce

Download a fresh ci4 version 4.4.3,
create a cell (u can use the php spark make cell) like Cells/ClassCell
inside create method called ClassCell::MakeMethod(array $parma):string,
create a normal view file called normalView which is loaded from a controller as usual,
call the cell which load it's own from the view as
view_cell(ClassCell::MakeMethod, [whatever array or obj here])
this produce an error like too few argument or so...

Expected Output

I just wanted the CI4 to work without my correction... if that is bug, then good if not then correct me...

Anything else?

No response

@MohammedNuru MohammedNuru added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 29, 2023
@kenjis
Copy link
Member

kenjis commented Oct 29, 2023

Thank you for reporting.

It sounds like a bug, but Controlled Cell doesn't call the method.

<?= view_cell('AlertMessageCell', 'type=warning, message=Failed.') ?>

See https://codeigniter4.github.io/CodeIgniter4/outgoing/view_cells.html#creating-a-controlled-cell

@lonnieezell What do you think?

@michalsn
Copy link
Member

This is not a bug. It's just an OP's misconception of how Controlled Cells work.

Simple Cells !== Controlled Cells. The user guide is very clear here.

In Controlled Cells, parameters are always mapped to public variables of the class, which should be declared inside the class.

@michalsn michalsn removed the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 31, 2023
@MohammedNuru
Copy link
Author

How many dynamic vars are we going to have/declare inside the class?.
it should be a bug michalsn...

@michalsn
Copy link
Member

How many dynamic vars are we going to have/declare inside the class?.

You need to declare public properties of the class - as many as needed.

it should be a bug michalsn...

No, it's not a bug. This is how Controlled Cells were designed and work. If you need a described behavior just use Simple Cells: https://codeigniter4.github.io/CodeIgniter4/outgoing/view_cells.html#simple-cells

@MohammedNuru
Copy link
Author

Exactly that is the problem, I reported...
https://codeigniter4.github.io/CodeIgniter4/outgoing/view_cells.html#simple-cells
Unless it if fixed the Error is always thrown!

@kenjis
Copy link
Member

kenjis commented Nov 1, 2023

The documentation seems to be a bit difficult to understand the difference between Simple and Controlled Cells.
I sent a PR to improve: #8132

@kenjis
Copy link
Member

kenjis commented Nov 1, 2023

@MohammedNuru It seems you don't know the difference between Simple Cells and Control Cells.
All you need to do is just to remove extends Cell in the Cell class (Simple Cells).
Or add public properties for the params (Control Cells).

@kenjis kenjis mentioned this issue Nov 1, 2023
2 tasks
@kenjis
Copy link
Member

kenjis commented Nov 2, 2023

This is not a bug, but a misuse.

@kenjis kenjis closed this as completed Nov 2, 2023
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

3 participants