PersistenceObjects for php

Manual

Naming restrictions:

This article explains naming restrictions that projects that use PersistenceObjects must follow.

PersistenceObjects for php forces a few naming restriction rules. This is because even though the objects use reflection to find methods and properties, it is easier to assume that a few basic princibles exist.

1. camelCase

Classnames, methods and properties should use camelCase in their names. for exampler:

WRONG
class user {
	
	private $id;
	private $property_that_is_wrongly_named;
	
	public getproperty() {
		return $this->property_that_is_wrongly_named;
	}
	
}

CORRECT
class User {
	
	private $id;
	private $propertyThatIsCorrectlyNamed;
	
	public getPropertyThatIsCorrectlyNamed() {
		return $this->propertyThatIsCorrectlyNamed;
	}
	
}

2. id must be "id", not "Id" or "iD" or anything else.

Each class must have an id property and it should be named "id". Remember camelCase with setters and getters.

WRONG
class User {
	
	private $ID;
	
	public getID() {
		return $this->ID;
	}
	
}

CORRECT
class User {
	
	private $id;
	
	public getId() {
		return $this->id;
	}
	
}

3. PersistenceObjects naming.

PersistenceObjects must be named "[className]Persistence". This is because when fetching connected objects, reflection is used to create a PersistenceObject-instance for the connected object.

WRONG, will not be found
class UserPO extends PersistenceObject {
	
	...
	
}

CORRECT
class UserPersistence extends PersistenceObject {
	
	...
	
}