Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Tomas Votruba:
How to Complete Type Declarations without Docblocks with Rector
Jan 07, 2019 @ 16:52:08

Following up on his prior post showing how to convert DocBlock comments to official type hinting, Tomas Votruba has continued the series with a new post showing how to do the same thing but without previously defined DocBlocks.

In previous post we looked at how to migrate from docblocks to type declarations. From @param Type $param to Type $param. Even if it doesn't break code like coding standards do, works with inheritance, localized self and static and propagates types to all child classes, it's still not such a big deal.

But how do you complete type declarations if don't have any docblocks?

After a "gloom and doom" start to the post, he circles back around and shows how PHPStan and Reactor can help with static analysis. After providing several examples of how the refactor should look, he shows how to set up Reactor for both return types and the migration of properties to their correctly typed versions automatically.

tagged: type declaration migration docblock reactor phpstan

Link: https://www.tomasvotruba.cz/blog/2019/01/03/how-to-complete-type-declarations-without-docblocks-with-rector/

Community News:
Namespaces in PHP6
Jul 06, 2007 @ 16:10:00

Spurred on by a recent post to the php-dev mailing list by Dmitry Stogov the ever-popular "namespaces discussion" has surged back to the top of everyone's list. Dmitry proposed a patch for PHP6 that would easily implement namespaces for the upcoming version.

All class and function names inside are automatically prefixed with namespace name. Inside namespace, local name always takes precedence over global name. It is possible to use the same namespace in several PHP files. The namespace declaration statement must be the very first statement in file.

The general idea is to provide an easy separation of functionality but to keep things accessible at any level (in scope, in parent scope, etc). He's included code in his mailing list post to illustrate how it would all work.

Several others in the PHP community have jumped on and are already talking about this new proposal:

tagged: namespace php6 patch declaration mailinglist phpdev namespace php6 patch declaration mailinglist phpdev

Link:

Community News:
Namespaces in PHP6
Jul 06, 2007 @ 16:10:00

Spurred on by a recent post to the php-dev mailing list by Dmitry Stogov the ever-popular "namespaces discussion" has surged back to the top of everyone's list. Dmitry proposed a patch for PHP6 that would easily implement namespaces for the upcoming version.

All class and function names inside are automatically prefixed with namespace name. Inside namespace, local name always takes precedence over global name. It is possible to use the same namespace in several PHP files. The namespace declaration statement must be the very first statement in file.

The general idea is to provide an easy separation of functionality but to keep things accessible at any level (in scope, in parent scope, etc). He's included code in his mailing list post to illustrate how it would all work.

Several others in the PHP community have jumped on and are already talking about this new proposal:

tagged: namespace php6 patch declaration mailinglist phpdev namespace php6 patch declaration mailinglist phpdev

Link:

Matthew Weir O'Phinney's Blog:
exuberant ctags with PHP in Vim
Feb 01, 2007 @ 13:17:46

In a new post, Matthew Weir O'Phinney sharing a handy new tool that he discovered - exuberant ctags - that lets you magically click on a class of function name and move to its declaration.

I found exuberant ctags, a library which can be used to generate an index file mapping language objects to source files and the line in the source file where they are declared. Contrary to its name, it's not just for the C language; it currently supports 33 different programming languages, including PHP.

He also includes a usage example in the post, specifically for getting the tool up and working in your Vim installation (via a bash script). Then it's just a matter of issuing a :set command to point at the correct file and you're one keystroke away from the function/class declaration of your choice.

tagged: vim exuberantctags jump function class declaration vim exuberantctags jump function class declaration

Link:

Matthew Weir O'Phinney's Blog:
exuberant ctags with PHP in Vim
Feb 01, 2007 @ 13:17:46

In a new post, Matthew Weir O'Phinney sharing a handy new tool that he discovered - exuberant ctags - that lets you magically click on a class of function name and move to its declaration.

I found exuberant ctags, a library which can be used to generate an index file mapping language objects to source files and the line in the source file where they are declared. Contrary to its name, it's not just for the C language; it currently supports 33 different programming languages, including PHP.

He also includes a usage example in the post, specifically for getting the tool up and working in your Vim installation (via a bash script). Then it's just a matter of issuing a :set command to point at the correct file and you're one keystroke away from the function/class declaration of your choice.

tagged: vim exuberantctags jump function class declaration vim exuberantctags jump function class declaration

Link:


Trending Topics: