phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 630 forks source link

WebTools: models generated with no namespace specified are broken because line is not omitted #1467

Closed gianks closed 3 years ago

gianks commented 4 years ago

Questions should go to https://forum.phalconphp.com Documentation issues should go to https://github.com/phalcon/docs/issues

Expected and Actual Behavior

Generate Models from Database Tables with WebTools without specifing a namespace

Provide output if related

[error] Uncaught exception: syntax error, unexpected ';', expecting '{' in /var/www/bw/app/models/ActivationToken.php on line 3

Provide minimal script to reproduce the issue

Add to any PHP file the generated line: 

namespace ;

Details

Environment: OS: Linux BW 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 PHP Version: 7.3.19-1~deb10u1 PHP SAPI: cli PHP Bin: /usr/bin/php7.3 PHP Extension Dir: /usr/lib/php/20180731 PHP Bin Dir: /usr/bin Loaded PHP config: /etc/php/7.3/cli/php.ini Versions: Phalcon DevTools Version: 4.0.3 Phalcon Version: 4.0.6 AdminLTE Version: 2.3.6

Directive => Local Value => Master Value phalcon.db.escape_identifiers => On => On phalcon.db.force_casting => Off => Off phalcon.orm.case_insensitive_column_map => Off => Off phalcon.orm.cast_last_insert_id_to_int => Off => Off phalcon.orm.cast_on_hydrate => Off => Off phalcon.orm.column_renaming => On => On phalcon.orm.disable_assign_setters => Off => Off phalcon.orm.enable_implicit_joins => On => On phalcon.orm.enable_literals => On => On phalcon.orm.events => On => On phalcon.orm.exception_on_failed_save => Off => Off phalcon.orm.exception_on_failed_metadata_save => On => On phalcon.orm.ignore_unknown_columns => Off => Off phalcon.orm.late_state_binding => Off => Off phalcon.orm.not_null_validations => On => On phalcon.orm.update_snapshot_on_save => On => On phalcon.orm.virtual_foreign_keys => On => On phalcon.warning.enable => On => On

* PHP Version:

PHP 7.3.19-1~deb10u1 (cli) (built: Jul 5 2020 06:46:45) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.19-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies


* Operating System:

Debian 10.4

* Server: Nginx
* Other related info (Database, table schema): MariaDB

### My Easy Fix (run it in models folder after generation):
```php
find ./ -prinf '%p' -type f -exec send -i -n '/namespace ;/!p' {} \;
BeMySlaveDarlin commented 3 years ago

Added empty string checks on namespace templating

Jeckerson commented 3 years ago

Fixed in #1496