This is an subjective question, I need your feels and thoughts about coding standards, and formatting practices.
PHP Zend coding standard requires to write multiline function calls like this:
$returnedValue = $object->longMethodName(
$argument1,
$otherArgument,
42
);
I think the following approach is more readable:
$returnedValue = $object->longMethodName($argument1,
$otherArgument,
42);
Becouse the there is only one line on the left side, this indicates this is only one statement, and the arguments are closer to the method name.
Which one do YOU prefer?
Aspect Oriented Design pattern.
Zend Framework is a collection of professional PHP packages with more than 570 million installations. It can be used to develop web applications and services using PHP 5.6+, and provides 100% object-oriented code using a broad spectrum of language features.
The Zend framework makes web development easy, and can complete tasks quickly and efficiently. The ZF doesn't come as a whole unit that doesn't budge at all. It is decoupled, meaning the components come as an individual library , so the developers need to load only the required components.
Zend is an open source PHP framework. It is pure object-oriented and built around the MVC design pattern. Zend framework contains collection of PHP packages which can be used to develop web applications and services. Zend was started by Andi Gutmans and Zeev Suraski.
The second approach leaves you with one additional Problem: Line length. The Zend Coding Standard suggest that "The maximum length of any line of PHP code is 120 characters."
This means if you want good (long, descriptive) Variables names and you happen to have one for the return value, the object, a good named function and a long parameter you are much more likely to hit that 120 chars limit.
Adding to that and depending on your standard the max length may be only 80 Chars or something in between.
Additionally i like the first one better if used repeatedly
$returnedValue = $object->longMethodName(
$argument1,
$otherArgument,
42
);
$returnedValue = $object->longMethodName(
$argument1,
$otherArgument,
42
);
$returnedValue = $object->longMethodName(
$argument1,
$otherArgument,
42
);
$returnedValue = $object->longMethodName(
$argument1,
$otherArgument,
42
);
$returnedValue = $object->longMethodName($argument1,
$otherArgument,
42);
$returnedValue = $object->longMethodName($argument1,
$otherArgument,
42);
$returnedValue = $object->longMethodName($argument1,
$otherArgument,
42);
$returnedValue = $object->longMethodName($argument1,
$otherArgument,
42);
Like Pekka said, less eye jumping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With