zephir-lang / zephir Goto Github PK
View Code? Open in Web Editor NEWZephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
Home Page: https://zephir-lang.com
License: MIT License
Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
Home Page: https://zephir-lang.com
License: MIT License
Hey!
Compiling Zephir goes okay, but running ./bin/zephir gives me:
Note, thats the 2nd run, so not everything may be contained.
Kind regards,
Ingwie
my zephir code is .......
// mage.zep
namespace magento;
final class Mage {
static private _registry = null;
public static function registry(key) {
var __isset__;
if fetch __isset__, self::_registry[key] {
return self::_registry[key];
}
return null;
}
public static function register(key, value, graceful = false) -> void {
if self::_registry === null { let self::_registry = []; }
var __isset__;
if fetch __isset__, self::_registry[key] {
if (graceful){ return; }
self::throwException("Mage registry key \"".key."\" already exists");
}
let self::_registry[key] = value; // this code is NOT woring...WHY?????
}
public static function throwException(message, messageStorage = null) {
throw new Mage_Core_Exception(message);
}
}
then build extension
zephir compile
cd ext
phpize && configure && make && make install
echo "extension=magento.so" > /etc/php.d/magento.ini
service httpd restart
then My PHP Code for test is.......
<?php
use \Magento\Mage as Mage;
Mage::register("myid", "4535363");
var_dump( Mage::registry("myid") );
?>
the webpage result is .........
null
It is not working the zephir code below. not saved...
self::_registry[key] = value;
why is not saved static variables ?
Currently Zephir doesn't understand PHP bitwise operators, i.e. |
, &
, etc. Bitwise or is particularly useful for constructing and evaluating flags.
Work around: Of course, strictly speaking, bitwise or is really the same as +.
Why has zephir a different syntax for things like foreach ?
It would make sense to be able to compile simple php files.
re2c and json-c are both available there, so it should not be too much of an hassle to port...
The documentation at http://zephir-lang.com/control.html#let suggests that the increment and decrement operator can be used on an object property. However, I've found with a very simple test that this doesn't appear to be so.
My simple test class (which is basically the 'hello world' from the tutorial), php calling code and results are be seen here:
https://gist.github.com/amnuts/8633535
In essence; neither of these work:
let this->counter1++;
let this->revcounter1--;
These always produce the value 1:
let this->counter2 += 1;
let this->revcounter2 -= 1;
These reliably work:
let this->counter3 = this->counter3 + 1;
let this->revcounter3 = this->revcounter3 - 1;
This is using Zephir 0.3.0a.
Here is my code
class Example
{
protected props;
public function set(int idx, string name) -> void
{
if !isset this->props[idx] {
let this->props[idx] = [];
}
var arr;
let arr = this->props[idx];
let arr[] = idx;
let this->props[idx] = arr;
}
}
It's produce some c code like this
PHP_METHOD(Test_Example, setHandler) {
...
_0 = zephir_fetch_nproperty_this(this_ptr, SL("props"), PH_NOISY_CC);
if (!(zephir_array_isset_long(_0, method))) {
ZEPHIR_INIT_VAR(_1);
array_init(_1);
//missing
}
_2 = zephir_fetch_nproperty_this(this_ptr, SL("props"), PH_NOISY_CC);
ZEPHIR_OBS_VAR(arr);
zephir_array_fetch_long(&arr, _2, method, PH_NOISY TSRMLS_CC);
zephir_array_update_zval(&arr, idx, &name, PH_COPY | PH_SEPARATE);
//missing
ZEPHIR_MM_RESTORE();
}
But no problem when use string as key.
ParseException: Syntax error in test.zep on line 11
else if ($z == 1)
--------^
http://www.php.net/manual/en/control-structures.elseif.php
#define XX_T_IF 363
#define XX_T_ELSE 364
+ #define XX_T_ELSE_IF ???
+ #define XX_T_ELSEIF ???
+ 'else if' {
+ s->active_char += sizeof("else if")-1;
+ token->opcode = XX_T_ELSE_IF;
+ return 0;
+ }
+
+ 'elseif' {
+ s->active_char += sizeof("elseif")-1;
+ token->opcode = XX_T_ELSEIF;
+ return 0;
+ }
19:02 | mac_nibblet > andresgut: https://github.com/macnibblet/ZephirEvm/blob/zf3/cyant/eventmanager/eventmanager.zep#L214
19:02 | mac_nibblet > andresgut: the test file https://github.com/macnibblet/ZephirEvm/blob/zf3/test.php
19:04 | mac_nibblet > andresgut: output from lldb (os x gdb) https://gist.github.com/macnibblet/7604247
19:06 | mac_nibblet > andresgut: The C code https://github.com/macnibblet/ZephirEvm/blob/zf3/ext/cyant/eventmanager/eventmanager.c#L383
using call_user_func works but is extremely slow....
I have the following block of code (echoes
added for diagnostic purposes)
private function getTrieNodeByKey(string key, create = false)
{
var trieNode, keyLen, i, character;
let trieNode = this->trie;
let keyLen = strlen(key);
let i = 0;
echo "key = [", key, "]", PHP_EOL;
echo "keyLen = [", keyLen, "]", PHP_EOL;
echo "i = [", i, "]", PHP_EOL;
while (i < keyLen) {
echo "In while loop", PHP_EOL;
let character = substr(key,i,1);
if (!isset(trieNode->children[character])) {
if (create) {
let trieNode->children[character] = new tries\trienode();
} else {
return false;
}
}
let trieNode = trieNode->children[character];
let i += 1;
}
return trieNode;
}
which compiles successfully, but the while
loop is never executed
The output I get is:
key = [adder]
keyLen = [5]
i = [0]
key = [addled]
keyLen = [6]
i = [0]
key = [advance]
keyLen = [7]
i = [0]
As you can see, the In while loop
message is never displayed, despite the fact that the keyLen
and I
values clearly show that it should be
The only way I've been able to get this to work is to evaluate an intermediate variable j
, but that is more of a workround.
Is there any syntax I can use to handle the evaluated expression in the while
itself?
I encountered a problem that the parser generates an error when I extends from the other class and implements an interface
namespace Igor;
abstract class MyClassA
{
// some methods here
}
namespace Igor;
interface MyInterfaceB
{
// some methods here
}
namespace Igor;
abstract class MyClassC extends Igor\MyClassA implements Igor\MyInterfaceB
{
// methods here
}
p.s. if in this class not use "abstract" then all works fine.
error:
ParseException: Syntax error in ....myclassc.zep
abstract class MyClassC extends Igor\MyClassA implements Igor\MyInterfaceB
-----------------------------------------------------^
A call like the following:
if typeof this->prop == "array" { ...
generates a compiler exception: "CompilerException: Typeof operator on non-variable"
Zephir code is....
namespace magento;
final class Mage {
static private _app;
static private _events;
public static function app(code = "", type = "store", options = []) {
let self::_app = new Mage_Core_Model_App();
let self::_events = new Varien_Event_Collection();
Varien_Profiler::start("self::app::init");
Varien_Profiler::stop("self::app::init");
return self::_app;
}
}
when compiling zephir code above, I got this error.
[hopsoed@localhost]$ zephir compile
Type=ternary
int
CompilerException:
Incorrect class name: Varien_Profiler in /var/www/shell/zephir/magento/test.zep on line 12
Varien_Profiler::start("self::app::init");
-------------------------------------------^
what is the problem ?
Currently there is very difficult to implement __callStatic magic to functions with variable number of arguments because call_user_func/call_user_func_array functions has no access to protected/private methods of extension class.
Such code will compile OK, but runtime error will appear when we'll try to call own private or protected method with these functions.
Taking this as an example:
namespace Amnuts;
class Utils
{
public function test() -> void
{
echo PHP_VERSION, PHP_EOL;
/*
This is OK
*/
// as is this
}
//
// This is OK
//
/*
This produces parse error
*/
}
With the multiline comment at the end of the class it'll throw a ParseException due to a syntax error with the closing brace.
Looks like unset not works properly or i am making something wrong:
public function has(var key)
{
return isset this->keys[key];
}
public function set(var key, value)
{
let this->keys[key] = true;
let this->archive[key] = value;
}
public function remove(var key)
{
if !this->has(key) {
return;
}
unset this->archive[key];
unset this->keys[key];
}
var_dump($this->has('foo')); //return false
$this->set('foo','bar');
var_dump($this->has('foo')); //return true
$this->remove('foo');
var_dump($this->has('foo')); //return true
Regards
Example: in the following each of these variables will be passed as null.
new {fullClassName}("variable one", "variable two", "variable three")
Could I call this function or get all args from method?
while i'm try this code in .zep:
.....
eval("echo 'hahaha';");
...
i recieved error:
"Warning: Function "eval" does not exist at compile time in /root/zephir/utils/utils/Greeting.zep on 44 [nonexistent-function]"
please fix this error!
thanks
I want to start off with saying I'm a very performance oriented person when it comes to my code. Which is the number one reason for my interest in Zephir. Also, this is less of a bug, and more of an issue/area of concern.
I decided to make a side-by-side comparison of execution times between an extension compiled with Zephir and native php code.
To make my test, I first wrote my php function. It's a simple function only 28 lines long, that takes a router signature string (to define a route in a framework) and compiles it into a regular expression. I then literally copy and pasted the php function into a zep file, altered the php accordingly to become zephir code.
so now I have these two identical functions, one in native php, and one in a compiled extension.
I then made a script to run each of them 1000 times (with the same signature, it was just a simple for loop)
What I saw kind of blew my mind... the php code was consistantly outperforming the compiled code!
I'm seeing results like the following:
PHP Execution Time 0.24159812927246s
Compiled Execution Time 0.28048205375671s
That was on my little machine dedicated to Zephir work. so then i compiled the extension on my big server and ran the tests.. still it's the same deal (though the time is lower, the difference is about the same)!
PHP Execution Time 0.071985960006714
Compiled Execution Time 0.075214147567749
I think it's important to point out that in my code, I'm calling the following php functions (which means that the compiled code is calling them also):
trim() x 5
explode() x 1
substr() x 6
If anyone would like to see my code just let me know, maybe i'm not writing my Zephir code "correctly"
I'd like to see support for late binding available in PHP 5.3 such as:
class A
{
public static function makeNew()
{
return new static();
}
}
class B extends A
{ }
$a = A::makeNew(); // $a is an A
$b = B::makeNew(); // $b is a B
Of course, this is only an over simplified example.
require filePath;
in .zep is converted to //missing require
in .c
Shortcuts in Zephir aren't exported as real methods
class Event
{
protected _type { set, get };
is compiled to:
PHP_METHOD(Phalcon_Events_Event, setType) {
zval *type;
zephir_fetch_params(0, 1, 0, &type);
}
PHP_METHOD(Phalcon_Events_Event, getType) {
}
but should be something like this:
PHP_METHOD(Phalcon_Events_Event, setType){
zval *event_type;
phalcon_fetch_params(0, 1, 0, &event_type);
phalcon_update_property_this(this_ptr, SL("_type"), event_type TSRMLS_CC);
}
PHP_METHOD(Phalcon_Events_Event, getType){
RETURN_MEMBER(this_ptr, "_type");
}
Hi,
First all thanks for create this excellent language.
I am testing zephir and when i use typeof in this way:
if typeof root == "object" {
...
}
produces a weird warning:
/Users/mcuadros/workspace/zephir/mongator/ext/mongator/zephirdocument.c:314:28: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if ((Z_TYPE_P(embedded) == IS_OBJECT)) {
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
/Users/mcuadros/workspace/zephir/mongator/ext/mongator/zephirdocument.c:314:28: note: remove extraneous parentheses around the comparison to silence this warning
if ((Z_TYPE_P(embedded) == IS_OBJECT)) {
~ ^ ~
/Users/mcuadros/workspace/zephir/mongator/ext/mongator/zephirdocument.c:314:28: note: use '=' to turn this equality comparison into an assignment
if ((Z_TYPE_P(embedded) == IS_OBJECT)) {
i know that is just a warning but can be interest fix it.
Regards!
strtok tokenizes a string and allows you to "iterate" through the given results. The first call to strtok requires both the string and a token. In order to iterate through the tokens, subsequent calls to strtok need to be made giving just the token.
Attempts to call strtok with just a single parameter result in:
CompilerException: The number of parameters passed is less than the number of requiered parameters by 'strtok'
Example code:
namespace Testing;
class Tokenizer
{
public static function parse()
{
var first_token;
var second_token;
let first_token = strtok("/something", "/");
let second_token = strtok("/");
var_dump(first_token, second_token);
}
}
Hi
In commit i failed on $variableVariable->getClassTypes()[0]
because this simple code supports on php 5.4 >=
I think we need on run see php language and if if < 5.4 exception on it and write this requriment in docs
I couldn't find the way how to handle exceptions.
Will the Zephir support something like "try {} catch ()"?
I'm trying to use array_keys:
let byteUnits = ["B": 0, "K": 10, "M": 20, "G": 30, "T": 40, "KB": 10, "MB": 20, "GB": 30, "TB": 40];
let tmp = implode("|", array_keys(byteUnits));
and I have memory leak:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /home/mruz/Dropbox/osc/test/app/frontend/controllers/IndexController.php on line 40
router.c
if (((((((((ch >= 'a') && (ch <= 'z'))) || (((ch >= 'A') && (ch <= 'Z')))) || (((ch >= '0') && (ch <= '9')))) || (ch == '-')) || (ch == '_')) || (ch == ':'))) {
Work on this
@phalcon I would like to contribute project can your supervise me for next time like create task and milestones or etc mm?
Would it be ok if I moved the clean and install files to templates
? Also, the ext/kernel directory could be moved to template and the ext directory cleaned up from the repo and git-ignored? It would be rebuilt on the next zephyr
command anyway. I think it might look cleaner at the end.
I imagine the final hierarchy as being something like that:
zephir
|- bin
|- Library
|- parser
|- scripts
|- tempates
|- test
|-ext
|-test (all test zep files)
|- unit-tests (all test php files)
Please let me know if it's ok
What would be really nice in zephir is a way to obfuscate variables so that they won't be visible as raw string in binary extension thus preventing from easy reverse-engineering.
Imagine you have something that you need to distribute with your application but need to keep it secret. Like a RSA public keys or some API keys.
Currently one can define these in following way:
class Secret {
const RSA_PUB_KEY = '------ PUB KEY -------\nBlaBlaBla';
private _apiName = 'secret Login';
private _apiKey = 'secret Password';
}
However, both will be visible from compiled binary extension in hex mode.
The nice way, for instance could be something like:
class Secret {
const obf RSA_PUB_KEY = '------ PUB KEY -------\nBlaBlaBla';
private obf _apiName = 'secret Login';
private obf _apiKey = 'secret Password';
}
Before compilation a zaphir macro would obfuscate variables declared in such way.
I don't want to start discussion on how safe this is, as almost everyone armed with debugger or reflection would be able to reverse-engineer it (unless there's some technique to prevent this I'm not aware of) but it's a nice and easy way to stop 99% of attacks at the application.
It might or may not be a good way to make things safer and a good alternative to Zend Encoder or IonCube.
It could be opensource or a paid add-on for Zephir you could use to make money on it.
What are your thoughts on this?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Subject. When I edit C source directly, wrapping "\x00" as '\x00' or '\0', I get segmentation fault after compilation.
I get this error
PHP Fatal error: Can't inherit abstract function CommandInterface::getCommand() (previously declared abstract in CommandAbstract) in /home/xxxx/Downloads/zephir/Library/Commands/Abstract.php on line 26
When doing this
../zephir/bin/zephir generate
I know phalcon 2 is not support and all, but do you have an idea what might be the problem ? (i'm on centOS 6, PHP 5.3.3 (cli))
I followed this guide https://github.com/phalcon/cphalcon/tree/2.0.0
Suppose you want to make a class that represents a data type:
class Boolean {}
This throws a ParserException:
ParseException: Syntax error in /path/to/my/extension/Boolean.zep on line 3
class Boolean
-----------^
This is an interesting little find (at least I think so)
I have a Zephir class: NOTICE; it's abstract with a final constructor
abstract class Test {
public someValue;
final public function __construct(){
echo "This Ran";
let this->someValue = "foobar";
}
}
I have a PHP class:
class ChildTest extends \Ext\Test {
public function whatever(){
}
}
Now, here's the issue:
I have a method in my extension that takes a class name, creates an instance, and returns that instance (this is not what i'm actually doing, but this is what you can do to recreate the issue) NOTICE: I'm calling the class in a dynamic way.
class SomeKindOfLoader {
// the method in a zephir class
public function createInstance(className)
{
return new {className}();
}
}
now in php:
$somekindofloader = new \Ext\SomeKindOfLoader();
$ChildTest = $somekindofloader->createInstance('ChildTest');
var_dump($ChildTest); // outputs object(ChildTest); however "This Ran" never shows up and $ChildTest->someValue is null
So... the constructor for \Ext\Test never runs. I DO however get an error if I try to override the final constructor from \Ext\Test.
It would be nice to can use list():
var width, height;
list(width, height) = getimagesize(value["tmp_name"]);
I'm trying to use:
let value = 1;
if typeof value == "array" && isset value["error"] && value["error"] === 1 {
}
And I'm receiving:
Notice: Cannot use a scalar value as an array
Hello,
I would like to access mysql functions like accessing other php functions (strpos, strlen etc.).
How can I access?
namespace MySQLTest;
class TestingDB
{
public function mysql_func(var id)
{
var result;
mysql_connect("localhost", "root", "");
mysql_select_db("cdcol");
result = mysql_query("SELECT * cds WHERE id=" . id);
// var row;
// while (var row = mysql_fetch_assoc(result)){
// echo row["id"].' '.row["titel"];
// }
for key, value in mysql_fetch_assoc(result) {
echo key.' '.value.'\n';
}
}
}
I got error like:
ParseException: Syntax error in /root/mysqltest/mysqltest/testingdb.zep on line 11
result = mysql_query("SELECT * cds WHERE id=" . id);
---------------^
I got a ParseException: Syntax error. at here '&'
padraic@numenor:~/Projects/play/tools$ zephir build
Copying new kernel files...
Preparing for PHP compilation...
Preparing configuration file...
Compiling...
/home/padraic/Projects/play/tools/ext/tools/spellcheck.c: In function 'zim_Tools_SpellCheck_loadDictionary':
/home/padraic/Projects/play/tools/ext/tools/spellcheck.c:196:18: error: lvalue required as unary '&' operand
zephir_var_dump(&(&_4) TSRMLS_CC);
^
make: *** [tools/spellcheck.lo] Error 1
Installing...
Extension installed!
Don't forget to restart your web server
You can view the zephir code here:
https://gist.github.com/padraic/2bbfa946844f53d705fb
Note: Line 66 creates an infinite loop since it doesn't register false as being empty as PHP would. That was the error I made by not RTFM! :P
The var_dump call is line 77. This is from current HEAD as of 11:30 GMT, Sunday 26 January.
If I compile under the previous night's HEAD, I see it mentioning the optimizer specifically so you guys may be working on this already :P.
padraic@numenor:~/Projects/play/tools$ zephir build
PHP Notice: Undefined index: &_4 in /home/padraic/Projects/zephir/Library/SymbolTable.php on line 116
PHP Stack trace:
PHP 1. {main}() /home/padraic/Projects/zephir/compiler.php:0
PHP 2. Bootstrap::boot() /home/padraic/Projects/zephir/compiler.php:104
PHP 3. CommandAbstract->execute() /home/padraic/Projects/zephir/Library/Bootstrap.php:165
PHP 4. Compiler->build() /home/padraic/Projects/zephir/Library/Commands/Abstract.php:85
PHP 5. Compiler->generate() /home/padraic/Projects/zephir/Library/Compiler.php:640
PHP 6. CompilerFile->compile() /home/padraic/Projects/zephir/Library/Compiler.php:481
PHP 7. CompilerFile->compileClass() /home/padraic/Projects/zephir/Library/CompilerFile.php:560
PHP 8. ClassDefinition->compile() /home/padraic/Projects/zephir/Library/CompilerFile.php:112
PHP 9. ClassMethod->compile() /home/padraic/Projects/zephir/Library/ClassDefinition.php:724
PHP 10. StatementsBlock->compile() /home/padraic/Projects/zephir/Library/ClassMethod.php:976
PHP 11. FunctionCall->compile() /home/padraic/Projects/zephir/Library/StatementsBlock.php:175
PHP 12. FunctionCall->_callNormal() /home/padraic/Projects/zephir/Library/FunctionCall.php:553
PHP 13. FunctionCall->optimize() /home/padraic/Projects/zephir/Library/FunctionCall.php:277
PHP 14. VarDumpOptimizer->optimize() /home/padraic/Projects/zephir/Library/FunctionCall.php:212
PHP 15. SymbolTable->getVariable() /home/padraic/Projects/zephir/Library/Optimizers/FunctionCall/VarDumpOptimizer.php:47
PHP Notice: Undefined index: &_4 in /home/padraic/Projects/zephir/Library/SymbolTable.php on line 116
PHP Stack trace:
PHP 1. {main}() /home/padraic/Projects/zephir/compiler.php:0
PHP 2. Bootstrap::boot() /home/padraic/Projects/zephir/compiler.php:104
PHP 3. CommandAbstract->execute() /home/padraic/Projects/zephir/Library/Bootstrap.php:165
PHP 4. Compiler->build() /home/padraic/Projects/zephir/Library/Commands/Abstract.php:85
PHP 5. Compiler->install() /home/padraic/Projects/zephir/Library/Compiler.php:641
PHP 6. Compiler->compile() /home/padraic/Projects/zephir/Library/Compiler.php:584
PHP 7. Compiler->generate() /home/padraic/Projects/zephir/Library/Compiler.php:547
PHP 8. CompilerFile->compile() /home/padraic/Projects/zephir/Library/Compiler.php:481
PHP 9. CompilerFile->compileClass() /home/padraic/Projects/zephir/Library/CompilerFile.php:560
PHP 10. ClassDefinition->compile() /home/padraic/Projects/zephir/Library/CompilerFile.php:112
PHP 11. ClassMethod->compile() /home/padraic/Projects/zephir/Library/ClassDefinition.php:724
PHP 12. StatementsBlock->compile() /home/padraic/Projects/zephir/Library/ClassMethod.php:976
PHP 13. FunctionCall->compile() /home/padraic/Projects/zephir/Library/StatementsBlock.php:175
PHP 14. FunctionCall->_callNormal() /home/padraic/Projects/zephir/Library/FunctionCall.php:553
PHP 15. FunctionCall->optimize() /home/padraic/Projects/zephir/Library/FunctionCall.php:277
PHP 16. VarDumpOptimizer->optimize() /home/padraic/Projects/zephir/Library/FunctionCall.php:212
PHP 17. SymbolTable->getVariable() /home/padraic/Projects/zephir/Library/Optimizers/FunctionCall/VarDumpOptimizer.php:47
Preparing for PHP compilation...
Preparing configuration file...
Compiling...
/home/padraic/Projects/play/tools/ext/tools/spellcheck.c: In function 'zim_Tools_SpellCheck_loadDictionary':
/home/padraic/Projects/play/tools/ext/tools/spellcheck.c:200:18: error: lvalue required as unary '&' operand
zephir_var_dump(&(&_4) TSRMLS_CC);
^
make: *** [tools/spellcheck.lo] Error 1
Installing...
Extension installed!
if unlikely empty this->checkKnownWords([word]) {
// do something
} else {
// do something else
}
Trying to do something like this (or even with the empty() function from PHP) seems to kill the branch entirely (it switches to "something else" even when the condition evaluates to TRUE. If I remove unlikely, it all works as expected.
I would like to use do while loop:
do {
let key = key(variable);
let value = current(variable);
} while next(variable);
but I've got the message:
Call to undefined method CodePrinter::outputLineBreak() in ../zephir-master/Library/Statements/DoWhileStatement.php on line 49
Can we use magic constants as DIR or METHOD with zephir, compiler return me an error when i use DIR
to give it wider adoption, being installable via composer is a must.
Imho a composer.json file and registration on packagist.org would be nice - even if there is still a compilation step involved after download
We have many problems about lexer parser and wee need tests for it.
Example
if (!empty(eventName) && isset(this->events[eventName])) {
generate
array(5) {
'type' =>
string(5) "empty"
'left' =>
array(6) {
'type' =>
string(3) "and"
'left' =>
array(5) {
'type' =>
string(4) "list"
'left' =>
array(5) {
...
}
'file' =>
string(61) "/media/projects/ZephirEvm/cyant/eventmanager/eventmanager.zep"
'line' =>
int(147)
'char' =>
int(32)
}
'right' =>
array(5) {
'type' =>
string(5) "isset"
'left' =>
array(5) {
...
}
'file' =>
string(61) "/media/projects/ZephirEvm/cyant/eventmanager/eventmanager.zep"
'line' =>
int(147)
'char' =>
int(64)
}
'file' =>
string(61) "/media/projects/ZephirEvm/cyant/eventmanager/eventmanager.zep"
'line' =>
int(147)
'char' =>
int(64)
}
'file' =>
string(61) "/media/projects/ZephirEvm/cyant/eventmanager/eventmanager.zep"
'line' =>
int(147)
'char' =>
int(64)
}
but works like
if ((!empty(eventName)) && isset(this->events[eventName])) {
Sorry I can't provide too much info, I've just observed this strange behavior:
I have a method defined as such:
class Thing {
public function test(string! param1, string param2 = null)
{
var_dump(param1);
var_dump(param2);
}
}
This compiles just fine.
The issue comes when you attempt to call the method:
$thing->test('foo','bar');
This results in a php log entry:
[17-Jan-2014 14:30:05.337043] WARNING: pid 768, fpm_children_bury(), line 252: [pool www] child 770 exited on signal 11 (SIGSEGV - core dumped) after 3.073586 seconds from start
The (userland) fix is to remove either the type or the default. Just thought I'd put this on your radar.
In the Validation:
for scope in validators {
if typeof scope != "array" {
throw new Phalcon\Validation\Exception("The validator scope is not valid");
}
let attribute = scope[0],
validator = scope[1];
if typeof validator != "object" {
throw new Phalcon\Validation\Exception("One of the validators is not valid");
}
/**
* Check if the validation must be canceled if this validator fails
*/
if validator->validate(this, attribute) === false {
if (validator->getOption(cancelOnFail)) {
break;
}
}
}
validate() method of Validator is cached:
validator->validate(this, attribute)
is converted to:
zephir_call_method_p2_cache(_0, validator, "validate", &_4, this_ptr, attribute);
and always validate first Validator in the scope. How to call not cached method zephir_call_method_p2
? This issue is related to phalcon/cphalcon#1696
When I, for example, create successfully socket with fsockopen, statement 'if empty socket {throw new Exception;}', exception is still being thrown, empty does not work as expected.
when I run ./bin/zephir compile in zephir directory
there is a warning:
Warning: Class "fullClassName" does not exist at compile time in zephir/test/oo/oodynamica.zep on 15 [nonexistent-class]
If we have a class hierarchy such as:
interface I {}
class A implement I {}
class B extends A {}
Then the following returns false:
let b = new B();
b instanceof A; // evaluates to false
b instanceof I; // evaluates to false
This returns true:
b instanceof B // evaluates to true
Is that the expected behaviour?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.