[PHP-DEV] Assign return value of function to property or replace parse error with nice fatal error

2016-07-11 Thread Khawer .
It would be better if we can assign return value of function to property.

If not at least we should generate a nice error message.

Currently when we try to assign return value of function to property we get
the following error:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
index.php on line 4

We should replace this error with the following error:
Fatal error: You must assign a static value to property in index.php on
line 4.
OR
Fatal error: Dynamic values cannot be assigned to property in index.php on
line 4.


[PHP-DEV] Change -> to dot(.)

2017-07-05 Thread 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(.). We will still keep "->" until PHP 8 to
maintain backward compatibility.


[PHP-DEV] Partial Classes

2017-07-06 Thread Khawer .
Partial Classes

If we are using same class for different purposes we can extend it, and add
new properties and methods. But we will also have to use new class name,
when we create objects. C# provides a better concept "Partial Classes". Why
not to also implement it in PHP?

Example:

Partial Class abc {

  public function sayhi() {
   echo "Hi";
  }

}

Partial Class abc {

  public function sayhello() {
   echo "Hello";
  }

}

Q: What will happen if both classes contain same method names?
A: We will show error method already exists.

Q: Will it break any existing code?
A: No, there will be no impact on any existing coding because we are not
changing anything.


[PHP-DEV] Changes in namespace importing

2017-11-23 Thread Khawer .
We use 'use' keyword to import other namespaces, namespace classes,
namespace functions, and namespace constants.

Example
1) use abc; (Import abc namespace)
2) use abc\ClassB; (Import ClassB  from abc namespace)
3) use function abc\sayhello; (Import sayhello function from abc namespace)
4) use const abc\name; (Import name constant  from abc namespace)

In (1) we are importing whole namespace and in (2) we are just importing
class. But there is no difference in syntax like when we import function we
use 'use function'. We should change (2) to 'use class abc\ClassB'. It will
make syntax more clear and remove any confusion and also match with other
syntax like use function  and use const. Current syntax will also work so
there will be no backward compatibility break.