Task #2515
Inconsistent class names in sub namespaces
Status: | Resolved | Start date: | 2009-01-26 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Robert Lemke | % Done: | 100% |
|
Category: | - | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 1 | |||
Sprint: | Has patch: | |||
PHP Version: | Complexity: |
Description
In the current code base the naming of classes in sub namespaces is not consistent. After a short discussion we came up with the following rules:
- The unqualified class name must be meant literally even without the namespace.
- The main purpose of namespaces is categorization and ordering
Thes rules prevent us from running into conflicts with reserved keywords.
Bad examples:¶
Fully qualified class name Unqualified class name Remarks -------------------------------------------------------------------------------------------------------------------- \F3\FLOW3\Session\PHP PHP The class is not a representation of PHP! \F3\FLOW3\Cache\Backend\File File The class doesn't represent a file! \F3\FLOW3\Session\Interface Interface Not allowed, "Interface" is a reserved keyword \F3\Foo\Controller\Default Default Not allowed, "Default" is a reserved keyword
Good examples:¶
Fully qualified class name Unqualified class name Remarks -------------------------------------------------------------------------------------------------------------------- \F3\FLOW3\Session\PHPSession PHPSession That's a PHP Session \F3\FLOW3\Cache\Backend\FileBackend FileBackend A File Backend \F3\FLOW3\Session\SessionInterface SessionInterface Interface for a session \F3\Foo\Controller\DefaultController DefaultController The default controller
Edge cases:¶
Fully qualified class name Unqualified class name Remarks -------------------------------------------------------------------------------------------------------------------- \F3\FLOW3\Object\Manager Manager If it's the only manager in that namespace, it's okay \F3\Foo\Bar\Builder Builder If it's clear what the builder builds (Bar?), it's okay \F3\FLOW3\Object\Builder Builder Problem: There's a "ConfigurationBuilder" in the same namespace, therefore better rename the Builder to ObjectBuilder \F3\FLOW3\Object\Factory Factory As long as it is the only factory in that namespace, okay \F3\FLOW3\MVC\ControllerInterface ControllerInterface Consequently the interface belongs to all the controllers in the Controller sub namespace \F3\FLOW3\MVC\Controller\ControllerInterface Better \F3\FLOW3\Cache\AbstractBackend AbstractBackend Same here: In reality this class belongs to the backends \F3\FLOW3\Cache\Backend\AbstractBackend BetterScope of this ticket:
- Refactor class names which don't follow the above rules.
Add the above rules to the CGL.
Associated revisions
- Testing: Fixed the initialization sequence in the TestRunner which didn't work anymore since the last modifications on the session init in the FLOW3 bootstrap
- FLOW3: (Session) Renamed the classes ...\Session\PHP and ...\Session\Transient to ...\Session\PHPSession and ...\Session\TransientSession respectively. Addresses #2515
- FLOW3: (MVC) Renamed the setSettings() method of the AbstractController to injectSettings() in order to use the new settings injection feature
- FLOW3: (MVC) Moved the Controller Interface to the Controller namespace. Addresses #2515
- FLOW3: (Utility) Removed the REQUEST_METHOD_* constants in the Environment class
- FLOW3: (Utility) Renamed the getPOSTArguments and getGETArguments methods to getRawPOSTArguments and getRawGETArguments respectively
- FLOW3: (Utility) Introduced a new method getRawServerEnvironment to the Environment API
FLOW3:
- moved and renamed some cache backend classes and interfaces, refs #2515
- adjusted one reference to Cache\Backend\File to the new name
FLOW3:
- moved and renamed some Log backend classes and interfaces, refs #2515
FLOW3:
- moved and renamed cache frontend classes and interfaces, refs #2515
- FLOW3: (MVC) Moved the ViewInterface into the View sub namespace. Addresses #2515
- FLOW3: (MVC) Added a ControllerInterface to decouple classes using controllers from the AbstractController
- FLOW3: (MVC) Merged the RequestHandlingController into the AbstractController. Still needs further cleanup and some tests are currently disabled.
- FLOW3: (MVC) Wrote a proper testcase for the dispatcher
- FLOW3: (MVC) Moved the ConverterInterface into the correct namespace. Addresses #2515
- FLOW3: (Utility) Added a new function getFileContents() to the Files library. Preferibly use this function instead of PHP's built-in file_get_contents() function because it will handle warnings and errors more gracefully.
- Fluid: Cleaned up and partly refactored the TemplateView. Especially fixed the error prone comparisons (see #2536). There are still some skeletons in the closet and especially the unit tests badly need some improvements (more / proper use of mock objects, no functional test but unit tests etc.).
FLOW3:
- added better examples and more explanations about namespace/class naming to CGL, refs #2515
- FLOW3: Renamed a few classes / moved them in the namespaces hierarchy to make naming more consistent. Resolves #2515
- FLOW3: (MVC) Removed the AbstractWidget
History
#1 Updated by Karsten Dambekalns about 6 years ago
- Assigned To set to Robert Lemke
#2 Updated by Robert Lemke about 6 years ago
- Status changed from Accepted to Resolved
- % Done changed from 0 to 100
Applied in changeset r2282.