In all major programming languages we access object properties and methods
using dot(.).
C#:
Abc Abc = new Abc();
Abc.method();
Java:
Abc Abc = new Abc();
Abc.method();
JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());
Why not to make PHP similar to these languages by allowing to access object
properties and methods using dot(.). We will still keep "->" until PHP 8 to
maintain backward compatibility.
The dot is already the string concatenation operator. This would be a horrible migration process. The PHP team is never going to upset the developer experience that much for a purely cosmetic change.
Also, C and C++ use the -> symbol, two major languages.
Regards
In all major programming languages we access object properties and methods
using dot(.).C#:
Abc Abc = new Abc();
Abc.method();Java:
Abc Abc = new Abc();
Abc.method();JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());Why not to make PHP similar to these languages by allowing to access object
properties and methods using dot(.). We will still keep "->" until PHP 8 to
maintain backward compatibility.
What's the point?
Sorry for the snarky response, but it had to be done ?
In all major programming languages we access object properties and methods
using dot(.).
C#:
Abc Abc = new Abc();
Abc.method();
Java:
Abc Abc = new Abc();
Abc.method();
JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());
Why not to make PHP similar to these languages by allowing to access object
properties and methods using dot(.). We will still keep "->" until PHP 8 to
maintain backward compatibility.
In all major programming languages we access object properties and methods
using dot(.).C#:
Abc Abc = new Abc();
Abc.method();Java:
Abc Abc = new Abc();
Abc.method();JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());Why not to make PHP similar to these languages by allowing to access object
properties and methods using dot(.). We will still keep "->" until PHP 8 to
maintain backward compatibility.
In each of those languages, the plus operator is used for string concatenation.
In PHP the dot operator is used for string concatenation, and objects can be cast to strings when concatenating, so how do you differentiate the two calls at the end of this block:
class Bar {
public function baz() {…}
public function __toString(): string {...}
}
function baz(): string {…}
$foo = new Bar();
$foo.baz(); // call method Baz on object $foo
$foo.baz(); // concat the result of casting $foo to string, with the result of calling baz()
Stephen Reay php-lists@koalephant.com schrieb am Do., 6. Juli 2017, 09:04:
In all major programming languages we access object properties and
methods
using dot(.).C#:
Abc Abc = new Abc();
Abc.method();Java:
Abc Abc = new Abc();
Abc.method();JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());Why not to make PHP similar to these languages by allowing to access
object
properties and methods using dot(.). We will still keep "->" until PHP 8
to
maintain backward compatibility.In each of those languages, the plus operator is used for string
concatenation.In PHP the dot operator is used for string concatenation, and objects can
be cast to strings when concatenating, so how do you differentiate the two
calls at the end of this block:class Bar {
public function baz() {…}public function __toString(): string {...}
}
function baz(): string {…}
$foo = new Bar();
$foo.baz(); // call method Baz on object $foo
$foo.baz(); // concat the result of casting $foo to string, with the
result of calling baz()
Obviously by using plus for concatenation.
Regards, Niklas
06.07.2017 09:43 "Niklas Keller" me@kelunik.com napisał(a):
Stephen Reay php-lists@koalephant.com schrieb am Do., 6. Juli 2017,
09:04:In all major programming languages we access object properties and
methods
using dot(.).C#:
Abc Abc = new Abc();
Abc.method();Java:
Abc Abc = new Abc();
Abc.method();JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());Why not to make PHP similar to these languages by allowing to access
object
properties and methods using dot(.). We will still keep "->" until
PHP 8
to
maintain backward compatibility.In each of those languages, the plus operator is used for string
concatenation.In PHP the dot operator is used for string concatenation, and objects
can
be cast to strings when concatenating, so how do you differentiate the
two
calls at the end of this block:class Bar {
public function baz() {…}public function __toString(): string {...}
}
function baz(): string {…}
$foo = new Bar();
$foo.baz(); // call method Baz on object $foo
$foo.baz(); // concat the result of casting $foo to string, with the
result of calling baz()Obviously by using plus for concatenation.
That would be huge BC break because plus on string which ale numerical is
adding numbers so result fir now would be sum. Not concatenated string.
Regards, Niklas
Am 06.07.2017 um 08:13 schrieb Khawer.:
In all major programming languages we access object properties and methods
using dot(.).C#:
Abc Abc = new Abc();
Abc.method();Java:
Abc Abc = new Abc();
Abc.method();JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());Why not to make PHP similar to these languages by allowing to access object
properties and methods using dot(.)
to gain what?
We will still
who is "we"
keep "->" until PHP 8 to maintain backward compatibility
and then force to rewrite every single piece of code out there?
that's a "have a solution and seeking for the problem"