Opened 10 years ago
Closed 5 years ago
#42 closed task (fixed)
Bring the codebase up-to-date with php 5.3+ standards
Reported by: | quinn | Owned by: | eli |
---|---|---|---|
Priority: | major | Milestone: | 2.1 |
Keywords: | Cc: | quinn, eli |
Description
I would like to bring our codebase framework up-to-date with php 5.3+ standards, specifically with class definitions, public/private method statements, magic functions, etc. Currently it works fine under php5, but I'd like to take the final step so it runs exceptionally on php5 and not at all on php4.
Goals
Identify new features introduced between php 5.0 and 5.3 that will:
- bring tangible benefit for our use (e.g., anything that brings a performance benefit, or improves error handling)
- make the codebase more future proof (e.g., migrating the current mysql_* function calls (which are to be depreciated in v6) with something else, or implement the required aspects of the new Object Model).
The code should run with no errors using 'E_STRICT' and 'E_ALL' error_reporting, and pass all the unit tests (run via codebase/test/run_tests.sh).
Requirements
- Backwards compatibility with existing sites that use the codebase. This will make implementation of PDO slightly more tricky, but is possible.
- Don't make modifications that require extensive testing. Currently the codebase is mature and very stable. I hope the changes we make won't' make it unstable.
- We only implement what we can do in 10-15 hours.
Attachments (3)
Change History (9)
Changed 10 years ago by eli
comment:1 Changed 10 years ago by eli
comment:2 follow-up: ↓ 3 Changed 10 years ago by eli
One of the new and shiny features in 5.3 is the use of lambda functions and closures. I'm not sure where these might be applied in the codebase, but there may be spots where these could be applied.
Another page worth looing at is new classes introduced in 5.3: http://php.net/manual/en/migration53.classes.php
comment:3 in reply to: ↑ 2 Changed 10 years ago by quinn
Replying to eli:
One of the new and shiny features in 5.3 is the use of lambda functions and closures. I'm not sure where these might be applied in the codebase, but there may be spots where these could be applied.
Another page worth looing at is new classes introduced in 5.3: http://php.net/manual/en/migration53.classes.php
Perhaps in the case where a function was defined only to be passed as a callable argument, e.g., to array_map(). But there isn't any benefit to rewriting this code. Leave as is.
comment:4 Changed 10 years ago by quinn
- Cc quinn eli added
Oh rats; this comment didn't get posted last night (POST error):
Eli
I've reviewed your suggestions and the PHP docs, and enumerated some tasks in the "Codebase PHP updates" spreadsheet (I shared it with your gmail address). Please review, amend if I missed anything, and let me know if you have any questions.
The next step is to define a test suite, what it means to maintain "backwards compatibility", and define a methodology for attacking these tasks.
I'll be off the computer Thurs-Sun, so if you have time to chat tonight (after 7 or 8pm) we can discuss this to get you started.
Ok, so we didn't connect last night. I'll just give you a couple guidelines to get started:
- follow our coding standards (4 spaces per tab)
- do one task, then comit your work (svn ci -m "description of work") so we can easily review and roll back changes if needed.
- If in doubt about how to do something, or if it might break backwards computability, leave it for us to discuss next week.
- or go on a weekend off the computer like me! anyways, enjoy.
Q
comment:5 Changed 10 years ago by eli
Quinn,
I've run both pmd (php mess detector) and phpcs (PHP_CodeSniffer) and am uploading their respective outputs here. I ran phpcs on just one file, ACL.inc.php, rather than the entire codebase. Figuring that you would review the output and decide on what's important and what's not.
-Eli
comment:6 Changed 5 years ago by quinn
- Resolution set to fixed
- Status changed from new to closed
OK. This is just a preliminary sketch of what could be done. I'll do a bit more investigating around what changes will bring more efficiency, and post back. The PSR-0 suggestion would probably break backwards compatibility, so that one should probably be stricken. But I think it's worth considering, and there might be a way to do it that wouldn't break back-compat.
PHP Deprecated: Assigning the return value of new by reference is deprecated in /opt/codebase/tests/VersionTest.php on line 49. --- So anything like $var &= new Class();