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: ClassMethod #3050

Closed
fujael opened this issue May 31, 2020 · 2 comments
Closed

Bug: ClassMethod #3050

fujael opened this issue May 31, 2020 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@fujael
Copy link

fujael commented May 31, 2020

The issue
When one writes PHP code, he/she shouldn't use php core keywords.
Take a look at those files-
codeigniter4\framework\system\View\Filters.php (Line 114) public static function default
codeigniter4\framework\system\View\View.php (Line 523) public function include
codeigniter4\framework\system\CLI\CLI.php (Line 308) public static function print
codeigniter4\framework\system\RESTful\ResourcePresenter.php (Line 107) public function new
codeigniter4\framework\system\RESTful\ResourcePresenter.php (Line 104) public function new

CodeIgniter 4 version
Release: 4.0.3

Describe the bug
PHP has some reserved keywords like new default include class, array etc. If you use these reserved keywords it will make troubles to IDE parsers who has autocomplete features. So a developer avoids the conflicts at any cost.

Affected module(s)
codeigniter4\framework\system\View\Filters.php
codeigniter4\framework\system\View\View.php
codeigniter4\framework\system\CLI\CLI.php
codeigniter4\framework\system\RESTful\ResourcePresenter.php

Expected behavior, and steps to reproduce if appropriate
You can add underscore before function name like public static function default should be public static function _default

Context

  • PHP version [7.2]
@fujael fujael added the bug Verified issues on the current code behavior or pull requests that will fix them label May 31, 2020
@dafriend
Copy link
Contributor

dafriend commented Jun 1, 2020

The PHP manual has this to say about keywords.

As of PHP 7.0.0 these keywords are allowed as property, constant, and method names of classes, interfaces and traits, except that class may not be used as constant name.

Taking that into consideration there is no problem with the code you reference.

@lonnieezell
Copy link
Member

Agreed. Perfectly acceptable code in the versions of PHP that we require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

3 participants