Child pages
  • Coding Standards Compliance [5.2.1-RC1]
Skip to end of metadata
Go to start of metadata

In-Portal is out there for quite a long time and it doesn't really conform to any existing coding standard (e.g. PSR2 and such).

I think that:

  1. it's time to develop a Coding Standard
  2. find a way to automatically check for any standard violations
  3. make the "Custom" (Developer Kit) module comply to all standards
  4. update Unit Config Generator to produce only standard compliant code

I've create a list of replacements, that can be made in PhpStorm to at least start fixing the standards.

Replace ThisWith ThisIs Regular ExpressionReplace Options
Array (array(nocase sensitive, match whole words
array (array(nocase sensitive, match whole words
Array(array(nocase sensitive, match whole words
(@param kEvent \$event)\n$1 Event.\nyescase sensitive, match whole words
[\t]+ \* @access protected\n yes 
=> NULL=> nullnocase sensitive, match whole words
\tclassmanually remove 1 indention level  
class (.*?) extends (.*?) \{class $1 extends $2\n\{yes 
@param Array @param array no, but notice space at the end 
* @param int * @param integer no, but notice space at the end 
(\* @param array \$params)\n$1 Tag params\.\nyes 
(// .*?[^\.])\n$1.\nyes, but manually check where a replacement is valid 

Class declaration

Another thing, that is fairly common is to apply 1 more extra TAB for class declaration indentation (see below). So it's commended to use Shift+TAB shortcut of PhpStorm to fix that instantly.

	class SomeClass {

class SomeClass {



In fact I've developed a coding standard already (see, but it's not mature yet to be released.

Related Tasks


  1. I guess we need to reformat in core some methods which we are using most frequently to avoid repeating code style errors on projects.

    1. Can you please list methods and classes they're located in, that we should change first?

        • kDBItem::SetFieldsFromHash()


        • kDBEventHandler::applyItemFilters()


        • kDBTagProcessor::ItemLink()
        • KDBTagProcessor::ModifyUnitConfig() (be careful with In-Commerce)
        • KDBTagProcessor::PageLink()
        • KDBTagProcessor::PrepareListElementParams()


        • CategoriesTagProcessor:: CategoryLink()


        • kCatDBEventHandler::getTypeClauses()


        • kHelper::InitHelper()


        • FavoritesEventHandler::OnFavoriteToggle()


        • kCountryStatesHelper ::PopulateStates()


        • ItemFilterTagProcessor::ListFilterOptions()


        • UsersEventHandler::OnLogin()
        • UsersEventHandler::OnResetLostPassword()
        • UsersEventHandler::beforeItemChanged()


        • UsersTagProcessor::ConfirmPasswordLink()
        • UsersTagProcessor::LogoutLink()
        • UsersTagProcessor::ProfileLink()
  2. Here are some more methods, that needs to be taken care of:

    • kRewriteUrlProcessor::_parsePage
    • kDBTagProcessor::PresetFormFields
    • CategoriesTagProcessor::CachedMenu
    • kFormatter::PrepareOptions
    • kDBEventHandler::PrepareObject
    • kDBItem::UpdateSubFields
    • kDBItem::UpdateMasterFields
    • UsersEventHandler::_makePasswordRequired
    • UsersEventHandler::afterItemChanged
    • UsersEventHandler::saveUserImages
    • UsersEventHandler::AddSubscriberGroup
    • UsersEventHandler::setNextTemplate
    • OrdersEventHandler::AddItemToOrder
    • OrdersEventHandler::CheckOptions
    • event declarations in general
    • tag declarations in general