cakephp-ide-helper

IDE Helper plugin for CakePHP

MIT License

Downloads
1.5M
Stars
183
Committers
25
cakephp-ide-helper - 0.12.5

Published by dereuromark about 6 years ago

Bugfixes

Fixed the pivot relation from BelongsToMany to the correct one (HasMany):

 * @property \App\Model\Table\FeaturesFeaturesTable|\Cake\ORM\Association\HasMany $FeaturesFeatures
 * @property \App\Model\Table\FeaturesModulesTable|\Cake\ORM\Association\HasMany $FeaturesModules
 */
class FeaturesTable extends Table

HABTM is always 2x hasMany from the outside in and 2x belongsTo from the inside out.

cakephp-ide-helper - 0.12.4

Published by dereuromark about 6 years ago

Improvements

Added HABTM annotations for pivot table and its Table class relation.

For BelongsToMany relationships this will add typehinting/clickability for the pivot table and its Table class:

// FeaturesTable
        $this->belongsToMany('DependingFeatures', [
            'foreignKey' => 'feature_id',
            'className' => 'Features',
            'targetForeignKey' => 'depending_feature_id',
            'joinTable' => 'features_features',
            'propertyName' => 'depending_features',
        ]);
        $this->belongsToMany('Modules', [
            'foreignKey' => 'feature_id',
            'targetForeignKey' => 'module_id',
            'through' => 'FeaturesModules',
            'joinTable' => 'features_modules',
            'propertyName' => 'modules',
        ]);

now adds

 * @property \App\Model\Table\FeaturesFeaturesTable|\Cake\ORM\Association\HasMany $FeaturesFeatures
 * @property \App\Model\Table\FeaturesModulesTable|\Cake\ORM\Association\HasMany $FeaturesModules
 */
class FeaturesTable extends Table

or at least basic Cake\ORM\Table class for chaining and querying on the pivot table as in

$this->Features->FeaturesModules->find()->contain(['Modules', 'Features']);
// or
$this->Features->FeaturesFeatures->find()->contain(['DependingFeatures', 'Features']);

Note one time through and one time auto-calculation alias.

habtm

cakephp-ide-helper - 0.12.3

Published by dereuromark about 6 years ago

Improvements

Added callback tasks

Table behaviors and generic model code use the following signature:

/**
 * @param \Cake\Event\Event $event Event
 * @param \Cake\Datasource\EntityInterface $entity Entity
 * @param \ArrayObject $options Options
 * @return void
 */
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)

And as long you only use methods and attributes of the EntityInterface (as contracted here), this is fine.

But in specific Table class code, you usually also access the entities' concrete properties.
Here using this typehint is somewhat a lie. To please IDE and tooling like PHPStan we can at least fix up the doc block, however.
And that is what this task is doing, declaring the concrete entity to be available and used inside.

Inside the concrete PostsTable after running the callbacks command:

/**
 * @param \Cake\Event\Event $event Event
 * @param \App\Model\Entity\Post $entity Entity
 * @param \ArrayObject $options Options
 * @return void
 */
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)

The tooling now knows to expect the apps' Post entity and its methods/properties to be available.

You can also add your own tasks into the collection to make certain changes for other CakePHP callbacks. See docs for details.

cakephp-ide-helper - 0.12.2

Published by dereuromark about 6 years ago

Bugfixes

Fix classes annotation inside subfolders.

cakephp-ide-helper - 0.12.1

Published by dereuromark about 6 years ago

Improvements

PHPStorm generator

Added Query::find() auto-complete besides the existing Table::find(), e.g. in callbacks:

$searchManager
	->callback('tag', [
		'callback' => function (QueryInterface $query, array $args) {
			$query->find('tagged', $args);
		}
	]);

The tagged finder would be autocompleted now.

Here is an example in PHPStorm:
untitled

Added class annotating

In order to run certain "fixers" over all classes, class annotations and their tasks are now available.
Out of the box it will already ship with one: ModelAware annotating.

Inside any non-ORM business logic class, e.g. Service/FooBar layer:

$this->loadModel('Posts');

automatically annotates

@property \App\Model\Table\PostsTable $Posts

above the class then.

This does, however, impact existing ones in terms of -r (remove) cleanup option as it is not completely in sync.
So use this only without the -r option for now.

cakephp-ide-helper - 0.12.0

Published by dereuromark over 6 years ago

Included commits: https://github.com/dereuromark/cakephp-ide-helper/compare/0.11.2...0.12.0

Improvements

CakePHP 3.6+ support
It can, however, be still necessary to set your error level to E_ALL & ~E_USER_DEPRECATED in your app.php config.

Note: squizlabs/php_codesniffer ^2.8 has been dropped in favor of ^3.0 only.

cakephp-ide-helper - 0.11.2

Published by dereuromark over 6 years ago

Improvements

Use the configured application namespace.

cakephp-ide-helper - 0.11.1

Published by dereuromark over 6 years ago

Bugfixes

Fixed element names for Windows OS users. The slashes inside element names are always forward / (and are not DS at this point).

cakephp-ide-helper - 0.11.0

Published by dereuromark over 6 years ago

Improvements

New auto-complete functionality for element() usage in templates:
No more typing of the full file name necessary, it will even find your plugin's elements or nested ones.

Demo: https://streamable.com/ixrbg

screenshot from 2018-03-16 11-40-16

Adjustments

CakePHP 3.5 and 3.6 are only supported from here on.
This is necessary as 3.4 does not fully work with PHP7.2+, and otherwise testing compatibility is difficult.
Make sure you upgraded to at least 3.5 already.

cakephp-ide-helper - 0.10.11

Published by dereuromark over 6 years ago

Improvements

  • Add saveOrFail() annotation for Table classes.
  • Allow for new diff tool dependency major
cakephp-ide-helper - 0.10.10

Published by dereuromark almost 7 years ago

Improvements

  • Allow including all loaded plugins and their helpers to View annotations.
  • Improved controller annotation for pagination collections by having the ResultSetInterface added

Bugfixes

  • Fixed controller pagination annotations for plugins
cakephp-ide-helper - 0.10.9

Published by dereuromark almost 7 years ago

Improvements

Allow plugin controllers to be annotated with their plugin models.

cakephp-ide-helper - 0.10.8

Published by dereuromark almost 7 years ago

Improvements

Also allow namespaced plugins to be annotated correctly.

cakephp-ide-helper - 0.10.7

Published by dereuromark almost 7 years ago

Improvements

Allow dynamically loaded behaviors to be annotated in Table classes.

cakephp-ide-helper - 0.10.6

Published by dereuromark almost 7 years ago

Bugfixes

  • Try catch didnt respect PHP7 errors.
  • Fixed custom vendor folder resolution.
cakephp-ide-helper - 0.10.5

Published by dereuromark almost 7 years ago

Improvements

Allow database Type auto-complete.

cakephp-ide-helper - 0.10.4

Published by dereuromark about 7 years ago

Improvements

  • Allow adding View class annotations for helpers from controller helpers array.
  • Allow ViewAnnotator to also look into loaded plugins for additional helper parsing (e.g. in ROOT/plugins).
cakephp-ide-helper - 0.10.3

Published by dereuromark about 7 years ago

Improvements

  • Add annotations in shells and tasks for loaded tasks.
  • Allow custom View class for TemplateAnnotator
  • Allow file license doc block above annotation doc block in templates
cakephp-ide-helper - 0.10.2

Published by dereuromark about 7 years ago

Bugfixes

  • Only remove inline comments if completely replaced, otherwise just keep it below the new doc block.
  • Small fixes for Windows.
cakephp-ide-helper - 0.10.1

Published by dereuromark about 7 years ago

Bugfixes

  • Fixed TemplateAnnotator for empty templates and also around inline doc blocks.
  • Removed preemptive template annotations by default, this was a bit too eager for some probably. Whoever wants this can easily enable it via Configure setting.
  • Improved syntax for vendor namespaced plugins: E.g. Vendor/PluginName.ModelName syntax now works.

Improvements

  • Added a -f/--filter option for AnnotationsShell to more quickly annotate specific new files.
Package Rankings
Top 1.19% on Packagist.org
Badges
Extracted from project README
CI Coverage Status PHPStan Minimum PHP Version
Related Projects