Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

PHP coding guidelines

Benjamin Jakobus edited this page Apr 9, 2014 · 18 revisions

PHP core

The PHP core and Moodle block follow the Zend Coding Standard for PHP. The only deviation from these guidelines is the class documentation: Classes are required to contain the IBM SBT copyright notice and may only contain a description and @author tag (other tags are optional). The IBM SBT copyright notice is as follows:

© Copyright IBM Corp. 2013 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You should run PHP CodeSniffer using the rulset (at the root of the PHP directory; php/ruleset.xml) against the file that you are to commit and fix any errors that it might report.

Run PHP CodeSniffer using the -n flag. For example: phpcs -n --standard=~/SocialSDK/php/ruleset.xml php-core/src/autoload.php > ~/phpcs_report

Wordpress plugin

The Wordpress plugin (SocialSDK/php/wordpress-plugin) follows the official Wordpress coding standards specified in the Core Contributor Handbook.

Widget files must be contained in /views/widgets and must be pre-fixed with ibm-sbt and end in .php

Widget functions must be prefixed with ibm_sbt to avoid potential collisions.

Naming conventions

Tuples written to a database as part of either the PHP Core, Moodle block or Wordpress plugin must be prefixed with ibm-sbt- in order to prevent conflicts with any other 3rd party applications.