M
M
Michael2018-05-04 18:19:33
PHP
Michael, 2018-05-04 18:19:33

What is the correct way to write "&" from the point of view of PSR?

I do not see in the standards a recommendation for writing an ampersand.

foreach ($dataSource as & $item) {
}

How to write:
& $item
or
&$item

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Romashkan, 2018-05-04
@springimport

Here is the psr https://github.com/php-fig/fig-standards/blob/mast...
Item 4.4
A method declaration looks like the following. Note the placement of parentheses, commas, spaces , and braces:

<?php

namespace Vendor\Package;

class ClassName
{
    public function fooBarBaz($arg1, &$arg2, $arg3 = [])
    {
        // method body
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question