Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update Column.php: Rename data method to setData#231

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@bishwajitcadhikary
Copy link

@bishwajitcadhikarybishwajitcadhikary commentedNov 28, 2024
edited
Loading

This change renames the data method in the Yajra\DataTables\Html\Column class to setData to resolve a method signature conflict with the parent class Illuminate\Support\Fluent.

publicfunction data(array|string$value):static

This conflicts with the data method in the parent Illuminate\Support\Fluent class, which has the signature:

protectedfunction data($key =null,$default =null)

This results in the following PHP error:

Declaration of Yajra\DataTables\Html\Column::data(array|string$value): static must be compatible withIlluminate\Support\Fluent::data($key =null,$default =null)

Proposed Solution
The data method in the Column class has been renamed to setData to avoid the conflict:

/** * Set column data option value. * * @param  array|string  $value * @return $this * * @see https://datatables.net/reference/option/columns.data * @see https://datatables.net/manual/data/orthogonal-data */publicfunctionsetData(array|string$value):static{$this->attributes['data'] =$value;return$this;}

Benefits of the Fix
1.Conflict Resolution: Avoids the signature conflict with Illuminate\Support\Fluent.
2.Clarity: Improves method naming by explicitly reflecting its purpose (setData for setting values).
3.Backward Compatibility: Allows the Column class to coexist with Fluent without breaking functionality.

Additional Notes
•Any existing usage of data() to set column data will need to be updated to setData() in the codebase.
•This change only affects the method used to set column data. The method inherited from Fluent (data($key = null, $default = null)) remains intact for retrieving data.

Renamed the data method to setData in the Yajra\DataTables\Html\Column class to avoid conflicts with the data method in Illuminate\Support\Fluent
@sonarqubecloud
Copy link

@yajra
Copy link
Owner

fixed via#230, thanks!

@yajrayajra closed thisNov 29, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@bishwajitcadhikary@yajra

[8]ページ先頭

©2009-2025 Movatter.jp