We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Stubs for Phalcon 2.0

Hello community,

how can stubfiles for IDEs like PhpStorm, etc. generated for Phalcon 2.0? Or, does somebody own such files?

UPDATE: I know that I can generate the files with zephir stubs now.

But I think that the generator is making mistakes. A short example:

<?php

namespace Phalcon\Mvc;

class Application extends \Phalcon\Di\Injectable
{

    protected $_defaultModule;

    protected $_modules;

    protected $_implicitView = true;

    /**
     * Phalcon\Mvc\Application
     *  
     * @param Phalcon\DiInterface dependencyInjector <--- HERE is the mistake: Autocomplete is not working correctly. "\Phalcon\DiInterface" would be right.
     *  
     *
     * @param mixed $dependencyInjector 
     */
    public function __construct($dependencyInjector = null) {}

}

Am I right?



98.9k
Accepted
answer


6.6k

Thank you @Phalcon, that's working!



6.6k

Another question: The stubs which are generated by the old generator for Phalcon 2 are not completely correct. E.g. here:

<?php
namespace Phalcon\Mvc {

    interface ModuleDefinitionInterface {

        public function registerAutoloaders($dependencyInjector=null);

        public function registerServices($dependencyInjector);

    }
}

But the following signature is enforced by the runtime:

public function registerAutoloaders(DiInterface $dependencyInjector = null)
{
    //...
}

public function registerServices(DiInterface $dependencyInjector)
{
    //...
}

As a result of this the autocomplete of the Phpstorm doesn't work correctly for me.

What can I do?



98.9k

I think the script must be updated to support Phalcon 2



6.6k

I've updated the script with support for this. I'll try to commit it.

@skollro Meanwhile could you please upload the result for us?! Would appreciate it very much sir :)



6.6k

I've uploaded the stubfiles and the generator to my fork of the phalcon-devtools. If there are some things missing for complete Phalcon 2 stubs feel free to comment.

https://github.com/skollro/phalcon-devtools

edited Nov '14

I recently did some work on zephir stubs it's probably not 100% there yet but you may give it a try again.



6.6k

Well done @rzajac! :) Could you please implement the type hints for method parameters I proposed some days ago? And what shall we do with magic property setters and getters of Zephir? They have no documentation. The IDE thinks the getters would have a void return type, which is obviously not true.

Hey thanks, I was just scratching my itch :) The method parameters are still somethong to be done but the method documentation for example you gave (ModuleDefinitionInterface) right now have proper types for parametes. The documentation for Zephir magic setters / getters are aloso generated as long as there is documentation for them in Zephir. I tested it on: https://github.com/phalcon/cphalcon/commit/e802a2dbaf55d496f7ee16d473c327629c72b020 and generated docs have propertioes and setters / getters documented.

I will be adding some more docs to Zephir code but probebly only to things I use in my project. Maybe you shuld add some docs for things you use :)



6.6k

I will be adding some more docs to Zephir code but probebly only to things I use in my project. Maybe you shuld add some docs for things you use :)

Thanks @rzajac! Now that I know that contribution for better stub files need a documentation in the Zephir code I will comment the methods that I use and commit them. I think I will take a look at the problem with the missing method parameters...



6.6k

@rzajac, @phalcon: Do you know how to solve the problem to distinguish between an auto generated setter when generating the docs?

I've added documentation to Phalcon\Events\Event today and the following is produced:

class Event
{
    /**
     * Event type
     *
     * @var string
     */
    protected $_type;

    /**
     * Event type
     *
     * @param mixed $type 
     * @return string               // <-- here is the problem
     */
    public function setType($type) {}

    /**
     * Event type
     *
     * @return string 
     */
    public function getType() {}
}

The function setType() has a void return type, not a string. I think some changes are required here: https://github.com/phalcon/zephir/blob/master/Library/Stubs/MethodDocBlock.php#L79. Am I right?

I created a pull request to fix this and some other issues.

https://github.com/phalcon/zephir/pull/638