Opened 8 years ago
Closed 8 years ago
#7299 closed enhancement (fixed)
PHP 5.2 -> PHP 5.3 code improvements
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | |
Cc: |
Description
This ticket is to discuss asynchronously how we should start to use PHP 5.3 in the existing codebase. I do not think it is wise to just go and change everything possible in one go just because we can, but there are a few areas that I'd personally like to see update. It is a tricky balance and we should have some consensus amongst frequent contributors of how we should approach it.
Areas we could change:
- Remove compatibility functions for PHP functions that don't exist in PHP 5.2. Reason would be to remove dead code branches which, as we'd never expect them to be used, would be missed in the future if some bug was found in them. I've only found one so far:
BP_Activity_Activity::array_replace_recursive
.
- Anonymous functions/closures.
- See class
BP_Core_Sort_By_Key_Callback
- See class
- Using
func_get_args
as a function parameter.- Search for
$func_args = func_get_args();
in BP.
- Search for
- Autoloader support.
- All the
do_nav_backcompat
checks that Boone added a few versions back.
- All the
- The functions in bp-core-dependency.php long have a note that says replace with anonymous functions.
- This would be by design because unhooking these core BuddyPress actions would just break BuddyPress.
Change History (9)
#2
@
8 years ago
Will likely need to include unit tests, but anywhere that uses create_function() would be a good place to look at, especially as you come across working in those areas.
#3
@
8 years ago
I'm going to remove the do_autoload
checks throughout BP. This also involves removing all bp-*-classes.php
files, since they're only loaded when ! do_autoload
. This could cause problems for anyone who is calling require ... bp-*-classes.php
, but those instances are probably already broken, since loading the classes.php file after autoload would cause duplicate class definitions. If we run into error reports, I suppose we can reintroduce these files (they'd be empty).
The ones I am most keen on personally are
array_replace_recursive
,BP_Core_Sort_By_Key_Callback
, and the autoloader changes. The others seem to be more-or-less code style improvements. IMO>