[TYPO3-50-general] Common namings for variables with path-content

Robert Lemke robert at typo3.org
Mon Jan 12 12:31:46 CET 2009


Hi Malte,

Am 12.01.2009 um 12:06 schrieb Malte Jansen:

>>> So for the class-part, would suggest:
>>>
>>> namespace F3\MyPackage\;
>>> class MyClass {}
>>>
>>> => "className" == MyClass
>>> => "class" == F3\MyPackage\MyClass  (PHP: __CLASS__)
>>
>> currently $class in FLOW3 means ReflectionClass($className), $method
>> means ReflectionMethod($methodName) etc.
>
> I would suggest
> $reflectionClass = Reflection_ReflectionClass($class)
> like $objectFactory = Object_Factory($class)

The rule we have is to take variable names as literal as possible, so  
if you
have a variable called $objectFactory it contains an object which is an
Object Factory. In your example $class does not contain a class (or  
object
thereof) but the name of the class.

> We should stic closer to PHP...

... not always a good thing because PHP is not famous for its  
consistent and
intuitive naming ;-)

> $class == __CLASS__
> $class == $namespace . $className (like $file == $path . $fileName)
> $class == __NAMESPACE__ . $className

I'd say that $className should in most cases be __CLASS__, i.e. the  
full qualified
class name without leading backslash. That's what I'd expect most of  
the time.

> basically in FLOW3
> we are useing $componentClassName for an object.

we don't have something like $componentClassName. What we do have is  
"className" in
the ObjectConfiguration.

>> Strictly speaking, __CLASS__ should be $fullQualifiedClassName - but
>> maybe we find a better name?
>
> There is also a name missing for a part of the namespace. First I  
> had in
> mind "component", but it's reserved for a subpackage.
>
> e.g. $class = F3\MyPackage\SubPackage\MyClass
> foreach (explode('\\', $class) AS ??????) {}
> Any ideas?
>
>
> Annotation:
> Sticing closer to PHP I had in mind
> with "directory" as "absolutePath", because of the function is_dir()  
> and
> the  DirectoryIterator...

I understand, but still it would weaken consistency in terms of being  
able to
guess what a variable contains.

robert



More information about the TYPO3-project-5_0-general mailing list