Do not introduce unnecessary intermediate variables when accessing object properties. Access properties directly using chain notation.
Bad:
$sessionConfig = $serverConfig->session;
$type = $sessionConfig->type;
$ttl = $sessionConfig->ttl;Good:
$type = $serverConfig->session->type;
$ttl = $serverConfig->session->ttl;Only create intermediate variables when:
- The same property chain is accessed many times (3+) and readability improves
- The intermediate value needs to be modified
- The property access has side effects that should only happen once