Commit eec1f14d by Scott

Merge branch 'master' into dev

parents dd724732 9f925639
language: php
php:
- 5.3.3
- 5.4
- 5.5
before_script:
## PHP_CodeSniffer
- pear install pear/PHP_CodeSniffer
- phpenv rehash
## PHP Copy/Paste Detector
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
## PHP Mess Detector
- pear config-set preferred_state beta
- printf "\n" | pecl install imagick
- pear channel-discover pear.phpmd.org
- pear channel-discover pear.pdepend.org
- pear install --alldeps phpmd/PHP_PMD
- phpenv rehash
## PHPLOC
- curl -o phploc.phar https://phar.phpunit.de/phploc.phar
script:
## PHP_CodeSniffer
- phpcs --report=emacs --standard=PSR1 .
- phpcs --report=emacs --standard=PSR2 .
## PHP Copy/Paste Detector
- php phpcpd.phar --verbose .
## PHP Mess Detector
- phpmd . text cleancode
- phpmd . text codesize
- phpmd . text controversial
- phpmd . text design
- phpmd . text naming
- phpmd . text unusedcode
## PHPLOC
- php phploc.phar .
## PHPUNIT
- phpunit .
......@@ -17,7 +17,83 @@ If you have found the cause of the bug in the Q2A code, you can submit the patch
If you wish to implement a feature, you should start a discussion on the [Question2Answer Q&A][QA] first. We welcome all ideas but they may not be appropriate for the Q2A core.
## Coding style
From 1.7 onwards a new coding style is being implemented that is more in line with other projects. The core codebase is gradually being refactored, and any new code should use the guidelines below. When making changes it's encouraged to update the style of the surrounding code, e.g. the rest of the function being modified.
However, **please keep style-only changes to a separate commit!** For example if you fix a bug, do that first in one commit, then optionally reformat the rest of the function's code and perform a second commit.
### Guidelines
- PHP code should start with `<?php` (almost always the very first line). The closing tag `?>` should be omitted to avoid accidental output.
- PHP files should use UTF-8 encoding without BOM (this is usually default in most text editors).
- Trailing whitespace (tabs or spaces at the end of lines) should be trimmed on save. Any advanced text editor should be able to do this. (For Sublime Text you can add the option `"trim_trailing_white_space_on_save": true` to your preferences. In Notepad++ you can press Alt+Shift+S.)
- Use tabs for indenting. Each file should start at level 0 (i.e. no indentation).
- Functions should use a DocBlock-style comment.
- Operators (`=`, `+` etc) should have a space either side.
- Control structure keywords (`if`, `else`, `foreach` etc) should have a space between them and the opening parenthesis.
- Opening braces for classes and functions should be on the next line.
- Opening braces for control structures should be on the same line.
- Optional braces may be omitted only when the statement spans only one line.
### Examples
Here is an example of the old style. Even though the braces are technically optional (the foreach contains only one statement), the statement spans several lines so brances should be used here for clarity.
foreach ($thingarray as $thing)
if (isset($thing['id']))
if (strpos($thing['id'], 'Hello')===0)
$newthing='Goodbye';
elseif ($thing['id']=='World')
$newerthing='Galaxy';
else
return null;
It should be rewritten as:
foreach ($thingarray as $thing) {
if (isset($thing['id'])) {
if (strpos($thing['id'], 'Hello') === 0)
$newthing = 'Goodbye';
elseif ($thing['id'] == 'World')
$newerthing = 'Galaxy';
}
else
return null;
}
Here is a class example showing the placement of braces, operators, and an advanced DocBlock comment.
class qa_example
{
/**
* Adds 1 to the supplied number.
*
* @param int $number The number to increment.
*
* @return int Returns the new number.
*/
public function add_one($number)
{
$result = $number + 1;
return $result;
}
}
### New autoloaded classes
From version 1.7 some classes are autoloaded, so it's possible to use them without adding a `require_once` first. These loosely follow [PSR-0][PSR0] using faux namespaces. This is being done slowly and carefully to maintain backwards compatibility, and does not apply to plugins, themes, nor most of the core for that matter.
Classes are stored in the `qa-include/Q2A` folder, and then in subfolders depending on their categorization.
Class names should be of the form `Q2A_<Namespace>_<Class>`, e.g. `Q2A_Util_Debug`. There may be multiple "namespaces", e.g. `Q2A_Db_User_Messages`.
Classes are mapped to PHP files with the underscores converted to directory separators. The `Q2A_Util_Debug` class is in the file `qa-include/Q2A/Util/Debug.php`. A class named `Q2A_Db_User_Messages` would be in a file `qa-include/Q2A/Db/User/Messages.php`.
[Home]: http://www.question2answer.org/
[QA]: http://www.question2answer.org/qa/
[Issues]: https://github.com/q2a/question2answer/issues
[PSR0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
Question2Answer on GitHub
-------------------------
Question2Answer
-----------------------------
[![Build Status](https://travis-ci.org/q2a/question2answer.png?branch=master)](https://travis-ci.org/q2a/question2answer)
[Question2Answer][Q2A] (Q2A) is a popular free open source Q&A platform for PHP/MySQL, used by over 14,000 sites in 40 languages.
As of version 1.6.3, all development is taking place through GitHub. The collaborative development process is being managed by [Scott Vivian][1]. (Note that official releases are still distributed via the Q2A website.)
Please read the [contributing page][2] for more information on how to get involved.
As of version 1.6.3, all development of [Question2Answer] will take place through GitHub.
Pull requests are officially welcomed!
Thanks and enjoy!
Gideon
[Question2Answer]: http://www.question2answer.org/
[Q2A]: http://www.question2answer.org/
[1]: http://www.question2answer.org/qa/user/Scott
[2]: https://github.com/q2a/question2answer/blob/master/CONTRIBUTING.md
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......@@ -68,6 +68,7 @@
$codetolanguage=array( // 2-letter language codes as per ISO 639-1
'ar' => 'Arabic - العربية',
'az' => 'Azerbaijani - Azərbaycanca',
'bg' => 'Bulgarian - Български',
'bn' => 'Bengali - বাংলা',
'ca' => 'Catalan - Català',
......@@ -110,6 +111,7 @@
'tr' => 'Turkish - Türkçe',
'ug' => 'Uyghur - ئۇيغۇرچە',
'uk' => 'Ukrainian - Українська',
'uz' => 'Uzbek - ўзбек',
'vi' => 'Vietnamese - Tiếng Việt',
'zh-TW' => 'Chinese Traditional - 繁體中文',
'zh' => 'Chinese Simplified - 简体中文',
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
<?php
/*
Question2Answer (c) Gideon Greenspan
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment