/** New BSD License Copyright (c) 2011-2015, Phalcon Framework Team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- The Zend Engine License, Version 2.00 Copyright (c) 1999-2006 Zend Technologies Ltd. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names "Zend" and "Zend Engine" must not be used to endorse or promote products derived from this software without prior permission from Zend Technologies Ltd. For written permission, please contact license@zend.com. 4. Zend Technologies Ltd. may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by Zend Technologies Ltd. No one other than Zend Technologies Ltd. has the right to modify the terms applicable to covered code created under this License. 5. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes the Zend Engine, freely available at http://www.zend.com" 6. All advertising materials mentioning features or use of this software must display the following acknowledgment: "The Zend Engine is freely available at http://www.zend.com" THIS SOFTWARE IS PROVIDED BY ZEND TECHNOLOGIES LTD. ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ZEND TECHNOLOGIES LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- -------------------------------------------------------------------- The PHP License, version 3.01 Copyright (c) 1999 - 2015 The PHP Group. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "PHP" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact group@php.net. 4. Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from group@php.net. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo" 5. The PHP Group may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by the PHP Group. No one other than the PHP Group has the right to modify the terms applicable to covered code created under this License. 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes PHP software, freely available from <http://www.php.net/software/>". THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- This software consists of voluntary contributions made by many individuals on behalf of the PHP Group. The PHP Group can be contacted via Email at group@php.net. For more information on the PHP Group and the PHP project, please see <http://www.php.net>. PHP includes the Zend Engine, freely available at <http://www.zend.com>. */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <math.h> #include <ctype.h> #include <stdlib.h> #include <main/php.h> #define ZEPHIR_RELEASE 1 #define PHALCON_RELEASE 1 #include "php_phalcon.h" #include "phalcon.zep.h" #include <main/php_main.h> #include <main/php_variables.h> #include <main/php_streams.h> #include <main/php_output.h> #include <main/php_ini.h> #include <main/SAPI.h> #include <ext/standard/php_string.h> #include <ext/standard/php_smart_str.h> #include <ext/standard/info.h> #include <ext/pdo/php_pdo_driver.h> #include <ext/standard/file.h> #include <ext/standard/php_filestat.h> #include <ext/standard/php_rand.h> #include <ext/standard/php_lcg.h> #include <ext/standard/php_math.h> #include <ext/standard/php_array.h> #include <ext/standard/php_var.h> #include <ext/standard/php_http.h> #include <ext/standard/php_versioning.h> #include <ext/standard/html.h> #include <ext/standard/base64.h> #include <ext/standard/md5.h> #include <ext/standard/head.h> #include <ext/standard/url.h> #include <ext/standard/crc32.h> #include <ext/hash/php_hash.h> #include <ext/spl/spl_heap.h> #include <ext/spl/spl_exceptions.h> #include <ext/spl/spl_directory.h> #include <ext/spl/spl_iterators.h> #include <ext/date/php_date.h> #include <Zend/zend_API.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include <Zend/zend_execute.h> #include <Zend/zend_extensions.h> #include <Zend/zend_builtin_functions.h> #include <Zend/zend_closures.h> #include <Zend/zend_multiply.h> #define PHQL_AGAINST 1 #define PHQL_BETWEEN 2 #define PHQL_EQUALS 3 #define PHQL_NOTEQUALS 4 #define PHQL_LESS 5 #define PHQL_GREATER 6 #define PHQL_GREATEREQUAL 7 #define PHQL_LESSEQUAL 8 #define PHQL_AND 9 #define PHQL_OR 10 #define PHQL_LIKE 11 #define PHQL_ILIKE 12 #define PHQL_BITWISE_AND 13 #define PHQL_BITWISE_OR 14 #define PHQL_BITWISE_XOR 15 #define PHQL_DIVIDE 16 #define PHQL_TIMES 17 #define PHQL_MOD 18 #define PHQL_PLUS 19 #define PHQL_MINUS 20 #define PHQL_IS 21 #define PHQL_IN 22 #define PHQL_NOT 23 #define PHQL_BITWISE_NOT 24 #define PHQL_COMMA 25 #define PHQL_SELECT 26 #define PHQL_FROM 27 #define PHQL_DISTINCT 28 #define PHQL_ALL 29 #define PHQL_IDENTIFIER 30 #define PHQL_DOT 31 #define PHQL_AS 32 #define PHQL_INNER 33 #define PHQL_JOIN 34 #define PHQL_CROSS 35 #define PHQL_LEFT 36 #define PHQL_OUTER 37 #define PHQL_RIGHT 38 #define PHQL_FULL 39 #define PHQL_ON 40 #define PHQL_INSERT 41 #define PHQL_INTO 42 #define PHQL_VALUES 43 #define PHQL_PARENTHESES_OPEN 44 #define PHQL_PARENTHESES_CLOSE 45 #define PHQL_UPDATE 46 #define PHQL_SET 47 #define PHQL_DELETE 48 #define PHQL_WITH 49 #define PHQL_WHERE 50 #define PHQL_ORDER 51 #define PHQL_BY 52 #define PHQL_ASC 53 #define PHQL_DESC 54 #define PHQL_GROUP 55 #define PHQL_HAVING 56 #define PHQL_FOR 57 #define PHQL_LIMIT 58 #define PHQL_OFFSET 59 #define PHQL_INTEGER 60 #define PHQL_HINTEGER 61 #define PHQL_NPLACEHOLDER 62 #define PHQL_SPLACEHOLDER 63 #define PHQL_BPLACEHOLDER 64 #define PHQL_EXISTS 65 #define PHQL_CAST 66 #define PHQL_CONVERT 67 #define PHQL_USING 68 #define PHQL_CASE 69 #define PHQL_END 70 #define PHQL_WHEN 71 #define PHQL_THEN 72 #define PHQL_ELSE 73 #define PHQL_NULL 74 #define PHQL_STRING 75 #define PHQL_DOUBLE 76 #define PHQL_TRUE 77 #define PHQL_FALSE 78 #define PHQL_SCANNER_RETCODE_EOF -1 #define PHQL_SCANNER_RETCODE_ERR -2 #define PHQL_SCANNER_RETCODE_IMPOSSIBLE -3 #define PHQL_T_IGNORE 257 /* Literals & Identifiers */ #define PHQL_T_INTEGER 258 #define PHQL_T_DOUBLE 259 #define PHQL_T_STRING 260 #define PHQL_T_IDENTIFIER 265 #define PHQL_T_HINTEGER 414 /* Operators */ #define PHQL_T_ADD '+' #define PHQL_T_SUB '-' #define PHQL_T_MUL '*' #define PHQL_T_DIV '/' #define PHQL_T_MOD '%' #define PHQL_T_BITWISE_AND '&' #define PHQL_T_BITWISE_OR '|' #define PHQL_T_BITWISE_XOR '^' #define PHQL_T_BITWISE_NOT '~' #define PHQL_T_AND 266 #define PHQL_T_OR 267 #define PHQL_T_LIKE 268 #define PHQL_T_ILIKE 275 #define PHQL_T_AGAINST 276 #define PHQL_T_DOT '.' #define PHQL_T_COMMA 269 #define PHQL_T_COLON ':' #define PHQL_T_EQUALS '=' #define PHQL_T_NOTEQUALS 270 #define PHQL_T_NOT '!' #define PHQL_T_LESS '<' #define PHQL_T_LESSEQUAL 271 #define PHQL_T_GREATER '>' #define PHQL_T_GREATEREQUAL 272 #define PHQL_T_PARENTHESES_OPEN '(' #define PHQL_T_PARENTHESES_CLOSE ')' /** Placeholders */ #define PHQL_T_NPLACEHOLDER 273 #define PHQL_T_SPLACEHOLDER 274 #define PHQL_T_BPLACEHOLDER 277 /** Reserved words */ #define PHQL_T_UPDATE 300 #define PHQL_T_SET 301 #define PHQL_T_WHERE 302 #define PHQL_T_DELETE 303 #define PHQL_T_FROM 304 #define PHQL_T_AS 305 #define PHQL_T_INSERT 306 #define PHQL_T_INTO 307 #define PHQL_T_VALUES 308 #define PHQL_T_SELECT 309 #define PHQL_T_ORDER 310 #define PHQL_T_BY 311 #define PHQL_T_LIMIT 312 #define PHQL_T_GROUP 313 #define PHQL_T_HAVING 314 #define PHQL_T_IN 315 #define PHQL_T_ON 316 #define PHQL_T_INNER 317 #define PHQL_T_JOIN 318 #define PHQL_T_LEFT 319 #define PHQL_T_RIGHT 320 #define PHQL_T_IS 321 #define PHQL_T_NULL 322 #define PHQL_T_NOTIN 323 #define PHQL_T_CROSS 324 #define PHQL_T_FULL 325 #define PHQL_T_OUTER 326 #define PHQL_T_ASC 327 #define PHQL_T_DESC 328 #define PHQL_T_OFFSET 329 #define PHQL_T_DISTINCT 330 #define PHQL_T_BETWEEN 331 #define PHQL_T_CAST 332 #define PHQL_T_TRUE 333 #define PHQL_T_FALSE 334 #define PHQL_T_CONVERT 335 #define PHQL_T_USING 336 #define PHQL_T_ALL 337 #define PHQL_T_FOR 338 /** Special Tokens */ #define PHQL_T_FCALL 350 #define PHQL_T_NLIKE 351 #define PHQL_T_STARALL 352 #define PHQL_T_DOMAINALL 353 #define PHQL_T_EXPR 354 #define PHQL_T_QUALIFIED 355 #define PHQL_T_ENCLOSED 356 #define PHQL_T_NILIKE 357 #define PHQL_T_RAW_QUALIFIED 358 #define PHQL_T_INNERJOIN 360 #define PHQL_T_LEFTJOIN 361 #define PHQL_T_RIGHTJOIN 362 #define PHQL_T_CROSSJOIN 363 #define PHQL_T_FULLJOIN 364 #define PHQL_T_ISNULL 365 #define PHQL_T_ISNOTNULL 366 #define PHQL_T_MINUS 367 /** Postgresql Text Search Operators */ #define PHQL_T_TS_MATCHES 401 #define PHQL_T_TS_OR 402 #define PHQL_T_TS_AND 403 #define PHQL_T_TS_NEGATE 404 #define PHQL_T_TS_CONTAINS_ANOTHER 405 #define PHQL_T_TS_CONTAINS_IN 406 #define PHQL_T_SUBQUERY 407 #define PHQL_T_EXISTS 408 #define PHQL_T_CASE 409 #define PHQL_T_WHEN 410 #define PHQL_T_ELSE 411 #define PHQL_T_END 412 #define PHQL_T_THEN 413 #define PHQL_T_WITH 415 /* list of tokens and their names */ typedef struct _phql_token_names { char *name; unsigned int length; unsigned int code; } phql_token_names; /* active token state */ typedef struct _phql_scanner_state { int active_token; unsigned int start_length; char* start; char* end; } phql_scanner_state; /* extra information tokens */ typedef struct _phql_scanner_token { char *value; int opcode; unsigned int len; } phql_scanner_token; static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token); const phql_token_names phql_tokens[]; #ifndef PHALCON_MVC_MODEL_QUERY_PHQL_H #define PHALCON_MVC_MODEL_QUERY_PHQL_H typedef struct _phql_parser_token { char *token; int opcode; unsigned int token_len; int free_flag; } phql_parser_token; typedef struct _phql_parser_status { zval *ret; char* phql; unsigned int phql_length; int status; phql_scanner_state *scanner_state; phql_scanner_token *token; char *syntax_error; zend_uint syntax_error_len; zend_bool enable_literals; } phql_parser_status; #define PHQL_PARSING_OK 1 #define PHQL_PARSING_FAILED 0 static int phql_parse_phql(zval *result, zval *phql TSRMLS_DC); static int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length, zval **error_msg TSRMLS_DC); #endif /* PHALCON_MVC_MODEL_QUERY_PHQL_H */ #define PHVOLT_OPEN_DELIMITER 1 #define PHVOLT_COMMA 2 #define PHVOLT_IN 3 #define PHVOLT_QUESTION 4 #define PHVOLT_COLON 5 #define PHVOLT_RANGE 6 #define PHVOLT_AND 7 #define PHVOLT_OR 8 #define PHVOLT_IS 9 #define PHVOLT_EQUALS 10 #define PHVOLT_NOTEQUALS 11 #define PHVOLT_LESS 12 #define PHVOLT_GREATER 13 #define PHVOLT_GREATEREQUAL 14 #define PHVOLT_LESSEQUAL 15 #define PHVOLT_IDENTICAL 16 #define PHVOLT_NOTIDENTICAL 17 #define PHVOLT_DIVIDE 18 #define PHVOLT_TIMES 19 #define PHVOLT_MOD 20 #define PHVOLT_PLUS 21 #define PHVOLT_MINUS 22 #define PHVOLT_CONCAT 23 #define PHVOLT_SBRACKET_OPEN 24 #define PHVOLT_PIPE 25 #define PHVOLT_NOT 26 #define PHVOLT_INCR 27 #define PHVOLT_DECR 28 #define PHVOLT_PARENTHESES_OPEN 29 #define PHVOLT_DOT 30 #define PHVOLT_IF 31 #define PHVOLT_CLOSE_DELIMITER 32 #define PHVOLT_ENDIF 33 #define PHVOLT_ELSE 34 #define PHVOLT_ELSEIF 35 #define PHVOLT_ELSEFOR 36 #define PHVOLT_FOR 37 #define PHVOLT_IDENTIFIER 38 #define PHVOLT_ENDFOR 39 #define PHVOLT_SET 40 #define PHVOLT_ASSIGN 41 #define PHVOLT_ADD_ASSIGN 42 #define PHVOLT_SUB_ASSIGN 43 #define PHVOLT_MUL_ASSIGN 44 #define PHVOLT_DIV_ASSIGN 45 #define PHVOLT_SBRACKET_CLOSE 46 #define PHVOLT_MACRO 47 #define PHVOLT_PARENTHESES_CLOSE 48 #define PHVOLT_ENDMACRO 49 #define PHVOLT_INTEGER 50 #define PHVOLT_STRING 51 #define PHVOLT_DOUBLE 52 #define PHVOLT_NULL 53 #define PHVOLT_FALSE 54 #define PHVOLT_TRUE 55 #define PHVOLT_CALL 56 #define PHVOLT_ENDCALL 57 #define PHVOLT_OPEN_EDELIMITER 58 #define PHVOLT_CLOSE_EDELIMITER 59 #define PHVOLT_BLOCK 60 #define PHVOLT_ENDBLOCK 61 #define PHVOLT_CACHE 62 #define PHVOLT_ENDCACHE 63 #define PHVOLT_RAW 64 #define PHVOLT_ENDRAW 65 #define PHVOLT_EXTENDS 66 #define PHVOLT_INCLUDE 67 #define PHVOLT_WITH 68 #define PHVOLT_DO 69 #define PHVOLT_RETURN 70 #define PHVOLT_AUTOESCAPE 71 #define PHVOLT_ENDAUTOESCAPE 72 #define PHVOLT_BREAK 73 #define PHVOLT_CONTINUE 74 #define PHVOLT_RAW_FRAGMENT 75 #define PHVOLT_DEFINED 76 #define PHVOLT_EMPTY 77 #define PHVOLT_EVEN 78 #define PHVOLT_ODD 79 #define PHVOLT_NUMERIC 80 #define PHVOLT_SCALAR 81 #define PHVOLT_ITERABLE 82 #define PHVOLT_CBRACKET_OPEN 83 #define PHVOLT_CBRACKET_CLOSE 84 #ifndef PHALCON_MVC_VIEW_ENGINE_VOLT_SCANNER_H #define PHALCON_MVC_VIEW_ENGINE_VOLT_SCANNER_H #define PHVOLT_RAW_BUFFER_SIZE 256 #define PHVOLT_SCANNER_RETCODE_EOF -1 #define PHVOLT_SCANNER_RETCODE_ERR -2 #define PHVOLT_SCANNER_RETCODE_IMPOSSIBLE -3 /** Modes */ #define PHVOLT_MODE_RAW 0 #define PHVOLT_MODE_CODE 1 #define PHVOLT_MODE_COMMENT 2 #define PHVOLT_T_IGNORE 257 /* Literals & Identifiers */ #define PHVOLT_T_INTEGER 258 #define PHVOLT_T_DOUBLE 259 #define PHVOLT_T_STRING 260 #define PHVOLT_T_NULL 261 #define PHVOLT_T_FALSE 262 #define PHVOLT_T_TRUE 263 #define PHVOLT_T_IDENTIFIER 265 /* Operators */ #define PHVOLT_T_ADD '+' #define PHVOLT_T_SUB '-' #define PHVOLT_T_MUL '*' #define PHVOLT_T_DIV '/' #define PHVOLT_T_MOD '%' #define PHVOLT_T_AND 266 #define PHVOLT_T_OR 267 #define PHVOLT_T_CONCAT '~' #define PHVOLT_T_PIPE '|' #define PHVOLT_T_DOT '.' #define PHVOLT_T_COMMA 269 #define PHVOLT_T_NOT '!' #define PHVOLT_T_LESS '<' #define PHVOLT_T_LESSEQUAL 270 #define PHVOLT_T_GREATER '>' #define PHVOLT_T_GREATEREQUAL 271 #define PHVOLT_T_EQUALS 272 #define PHVOLT_T_NOTEQUALS 273 #define PHVOLT_T_IDENTICAL 274 #define PHVOLT_T_NOTIDENTICAL 275 #define PHVOLT_T_RANGE 276 #define PHVOLT_T_ASSIGN '=' #define PHVOLT_T_COLON 277 #define PHVOLT_T_QUESTION '?' #define PHVOLT_T_POW 278 #define PHVOLT_T_INCR 279 #define PHVOLT_T_DECR 280 #define PHVOLT_T_ADD_ASSIGN 281 #define PHVOLT_T_SUB_ASSIGN 282 #define PHVOLT_T_MUL_ASSIGN 283 #define PHVOLT_T_DIV_ASSIGN 284 #define PHVOLT_T_PARENTHESES_OPEN '(' #define PHVOLT_T_PARENTHESES_CLOSE ')' #define PHVOLT_T_SBRACKET_OPEN '[' #define PHVOLT_T_SBRACKET_CLOSE ']' #define PHVOLT_T_CBRACKET_OPEN '{' #define PHVOLT_T_CBRACKET_CLOSE '}' /** Reserved words */ #define PHVOLT_T_IF 300 #define PHVOLT_T_ELSE 301 #define PHVOLT_T_ELSEIF 302 #define PHVOLT_T_ENDIF 303 #define PHVOLT_T_FOR 304 #define PHVOLT_T_ENDFOR 305 #define PHVOLT_T_SET 306 #define PHVOLT_T_BLOCK 307 #define PHVOLT_T_ENDBLOCK 308 #define PHVOLT_T_IN 309 #define PHVOLT_T_EXTENDS 310 #define PHVOLT_T_IS 311 #define PHVOLT_T_DEFINED 312 #define PHVOLT_T_INCLUDE 313 #define PHVOLT_T_CACHE 314 #define PHVOLT_T_ENDCACHE 315 #define PHVOLT_T_DO 316 #define PHVOLT_T_AUTOESCAPE 317 #define PHVOLT_T_ENDAUTOESCAPE 318 #define PHVOLT_T_CONTINUE 319 #define PHVOLT_T_BREAK 320 #define PHVOLT_T_ELSEFOR 321 #define PHVOLT_T_MACRO 322 #define PHVOLT_T_ENDMACRO 323 #define PHVOLT_T_WITH 324 #define PHVOLT_T_CALL 325 #define PHVOLT_T_ENDCALL 326 #define PHVOLT_T_RETURN 327 /** Delimiters */ #define PHVOLT_T_OPEN_DELIMITER 330 #define PHVOLT_T_CLOSE_DELIMITER 331 #define PHVOLT_T_OPEN_EDELIMITER 332 #define PHVOLT_T_CLOSE_EDELIMITER 333 /** Special Tokens */ #define PHVOLT_T_FCALL 350 #define PHVOLT_T_EXPR 354 #define PHVOLT_T_QUALIFIED 355 #define PHVOLT_T_ENCLOSED 356 #define PHVOLT_T_RAW_FRAGMENT 357 #define PHVOLT_T_EMPTY_STATEMENT 358 #define PHVOLT_T_ECHO 359 #define PHVOLT_T_ARRAY 360 #define PHVOLT_T_ARRAYACCESS 361 #define PHVOLT_T_NOT_ISSET 362 #define PHVOLT_T_ISSET 363 #define PHVOLT_T_RESOLVED_EXPR 364 #define PHVOLT_T_SLICE 365 #define PHVOLT_T_TERNARY 366 #define PHVOLT_T_NOT_IN 367 #define PHVOLT_T_MINUS 368 #define PHVOLT_T_PLUS 369 #define PHVOLT_T_EMPTY 380 #define PHVOLT_T_EVEN 381 #define PHVOLT_T_ODD 382 #define PHVOLT_T_NUMERIC 383 #define PHVOLT_T_SCALAR 384 #define PHVOLT_T_ITERABLE 385 #define PHVOLT_T_ISEMPTY 386 #define PHVOLT_T_ISEVEN 387 #define PHVOLT_T_ISODD 388 #define PHVOLT_T_ISNUMERIC 389 #define PHVOLT_T_ISSCALAR 390 #define PHVOLT_T_ISITERABLE 391 #define PHVOLT_T_NOT_ISEMPTY 392 #define PHVOLT_T_NOT_ISEVEN 393 #define PHVOLT_T_NOT_ISODD 394 #define PHVOLT_T_NOT_ISNUMERIC 395 #define PHVOLT_T_NOT_ISSCALAR 396 #define PHVOLT_T_NOT_ISITERABLE 397 #define PHVOLT_T_RAW 400 #define PHVOLT_T_ENDRAW 401 /* List of tokens and their names */ typedef struct _phvolt_token_names { char *name; int len; unsigned int code; } phvolt_token_names; /* Active token state */ typedef struct _phvolt_scanner_state { int active_token; int mode; char* start; char* end; unsigned int start_length; unsigned int active_line; zval *active_file; unsigned int statement_position; unsigned int extends_mode; unsigned int block_level; unsigned int macro_level; char *raw_buffer; unsigned int raw_buffer_cursor; unsigned int raw_buffer_size; unsigned int old_if_level; unsigned int if_level; unsigned int for_level; int whitespace_control; int forced_raw_state; } phvolt_scanner_state; /* Extra information tokens */ typedef struct _phvolt_scanner_token { int opcode; int len; char *value; } phvolt_scanner_token; static int phvolt_get_token(phvolt_scanner_state *s, phvolt_scanner_token *token); const phvolt_token_names phvolt_tokens[]; #endif /* PHALCON_MVC_VIEW_ENGINE_VOLT_SCANNER_H */ typedef struct _phvolt_parser_token { char *token; int opcode; int token_len; int free_flag; } phvolt_parser_token; typedef struct _phvolt_parser_status { zval *ret; phvolt_scanner_state *scanner_state; int status; zend_uint syntax_error_len; char *syntax_error; phvolt_scanner_token *token; } phvolt_parser_status; #define PHVOLT_PARSING_OK 1 #define PHVOLT_PARSING_FAILED 0 static int phvolt_parse_view(zval *result, zval *view_code, zval *template_path TSRMLS_DC); static int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_path, zval **error_msg TSRMLS_DC); #define PHANNOT_COMMA 1 #define PHANNOT_AT 2 #define PHANNOT_IDENTIFIER 3 #define PHANNOT_PARENTHESES_OPEN 4 #define PHANNOT_PARENTHESES_CLOSE 5 #define PHANNOT_STRING 6 #define PHANNOT_EQUALS 7 #define PHANNOT_COLON 8 #define PHANNOT_INTEGER 9 #define PHANNOT_DOUBLE 10 #define PHANNOT_NULL 11 #define PHANNOT_FALSE 12 #define PHANNOT_TRUE 13 #define PHANNOT_BRACKET_OPEN 14 #define PHANNOT_BRACKET_CLOSE 15 #define PHANNOT_SBRACKET_OPEN 16 #define PHANNOT_SBRACKET_CLOSE 17 #ifndef PHALCON_ANNOTATIONS_SCANNER_H #define PHALCON_ANNOTATIONS_SCANNER_H #define PHANNOT_SCANNER_RETCODE_EOF -1 #define PHANNOT_SCANNER_RETCODE_ERR -2 #define PHANNOT_SCANNER_RETCODE_IMPOSSIBLE -3 /** Modes */ #define PHANNOT_MODE_RAW 0 #define PHANNOT_MODE_ANNOTATION 1 #define PHANNOT_T_IGNORE 297 #define PHANNOT_T_DOCBLOCK_ANNOTATION 299 #define PHANNOT_T_ANNOTATION 300 /* Literals & Identifiers */ #define PHANNOT_T_INTEGER 301 #define PHANNOT_T_DOUBLE 302 #define PHANNOT_T_STRING 303 #define PHANNOT_T_NULL 304 #define PHANNOT_T_FALSE 305 #define PHANNOT_T_TRUE 306 #define PHANNOT_T_IDENTIFIER 307 #define PHANNOT_T_ARRAY 308 #define PHANNOT_T_ARBITRARY_TEXT 309 /* Operators */ #define PHANNOT_T_AT '@' #define PHANNOT_T_DOT '.' #define PHANNOT_T_COMMA ',' #define PHANNOT_T_EQUALS '=' #define PHANNOT_T_COLON ':' #define PHANNOT_T_BRACKET_OPEN '{' #define PHANNOT_T_BRACKET_CLOSE '}' #define PHANNOT_T_SBRACKET_OPEN '[' #define PHANNOT_T_SBRACKET_CLOSE ']' #define PHANNOT_T_PARENTHESES_OPEN '(' #define PHANNOT_T_PARENTHESES_CLOSE ')' /* List of tokens and their names */ typedef struct _phannot_token_names { char *name; unsigned int code; } phannot_token_names; /* Active token state */ typedef struct _phannot_scanner_state { char* start; char* end; int active_token; unsigned int start_length; int mode; unsigned int active_line; const char *active_file; } phannot_scanner_state; /* Extra information tokens */ typedef struct _phannot_scanner_token { char *value; int opcode; int len; } phannot_scanner_token; static int phannot_get_token(phannot_scanner_state *s, phannot_scanner_token *token); const phannot_token_names phannot_tokens[]; #endif /* PHALCON_ANNOTATIONS_SCANNER_H */ #ifndef PHALCON_ANNOTATIONS_ANNOT_H #define PHALCON_ANNOTATIONS_ANNOT_H #include <Zend/zend.h> typedef struct _phannot_parser_token { char *token; int opcode; int token_len; int free_flag; } phannot_parser_token; typedef struct _phannot_parser_status { zval *ret; phannot_scanner_state *scanner_state; phannot_scanner_token *token; char *syntax_error; int status; } phannot_parser_status; #define PHANNOT_PARSING_OK 1 #define PHANNOT_PARSING_FAILED 0 static int phannot_parse_annotations(zval *result, zval *comment, zval *file_path, zval *line TSRMLS_DC); static int phannot_internal_parse_annotations(zval **result, const char *comment, zend_uint comment_len, const char *file_path, zend_uint line, char **error_msg TSRMLS_DC); #endif /* PHALCON_ANNOTATIONS_ANNOT_H */ #ifndef ZEPHIR_KERNEL_MAIN_H #define ZEPHIR_KERNEL_MAIN_H #include <Zend/zend_interfaces.h> #include <ext/spl/spl_exceptions.h> #include <ext/spl/spl_iterators.h> /** Main macros */ #define PH_DEBUG 0 #define PH_NOISY 256 #define PH_SILENT 1024 #define PH_READONLY 4096 #define PH_NOISY_CC PH_NOISY TSRMLS_CC #define PH_SILENT_CC PH_SILENT TSRMLS_CC #define PH_SEPARATE 256 #define PH_COPY 1024 #define PH_CTOR 4096 #ifndef zend_uint #define zend_uint uint #endif #define SL(str) ZEND_STRL(str) #define SS(str) ZEND_STRS(str) #define ISL(str) (zephir_interned_##str), (sizeof(#str)-1) #define ISS(str) (zephir_interned_##str), (sizeof(#str)) #include <Zend/zend_constants.h> /* Compatibility with PHP 5.3 */ #ifndef ZVAL_COPY_VALUE #define ZVAL_COPY_VALUE(z, v)\ (z)->value = (v)->value;\ Z_TYPE_P(z) = Z_TYPE_P(v); #endif #ifndef INIT_PZVAL_COPY #define INIT_PZVAL_COPY(z, v) ZVAL_COPY_VALUE(z, v);\ Z_SET_REFCOUNT_P(z, 1);\ Z_UNSET_ISREF_P(z); #endif /* Startup functions */ zend_class_entry *zephir_register_internal_interface_ex(zend_class_entry *orig_ce, zend_class_entry *parent_ce TSRMLS_DC); /* Globals functions */ static int zephir_init_global(char *global, unsigned int global_length TSRMLS_DC); static int zephir_get_global(zval **arr, const char *global, unsigned int global_length TSRMLS_DC); static int zephir_is_callable(zval *var TSRMLS_DC); static int zephir_is_scalar(zval *var); static int zephir_function_exists(const zval *function_name TSRMLS_DC); static int zephir_function_exists_ex(const char *func_name, unsigned int func_len TSRMLS_DC); static int zephir_function_quick_exists_ex(const char *func_name, unsigned int func_len, unsigned long key TSRMLS_DC); zend_class_entry* zephir_get_internal_ce(const char *class_name, unsigned int class_name_len TSRMLS_DC); /* types */ static void zephir_gettype(zval *return_value, zval *arg TSRMLS_DC); /* Count */ static void zephir_fast_count(zval *result, zval *array TSRMLS_DC); static int zephir_fast_count_ev(zval *array TSRMLS_DC); static int zephir_fast_count_int(zval *value TSRMLS_DC); /* Utils functions */ static inline int zephir_maybe_separate_zval(zval** z) { if (Z_REFCOUNT_PP(z) > 1 && !Z_ISREF_PP(z)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, *z); *z = new_zv; zval_copy_ctor(new_zv); return 1; } return 0; } static int zephir_is_iterable_ex(zval *arr, HashTable **arr_hash, HashPosition *hash_position, int duplicate, int reverse); static void zephir_safe_zval_ptr_dtor(zval *pzval); /* Fetch Parameters */ static int zephir_fetch_parameters(int num_args TSRMLS_DC, int required_args, int optional_args, ...); /** Symbols */ #define ZEPHIR_READ_SYMBOL(var, auxarr, name) if (EG(active_symbol_table)){ \ if (zend_hash_find(EG(active_symbol_table), name, sizeof(name), (void **) &auxarr) == SUCCESS) { \ var = *auxarr; \ } else { \ ZVAL_NULL(var); \ } \ } else { \ ZVAL_NULL(var); \ } #define RETURN_ON_FAILURE(what) \ do { \ if (what == FAILURE) { \ return; \ } \ } while (0) #define RETURN_MM_ON_FAILURE(what) \ do { \ if (what == FAILURE) { \ ZEPHIR_MM_RESTORE(); \ return; \ } \ } while (0) #if PHP_VERSION_ID < 50600 /** Return zval checking if it's needed to ctor */ #define RETURN_CCTOR(var) { \ *(return_value) = *(var); \ if (Z_TYPE_P(var) > IS_BOOL) { \ zephir_copy_ctor(return_value, var); \ } \ INIT_PZVAL(return_value) \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval checking if it's needed to ctor, without restoring the memory stack */ #define RETURN_CCTORW(var) { \ *(return_value) = *(var); \ if (Z_TYPE_P(var) > IS_BOOL) { \ zephir_copy_ctor(return_value, var); \ } \ INIT_PZVAL(return_value) \ } \ return; /** Return zval with always ctor */ #define RETURN_CTOR(var) { \ RETVAL_ZVAL(var, 1, 0); \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval with always ctor, without restoring the memory stack */ #define RETURN_CTORW(var) { \ RETVAL_ZVAL(var, 1, 0); \ } \ return; /** Return this pointer */ #define RETURN_THIS() { \ RETVAL_ZVAL(this_ptr, 1, 0); \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval with always ctor, without restoring the memory stack */ #define RETURN_THISW() \ RETURN_ZVAL(this_ptr, 1, 0); #else /** Return zval checking if it's needed to ctor */ #define RETURN_CCTOR(var) { \ RETVAL_ZVAL_FAST(var); \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval checking if it's needed to ctor, without restoring the memory stack */ #define RETURN_CCTORW(var) { \ RETVAL_ZVAL_FAST(var); \ } \ return; /** Return zval with always ctor */ #define RETURN_CTOR(var) { \ RETVAL_ZVAL_FAST(var); \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval with always ctor, without restoring the memory stack */ #define RETURN_CTORW(var) { \ RETVAL_ZVAL_FAST(var); \ } \ return; /** Return this pointer */ #define RETURN_THIS() { \ RETVAL_ZVAL_FAST(this_ptr); \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Return zval with always ctor, without restoring the memory stack */ #define RETURN_THISW() \ RETURN_ZVAL_FAST(this_ptr); #endif /** Returns variables without ctor */ #define RETURN_NCTOR(var) { \ *(return_value) = *(var); \ INIT_PZVAL(return_value) \ } \ ZEPHIR_MM_RESTORE(); \ return; /** Returns variables without ctor, without restoring the memory stack */ #define RETURN_NCTORW(var) { \ *(return_value) = *(var); \ INIT_PZVAL(return_value) \ } \ return; /** Check for ctor on the same return_value */ #define RETURN_SCTOR() \ if (Z_TYPE_P(return_value) > IS_BOOL) { \ zval_copy_ctor(return_value); \ } \ ZEPHIR_MM_RESTORE(); \ return; #define RETURN_LCTOR(var) { \ zend_uchar is_ref = Z_ISREF_P(return_value); \ zend_uint refcount = Z_REFCOUNT_P(return_value); \ (return_value)->value = var.value; \ Z_TYPE_P(return_value) = Z_TYPE(var); \ zval_copy_ctor(return_value); \ Z_SET_ISREF_TO_P(return_value, is_ref); \ Z_SET_REFCOUNT_P(return_value, refcount); \ ZEPHIR_MM_RESTORE(); \ return; \ } #define RETURN_LCTORW(var) { \ zend_uchar is_ref = Z_ISREF_P(return_value); \ zend_uint refcount = Z_REFCOUNT_P(return_value); \ (return_value)->value = var.value; \ Z_TYPE_P(return_value) = Z_TYPE(var); \ zval_copy_ctor(return_value); \ Z_SET_ISREF_TO_P(return_value, is_ref); \ Z_SET_REFCOUNT_P(return_value, refcount); \ return; \ } #define RETURN_SCTORW() \ if (Z_TYPE_P(return_value) > IS_BOOL) { \ zval_copy_ctor(return_value); \ } \ return; #define RETURN_MEMBER(object, member_name) \ zephir_return_property_quick(return_value, return_value_ptr, object, SL(member_name), zend_inline_hash_func(SS(member_name)) TSRMLS_CC); \ return; #define RETURN_MM_MEMBER(object, member_name) \ zephir_return_property_quick(return_value, return_value_ptr, object, SL(member_name), zend_inline_hash_func(SS(member_name)) TSRMLS_CC); \ RETURN_MM(); #define RETURN_MEMBER_QUICK(object, member_name, key) \ zephir_return_property_quick(return_value, NULL, object, SL(member_name), key TSRMLS_CC); \ return; #define RETURN_MM_MEMBER_QUICK(object, member_name, key) \ zephir_return_property_quick(return_value, NULL, object, SL(member_name), key TSRMLS_CC); \ RETURN_MM(); /** Return without change return_value */ #define RETURN_MM() { ZEPHIR_MM_RESTORE(); return; } /** Return null restoring memory frame */ #define RETURN_MM_BOOL(value) { RETVAL_BOOL(value); ZEPHIR_MM_RESTORE(); return; } /** Return null restoring memory frame */ #define RETURN_MM_NULL() { RETVAL_NULL(); ZEPHIR_MM_RESTORE(); return; } /** Return bool restoring memory frame */ #define RETURN_MM_FALSE { RETVAL_FALSE; ZEPHIR_MM_RESTORE(); return; } #define RETURN_MM_TRUE { RETVAL_TRUE; ZEPHIR_MM_RESTORE(); return; } /** Return string restoring memory frame */ #define RETURN_MM_STRING(str, copy) { RETVAL_STRING(str, copy); ZEPHIR_MM_RESTORE(); return; } #define RETURN_MM_EMPTY_STRING() { RETVAL_EMPTY_STRING(); ZEPHIR_MM_RESTORE(); return; } /** Return empty array */ #define RETVAL_EMPTY_ARRAY() { array_init(return_value); } #define RETURN_EMPTY_ARRAY() { RETVAL_EMPTY_ARRAY(); return; } #define RETURN_MM_EMPTY_ARRAY() { RETVAL_EMPTY_ARRAY(); ZEPHIR_MM_RESTORE(); return; } /* Return long */ #define RETURN_MM_LONG(value) { RETVAL_LONG(value); ZEPHIR_MM_RESTORE(); return; } /* Return double */ #define RETURN_MM_DOUBLE(value) { RETVAL_DOUBLE(value); ZEPHIR_MM_RESTORE(); return; } /* Compat for interned strings < 5.4 */ #ifndef IS_INTERNED #define IS_INTERNED(key) 0 #define INTERNED_HASH(key) 0 #endif /* Compat for reallocation of interned strings < 5.4 */ #ifndef str_erealloc #define str_erealloc(str, new_len) \ (IS_INTERNED(str) \ ? _str_erealloc(str, new_len, INTERNED_LEN(str)) \ : erealloc(str, new_len)) static inline char *_str_erealloc(char *str, size_t new_len, size_t old_len) { char *buf = (char *) emalloc(new_len); memcpy(buf, str, old_len); return buf; } #endif #ifndef str_efree #define str_efree(s) do { \ if (!IS_INTERNED(s)) { \ efree((char*)s); \ } \ } while (0) #endif /** Get the current hash key without copying the hash key */ #define ZEPHIR_GET_HKEY(var, hash, hash_position) \ zephir_get_current_key(&var, hash, &hash_position TSRMLS_CC); /** Get current hash key copying the hash_value if needed */ #define ZEPHIR_GET_HMKEY(var, hash, hash_pointer) \ {\ int hash_type; \ char *hash_index; \ uint hash_index_len; \ ulong hash_num; \ \ ZEPHIR_INIT_NVAR(var); \ hash_type = zend_hash_get_current_key_ex(hash, &hash_index, &hash_index_len, &hash_num, 0, &hash_pointer); \ if (hash_type == HASH_KEY_IS_STRING) { \ if (IS_INTERNED(hash_index)) { \ ZVAL_STRINGL(var, hash_index, hash_index_len - 1, 0); \ } else { \ ZVAL_STRINGL(var, hash_index, hash_index_len - 1, 1); \ } \ } else { \ if (hash_type == HASH_KEY_IS_LONG) { \ ZVAL_LONG(var, hash_num); \ }\ }\ } /** Get current hash key copying the iterator if needed */ #if PHP_VERSION_ID < 50500 #define ZEPHIR_GET_IMKEY(var, it) \ {\ int key_type; uint str_key_len; \ ulong int_key; \ char *str_key; \ \ ZEPHIR_INIT_NVAR(var); \ key_type = it->funcs->get_current_key(it, &str_key, &str_key_len, &int_key TSRMLS_CC); \ if (key_type == HASH_KEY_IS_STRING) { \ ZVAL_STRINGL(var, str_key, str_key_len - 1, 1); \ efree(str_key); \ } else { \ if (key_type == HASH_KEY_IS_LONG) { \ ZVAL_LONG(var, int_key); \ } else { \ ZVAL_NULL(var); \ } \ } \ } #else #define ZEPHIR_GET_IMKEY(var, it) \ {\ ZEPHIR_INIT_NVAR(var); \ it->funcs->get_current_key(it, var TSRMLS_CC); \ } #endif /** Foreach */ #define ZEPHIR_GET_FOREACH_KEY(var, hash, hash_pointer) ZEPHIR_GET_HMKEY(var, hash, hash_pointer) /** Check if an array is iterable or not */ #define zephir_is_iterable(var, array_hash, hash_pointer, duplicate, reverse, file, line) \ if (!var || !zephir_is_iterable_ex(var, array_hash, hash_pointer, duplicate, reverse)) { \ ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(zend_exception_get_default(TSRMLS_C), "The argument is not initialized or iterable()", file, line); \ ZEPHIR_MM_RESTORE(); \ return; \ } #define ZEPHIR_GET_FOREACH_VALUE(var) \ ZEPHIR_OBS_NVAR(var); \ var = *hd; \ Z_ADDREF_P(var); #define ZEPHIR_GET_HVALUE(var, hd) \ ZEPHIR_OBS_NVAR(var); \ var = *hd; \ Z_ADDREF_P(var); /** class/interface registering */ #define ZEPHIR_REGISTER_CLASS(ns, class_name, lower_ns, name, methods, flags) \ { \ zend_class_entry ce; \ memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, methods); \ lower_ns## _ ##name## _ce = zend_register_internal_class(&ce TSRMLS_CC); \ lower_ns## _ ##name## _ce->ce_flags |= flags; \ } #define ZEPHIR_REGISTER_CLASS_EX(ns, class_name, lower_ns, lcname, parent_ce, methods, flags) \ { \ zend_class_entry ce; \ if (!parent_ce) { \ fprintf(stderr, "Can't register class %s::%s with null parent\n", #ns, #class_name); \ return FAILURE; \ } \ memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_NS_CLASS_ENTRY(ce, #ns, #class_name, methods); \ lower_ns## _ ##lcname## _ce = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC); \ if (!lower_ns## _ ##lcname## _ce) { \ fprintf(stderr, "Zephir Error: Class to extend '%s' was not found when registering class '%s'\n", (parent_ce ? parent_ce->name : "(null)"), ZEND_NS_NAME(#ns, #class_name)); \ return FAILURE; \ } \ lower_ns## _ ##lcname## _ce->ce_flags |= flags; \ } #if PHP_VERSION_ID < 50399 #define object_properties_init(object, class_type) { \ ALLOC_HASHTABLE_REL(object->properties); \ zend_hash_init(object->properties, zend_hash_num_elements(&class_type->default_properties), NULL, ZVAL_PTR_DTOR, 0); \ zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \ } #endif #define ZEPHIR_CREATE_OBJECT(obj_ptr, class_type) \ { \ zend_object *object; \ ZEPHIR_INIT_ZVAL_NREF(obj_ptr); \ Z_TYPE_P(obj_ptr) = IS_OBJECT; \ Z_OBJVAL_P(obj_ptr) = zend_objects_new(&object, class_type TSRMLS_CC); \ object_properties_init(object, class_type); \ } #define ZEPHIR_MAKE_REF(obj) Z_SET_ISREF_P(obj); #define ZEPHIR_UNREF(obj) Z_UNSET_ISREF_P(obj); #define ZEPHIR_REGISTER_INTERFACE(ns, classname, lower_ns, name, methods) \ { \ zend_class_entry ce; \ memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_NS_CLASS_ENTRY(ce, #ns, #classname, methods); \ lower_ns## _ ##name## _ce = zend_register_internal_interface(&ce TSRMLS_CC); \ } #define ZEPHIR_REGISTER_INTERFACE_EX(ns, classname, lower_ns, lcname, parent_ce, methods) \ { \ zend_class_entry ce; \ if (!parent_ce) { \ fprintf(stderr, "Can't register interface %s with null parent\n", ZEND_NS_NAME(#ns, #classname)); \ return FAILURE; \ } \ memset(&ce, 0, sizeof(zend_class_entry)); \ INIT_NS_CLASS_ENTRY(ce, #ns, #classname, methods); \ lower_ns## _ ##lcname## _ce = zephir_register_internal_interface_ex(&ce, parent_ce TSRMLS_CC); \ if (!lower_ns## _ ##lcname## _ce) { \ fprintf(stderr, "Can't register interface %s with parent %s\n", ZEND_NS_NAME(#ns, #classname), (parent_ce ? parent_ce->name : "(null)")); \ return FAILURE; \ } \ } /** Method declaration for API generation */ #define ZEPHIR_DOC_METHOD(class_name, method) /** Low overhead parse/fetch parameters */ #define zephir_fetch_params(memory_grow, required_params, optional_params, ...) \ if (zephir_fetch_parameters(ZEND_NUM_ARGS() TSRMLS_CC, required_params, optional_params, __VA_ARGS__) == FAILURE) { \ if (memory_grow) { \ RETURN_MM_NULL(); \ } else { \ RETURN_NULL(); \ } \ } #define ZEPHIR_VERIFY_INTERFACE(instance, interface_ce) \ do { \ if (Z_TYPE_P(instance) != IS_OBJECT || !instanceof_function_ex(Z_OBJCE_P(instance), interface_ce, 1 TSRMLS_CC)) { \ char *buf; \ if (Z_TYPE_P(instance) != IS_OBJECT) { \ spprintf(&buf, 0, "Unexpected value type: expected object implementing %s, %s given", interface_ce->name, zend_zval_type_name(instance)); \ } \ else { \ spprintf(&buf, 0, "Unexpected value type: expected object implementing %s, object of type %s given", interface_ce->name, Z_OBJCE_P(instance)->name); \ } \ ZEPHIR_THROW_EXCEPTION_STR(spl_ce_LogicException, buf); \ efree(buf); \ return; \ } \ } while (0) #define ZEPHIR_VERIFY_CLASS(instance, class_ce) \ do { \ if (Z_TYPE_P(instance) != IS_OBJECT || !instanceof_function_ex(Z_OBJCE_P(instance), class_ce, 0 TSRMLS_CC)) { \ char *buf; \ if (Z_TYPE_P(instance) != IS_OBJECT) { \ spprintf(&buf, 0, "Unexpected value type: expected object of type %s, %s given", class_ce->name, zend_zval_type_name(instance)); \ } \ else { \ spprintf(&buf, 0, "Unexpected value type: expected object of type %s, object of type %s given", class_ce->name, Z_OBJCE_P(instance)->name); \ } \ ZEPHIR_THROW_EXCEPTION_STR(spl_ce_LogicException, buf); \ efree(buf); \ return; \ } \ } while (0) #define ZEPHIR_GET_CONSTANT(return_value, const_name) \ RETURN_MM_ON_FAILURE(zend_get_constant(SL(const_name), return_value TSRMLS_CC)); #ifndef ZEPHIR_RELEASE #define ZEPHIR_DEBUG_PARAMS , const char *file, int line #define ZEPHIR_DEBUG_PARAMS_DUMMY , "", 0 #else #define ZEPHIR_DEBUG_PARAMS , const char *file, int line #define ZEPHIR_DEBUG_PARAMS_DUMMY , "", 0 #endif #define ZEPHIR_CHECK_POINTER(v) if (!v) fprintf(stderr, "%s:%d\n", __PRETTY_FUNCTION__, __LINE__); #define zephir_is_php_version(id) (PHP_VERSION_ID / 10 == id / 10 ? 1 : 0) #endif /* ZEPHIR_KERNEL_MAIN_H */ #ifndef ZEPHIR_KERNEL_MEMORY_H #define ZEPHIR_KERNEL_MEMORY_H #include <php.h> #include <Zend/zend.h> #define ZEPHIR_NUM_PREALLOCATED_FRAMES 25 /* Variable Tracking */ static void zephir_init_nvar(zval **var TSRMLS_DC); static void zephir_cpy_wrt(zval **dest, zval *var TSRMLS_DC); static void zephir_cpy_wrt_ctor(zval **dest, zval *var TSRMLS_DC); static void zephir_value_dtor(zval *zvalue ZEND_FILE_LINE_DC); void ZEND_FASTCALL zephir_ptr_dtor(zval **var); void ZEND_FASTCALL zephir_dtor(zval *var); /* Memory Frames */ #ifndef ZEPHIR_RELEASE static void ZEPHIR_FASTCALL zephir_memory_grow_stack(const char *func TSRMLS_DC); static int ZEPHIR_FASTCALL zephir_memory_restore_stack(const char *func TSRMLS_DC); #define ZEPHIR_MM_GROW() zephir_memory_grow_stack(NULL TSRMLS_CC) #define ZEPHIR_MM_RESTORE() zephir_memory_restore_stack(NULL TSRMLS_CC) #else static void ZEPHIR_FASTCALL zephir_memory_grow_stack(TSRMLS_D); static int ZEPHIR_FASTCALL zephir_memory_restore_stack(TSRMLS_D); #define ZEPHIR_MM_GROW() zephir_memory_grow_stack(TSRMLS_C) #define ZEPHIR_MM_RESTORE() zephir_memory_restore_stack(TSRMLS_C) #endif static void ZEPHIR_FASTCALL zephir_memory_observe(zval **var TSRMLS_DC); static void ZEPHIR_FASTCALL zephir_memory_remove(zval **var TSRMLS_DC); static void ZEPHIR_FASTCALL zephir_memory_alloc(zval **var TSRMLS_DC); static void ZEPHIR_FASTCALL zephir_memory_alloc_pnull(zval **var TSRMLS_DC); static int ZEPHIR_FASTCALL zephir_clean_restore_stack(TSRMLS_D); /* Virtual symbol tables */ static void zephir_create_symbol_table(TSRMLS_D); /*void zephir_restore_symbol_table(TSRMLS_D);*/ static void zephir_clean_symbol_tables(TSRMLS_D); /** Export symbols to active symbol table */ static int zephir_set_symbol(zval *key_name, zval *value TSRMLS_DC); static int zephir_set_symbol_str(char *key_name, unsigned int key_length, zval *value TSRMLS_DC); static void ZEPHIR_FASTCALL zephir_copy_ctor(zval *destiny, zval *origin); static void zephir_initialize_memory(zend_zephir_globals_def *zephir_globals_ptr TSRMLS_DC); static int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key); static void zephir_deinitialize_memory(TSRMLS_D); /* Memory macros */ #define ZEPHIR_ALLOC_ZVAL(z) \ ALLOC_INIT_ZVAL(z) #define ZEPHIR_SINIT_VAR(z) \ INIT_PZVAL(&z); \ ZVAL_NULL(&z); #define ZEPHIR_SINIT_NVAR(z) Z_SET_REFCOUNT_P(&z, 1) #define ZEPHIR_INIT_ZVAL_NREF(z) \ ALLOC_ZVAL(z); \ Z_SET_REFCOUNT_P(z, 0); \ Z_UNSET_ISREF_P(z); #define ZEPHIR_INIT_VAR(z) \ zephir_memory_alloc(&z TSRMLS_CC) #define ZEPHIR_INIT_NVAR(z)\ if (z) { \ if (!Z_ISREF_P(z)) { \ if (Z_REFCOUNT_P(z) > 1) { \ Z_DELREF_P(z); \ ALLOC_ZVAL(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } else { \ zephir_dtor(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } \ ZVAL_NULL(z); \ } \ } else { \ zephir_memory_alloc(&z TSRMLS_CC); \ } #define ZEPHIR_INIT_BNVAR(z) \ if (Z_REFCOUNT_P(z) > 1) { \ zephir_ptr_dtor(&z); \ ALLOC_ZVAL(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ ZVAL_NULL(z); \ } else {\ zephir_ptr_dtor(&z); \ ZEPHIR_ALLOC_ZVAL(z); \ } #define ZEPHIR_INIT_NVAR_PNULL(z)\ if (z) { \ if (Z_REFCOUNT_P(z) > 1) { \ Z_DELREF_P(z); \ if (Z_REFCOUNT_P(z) >= 1) { \ zval_copy_ctor(z); \ } \ ALLOC_ZVAL(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } \ ZVAL_NULL(z); \ } else { \ zephir_memory_alloc_pnull(&z TSRMLS_CC); \ } /* only removes the value body of the zval */ #define ZEPHIR_INIT_LNVAR(z)\ if (z) { \ if (Z_REFCOUNT_P(z) > 1) { \ Z_DELREF_P(z); \ ALLOC_ZVAL(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } else { \ if (!Z_ISREF_P(z)) { \ zephir_value_dtor(z ZEND_FILE_LINE_CC); \ } \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } \ ZVAL_NULL(z); \ } else { \ zephir_memory_alloc(&z TSRMLS_CC); \ } #define ZEPHIR_CPY_WRT(d, v) \ Z_ADDREF_P(v); \ if (d) { \ if (Z_REFCOUNT_P(d) > 0) { \ zephir_ptr_dtor(&d); \ } \ } else { \ zephir_memory_observe(&d TSRMLS_CC); \ } \ d = v; #define ZEPHIR_CPY_WRT_CTOR(d, v) \ if (d) { \ if (Z_REFCOUNT_P(d) > 0) { \ zephir_ptr_dtor(&d); \ } \ } else { \ zephir_memory_observe(&d TSRMLS_CC); \ } \ ALLOC_ZVAL(d); \ *d = *v; \ zval_copy_ctor(d); \ Z_SET_REFCOUNT_P(d, 1); \ Z_UNSET_ISREF_P(d); #define ZEPHIR_MAKE_REFERENCE(d, v) \ if (d) { \ if (Z_REFCOUNT_P(d) > 0) { \ zephir_ptr_dtor(&d); \ } \ } else { \ zephir_memory_observe(&d TSRMLS_CC); \ } \ ALLOC_ZVAL(d); \ Z_TYPE_P(d) = Z_TYPE_P(v); \ d->value = v->value; \ Z_SET_REFCOUNT_P(d, 1); \ Z_SET_ISREF_P(d); /* */ #define ZEPHIR_OBS_VAR(z) \ zephir_memory_observe(&z TSRMLS_CC) #define ZEPHIR_OBS_NVAR(z)\ if (z) { \ if (Z_REFCOUNT_P(z) > 1) { \ Z_DELREF_P(z); \ } else {\ zephir_ptr_dtor(&z); \ z = NULL; \ } \ } else { \ zephir_memory_observe(&z TSRMLS_CC); \ } #define ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(ppzv) \ do { \ zval ** restrict tmp_ = (ppzv); \ if (tmp_ != NULL) { \ if (*tmp_) { \ zephir_ptr_dtor(tmp_); \ *tmp_ = NULL; \ } \ else { \ zephir_memory_observe((ppzv) TSRMLS_CC); \ } \ } \ } while (0) #define ZEPHIR_OBSERVE_OR_NULLIFY_VAR(z) \ do { \ if (z) { \ zephir_ptr_dtor(&z); \ z = NULL; \ } \ else { \ zephir_memory_observe(&z TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_SEPARATE_ARRAY(a) \ { \ if (Z_REFCOUNT_P(a) > 1) { \ zval *new_zv; \ Z_DELREF_P(a); \ ALLOC_ZVAL(new_zv); \ INIT_PZVAL_COPY(new_zv, a); \ a = new_zv; \ zval_copy_ctor(new_zv); \ } \ } #define ZEPHIR_SEPARATE(z) SEPARATE_ZVAL(&z) #define ZEPHIR_SEPARATE_PARAM(z) \ do { \ zval *orig_ptr = z;\ zephir_memory_observe(&z TSRMLS_CC);\ ALLOC_ZVAL(z);\ *z = *orig_ptr;\ zval_copy_ctor(z);\ Z_SET_REFCOUNT_P(z, 1);\ Z_UNSET_ISREF_P(z);\ } while (0) #define ZEPHIR_SEPARATE_PARAM_NMO(z) { \ zval *orig_ptr = z; \ if (Z_REFCOUNT_P(orig_ptr) > 1) { \ ALLOC_ZVAL(z); \ *z = *orig_ptr; \ zval_copy_ctor(z); \ Z_SET_REFCOUNT_P(z, 1); \ Z_UNSET_ISREF_P(z); \ } \ } #endif #ifndef ZEPHIR_KERNEL_EXCEPTIONS_H #define ZEPHIR_KERNEL_EXCEPTIONS_H #include <Zend/zend.h> /** Exceptions */ #define ZEPHIR_THROW_EXCEPTION_STR(class_entry, message) \ do { \ zephir_throw_exception_string(class_entry, message, strlen(message) TSRMLS_CC); \ ZEPHIR_MM_RESTORE(); \ } while (0) #define ZEPHIR_THROW_EXCEPTION_DEBUG_STR(class_entry, message, file, line) \ do { \ zephir_throw_exception_string_debug(class_entry, message, strlen(message), file, line TSRMLS_CC); \ ZEPHIR_MM_RESTORE(); \ } while (0) #define ZEPHIR_THROW_EXCEPTION_ZVAL(class_entry, message) \ do { \ zephir_throw_exception_zval(class_entry, message TSRMLS_CC); \ ZEPHIR_MM_RESTORE(); \ } while (0) #define ZEPHIR_THROW_EXCEPTION_DEBUG_ZVAL(class_entry, message, file, line) \ do { \ zephir_throw_exception_zval(class_entry, message, file, line TSRMLS_CC); \ ZEPHIR_MM_RESTORE(); \ } while (0) #define ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(class_entry, message, file, line) zephir_throw_exception_string_debug(class_entry, message, strlen(message), file, line TSRMLS_CC) #define ZEPHIR_THROW_EXCEPTION_STRW(class_entry, message) zephir_throw_exception_string(class_entry, message, strlen(message) TSRMLS_CC) #define ZEPHIR_THROW_EXCEPTION_ZVALW(class_entry, message) zephir_throw_exception_zval(class_entry, message TSRMLS_CC) #define ZEPHIR_THROW_EXCEPTION_DEBUG_ZVALW(class_entry, message, file, line) zephir_throw_exception_zval_debug(class_entry, message, file, line TSRMLS_CC) /** Throw Exceptions */ static void zephir_throw_exception(zval *object TSRMLS_DC); static void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC); static void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *message, zend_uint message_len, const char *file, zend_uint line TSRMLS_DC); static void zephir_throw_exception_string(zend_class_entry *ce, const char *message, zend_uint message_len TSRMLS_DC); static void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC); static void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, const char *file, zend_uint line TSRMLS_DC); static void zephir_throw_exception_format(zend_class_entry *ce TSRMLS_DC, const char *format, ...); #endif /* ZEPHIR_KERNEL_EXCEPTIONS_H */ #ifndef ZEPHIR_KERNEL_HASH_H #define ZEPHIR_KERNEL_HASH_H #include <php.h> #include <Zend/zend.h> #include <Zend/zend_hash.h> static int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent); static int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength); static int zephir_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h); static int zephir_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData); static int zephir_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData); static void zephir_get_current_key(zval **key, const HashTable *hash_table, HashPosition *hash_position TSRMLS_DC); zval zephir_get_current_key_w(const HashTable *hash_table, HashPosition *hash_position); static int zephir_has_numeric_keys(const zval *data); static void zephir_hash_update_or_insert(HashTable *ht, zval *offset, zval *value); zval** zephir_hash_get(HashTable *ht, zval *key, int type); static int zephir_hash_unset(HashTable *ht, zval *offset); #define zephir_hash_move_forward_ex(ht, pos) *pos = (*pos ? (*pos)->pListNext : NULL) #if PHP_VERSION_ID < 70000 static zend_always_inline int zephir_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos) { Bucket *p; p = pos ? (*pos) : ht->pInternalPointer; if (p) { *pData = p->pData; return SUCCESS; } else { return FAILURE; } } #else static zend_always_inline zval *zephir_hash_get_current_data_ex(HashTable *ht, HashPosition *pos) { uint idx = *pos; Bucket *p; IS_CONSISTENT(ht); if (idx != INVALID_IDX) { p = ht->arData + idx; return &p->val; } else { return NULL; } } #endif static zend_always_inline int zephir_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) { #if PHP_VERSION_ID < 70000 HashPosition *current = pos ? pos : &ht->pInternalPointer; if (*current) { *current = (*current)->pListLast; return SUCCESS; } else { return FAILURE; } #else uint idx = *pos; IS_CONSISTENT(ht); if (idx != INVALID_IDX) { while (idx > 0) { idx--; if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) { *pos = idx; return SUCCESS; } } *pos = INVALID_IDX; return SUCCESS; } else { return FAILURE; } #endif } #endif #ifndef ZEPHIR_KERNEL_DEBUG_H #define ZEPHIR_KERNEL_DEBUG_H #ifndef ZEPHIR_RELEASE #include <php.h> #define PHV(v) zephir_vdump(v) #define PHPR(v) zephir_print_r(v) typedef struct _zephir_debug_entry { struct _zephir_debug_entry *prev; struct _zephir_debug_entry *next; char *class_name; char *method_name; int lineno; } zephir_debug_entry; static int zephir_start_debug(); static int zephir_stop_debug(); static int zephir_print_r(zval *userval TSRMLS_DC); static int zephir_vdump(zval *uservar TSRMLS_DC); static int zephir_debug_assign(char *name, zval *value TSRMLS_DC); static int zephir_vpdump(const zval **uservar TSRMLS_DC); static int zephir_dump_ce(zend_class_entry *ce TSRMLS_DC); static int zephir_class_debug(zval *val TSRMLS_DC); static int zephir_debug_backtrace_internal(); static int zephir_debug_str(char *what, char *message); static int zephir_debug_long(char *what, uint vlong); static int zephir_debug_screen(char *message); static int zephir_step_over(char *message); static int zephir_step_into(char *message); static int zephir_step_out(char *message); static int zephir_step_into_entry(char *class_name, char *method_name, int lineno); static int zephir_step_out_entry(); static int zephir_debug_method_call(zval *obj, char *method_name TSRMLS_DC); static int zephir_debug_vdump(char *preffix, zval *value TSRMLS_DC); static int zephir_debug_param(zval *param TSRMLS_DC); static int zephir_error_space(); static int zephir_debug_space(); #endif #endif #ifndef ZEPHIR_KERNEL_BACKTRACE_H #define ZEPHIR_KERNEL_BACKTRACE_H #ifndef ZEPHIR_RELEASE static void zephir_print_backtrace(void); #else #ifndef zephir_print_backtrace #define zephir_print_backtrace() #endif #endif #endif /* ZEPHIR_KERNEL_BACKTRACE_H */ #ifndef ZEPHIR_KERNEL_OBJECT_H #define ZEPHIR_KERNEL_OBJECT_H #include <php.h> #include <Zend/zend.h> /** Class Retrieving/Checking */ static int zephir_class_exists(const zval *class_name, int autoload TSRMLS_DC); static int zephir_interface_exists(const zval *interface_name, int autoload TSRMLS_DC); static void zephir_get_class(zval *result, zval *object, int lower TSRMLS_DC); static void zephir_get_class_ns(zval *result, zval *object, int lower TSRMLS_DC); static void zephir_get_ns_class(zval *result, zval *object, int lower TSRMLS_DC); static void zephir_get_called_class(zval *return_value TSRMLS_DC); zend_class_entry *zephir_fetch_class(const zval *class_name TSRMLS_DC); zend_class_entry* zephir_fetch_self_class(TSRMLS_D); zend_class_entry* zephir_fetch_parent_class(TSRMLS_D); zend_class_entry* zephir_fetch_static_class(TSRMLS_D); #define ZEPHIR_GET_CLASS_CONSTANT(return_value, ce, const_name) \ do { \ if (FAILURE == zephir_get_class_constant(return_value, ce, const_name, strlen(const_name)+1 TSRMLS_CC)) { \ ZEPHIR_MM_RESTORE(); \ return; \ } \ } while (0) /** Class constants */ static int zephir_get_class_constant(zval *return_value, zend_class_entry *ce, char *constant_name, unsigned int constant_length TSRMLS_DC); /** Cloning/Instance of*/ static int zephir_clone(zval *destiny, zval *obj TSRMLS_DC); static int zephir_instance_of(zval *result, const zval *object, const zend_class_entry *ce TSRMLS_DC); static int zephir_is_instance_of(zval *object, const char *class_name, unsigned int class_length TSRMLS_DC); static int zephir_instance_of_ev(const zval *object, const zend_class_entry *ce TSRMLS_DC); static int zephir_zval_is_traversable(zval *object TSRMLS_DC); /** Method exists */ static int zephir_method_exists(const zval *object, const zval *method_name TSRMLS_DC); static int zephir_method_exists_ex(const zval *object, const char *method_name, unsigned int method_len TSRMLS_DC); static int zephir_method_quick_exists_ex(const zval *object, const char *method_name, unsigned int method_len, unsigned long hash TSRMLS_DC); /** Isset properties */ static int zephir_isset_property(zval *object, const char *property_name, unsigned int property_length TSRMLS_DC); static int zephir_isset_property_quick(zval *object, const char *property_name, unsigned int property_length, unsigned long hash TSRMLS_DC); static int zephir_isset_property_zval(zval *object, const zval *property TSRMLS_DC); /** Reading properties */ zval* zephir_fetch_property_this_quick(zval *object, const char *property_name, zend_uint property_length, ulong key, int silent TSRMLS_DC); static int zephir_read_property(zval **result, zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC); static int zephir_read_property_zval(zval **result, zval *object, zval *property, int silent TSRMLS_DC); static int zephir_return_property(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length TSRMLS_DC); static int zephir_return_property_quick(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC); static int zephir_fetch_property(zval **result, zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC); static int zephir_fetch_property_zval(zval **result, zval *object, zval *property, int silent TSRMLS_DC); /** Updating properties */ static int zephir_update_property_this(zval *object, char *property_name, unsigned int property_length, zval *value TSRMLS_DC); static int zephir_update_property_long(zval *obj, char *property_name, unsigned int property_length, long value TSRMLS_DC); static int zephir_update_property_string(zval *object, char *property_name, unsigned int property_length, char *str, unsigned int str_length TSRMLS_DC); static int zephir_update_property_bool(zval *obj, char *property_name, unsigned int property_length, int value TSRMLS_DC); static int zephir_update_property_null(zval *obj, char *property_name, unsigned int property_length TSRMLS_DC); static int zephir_update_property_zval(zval *obj, const char *property_name, unsigned int property_length, zval *value TSRMLS_DC); static int zephir_update_property_zval_zval(zval *obj, zval *property, zval *value TSRMLS_DC); static int zephir_update_property_empty_array(zend_class_entry *ce, zval *object, char *property, unsigned int property_length TSRMLS_DC); /** Updating array properties */ static int zephir_update_property_array(zval *object, const char *property, zend_uint property_length, const zval *index, zval *value TSRMLS_DC); static int zephir_update_property_array_string(zval *object, char *property, unsigned int property_length, char *index, unsigned int index_length, zval *value TSRMLS_DC); static int zephir_update_property_array_append(zval *object, char *property, unsigned int property_length, zval *value TSRMLS_DC); static int zephir_update_property_array_multi(zval *object, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...); /** Increment/Decrement properties */ static int zephir_property_incr(zval *object, char *property_name, unsigned int property_length TSRMLS_DC); static int zephir_property_decr(zval *object, char *property_name, unsigned int property_length TSRMLS_DC); /** Unset properties */ static int zephir_unset_property(zval* object, const char* name TSRMLS_DC); static int zephir_unset_property_array(zval *object, char *property, unsigned int property_length, zval *index TSRMLS_DC); /** Static properties */ static int zephir_read_static_property(zval **result, const char *class_name, unsigned int class_length, char *property_name, unsigned int property_length TSRMLS_DC); static int zephir_update_static_property_ce(zend_class_entry *ce, const char *name, int len, zval **value TSRMLS_DC); static int zephir_update_static_property_ce_cache(zend_class_entry *ce, const char *name, int len, zval **value, zend_property_info **property_info TSRMLS_DC); static int zephir_update_static_property(const char *class_name, unsigned int class_length, char *name, unsigned int name_length, zval **value TSRMLS_DC); static int zephir_read_static_property_ce(zval **result, zend_class_entry *ce, const char *property, int len TSRMLS_DC); static int zephir_read_class_property(zval **result, int type, const char *property, int len TSRMLS_DC); zval* zephir_fetch_static_property_ce(zend_class_entry *ce, const char *property, int len TSRMLS_DC); static int zephir_update_static_property_array_multi_ce(zend_class_entry *ce, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...); /** Create instances */ static int zephir_create_instance(zval *return_value, const zval *class_name TSRMLS_DC); static int zephir_create_instance_params(zval *return_value, const zval *class_name, zval *params TSRMLS_DC); /** Create closures */ static int zephir_create_closure_ex(zval *return_value, zval *this_ptr, zend_class_entry *ce, const char *method_name, zend_uint method_length TSRMLS_DC); ZEPHIR_ATTR_NONNULL static inline int zephir_read_property_this_quick(zval **result, zval *object, const char *property_name, zend_uint property_length, ulong key, int silent TSRMLS_DC) { zval *tmp = zephir_fetch_property_this_quick(object, property_name, property_length, key, silent TSRMLS_CC); if (EXPECTED(tmp != NULL)) { *result = tmp; Z_ADDREF_PP(result); return SUCCESS; } ALLOC_INIT_ZVAL(*result); return FAILURE; } ZEPHIR_ATTR_NONNULL static inline int zephir_read_property_this(zval **result, zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC) { #ifdef __GNUC__ if (__builtin_constant_p(property_name) && __builtin_constant_p(property_length)) { return zephir_read_property_this_quick(result, object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } #endif return zephir_read_property_this_quick(result, object, property_name, property_length, zend_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } ZEPHIR_ATTR_NONNULL static inline zval* zephir_fetch_nproperty_this_quick(zval *object, const char *property_name, zend_uint property_length, ulong key, int silent TSRMLS_DC) { #ifdef __GNUC__ if (__builtin_constant_p(property_name) && __builtin_constant_p(property_length)) { zval *result = zephir_fetch_property_this_quick(object, property_name, property_length, key, silent TSRMLS_CC); return result ? result : EG(uninitialized_zval_ptr); } #endif zval *result = zephir_fetch_property_this_quick(object, property_name, property_length, key, silent TSRMLS_CC); return result ? result : EG(uninitialized_zval_ptr); } ZEPHIR_ATTR_NONNULL static inline zval* zephir_fetch_nproperty_this(zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC) { #ifdef __GNUC__ if (__builtin_constant_p(property_name) && __builtin_constant_p(property_length)) { return zephir_fetch_nproperty_this_quick(object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } #endif return zephir_fetch_nproperty_this_quick(object, property_name, property_length, zend_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } ZEPHIR_ATTR_NONNULL static inline zval* zephir_fetch_property_this(zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC) { #ifdef __GNUC__ if (__builtin_constant_p(property_name) && __builtin_constant_p(property_length)) { return zephir_fetch_property_this_quick(object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } #endif return zephir_fetch_property_this_quick(object, property_name, property_length, zend_hash_func(property_name, property_length + 1), silent TSRMLS_CC); } #endif #define zephir_fetch_safe_class(destination, var) \ { \ if (Z_TYPE_P(var) == IS_STRING) { \ ZEPHIR_CPY_WRT(destination, var); \ } else { \ ZEPHIR_INIT_NVAR(destination); \ ZVAL_STRING(destination, "<undefined class>", 1); \ } \ } #ifndef ZEPHIR_KERNEL_ARRAY_H #define ZEPHIR_KERNEL_ARRAY_H #define ZEPHIR_MAX_ARRAY_LEVELS 16 #include <php.h> #include <Zend/zend.h> /** Combined isset/fetch */ static int zephir_array_isset_fetch(zval **fetched, const zval *arr, zval *index, int readonly TSRMLS_DC); static int zephir_array_isset_quick_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, unsigned long key, int readonly TSRMLS_DC); static int zephir_array_isset_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, int readonly TSRMLS_DC); static int zephir_array_isset_long_fetch(zval **fetched, zval *arr, unsigned long index, int readonly TSRMLS_DC); /** Check for index existence */ static int ZEPHIR_FASTCALL zephir_array_isset(const zval *arr, zval *index); static int ZEPHIR_FASTCALL zephir_array_isset_long(const zval *arr, unsigned long index); static int ZEPHIR_FASTCALL zephir_array_isset_string(const zval *arr, const char *index, uint index_length); /** Fast index existence checking */ static int ZEPHIR_FASTCALL zephir_array_isset_quick_string(const zval *arr, const char *index, uint index_length, unsigned long key); /** Unset existing indexes */ static int ZEPHIR_FASTCALL zephir_array_unset(zval **arr, zval *index, int flags); static int ZEPHIR_FASTCALL zephir_array_unset_long(zval **arr, unsigned long index, int flags); static int ZEPHIR_FASTCALL zephir_array_unset_string(zval **arr, const char *index, uint index_length, int flags); /** Append elements to arrays */ static int zephir_array_append(zval **arr, zval *value, int separate ZEPHIR_DEBUG_PARAMS); static int zephir_array_append_long(zval **arr, long value, int separate); static int zephir_array_append_string(zval **arr, char *value, uint value_length, int separate); /** Modify arrays */ static int zephir_array_update_zval(zval **arr, zval *index, zval **value, int flags); static int zephir_array_update_string(zval **arr, const char *index, uint index_length, zval **value, int flags); static int zephir_array_update_long(zval **arr, unsigned long index, zval **value, int flags ZEPHIR_DEBUG_PARAMS); /** Fetch items from arrays */ static int zephir_array_fetch(zval **return_value, zval *arr, zval *index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); static int zephir_array_fetch_string(zval **return_value, zval *arr, const char *index, uint index_length, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); static int zephir_array_fetch_long(zval **return_value, zval *arr, unsigned long index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC); /** Merge+Append */ static void zephir_merge_append(zval *left, zval *values); /* Traversing Arays */ static void zephir_array_get_current(zval *return_value, zval *array); static void zephir_array_next(zval *array); /* In Array */ static int zephir_fast_in_array(zval *needle, zval *haystack TSRMLS_DC); /** Fast Array Merge */ static void zephir_fast_array_merge(zval *return_value, zval **array1, zval **array2 TSRMLS_DC); /** Recursive merge */ static void zephir_array_merge_recursive_n(zval **a1, zval *a2 TSRMLS_DC); static void zephir_array_unshift(zval *arr, zval *arg TSRMLS_DC); static void zephir_array_keys(zval *return_value, zval *arr TSRMLS_DC); static void zephir_array_values(zval *return_value, zval *arr); static int zephir_array_key_exists(zval *arr, zval *key TSRMLS_DC); static int zephir_array_is_associative(zval *arr); static void zephir_array_update_multi_ex(zval **arr, zval **value, const char *types, int types_length, int types_count, va_list ap TSRMLS_DC); static int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...); static void ZEPHIR_FASTCALL zephir_create_array(zval *return_value, uint size, int initialize TSRMLS_DC); #define zephir_array_fast_append(arr, value) \ Z_ADDREF_P(value); \ zend_hash_next_index_insert(Z_ARRVAL_P(arr), &value, sizeof(zval *), NULL); #endif /* ZEPHIR_KERNEL_ARRAY_H */ #ifndef ZEPHIR_KERNEL_FCALL_EXT_H #define ZEPHIR_KERNEL_FCALL_EXT_H #define ZEPHIR_FCALL_TYPE_UNKNOWN 0 #define ZEPHIR_FCALL_TYPE_FUNC 1 #define ZEPHIR_FCALL_TYPE_ZVAL_METHOD 2 #define ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD 3 #define ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD 4 #define ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD 5 #define ZEPHIR_FCALL_TYPE_CE_METHOD 6 typedef struct _zephir_fcall_info { int type; zend_class_entry *ce; zval *object_ptr; const char *class_name; int class_length; const char *func_name; int func_length; } zephir_fcall_info; static int zephir_call_function_opt(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zephir_fcall_info *info TSRMLS_DC); static int zephir_call_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC); #endif #ifndef ZEPHIR_KERNEL_STRING_H #define ZEPHIR_KERNEL_STRING_H #include <php.h> #include <Zend/zend.h> #define ZEPHIR_TRIM_LEFT 1 #define ZEPHIR_TRIM_RIGHT 2 #define ZEPHIR_TRIM_BOTH 3 #define ZEPHIR_SUBSTR_NO_LENGTH 1 /** Fast char position */ static int zephir_memnstr(const zval *haystack, const zval *needle ZEPHIR_DEBUG_PARAMS); static int zephir_memnstr_str(const zval *haystack, char *needle, unsigned int needle_length ZEPHIR_DEBUG_PARAMS); /** Function replacement */ static void zephir_fast_strlen(zval *return_value, zval *str); static int zephir_fast_strlen_ev(zval *str); static void zephir_fast_strtolower(zval *return_value, zval *str); static void zephir_strtolower_inplace(zval *s); static void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC); static void zephir_fast_join_str(zval *result, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC); static void zephir_fast_explode(zval *result, zval *delimiter, zval *str, long limit TSRMLS_DC); static void zephir_fast_explode_str(zval *result, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC); static void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset); static void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length); static void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length); static void zephir_fast_str_replace(zval **return_value, zval *search, zval *replace, zval *subject TSRMLS_DC); static void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC); static void zephir_fast_strip_tags(zval *return_value, zval *str); static void zephir_fast_strtoupper(zval *return_value, zval *str); /** Camelize/Uncamelize */ static void zephir_camelize(zval *return_value, const zval *str); static void zephir_uncamelize(zval *return_value, const zval *str); /** Starts/Ends with */ static int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive); static int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length); static int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length); static int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive); static int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length); /** Random string */ static void zephir_random_string(zval *return_value, const zval *type, const zval *length TSRMLS_DC); /* Strips extra slashes */ static void zephir_remove_extra_slashes(zval *return_value, const zval *str); /** Generates a unique key for an array/object */ static void zephir_unique_key(zval *return_value, zval *prefix, zval *value TSRMLS_DC); /** spprintf */ static int zephir_spprintf(char **message, int max_len, char *format, ...); /* Substr */ static void zephir_substr(zval *return_value, zval *str, long from, long length, int flags); /** EOL */ zval *zephir_eol(int eol TSRMLS_DC); /** Preg-Match */ static void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC); /** Base64 */ static void zephir_base64_encode(zval *return_value, zval *data); static void zephir_base64_decode(zval *return_value, zval *data); /** Hash */ static void zephir_md5(zval *return_value, zval *str); static void zephir_crc32(zval *return_value, zval *str TSRMLS_DC); /** JSON */ static int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC); static int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC); /***/ static void zephir_lcfirst(zval *return_value, zval *s); static void zephir_ucfirst(zval *return_value, zval *s); static int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC); static void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC); static void zephir_htmlentities(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC); static void zephir_strval(zval *return_value, zval *v); static void zephir_date(zval *return_value, zval *format, zval *timestamp TSRMLS_DC); static void zephir_addslashes(zval *return_value, zval *str TSRMLS_DC); static void zephir_stripslashes(zval *return_value, zval *str TSRMLS_DC); static void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC); #if PHP_VERSION_ID < 50400 const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC); #define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) ZVAL_STRING(pz, string, 1); #else #define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) \ do { \ if (IS_INTERNED(string)) { \ ZVAL_STRINGL(pz, string, INTERNED_LEN(string)-1, 0); \ } \ else { \ ZVAL_STRING(pz, string, 1); \ } \ } while (0) #endif /* PHP_VERSION_ID < 50400 */ #endif /* ZEPHIR_KERNEL_STRING_H */ #ifndef ZEPHIR_KERNEL_FCALL_H #define ZEPHIR_KERNEL_FCALL_H #include <Zend/zend_hash.h> #include <Zend/zend.h> typedef enum _zephir_call_type { zephir_fcall_parent, zephir_fcall_self, zephir_fcall_static, zephir_fcall_ce, zephir_fcall_method, zephir_fcall_function } zephir_call_type; #if defined(_MSC_VER) #define ZEPHIR_PASS_CALL_PARAMS(x) x + 1 #define ZEPHIR_CALL_NUM_PARAMS(x) ((sizeof(x) - sizeof(x[0]))/sizeof(x[0])) #define ZEPHIR_FETCH_VA_ARGS NULL, #else #define ZEPHIR_PASS_CALL_PARAMS(x) x #define ZEPHIR_CALL_NUM_PARAMS(x) sizeof(x)/sizeof(zval*) #define ZEPHIR_FETCH_VA_ARGS #endif #define ZEPHIR_CALL_FUNCTIONW(return_value_ptr, func_name, cache, cache_slot, ...) \ do { \ zephir_fcall_cache_entry **cache_entry_ = cache; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(func_name)) { \ if (cache_entry_ && *cache_entry_) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams_fast(return_value_ptr, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #if PHP_VERSION_ID >= 50600 #define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \ do { \ zephir_fcall_cache_entry **cache_entry_ = cache; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(func_name)) { \ if (cache_entry_ && *cache_entry_) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams_fast(return_value_ptr, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #else #define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(func_name)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #endif #define ZEPHIR_RETURN_CALL_FUNCTIONW(func_name, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(func_name)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_FUNCTION(func_name, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(func_name)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_ZVAL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ ZEPHIR_LAST_CALL_STATUS = zephir_call_zval_func_aparams(return_value_ptr, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } while (0) #define ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(func_name, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_zval_function(return_value, return_value_ptr, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } while (0) /* Saves the if pointer, and called/calling scope */ #define ZEPHIR_BACKUP_THIS_PTR() \ zval *old_this_ptr = this_ptr; #define ZEPHIR_RESTORE_THIS_PTR() ZEPHIR_SET_THIS(old_this_ptr) #define ZEPHIR_SET_THIS(pzv) EG(This) = pzv; #define ZEPHIR_BACKUP_SCOPE() \ zend_class_entry *old_scope = EG(scope); \ zend_class_entry *old_called_scope = EG(called_scope); #define ZEPHIR_RESTORE_SCOPE() \ EG(called_scope) = old_called_scope; \ EG(scope) = old_scope; \ #define ZEPHIR_SET_SCOPE(_scope, _scope_called) \ EG(scope) = _scope; \ EG(called_scope) = _scope_called; \ /* End internal calls */ #define ZEPHIR_CALL_METHODW(return_value_ptr, object, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_METHOD(return_value_ptr, object, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_METHODW(object, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_METHOD(object, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_METHOD_ZVAL(return_value_ptr, object, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) #define ZEPHIR_RETURN_CALL_METHODW_ZVAL(object, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) #define ZEPHIR_RETURN_CALL_METHOD_ZVAL(object, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) #define ZEPHIR_CALL_METHOD_THIS(return_value_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_PARENTW(return_value_ptr, class_entry, this_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_PARENT(return_value_ptr, class_entry, this_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_PARENTW(class_entry, this_ptr, method, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_PARENT(class_entry, this_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_SELFW(return_value_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, cache_slot, sizeof(method)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, cache_slot, strlen(method), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_SELFW(method, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_STATICW(return_value_ptr, method, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_STATICW(method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \ } \ else { \ RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_CE_STATICW(return_value_ptr, class_entry, method, cache, cache_slot, ...) \ do { \ zval *params[] = {__VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_CE_STATIC(return_value_ptr, class_entry, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_CE_STATICW(class_entry, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_RETURN_CALL_CE_STATIC(class_entry, method, cache, cache_slot, ...) \ do { \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (__builtin_constant_p(method)) { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ else { \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ } \ } while (0) #define ZEPHIR_CALL_CE_STATIC_ZVAL(return_value_ptr, class_entry, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) #define ZEPHIR_RETURN_CALL_CE_STATICW_ZVAL(class_entry, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) #define ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(class_entry, method, cache, cache_slot, ...) \ do { \ char *method_name; \ int method_len; \ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \ if (Z_TYPE_P(method) == IS_STRING) { \ method_len = Z_STRLEN_P(method); \ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \ } else { \ method_len = 0; \ method_name = zend_str_tolower_dup("", 0); \ } \ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \ efree(method_name); \ } while (0) /** Use these functions to call functions in the PHP userland using an arbitrary zval as callable */ #define ZEPHIR_CALL_USER_FUNC(return_value, handler) ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, handler, NULL) #define ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, handler, params) \ do { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_user_func_array(return_value, handler, params TSRMLS_CC); \ } while (0) #define ZEPHIR_CALL_USER_FUNC_ARRAY_NOEX(return_value, handler, params) \ do { \ ZEPHIR_LAST_CALL_STATUS = zephir_call_user_func_array_noex(return_value, handler, params TSRMLS_CC); \ } while (0) static int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uint func_length, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC); static int zephir_call_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC); static int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT; ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_function(zval *return_value, zval **return_value_ptr, const char *func, uint func_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; int status; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); *return_value_ptr = NULL; } status = zephir_call_func_aparams(rvp, func, func_len, cache_entry, cache_slot, param_count, params TSRMLS_CC); if (status == FAILURE) { if (return_value_ptr && EG(exception)) { ALLOC_INIT_ZVAL(*return_value_ptr); } return FAILURE; } if (!return_value_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, rv); } return SUCCESS; } ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_zval_function(zval *return_value, zval **return_value_ptr, zval *func, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; int status; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); *return_value_ptr = NULL; } status = zephir_call_zval_func_aparams(rvp, func, cache_entry, cache_slot, param_count, params TSRMLS_CC); if (status == FAILURE) { if (return_value_ptr && EG(exception)) { ALLOC_INIT_ZVAL(*return_value_ptr); } return FAILURE; } if (!return_value_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, rv); } return SUCCESS; } static int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object, const char *method_name, uint method_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT; ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_class_method(zval *return_value, zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object, const char *method_name, uint method_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; int status; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); *return_value_ptr = NULL; } status = zephir_call_class_method_aparams(rvp, ce, type, object, method_name, method_len, cache_entry, cache_slot, param_count, params TSRMLS_CC); if (status == FAILURE) { if (return_value_ptr && EG(exception)) { ALLOC_INIT_ZVAL(*return_value_ptr); } return FAILURE; } if (!return_value_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, rv); } return SUCCESS; } //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL2(2, 3) //static inline int zephir_call_method(zval **return_value_ptr, zval *object, const char *method, // zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_call_class_method_aparams(return_value_ptr, Z_OBJCE_P(object), zephir_fcall_method, // object, method, strlen(method), cache_entry, nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL3(1, 3, 4) //static inline int zephir_return_call_method(zval *return_value, zval **return_value_ptr, zval *object, const char *method, // zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_return_call_class_method(return_value, return_value_ptr, Z_OBJCE_P(object), zephir_fcall_method, object, method, strlen(method), nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL1(2) //static inline int zephir_call_static(zval **return_value_ptr, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL2(1, 3) //static inline int zephir_return_call_static(zval *return_value, zval **return_value_ptr, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache_entry, nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL1(2) //static inline int zephir_call_self(zval **return_value_ptr, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache_entry, nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL2(1, 3) //static inline int zephir_return_call_self(zval *return_value, zval **return_value_ptr, const char *method, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL1(3) //static inline int zephir_call_parent(zval **return_value_ptr, zval *object, const char *method, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_call_class_method_aparams(return_value_ptr, (object ? Z_OBJCE_P(object) : NULL), zephir_fcall_parent, object, method, strlen(method), nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL2(1, 4) //static inline int zephir_return_call_parent(zval *return_value, zval **return_value_ptr, zval *object, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_return_call_class_method(return_value, return_value_ptr, (object ? Z_OBJCE_P(object) : NULL), zephir_fcall_parent, object, method, strlen(method), cache_entry, nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL2(2, 3) //static inline int zephir_call_ce(zval **return_value_ptr, zend_class_entry *ce, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_call_class_method_aparams(return_value_ptr, ce, zephir_fcall_ce, NULL, method, strlen(method), cache_entry, nparams, params TSRMLS_CC); //} //ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL3(1, 3, 4) //static inline int zephir_return_call_ce(zval *return_value, zval **return_value_ptr, zend_class_entry *ce, const char *method, zephir_fcall_cache_entry **cache_entry, uint nparams, zval **params TSRMLS_DC) //{ //return zephir_return_call_class_method(return_value, return_value_ptr, ce, zephir_fcall_ce, NULL, method, strlen(method), nparams, params TSRMLS_CC); //} /** Fast call_user_func_array/call_user_func */ static int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT; ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_call_user_func_array(zval *return_value, zval *handler, zval *params TSRMLS_DC) { int status = zephir_call_user_func_array_noex(return_value, handler, params TSRMLS_CC); return (EG(exception)) ? FAILURE : status; } static int zephir_has_constructor_ce(const zend_class_entry *ce) ZEPHIR_ATTR_PURE ZEPHIR_ATTR_NONNULL; ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL static inline int zephir_has_constructor(const zval *object TSRMLS_DC) { return Z_TYPE_P(object) == IS_OBJECT ? zephir_has_constructor_ce(Z_OBJCE_P(object)) : 0; } /** PHP < 5.3.9 has problems with closures */ #if PHP_VERSION_ID <= 50309 static int zephir_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC); #define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zephir_call_function #else #if PHP_VERSION_ID >= 50600 #define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zephir_call_function_opt #else #define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zend_call_function #endif #endif #ifndef zend_error_noreturn #define zend_error_noreturn zend_error #endif #define zephir_check_call_status() \ do \ if (ZEPHIR_LAST_CALL_STATUS == FAILURE) { \ ZEPHIR_MM_RESTORE(); \ return; \ } \ while(0) #define zephir_check_call_status_or_jump(label) \ if (ZEPHIR_LAST_CALL_STATUS == FAILURE) { \ if (EG(exception)) { \ goto label; \ } else { \ ZEPHIR_MM_RESTORE(); \ return; \ } \ } #ifdef ZEPHIR_RELEASE #define ZEPHIR_TEMP_PARAM_COPY 0 #define zephir_check_temp_parameter(param) do { if (Z_REFCOUNT_P(param) > 1) zval_copy_ctor(param); else ZVAL_NULL(param); } while(0) #else #define ZEPHIR_TEMP_PARAM_COPY 1 #define zephir_check_temp_parameter(param) #endif static void zephir_eval_php(zval *str, zval *retval_ptr, char *context TSRMLS_DC); #endif /* ZEPHIR_KERNEL_FCALL_H */ #ifndef ZEPHIR_KERNEL_REQUIRE_H #define ZEPHIR_KERNEL_REQUIRE_H static int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_DC) ZEPHIR_ATTR_NONNULL1(2); ZEPHIR_ATTR_NONNULL static inline int zephir_require(const char *require_path TSRMLS_DC) { return zephir_require_ret(NULL, require_path TSRMLS_CC); } ZEPHIR_ATTR_NONNULL static inline int zephir_require_zval(const zval *require_path TSRMLS_DC) { return zephir_require_ret(NULL, Z_TYPE_P(require_path) == IS_STRING ? Z_STRVAL_P(require_path) : "" TSRMLS_CC); } ZEPHIR_ATTR_NONNULL static inline int zephir_require_zval_ret(zval **return_value_ptr, const zval *require_path TSRMLS_DC) { return zephir_require_ret(return_value_ptr, Z_TYPE_P(require_path) == IS_STRING ? Z_STRVAL_P(require_path) : "" TSRMLS_CC); } #endif /* ZEPHIR_KERNEL_REQUIRE_H */ #ifndef ZEPHIR_KERNEL_FILE_H #define ZEPHIR_KERNEL_FILE_H #include <php.h> static int zephir_file_exists(zval *filename TSRMLS_DC); static int zephir_compare_mtime(zval *filename1, zval *filename2 TSRMLS_DC); static void zephir_fix_path(zval **return_value, zval *path, zval *directory_separator TSRMLS_DC); static void zephir_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_separator TSRMLS_DC); static void zephir_unique_path_key(zval *return_value, zval *path TSRMLS_DC); static void zephir_realpath(zval *return_value, zval *filename TSRMLS_DC); static void zephir_file_get_contents(zval *return_value, zval *filename TSRMLS_DC); static void zephir_file_put_contents(zval *return_value, zval *filename, zval *data TSRMLS_DC); static void zephir_possible_autoload_filepath(zval *return_value, zval *prefix, zval *class_name, zval *virtual_separator, zval *separator TSRMLS_DC); static void zephir_is_dir(zval *return_value, zval *path TSRMLS_DC); static void zephir_unlink(zval *return_value, zval *path TSRMLS_DC); static void zephir_filemtime(zval *return_value, zval *path TSRMLS_DC); static void zephir_basename(zval *return_value, zval *path TSRMLS_DC); static void zephir_fwrite(zval *return_value, zval *stream_zval, zval *data TSRMLS_DC); static int zephir_feof(zval *stream_zval TSRMLS_DC); static int zephir_fclose(zval *stream_zval TSRMLS_DC); #ifdef TSRM_WIN32 #define ZEPHIR_DIRECTORY_SEPARATOR "\\" #else #define ZEPHIR_DIRECTORY_SEPARATOR "/" #endif #endif /* ZEPHIR_KERNEL_FILE_H */ #ifndef ZEPHIR_KERNEL_OPERATORS_H #define ZEPHIR_KERNEL_OPERATORS_H #include <php.h> #include <Zend/zend.h> /** Strict comparing */ #define ZEPHIR_IS_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) == op2) || zephir_compare_strict_long(op1, op2 TSRMLS_CC)) #define ZEPHIR_IS_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) == op2) || zephir_compare_strict_double(op1, op2 TSRMLS_CC)) #define ZEPHIR_IS_STRING(op1, op2) zephir_compare_strict_string(op1, op2, strlen(op2)) #define ZEPHIR_IS_LONG_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) == op2) #define ZEPHIR_IS_DOUBLE_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) == op2) #define ZEPHIR_IS_STRING_IDENTICAL(op1, op2) (Z_TYPE_P(op1) == IS_STRING && zephir_compare_strict_string(op1, op2, strlen(op2))) /** strict boolean comparison */ #define ZEPHIR_IS_FALSE(var) ((Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var)) || zephir_compare_strict_bool(var, 0 TSRMLS_CC)) #define ZEPHIR_IS_TRUE(var) ((Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var)) || zephir_compare_strict_bool(var, 1 TSRMLS_CC)) #define ZEPHIR_IS_FALSE_IDENTICAL(var) (Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var)) #define ZEPHIR_IS_TRUE_IDENTICAL(var) (Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var)) #define ZEPHIR_IS_NOT_FALSE(var) (Z_TYPE_P(var) != IS_BOOL || (Z_TYPE_P(var) == IS_BOOL && Z_BVAL_P(var))) #define ZEPHIR_IS_NOT_TRUE(var) (Z_TYPE_P(var) != IS_BOOL || (Z_TYPE_P(var) == IS_BOOL && !Z_BVAL_P(var))) #define ZEPHIR_IS_BOOL(op1, op2) ((Z_TYPE_P(op1) == IS_BOOL && Z_BVAL_P(op1) == op2) || zephir_compare_strict_bool(op1, op2 TSRMLS_CC)) /** SQL null empty **/ #define ZEPHIR_IS_EMPTY(var) (Z_TYPE_P(var) == IS_NULL || ZEPHIR_IS_FALSE(var) || (Z_TYPE_P(var) == IS_STRING && !Z_STRLEN_P(var)) || !zend_is_true(var)) #define ZEPHIR_IS_NOT_EMPTY(var) (!ZEPHIR_IS_EMPTY(var)) /** Is scalar */ #define ZEPHIR_IS_SCALAR(var) (!ZEPHIR_IS_NOT_SCALAR(var)) #define ZEPHIR_IS_NOT_SCALAR(var) (Z_TYPE_P(var) == IS_NULL || Z_TYPE_P(var) == IS_ARRAY || Z_TYPE_P(var) == IS_OBJECT || Z_TYPE_P(var) == IS_RESOURCE) /** Equals/Identical */ #define ZEPHIR_IS_EQUAL(op1, op2) zephir_is_equal(op1, op2 TSRMLS_CC) #define ZEPHIR_IS_IDENTICAL(op1, op2) zephir_is_identical(op1, op2 TSRMLS_CC) /** Greater/Smaller equals */ #define ZEPHIR_LE(op1, op2) zephir_less_equal(op1, op2 TSRMLS_CC) #define ZEPHIR_LE_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) <= op2) || zephir_less_equal_long(op1, op2 TSRMLS_CC)) #define ZEPHIR_LE_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) <= op2) || zephir_less_equal_double(op1, op2 TSRMLS_CC)) #define ZEPHIR_GE(op1, op2) zephir_greater_equal(op1, op2 TSRMLS_CC) #define ZEPHIR_GE_LONG(op1, op2) zephir_greater_equal_long(op1, op2 TSRMLS_CC) #define ZEPHIR_LT(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_TYPE_P(op2) == IS_LONG) ? Z_LVAL_P(op1) < Z_LVAL_P(op2) : zephir_less(op1, op2 TSRMLS_CC)) #define ZEPHIR_LT_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) < op2) || zephir_less_long(op1, op2 TSRMLS_CC)) #define ZEPHIR_LT_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) < op2) || zephir_less_double(op1, op2 TSRMLS_CC)) #define ZEPHIR_GT(op1, op2) zephir_greater(op1, op2 TSRMLS_CC) #define ZEPHIR_GT_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) > op2) || zephir_greater_long(op1, op2 TSRMLS_CC)) #define ZEPHIR_GT_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) > op2) || zephir_greater_double(op1, op2 TSRMLS_CC)) #define ZEPHIR_STRING_OFFSET(op1, index) ((index >= 0 && index < Z_STRLEN_P(op1)) ? Z_STRVAL_P(op1)[index] : '\0') #if PHP_VERSION_ID < 50400 #define zephir_increment(var) increment_function(var) #else #define zephir_increment(var) fast_increment_function(var) #endif #if PHP_VERSION_ID < 50400 #define zephir_decrement(var) decrement_function(var) #else #define zephir_decrement(var) fast_decrement_function(var) #endif static void zephir_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy); #define zephir_add_function(result, left, right) zephir_add_function_ex(result, left, right TSRMLS_CC) #if PHP_VERSION_ID < 50400 #define zephir_sub_function(result, left, right) sub_function(result, left, right TSRMLS_CC) #else #define zephir_sub_function(result, left, right) fast_sub_function(result, left, right TSRMLS_CC) #endif #if PHP_VERSION_ID < 50600 static void zephir_pow_function_ex(zval *return_value, zval *zbase, zval *zexp TSRMLS_DC); #define zephir_pow_function(result, op1, op2) zephir_pow_function_ex(result, op1, op2 TSRMLS_CC) #else #define zephir_pow_function(result, op1, op2) pow_function(result, op1, op2 TSRMLS_CC) #endif /** Operator functions */ static int zephir_add_function_ex(zval *result, zval *op1, zval *op2 TSRMLS_DC); static int zephir_and_function(zval *result, zval *left, zval *right); static void zephir_negate(zval *z TSRMLS_DC); /** Bitwise functions */ static int zephir_bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); static int zephir_bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); static int zephir_bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); static int zephir_shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); static int zephir_shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); static void zephir_concat_self(zval **left, zval *right TSRMLS_DC); static void zephir_concat_self_str(zval **left, const char *right, int right_length TSRMLS_DC); static void zephir_concat_self_long(zval **left, const long right TSRMLS_DC); static void zephir_concat_self_char(zval **left, unsigned char right TSRMLS_DC); /** Strict comparing */ static int zephir_compare_strict_string(zval *op1, const char *op2, int op2_length); static int zephir_compare_strict_long(zval *op1, long op2 TSRMLS_DC); static int zephir_compare_strict_double(zval *op1, double op2 TSRMLS_DC); static int zephir_compare_strict_bool(zval *op1, zend_bool op2 TSRMLS_DC); static void zephir_cast(zval *result, zval *var, zend_uint type); static void zephir_convert_to_object(zval *op); long zephir_get_intval_ex(const zval *op); double zephir_get_doubleval_ex(const zval *op); zend_bool zephir_get_boolval_ex(const zval *op); static int zephir_is_numeric_ex(const zval *op); static int zephir_is_equal(zval *op1, zval *op2 TSRMLS_DC); static int zephir_is_identical(zval *op1, zval *op2 TSRMLS_DC); static int zephir_less(zval *op1, zval *op2 TSRMLS_DC); static int zephir_less_long(zval *op1, long op2 TSRMLS_DC); static int zephir_less_double(zval *op1, double op2 TSRMLS_DC); static int zephir_greater(zval *op1, zval *op2 TSRMLS_DC); static int zephir_greater_long(zval *op1, long op2 TSRMLS_DC); static int zephir_greater_double(zval *op1, double op2 TSRMLS_DC); static int zephir_less_equal(zval *op1, zval *op2 TSRMLS_DC); static int zephir_less_equal_long(zval *op1, long op2 TSRMLS_DC); static int zephir_greater_equal(zval *op1, zval *op2 TSRMLS_DC); static int zephir_greater_equal_long(zval *op1, long op2 TSRMLS_DC); double zephir_safe_div_long_long(long op1, long op2 TSRMLS_DC); double zephir_safe_div_long_double(long op1, double op2 TSRMLS_DC); double zephir_safe_div_double_long(double op1, long op2 TSRMLS_DC); double zephir_safe_div_double_double(double op1, double op2 TSRMLS_DC); double zephir_safe_div_zval_long(zval *op1, long op2 TSRMLS_DC); double zephir_safe_div_zval_double(zval *op1, double op2 TSRMLS_DC); double zephir_safe_div_long_zval(long op1, zval *op2 TSRMLS_DC); double zephir_safe_div_double_zval(double op1, zval *op2 TSRMLS_DC); long zephir_safe_mod_long_long(long op1, long op2 TSRMLS_DC); long zephir_safe_mod_long_double(long op1, double op2 TSRMLS_DC); long zephir_safe_mod_double_long(double op1, long op2 TSRMLS_DC); long zephir_safe_mod_double_double(double op1, double op2 TSRMLS_DC); long zephir_safe_mod_zval_long(zval *op1, long op2 TSRMLS_DC); long zephir_safe_mod_zval_double(zval *op1, double op2 TSRMLS_DC); long zephir_safe_mod_long_zval(long op1, zval *op2 TSRMLS_DC); long zephir_safe_mod_double_zval(double op1, zval *op2 TSRMLS_DC); #define zephir_get_numberval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_doubleval(z)) #define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z)) #define zephir_get_doubleval(z) (Z_TYPE_P(z) == IS_DOUBLE ? Z_DVAL_P(z) : zephir_get_doubleval_ex(z)) #define zephir_get_boolval(z) (Z_TYPE_P(z) == IS_BOOL ? Z_BVAL_P(z) : zephir_get_boolval_ex(z)) #ifndef PHP_WIN32 #define ZEPHIR_ADD_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ Z_LVAL_P(z) += Z_LVAL_P(v); \ } else { \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ Z_LVAL_P(z) += Z_DVAL_P(v); \ } else { \ add_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } \ } \ } #define ZEPHIR_SUB_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ Z_LVAL_P(z) -= Z_LVAL_P(v); \ } else { \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ Z_LVAL_P(z) -= Z_DVAL_P(v); \ } else { \ sub_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } \ } \ } #define ZEPHIR_MUL_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_LONG) { \ Z_LVAL_P(z) *= Z_LVAL_P(v); \ } else { \ if (Z_TYPE_P(z) == IS_LONG && Z_TYPE_P(v) == IS_DOUBLE) { \ Z_LVAL_P(z) *= Z_DVAL_P(v); \ } else { \ mul_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } \ } \ } #else #define ZEPHIR_ADD_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ add_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } #define ZEPHIR_SUB_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ sub_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } #define ZEPHIR_MUL_ASSIGN(z, v) \ { \ zval tmp; \ ZEPHIR_SEPARATE(z); \ mul_function(&tmp, z, v TSRMLS_CC); \ if (Z_TYPE(tmp) == IS_LONG) { \ Z_LVAL_P(z) = Z_LVAL(tmp); \ } else { \ if (Z_TYPE(tmp) == IS_DOUBLE) { \ Z_DVAL_P(z) = Z_DVAL(tmp); \ } \ } \ } #endif #define zephir_get_strval(left, right) \ { \ int use_copy_right; \ zval right_tmp; \ if (Z_TYPE_P(right) == IS_STRING) { \ ZEPHIR_CPY_WRT(left, right); \ } else { \ INIT_ZVAL(right_tmp); \ zephir_make_printable_zval(right, &right_tmp, &use_copy_right); \ if (use_copy_right) { \ ZEPHIR_INIT_NVAR(left); \ ZVAL_STRINGL(left, Z_STRVAL_P(&right_tmp), Z_STRLEN_P(&right_tmp), 0); \ } \ } \ } #define zephir_get_arrval(returnValue, passValue) \ { \ if (Z_TYPE_P(passValue) == IS_ARRAY) { \ ZEPHIR_CPY_WRT(returnValue, passValue); \ } else { \ ZEPHIR_INIT_NVAR(returnValue); \ array_init_size(returnValue, 0); \ } \ } #define zephir_is_numeric(value) (Z_TYPE_P(value) == IS_LONG || Z_TYPE_P(value) == IS_DOUBLE || zephir_is_numeric_ex(value)) #define zephir_is_true(value) \ (Z_TYPE_P(value) == IS_NULL ? 0 : \ (Z_TYPE_P(value) == IS_BOOL ? Z_BVAL_P(value) : \ (Z_TYPE_P(value) == IS_LONG ? (Z_LVAL_P(value) ? 1 : 0) : \ zend_is_true(value) \ ) \ ) \ ) #endif #ifndef ZEPHIR_KERNEL_CONCAT_H #define ZEPHIR_KERNEL_CONCAT_H #include <php.h> #include <Zend/zend.h> #define ZEPHIR_CONCAT_SV(result, op1, op2) \ zephir_concat_sv(&result, op1, sizeof(op1)-1, op2, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SV(result, op1, op2) \ zephir_concat_sv(&result, op1, sizeof(op1)-1, op2, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVS(result, op1, op2, op3) \ zephir_concat_svs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVS(result, op1, op2, op3) \ zephir_concat_svs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSV(result, op1, op2, op3, op4) \ zephir_concat_svsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSV(result, op1, op2, op3, op4) \ zephir_concat_svsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVS(result, op1, op2, op3, op4, op5) \ zephir_concat_svsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVS(result, op1, op2, op3, op4, op5) \ zephir_concat_svsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10) \ zephir_concat_svsvssvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10) \ zephir_concat_svsvssvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSV(result, op1, op2, op3, op4, op5, op6) \ zephir_concat_svsvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSV(result, op1, op2, op3, op4, op5, op6) \ zephir_concat_svsvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSVS(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_svsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSVS(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_svsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSVSSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11, op12) \ zephir_concat_svsvsvssvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, op11, op12, sizeof(op12)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSVSSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11, op12) \ zephir_concat_svsvsvssvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, op11, op12, sizeof(op12)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSVSV(result, op1, op2, op3, op4, op5, op6, op7, op8) \ zephir_concat_svsvsvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSVSV(result, op1, op2, op3, op4, op5, op6, op7, op8) \ zephir_concat_svsvsvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9) \ zephir_concat_svsvsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, op9, sizeof(op9)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9) \ zephir_concat_svsvsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, op9, sizeof(op9)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11) \ zephir_concat_svsvsvsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, op9, sizeof(op9)-1, op10, op11, sizeof(op11)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVSVSVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11) \ zephir_concat_svsvsvsvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, sizeof(op5)-1, op6, op7, sizeof(op7)-1, op8, op9, sizeof(op9)-1, op10, op11, sizeof(op11)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVV(result, op1, op2, op3, op4, op5) \ zephir_concat_svsvv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVV(result, op1, op2, op3, op4, op5) \ zephir_concat_svsvv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVVSV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_svsvvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, op6, sizeof(op6)-1, op7, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVVSV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_svsvvsv(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, op6, sizeof(op6)-1, op7, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVSVVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8) \ zephir_concat_svsvvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVSVVSVS(result, op1, op2, op3, op4, op5, op6, op7, op8) \ zephir_concat_svsvvsvs(&result, op1, sizeof(op1)-1, op2, op3, sizeof(op3)-1, op4, op5, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVV(result, op1, op2, op3) \ zephir_concat_svv(&result, op1, sizeof(op1)-1, op2, op3, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVV(result, op1, op2, op3) \ zephir_concat_svv(&result, op1, sizeof(op1)-1, op2, op3, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_SVVS(result, op1, op2, op3, op4) \ zephir_concat_svvs(&result, op1, sizeof(op1)-1, op2, op3, op4, sizeof(op4)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_SVVS(result, op1, op2, op3, op4) \ zephir_concat_svvs(&result, op1, sizeof(op1)-1, op2, op3, op4, sizeof(op4)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VS(result, op1, op2) \ zephir_concat_vs(&result, op1, op2, sizeof(op2)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VS(result, op1, op2) \ zephir_concat_vs(&result, op1, op2, sizeof(op2)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSV(result, op1, op2, op3) \ zephir_concat_vsv(&result, op1, op2, sizeof(op2)-1, op3, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSV(result, op1, op2, op3) \ zephir_concat_vsv(&result, op1, op2, sizeof(op2)-1, op3, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSVS(result, op1, op2, op3, op4) \ zephir_concat_vsvs(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSVS(result, op1, op2, op3, op4) \ zephir_concat_vsvs(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSVSV(result, op1, op2, op3, op4, op5) \ zephir_concat_vsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSVSV(result, op1, op2, op3, op4, op5) \ zephir_concat_vsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSVSVS(result, op1, op2, op3, op4, op5, op6) \ zephir_concat_vsvsvs(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSVSVS(result, op1, op2, op3, op4, op5, op6) \ zephir_concat_vsvsvs(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_vsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_vsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VSVV(result, op1, op2, op3, op4) \ zephir_concat_vsvv(&result, op1, op2, sizeof(op2)-1, op3, op4, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VSVV(result, op1, op2, op3, op4) \ zephir_concat_vsvv(&result, op1, op2, sizeof(op2)-1, op3, op4, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VV(result, op1, op2) \ zephir_concat_vv(&result, op1, op2, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VV(result, op1, op2) \ zephir_concat_vv(&result, op1, op2, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVS(result, op1, op2, op3) \ zephir_concat_vvs(&result, op1, op2, op3, sizeof(op3)-1, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVS(result, op1, op2, op3) \ zephir_concat_vvs(&result, op1, op2, op3, sizeof(op3)-1, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVSV(result, op1, op2, op3, op4) \ zephir_concat_vvsv(&result, op1, op2, op3, sizeof(op3)-1, op4, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVSV(result, op1, op2, op3, op4) \ zephir_concat_vvsv(&result, op1, op2, op3, sizeof(op3)-1, op4, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVV(result, op1, op2, op3) \ zephir_concat_vvv(&result, op1, op2, op3, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVV(result, op1, op2, op3) \ zephir_concat_vvv(&result, op1, op2, op3, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVVV(result, op1, op2, op3, op4) \ zephir_concat_vvvv(&result, op1, op2, op3, op4, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVVV(result, op1, op2, op3, op4) \ zephir_concat_vvvv(&result, op1, op2, op3, op4, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVVVSVV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_vvvvsvv(&result, op1, op2, op3, op4, op5, sizeof(op5)-1, op6, op7, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVVVSVV(result, op1, op2, op3, op4, op5, op6, op7) \ zephir_concat_vvvvsvv(&result, op1, op2, op3, op4, op5, sizeof(op5)-1, op6, op7, 1 TSRMLS_CC); #define ZEPHIR_CONCAT_VVVVV(result, op1, op2, op3, op4, op5) \ zephir_concat_vvvvv(&result, op1, op2, op3, op4, op5, 0 TSRMLS_CC); #define ZEPHIR_SCONCAT_VVVVV(result, op1, op2, op3, op4, op5) \ zephir_concat_vvvvv(&result, op1, op2, op3, op4, op5, 1 TSRMLS_CC); static void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC); static void zephir_concat_svs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC); static void zephir_concat_svsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC); static void zephir_concat_svsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, int self_var TSRMLS_DC); static void zephir_concat_svsvssvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, int self_var TSRMLS_DC); static void zephir_concat_svsvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, int self_var TSRMLS_DC); static void zephir_concat_svsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, int self_var TSRMLS_DC); static void zephir_concat_svsvsvssvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, zval *op11, const char *op12, zend_uint op12_len, int self_var TSRMLS_DC); static void zephir_concat_svsvsvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, int self_var TSRMLS_DC); static void zephir_concat_svsvsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, const char *op9, zend_uint op9_len, int self_var TSRMLS_DC); static void zephir_concat_svsvsvsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, const char *op9, zend_uint op9_len, zval *op10, const char *op11, zend_uint op11_len, int self_var TSRMLS_DC); static void zephir_concat_svsvv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, int self_var TSRMLS_DC); static void zephir_concat_svsvvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC); static void zephir_concat_svsvvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, int self_var TSRMLS_DC); static void zephir_concat_svv(zval **result, const char *op1, zend_uint op1_len, zval *op2, zval *op3, int self_var TSRMLS_DC); static void zephir_concat_svvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC); static void zephir_concat_vs(zval **result, zval *op1, const char *op2, zend_uint op2_len, int self_var TSRMLS_DC); static void zephir_concat_vsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, int self_var TSRMLS_DC); static void zephir_concat_vsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC); static void zephir_concat_vsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC); static void zephir_concat_vsvsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, int self_var TSRMLS_DC); static void zephir_concat_vsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC); static void zephir_concat_vsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, int self_var TSRMLS_DC); static void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC); static void zephir_concat_vvs(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC); static void zephir_concat_vvsv(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC); static void zephir_concat_vvv(zval **result, zval *op1, zval *op2, zval *op3, int self_var TSRMLS_DC); static void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC); static void zephir_concat_vvvvsvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, const char *op5, zend_uint op5_len, zval *op6, zval *op7, int self_var TSRMLS_DC); static void zephir_concat_vvvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC); static void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); #endif /* ZEPHIR_KERNEL_CONCAT_H */ #ifndef ZEPHIR_KERNEL_MATH_H #define ZEPHIR_KERNEL_MATH_H #include <php.h> #include <Zend/zend.h> double zephir_sin(zval *op1 TSRMLS_DC); double zephir_asin(zval *op1 TSRMLS_DC); double zephir_tan(zval *op1 TSRMLS_DC); double zephir_cos(zval *op1 TSRMLS_DC); double zephir_acos(zval *op1 TSRMLS_DC); double zephir_sqrt(zval *op1 TSRMLS_DC); double zephir_floor(zval *op1 TSRMLS_DC); double zephir_ceil(zval *op1 TSRMLS_DC); static void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC); static void zephir_pow(zval *return_value, zval *op1, zval *op2 TSRMLS_DC); long zephir_mt_rand(long min, long max TSRMLS_DC); #endif #ifndef ZEPHIR_KERNEL_VARIABLES_H #define ZEPHIR_KERNEL_VARIABLES_H #include <php.h> #include <Zend/zend.h> static void zephir_serialize(zval *return_value, zval **var TSRMLS_DC); static void zephir_unserialize(zval *return_value, zval *var TSRMLS_DC); static void zephir_var_export(zval **var TSRMLS_DC); static void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC); static void zephir_var_dump(zval **var TSRMLS_DC); #endif #ifndef ZEPHIR_KERNEL_FILTER_H #define ZEPHIR_KERNEL_FILTER_H #include <php.h> /** Low level filters */ static void zephir_filter_alphanum(zval *return_value, zval *param); static void zephir_filter_identifier(zval *return_value, zval *param); /** Encoding */ static void zephir_is_basic_charset(zval *return_value, const zval *param); /** Escaping */ static void zephir_escape_css(zval *return_value, zval *param); static void zephir_escape_js(zval *return_value, zval *param); static void zephir_escape_htmlattr(zval *return_value, zval *param); static void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC); #endif #ifndef ZEPHIR_KERNEL_ITERATOR_H #define ZEPHIR_KERNEL_ITERATOR_H #include <php.h> #include <Zend/zend.h> zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC); #endif #ifndef ZEPHIR_KERNEL_TIME_H #define ZEPHIR_KERNEL_TIME_H #include <php.h> #include <Zend/zend.h> #define MICRO_IN_SEC 1000000.00 static void zephir_time(zval *return_value); #ifdef HAVE_GETTIMEOFDAY static void zephir_microtime(zval *return_value, zval *get_as_float TSRMLS_DC); #endif #endif /* ZEPHIR_KERNEL_TIME_H */ #ifndef ZEPHIR_KERNEL_EXIT_H #define ZEPHIR_KERNEL_EXIT_H #include <Zend/zend.h> static void zephir_exit_empty(); static void zephir_exit(zval *ptr); #endif #ifdef HAVE_CONFIG_H #endif zend_class_entry *zephir_register_internal_interface_ex(zend_class_entry *orig_ce, zend_class_entry *parent_ce TSRMLS_DC) { zend_class_entry *ce; ce = zend_register_internal_interface(orig_ce TSRMLS_CC); if (parent_ce) { zend_do_inheritance(ce, parent_ce TSRMLS_CC); } return ce; } static int zephir_init_global(char *global, unsigned int global_length TSRMLS_DC) { #if PHP_VERSION_ID < 50400 zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays)); if (jit_initialization) { return zend_is_auto_global(global, global_length - 1 TSRMLS_CC); } #else if (PG(auto_globals_jit)) { return zend_is_auto_global(global, global_length - 1 TSRMLS_CC); } #endif return SUCCESS; } static int zephir_get_global(zval **arr, const char *global, unsigned int global_length TSRMLS_DC) { zval **gv; zend_bool jit_initialization = PG(auto_globals_jit); if (jit_initialization) { zend_is_auto_global(global, global_length - 1 TSRMLS_CC); } if (&EG(symbol_table)) { if (zend_hash_find(&EG(symbol_table), global, global_length, (void **) &gv) == SUCCESS) { if (Z_TYPE_PP(gv) == IS_ARRAY) { *arr = *gv; if (!*arr) { ZEPHIR_INIT_VAR(*arr); array_init(*arr); } } else { ZEPHIR_INIT_VAR(*arr); array_init(*arr); } return SUCCESS; } } ZEPHIR_INIT_VAR(*arr); array_init(*arr); return SUCCESS; } static void zephir_fast_count(zval *result, zval *value TSRMLS_DC) { if (Z_TYPE_P(value) == IS_ARRAY) { ZVAL_LONG(result, zend_hash_num_elements(Z_ARRVAL_P(value))); return; } if (Z_TYPE_P(value) == IS_OBJECT) { #ifdef HAVE_SPL zval *retval = NULL; #endif if (Z_OBJ_HT_P(value)->count_elements) { ZVAL_LONG(result, 1); if (SUCCESS == Z_OBJ_HT(*value)->count_elements(value, &Z_LVAL_P(result) TSRMLS_CC)) { return; } } #ifdef HAVE_SPL if (Z_OBJ_HT_P(value)->get_class_entry && instanceof_function(Z_OBJCE_P(value), spl_ce_Countable TSRMLS_CC)) { zend_call_method_with_0_params(&value, NULL, NULL, "count", &retval); if (retval) { convert_to_long_ex(&retval); ZVAL_LONG(result, Z_LVAL_P(retval)); zval_ptr_dtor(&retval); } return; } #endif ZVAL_LONG(result, 0); return; } if (Z_TYPE_P(value) == IS_NULL) { ZVAL_LONG(result, 0); return; } ZVAL_LONG(result, 1); } static int zephir_fast_count_ev(zval *value TSRMLS_DC) { long count = 0; if (Z_TYPE_P(value) == IS_ARRAY) { return zend_hash_num_elements(Z_ARRVAL_P(value)) > 0; } if (Z_TYPE_P(value) == IS_OBJECT) { #ifdef HAVE_SPL zval *retval = NULL; #endif if (Z_OBJ_HT_P(value)->count_elements) { Z_OBJ_HT(*value)->count_elements(value, &count TSRMLS_CC); return (int) count > 0; } #ifdef HAVE_SPL if (Z_OBJ_HT_P(value)->get_class_entry && instanceof_function(Z_OBJCE_P(value), spl_ce_Countable TSRMLS_CC)) { zend_call_method_with_0_params(&value, NULL, NULL, "count", &retval); if (retval) { convert_to_long_ex(&retval); count = Z_LVAL_P(retval); zval_ptr_dtor(&retval); return (int) count > 0; } return 0; } #endif return 0; } if (Z_TYPE_P(value) == IS_NULL) { return 0; } return 1; } static int zephir_fast_count_int(zval *value TSRMLS_DC) { long count = 0; if (Z_TYPE_P(value) == IS_ARRAY) { return zend_hash_num_elements(Z_ARRVAL_P(value)); } if (Z_TYPE_P(value) == IS_OBJECT) { #ifdef HAVE_SPL zval *retval = NULL; #endif if (Z_OBJ_HT_P(value)->count_elements) { Z_OBJ_HT(*value)->count_elements(value, &count TSRMLS_CC); return (int) count; } #ifdef HAVE_SPL if (Z_OBJ_HT_P(value)->get_class_entry && instanceof_function(Z_OBJCE_P(value), spl_ce_Countable TSRMLS_CC)) { zend_call_method_with_0_params(&value, NULL, NULL, "count", &retval); if (retval) { convert_to_long_ex(&retval); count = Z_LVAL_P(retval); zval_ptr_dtor(&retval); return (int) count; } return 0; } #endif return 0; } if (Z_TYPE_P(value) == IS_NULL) { return 0; } return 1; } static int zephir_function_exists(const zval *function_name TSRMLS_DC) { return zephir_function_quick_exists_ex( Z_STRVAL_P(function_name), Z_STRLEN_P(function_name) + 1, zend_inline_hash_func(Z_STRVAL_P(function_name), Z_STRLEN_P(function_name) + 1) TSRMLS_CC ); } static int zephir_function_exists_ex(const char *function_name, unsigned int function_len TSRMLS_DC) { return zephir_function_quick_exists_ex(function_name, function_len, zend_inline_hash_func(function_name, function_len) TSRMLS_CC); } static int zephir_function_quick_exists_ex(const char *method_name, unsigned int method_len, unsigned long key TSRMLS_DC) { if (zend_hash_quick_exists(CG(function_table), method_name, method_len, key)) { return SUCCESS; } return FAILURE; } static int zephir_is_callable(zval *var TSRMLS_DC) { char *error = NULL; zend_bool retval; retval = zend_is_callable_ex(var, NULL, 0, NULL, NULL, NULL, &error TSRMLS_CC); if (error) { efree(error); } return (int) retval; } static int zephir_is_scalar(zval *var) { switch (Z_TYPE_P(var)) { case IS_BOOL: case IS_DOUBLE: case IS_LONG: case IS_STRING: return 1; break; } return 0; } static int zephir_is_iterable_ex(zval *arr, HashTable **arr_hash, HashPosition *hash_position, int duplicate, int reverse) { if (unlikely(Z_TYPE_P(arr) != IS_ARRAY)) { return 0; } if (duplicate) { ALLOC_HASHTABLE(*arr_hash); zend_hash_init(*arr_hash, 0, NULL, NULL, 0); zend_hash_copy(*arr_hash, Z_ARRVAL_P(arr), NULL, NULL, sizeof(zval*)); } else { *arr_hash = Z_ARRVAL_P(arr); } if (reverse) { if (hash_position) { *hash_position = (*arr_hash)->pListTail; } else { (*arr_hash)->pInternalPointer = (*arr_hash)->pListTail; } } else { if (hash_position) { *hash_position = (*arr_hash)->pListHead; } else { (*arr_hash)->pInternalPointer = (*arr_hash)->pListHead; } } return 1; } static void zephir_safe_zval_ptr_dtor(zval *pzval) { if (pzval) { zval_ptr_dtor(&pzval); } } static int zephir_fetch_parameters(int num_args TSRMLS_DC, int required_args, int optional_args, ...) { va_list va; int arg_count = (int) (zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1); zval **arg, **p; int i; if (num_args < required_args || (num_args > (required_args + optional_args))) { zephir_throw_exception_string(spl_ce_BadMethodCallException, SL("Wrong number of parameters") TSRMLS_CC); return FAILURE; } if (num_args > arg_count) { zephir_throw_exception_string(spl_ce_BadMethodCallException, SL("Could not obtain parameters for parsing") TSRMLS_CC); return FAILURE; } if (!num_args) { return SUCCESS; } va_start(va, optional_args); i = 0; while (num_args-- > 0) { arg = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 - (arg_count - i)); p = va_arg(va, zval **); *p = *arg; i++; } va_end(va); return SUCCESS; } static void zephir_gettype(zval *return_value, zval *arg TSRMLS_DC) { switch (Z_TYPE_P(arg)) { case IS_NULL: RETVAL_STRING("NULL", 1); break; case IS_BOOL: RETVAL_STRING("boolean", 1); break; case IS_LONG: RETVAL_STRING("integer", 1); break; case IS_DOUBLE: RETVAL_STRING("double", 1); break; case IS_STRING: RETVAL_STRING("string", 1); break; case IS_ARRAY: RETVAL_STRING("array", 1); break; case IS_OBJECT: RETVAL_STRING("object", 1); break; case IS_RESOURCE: { const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_P(arg) TSRMLS_CC); if (type_name) { RETVAL_STRING("resource", 1); break; } } default: RETVAL_STRING("unknown type", 1); } } zend_class_entry* zephir_get_internal_ce(const char *class_name, unsigned int class_name_len TSRMLS_DC) { zend_class_entry** temp_ce; if (zend_hash_find(CG(class_table), class_name, class_name_len, (void **)&temp_ce) == FAILURE) { zend_error(E_ERROR, "Class '%s' not found", class_name); return NULL; } return *temp_ce; } #include <Zend/zend_alloc.h> static zephir_memory_entry* zephir_memory_grow_stack_common(zend_zephir_globals_def *g) { assert(g->start_memory != NULL); if (!g->active_memory) { g->active_memory = g->start_memory; #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 1); #endif } else if (!g->active_memory->next) { #ifndef PHP_WIN32 assert(g->active_memory >= g->end_memory - 1 || g->active_memory < g->start_memory); #endif zephir_memory_entry *entry = (zephir_memory_entry *) ecalloc(1, sizeof(zephir_memory_entry)); /* ecalloc() will take care of these members entry->pointer = 0; entry->capacity = 0; entry->addresses = NULL; entry->hash_pointer = 0; entry->hash_capacity = 0; entry->hash_addresses = NULL; entry->next = NULL; */ #ifndef ZEPHIR_RELEASE entry->permanent = 0; entry->func = NULL; #endif entry->prev = g->active_memory; entry->prev->next = entry; g->active_memory = entry; } else { #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 1); #endif assert(g->active_memory < g->end_memory && g->active_memory >= g->start_memory); g->active_memory = g->active_memory->next; } assert(g->active_memory->pointer == 0); assert(g->active_memory->hash_pointer == 0); return g->active_memory; } static void zephir_memory_restore_stack_common(zend_zephir_globals_def *g TSRMLS_DC) { size_t i; zephir_memory_entry *prev, *active_memory; zephir_symbol_table *active_symbol_table; zval **ptr; active_memory = g->active_memory; assert(active_memory != NULL); if (EXPECTED(!CG(unclean_shutdown))) { /* Clean active symbol table */ if (g->active_symbol_table) { active_symbol_table = g->active_symbol_table; if (active_symbol_table->scope == active_memory) { zend_hash_destroy(EG(active_symbol_table)); FREE_HASHTABLE(EG(active_symbol_table)); EG(active_symbol_table) = active_symbol_table->symbol_table; g->active_symbol_table = active_symbol_table->prev; efree(active_symbol_table); } } /* Check for non freed hash key zvals, mark as null to avoid string freeing */ for (i = 0; i < active_memory->hash_pointer; ++i) { assert(active_memory->hash_addresses[i] != NULL && *(active_memory->hash_addresses[i]) != NULL); if (Z_REFCOUNT_PP(active_memory->hash_addresses[i]) <= 1) { ZVAL_NULL(*active_memory->hash_addresses[i]); } else { zval_copy_ctor(*active_memory->hash_addresses[i]); } } #ifndef ZEPHIR_RELEASE for (i = 0; i < active_memory->pointer; ++i) { if (active_memory->addresses[i] != NULL && *(active_memory->addresses[i]) != NULL) { zval **var = active_memory->addresses[i]; #if PHP_VERSION_ID < 50400 if (Z_TYPE_PP(var) > IS_CONSTANT_ARRAY) { fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } #else if (Z_TYPE_PP(var) > IS_CALLABLE) { fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } #endif if (Z_REFCOUNT_PP(var) == 0) { fprintf(stderr, "%s: observed variable #%d (%p) has 0 references, type=%d [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } else if (Z_REFCOUNT_PP(var) >= 1000000) { fprintf(stderr, "%s: observed variable #%d (%p) has too many references (%u), type=%d [%s]\n", __func__, (int)i, *var, Z_REFCOUNT_PP(var), Z_TYPE_PP(var), active_memory->func); } #if 0 /* Skip this check, PDO does return variables with is_ref = 1 and refcount = 1*/ else if (Z_REFCOUNT_PP(var) == 1 && Z_ISREF_PP(var)) { fprintf(stderr, "%s: observed variable #%d (%p) is a reference with reference count = 1, type=%d [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } #endif } } #endif /* Traverse all zvals allocated, reduce the reference counting or free them */ for (i = 0; i < active_memory->pointer; ++i) { ptr = active_memory->addresses[i]; if (EXPECTED(ptr != NULL && *(ptr) != NULL)) { if (Z_REFCOUNT_PP(ptr) == 1) { if (!Z_ISREF_PP(ptr) || Z_TYPE_PP(ptr) == IS_OBJECT) { zval_ptr_dtor(ptr); } else { efree(*ptr); } } else { Z_DELREF_PP(ptr); } } } } #ifndef ZEPHIR_RELEASE active_memory->func = NULL; #endif prev = active_memory->prev; if (active_memory >= g->end_memory || active_memory < g->start_memory) { #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 0); #endif assert(prev != NULL); if (active_memory->hash_addresses != NULL) { efree(active_memory->hash_addresses); } if (active_memory->addresses != NULL) { efree(active_memory->addresses); } efree(g->active_memory); g->active_memory = prev; prev->next = NULL; } else { #ifndef ZEPHIR_RELEASE assert(g->active_memory->permanent == 1); #endif active_memory->pointer = 0; active_memory->hash_pointer = 0; g->active_memory = prev; } #ifndef ZEPHIR_RELEASE if (g->active_memory) { zephir_memory_entry *f = g->active_memory; if (f >= g->start_memory && f < g->end_memory - 1) { assert(f->permanent == 1); assert(f->next != NULL); if (f > g->start_memory) { assert(f->prev != NULL); } } } #endif } #ifndef ZEPHIR_RELEASE static void zephir_dump_memory_frame(zephir_memory_entry *active_memory TSRMLS_DC) { size_t i; assert(active_memory != NULL); fprintf(stderr, "Dump of the memory frame %p (%s)\n", active_memory, active_memory->func); if (active_memory->hash_pointer) { for (i = 0; i < active_memory->hash_pointer; ++i) { assert(active_memory->hash_addresses[i] != NULL && *(active_memory->hash_addresses[i]) != NULL); fprintf(stderr, "Hash ptr %lu (%p => %p), type=%u, refcnt=%u\n", (ulong)i, active_memory->hash_addresses[i], *active_memory->hash_addresses[i], Z_TYPE_PP(active_memory->hash_addresses[i]), Z_REFCOUNT_PP(active_memory->hash_addresses[i])); } } for (i = 0; i < active_memory->pointer; ++i) { if (EXPECTED(active_memory->addresses[i] != NULL && *(active_memory->addresses[i]) != NULL)) { zval **var = active_memory->addresses[i]; fprintf(stderr, "Obs var %lu (%p => %p), type=%u, refcnt=%u; ", (ulong)i, var, *var, Z_TYPE_PP(var), Z_REFCOUNT_PP(var)); switch (Z_TYPE_PP(var)) { case IS_NULL: fprintf(stderr, "value=NULL\n"); break; case IS_LONG: fprintf(stderr, "value=%ld\n", Z_LVAL_PP(var)); break; case IS_DOUBLE: fprintf(stderr, "value=%E\n", Z_DVAL_PP(var)); break; case IS_BOOL: fprintf(stderr, "value=(bool)%d\n", Z_BVAL_PP(var)); break; case IS_ARRAY: fprintf(stderr, "value=array(%p), %d elements\n", Z_ARRVAL_PP(var), zend_hash_num_elements(Z_ARRVAL_PP(var))); break; case IS_OBJECT: fprintf(stderr, "value=object(%u), %s\n", Z_OBJ_HANDLE_PP(var), Z_OBJCE_PP(var)->name); break; case IS_STRING: fprintf(stderr, "value=%*s (%p)\n", Z_STRLEN_PP(var), Z_STRVAL_PP(var), Z_STRVAL_PP(var)); break; case IS_RESOURCE: fprintf(stderr, "value=(resource)%ld\n", Z_LVAL_PP(var)); break; default: fprintf(stderr, "\n"); break; } } } fprintf(stderr, "End of the dump of the memory frame %p\n", active_memory); } static void zephir_dump_current_frame(TSRMLS_D) { zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; if (UNEXPECTED(zephir_globals_ptr->active_memory == NULL)) { fprintf(stderr, "WARNING: calling %s() without an active memory frame!\n", __func__); zephir_print_backtrace(); return; } zephir_dump_memory_frame(zephir_globals_ptr->active_memory TSRMLS_CC); } static void zephir_dump_all_frames(TSRMLS_D) { zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; zephir_memory_entry *active_memory = zephir_globals_ptr->active_memory; fprintf(stderr, "*** DUMP START ***\n"); while (active_memory != NULL) { zephir_dump_memory_frame(active_memory TSRMLS_CC); active_memory = active_memory->prev; } fprintf(stderr, "*** DUMP END ***\n"); } int ZEND_FASTCALL zephir_memory_restore_stack(const char *func TSRMLS_DC) { zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; if (UNEXPECTED(zephir_globals_ptr->active_memory == NULL)) { fprintf(stderr, "WARNING: calling zephir_memory_restore_stack() without an active memory frame!\n"); zephir_print_backtrace(); return FAILURE; } if (UNEXPECTED(zephir_globals_ptr->active_memory->func != func)) { fprintf(stderr, "Trying to free someone else's memory frame!\n"); fprintf(stderr, "The frame was created by %s\n", zephir_globals_ptr->active_memory->func); fprintf(stderr, "Calling function: %s\n", func); zephir_print_backtrace(); } zephir_memory_restore_stack_common(zephir_globals_ptr TSRMLS_CC); return SUCCESS; } void ZEND_FASTCALL zephir_memory_grow_stack(const char *func TSRMLS_DC) { zephir_memory_entry *entry; zend_zephir_globals_def *g = ZEPHIR_VGLOBAL; if (g->start_memory == NULL) { zephir_initialize_memory(g TSRMLS_CC); } entry = zephir_memory_grow_stack_common(g); entry->func = func; } #else void ZEND_FASTCALL zephir_memory_grow_stack(TSRMLS_D) { zend_zephir_globals_def *g = ZEPHIR_VGLOBAL; if (g->start_memory == NULL) { zephir_initialize_memory(g TSRMLS_CC); } zephir_memory_grow_stack_common(g); } int ZEND_FASTCALL zephir_memory_restore_stack(TSRMLS_D) { zephir_memory_restore_stack_common(ZEPHIR_VGLOBAL TSRMLS_CC); return SUCCESS; } #endif static void zephir_initialize_memory(zend_zephir_globals_def *zephir_globals_ptr TSRMLS_DC) { zephir_memory_entry *start; size_t i; start = (zephir_memory_entry *) pecalloc(ZEPHIR_NUM_PREALLOCATED_FRAMES, sizeof(zephir_memory_entry), 1); /* pecalloc() will take care of these members for every frame start->pointer = 0; start->hash_pointer = 0; start->prev = NULL; start->next = NULL; */ for (i = 0; i < ZEPHIR_NUM_PREALLOCATED_FRAMES; ++i) { start[i].addresses = pecalloc(24, sizeof(zval*), 1); start[i].capacity = 24; start[i].hash_addresses = pecalloc(8, sizeof(zval*), 1); start[i].hash_capacity = 8; #ifndef ZEPHIR_RELEASE start[i].permanent = 1; #endif } start[0].next = &start[1]; start[ZEPHIR_NUM_PREALLOCATED_FRAMES - 1].prev = &start[ZEPHIR_NUM_PREALLOCATED_FRAMES - 2]; for (i = 1; i < ZEPHIR_NUM_PREALLOCATED_FRAMES - 1; ++i) { start[i].next = &start[i + 1]; start[i].prev = &start[i - 1]; } zephir_globals_ptr->start_memory = start; zephir_globals_ptr->end_memory = start + ZEPHIR_NUM_PREALLOCATED_FRAMES; zephir_globals_ptr->fcache = pemalloc(sizeof(HashTable), 1); zend_hash_init(zephir_globals_ptr->fcache, 128, NULL, NULL, 1); // zephir_fcall_cache_dtor /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ ALLOC_INIT_ZVAL(zephir_globals_ptr->global_null); Z_SET_REFCOUNT_P(zephir_globals_ptr->global_null, 2); /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ ALLOC_INIT_ZVAL(zephir_globals_ptr->global_false); Z_SET_REFCOUNT_P(zephir_globals_ptr->global_false, 2); ZVAL_FALSE(zephir_globals_ptr->global_false); /* 'Allocator sizeof operand mismatch' warning can be safely ignored */ ALLOC_INIT_ZVAL(zephir_globals_ptr->global_true); Z_SET_REFCOUNT_P(zephir_globals_ptr->global_true, 2); ZVAL_TRUE(zephir_globals_ptr->global_true); zephir_globals_ptr->initialized = 1; } static int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zephir_fcall_cache_entry **entry = (zephir_fcall_cache_entry**) pDest; zend_class_entry *scope; uint len = hash_key->nKeyLength; assert(hash_key->arKey != NULL); assert(hash_key->nKeyLength > 2 * sizeof(zend_class_entry**)); memcpy(&scope, &hash_key->arKey[(len -1) - 2 * sizeof(zend_class_entry**)], sizeof(zend_class_entry*)); #ifndef ZEPHIR_RELEASE if ((*entry)->f->type != ZEND_INTERNAL_FUNCTION || (scope && scope->type != ZEND_INTERNAL_CLASS)) { return ZEND_HASH_APPLY_REMOVE; } #else if ((*entry)->type != ZEND_INTERNAL_FUNCTION || (scope && scope->type != ZEND_INTERNAL_CLASS)) { return ZEND_HASH_APPLY_REMOVE; } #endif #if PHP_VERSION_ID >= 50400 if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->info.internal.module->type != MODULE_PERSISTENT) { return ZEND_HASH_APPLY_REMOVE; } #else if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->module->type != MODULE_PERSISTENT) { return ZEND_HASH_APPLY_REMOVE; } #endif return ZEND_HASH_APPLY_KEEP; } static void zephir_deinitialize_memory(TSRMLS_D) { size_t i; zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; if (zephir_globals_ptr->initialized != 1) { zephir_globals_ptr->initialized = 0; return; } if (zephir_globals_ptr->start_memory != NULL) { zephir_clean_restore_stack(TSRMLS_C); } zend_hash_apply_with_arguments(zephir_globals_ptr->fcache TSRMLS_CC, zephir_cleanup_fcache, 0); #ifndef ZEPHIR_RELEASE assert(zephir_globals_ptr->start_memory != NULL); #endif for (i = 0; i < ZEPHIR_NUM_PREALLOCATED_FRAMES; ++i) { pefree(zephir_globals_ptr->start_memory[i].hash_addresses, 1); pefree(zephir_globals_ptr->start_memory[i].addresses, 1); } pefree(zephir_globals_ptr->start_memory, 1); zephir_globals_ptr->start_memory = NULL; zend_hash_destroy(zephir_globals_ptr->fcache); pefree(zephir_globals_ptr->fcache, 1); zephir_globals_ptr->fcache = NULL; for (i = 0; i < 2; i++) { zval_ptr_dtor(&zephir_globals_ptr->global_null); zval_ptr_dtor(&zephir_globals_ptr->global_false); zval_ptr_dtor(&zephir_globals_ptr->global_true); } zephir_globals_ptr->initialized = 0; } ZEPHIR_ATTR_NONNULL static void zephir_reallocate_memory(const zend_zephir_globals_def *g) { zephir_memory_entry *frame = g->active_memory; int persistent = (frame >= g->start_memory && frame < g->end_memory); void *buf = perealloc(frame->addresses, sizeof(zval **) * (frame->capacity + 16), persistent); if (EXPECTED(buf != NULL)) { frame->capacity += 16; frame->addresses = buf; } else { zend_error(E_CORE_ERROR, "Memory allocation failed"); } #ifndef ZEPHIR_RELEASE assert(frame->permanent == persistent); #endif } ZEPHIR_ATTR_NONNULL static void zephir_reallocate_hmemory(const zend_zephir_globals_def *g) { zephir_memory_entry *frame = g->active_memory; int persistent = (frame >= g->start_memory && frame < g->end_memory); void *buf = perealloc(frame->hash_addresses, sizeof(zval **) * (frame->hash_capacity + 4), persistent); if (EXPECTED(buf != NULL)) { frame->hash_capacity += 4; frame->hash_addresses = buf; } else { zend_error(E_CORE_ERROR, "Memory allocation failed"); } #ifndef ZEPHIR_RELEASE assert(frame->permanent == persistent); #endif } ZEPHIR_ATTR_NONNULL1(2) static inline void zephir_do_memory_observe(zval **var, const zend_zephir_globals_def *g) { zephir_memory_entry *frame = g->active_memory; #ifndef ZEPHIR_RELEASE if (UNEXPECTED(frame == NULL)) { fprintf(stderr, "ZEPHIR_MM_GROW() must be called before using any of MM functions or macros!"); zephir_print_backtrace(); abort(); } #endif if (UNEXPECTED(frame->pointer == frame->capacity)) { zephir_reallocate_memory(g); } #ifndef ZEPHIR_RELEASE { size_t i; for (i = 0; i < frame->pointer; ++i) { if (frame->addresses[i] == var) { fprintf(stderr, "Variable %p is already observed", var); zephir_print_backtrace(); abort(); } } } #endif frame->addresses[frame->pointer] = var; ++frame->pointer; } void ZEND_FASTCALL zephir_memory_observe(zval **var TSRMLS_DC) { zend_zephir_globals_def *g = ZEPHIR_VGLOBAL; zephir_do_memory_observe(var, g); *var = NULL; /* In case an exception or error happens BEFORE the observed variable gets initialized */ } void ZEND_FASTCALL zephir_memory_alloc(zval **var TSRMLS_DC) { zend_zephir_globals_def *g = ZEPHIR_VGLOBAL; zephir_do_memory_observe(var, g); ALLOC_INIT_ZVAL(*var); } void ZEND_FASTCALL zephir_ptr_dtor(zval **var) { if (!Z_ISREF_PP(var) || Z_TYPE_PP(var) == IS_OBJECT) { zval_ptr_dtor(var); } else { if (Z_REFCOUNT_PP(var) == 0) { efree(*var); } else { Z_DELREF_PP(var); if (Z_REFCOUNT_PP(var) == 0) { efree(*var); } } } } void ZEND_FASTCALL zephir_dtor(zval *var) { if (!Z_ISREF_P(var)) { zval_dtor(var); } } void ZEND_FASTCALL zephir_memory_alloc_pnull(zval **var TSRMLS_DC) { zend_zephir_globals_def *g = ZEPHIR_VGLOBAL; zephir_memory_entry *active_memory = g->active_memory; #ifndef ZEPHIR_RELEASE if (UNEXPECTED(active_memory == NULL)) { fprintf(stderr, "ZEPHIR_MM_GROW() must be called before using any of MM functions or macros!"); zephir_print_backtrace(); abort(); } #endif zephir_do_memory_observe(var, g); ALLOC_INIT_ZVAL(*var); if (active_memory->hash_pointer == active_memory->hash_capacity) { zephir_reallocate_hmemory(g); } active_memory->hash_addresses[active_memory->hash_pointer] = var; ++active_memory->hash_pointer; } void ZEND_FASTCALL zephir_memory_remove(zval **var TSRMLS_DC) { zval_ptr_dtor(var); *var = NULL; } int ZEND_FASTCALL zephir_clean_restore_stack(TSRMLS_D) { zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; while (zephir_globals_ptr->active_memory != NULL) { zephir_memory_restore_stack_common(zephir_globals_ptr TSRMLS_CC); } return SUCCESS; } void ZEND_FASTCALL zephir_copy_ctor(zval *destination, zval *origin) { if (Z_REFCOUNT_P(origin) > 1) { zval_copy_ctor(destination); } else { ZVAL_NULL(origin); } } static void zephir_create_symbol_table(TSRMLS_D) { zephir_symbol_table *entry; zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; HashTable *symbol_table; #ifndef ZEPHIR_RELEASE if (!zephir_globals_ptr->active_memory) { fprintf(stderr, "ERROR: Trying to create a virtual symbol table without a memory frame"); zephir_print_backtrace(); return; } #endif entry = (zephir_symbol_table *) emalloc(sizeof(zephir_symbol_table)); entry->scope = zephir_globals_ptr->active_memory; entry->symbol_table = EG(active_symbol_table); entry->prev = zephir_globals_ptr->active_symbol_table; zephir_globals_ptr->active_symbol_table = entry; ALLOC_HASHTABLE(symbol_table); zend_hash_init(symbol_table, 0, NULL, ZVAL_PTR_DTOR, 0); EG(active_symbol_table) = symbol_table; } static void zephir_clean_symbol_tables(TSRMLS_D) { /*unsigned int i; if (ZEPHIR_GLOBAL(symbol_tables)) { for (i = ZEPHIR_GLOBAL(number_symbol_tables); i > 0; i--) { EG(active_symbol_table) = ZEPHIR_GLOBAL(symbol_tables)[i - 1]; } efree(ZEPHIR_GLOBAL(symbol_tables)); ZEPHIR_GLOBAL(symbol_tables) = NULL; }*/ } static int zephir_set_symbol(zval *key_name, zval *value TSRMLS_DC) { if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } if (EG(active_symbol_table)) { if (Z_TYPE_P(key_name) == IS_STRING) { Z_ADDREF_P(value); zend_hash_update(EG(active_symbol_table), Z_STRVAL_P(key_name), Z_STRLEN_P(key_name) + 1, &value, sizeof(zval *), NULL); if (EG(exception)) { return FAILURE; } } } return SUCCESS; } static int zephir_set_symbol_str(char *key_name, unsigned int key_length, zval *value TSRMLS_DC) { if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } if (&EG(symbol_table)) { Z_ADDREF_P(value); zend_hash_update(&EG(symbol_table), key_name, key_length, &value, sizeof(zval *), NULL); if (EG(exception)) { return FAILURE; } } return SUCCESS; } static inline void zephir_dtor_func(zval *zvalue ZEND_FILE_LINE_DC) { switch (Z_TYPE_P(zvalue) & IS_CONSTANT_TYPE_MASK) { case IS_STRING: case IS_CONSTANT: CHECK_ZVAL_STRING_REL(zvalue); STR_FREE_REL(zvalue->value.str.val); break; #if PHP_VERSION_ID < 50600 case IS_CONSTANT_ARRAY: #endif case IS_ARRAY: { TSRMLS_FETCH(); if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) { /* break possible cycles */ Z_TYPE_P(zvalue) = IS_NULL; zend_hash_destroy(zvalue->value.ht); FREE_HASHTABLE(zvalue->value.ht); } } break; case IS_OBJECT: { TSRMLS_FETCH(); Z_OBJ_HT_P(zvalue)->del_ref(zvalue TSRMLS_CC); } break; case IS_RESOURCE: { TSRMLS_FETCH(); zend_list_delete(zvalue->value.lval); } break; case IS_LONG: case IS_DOUBLE: case IS_BOOL: case IS_NULL: default: return; break; } } static void zephir_value_dtor(zval *zvalue ZEND_FILE_LINE_DC) { if (zvalue->type <= IS_BOOL) { return; } zephir_dtor_func(zvalue ZEND_FILE_LINE_RELAY_CC); } #ifdef HAVE_CONFIG_H #endif static void zephir_throw_exception(zval *object TSRMLS_DC){ Z_ADDREF_P(object); zend_throw_exception_object(object TSRMLS_CC); } static void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC) { zend_class_entry *default_exception_ce; int ZEPHIR_LAST_CALL_STATUS = 0; zval *curline = NULL, *object_copy = NULL; ZEPHIR_MM_GROW(); if (Z_TYPE_P(object) != IS_OBJECT) { object_copy = object; ALLOC_INIT_ZVAL(object); object_init_ex(object, zend_exception_get_default(TSRMLS_C)); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, object_copy); } Z_ADDREF_P(object); if (line > 0) { curline = 0; ZEPHIR_CALL_METHOD(&curline, object, "getline", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(curline, 0)) { default_exception_ce = zend_exception_get_default(TSRMLS_C); zend_update_property_string(default_exception_ce, object, "file", sizeof("file") - 1, file TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "line", sizeof("line") - 1, line TSRMLS_CC); } } if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *message, zend_uint message_len, const char *file, zend_uint line TSRMLS_DC) { zval *object, *msg; int ZEPHIR_LAST_CALL_STATUS = 0; zend_class_entry *default_exception_ce; ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); ALLOC_INIT_ZVAL(msg); ZVAL_STRINGL(msg, message, message_len, 1); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg); if (line > 0) { default_exception_ce = zend_exception_get_default(TSRMLS_C); zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC); } if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } zval_ptr_dtor(&msg); } static void zephir_throw_exception_string(zend_class_entry *ce, const char *message, zend_uint message_len TSRMLS_DC){ zval *object, *msg; int ZEPHIR_LAST_CALL_STATUS = 0; ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); ALLOC_INIT_ZVAL(msg); ZVAL_STRINGL(msg, message, message_len, 1); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg); if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } zval_ptr_dtor(&msg); } static void zephir_throw_exception_format(zend_class_entry *ce TSRMLS_DC, const char *format, ...) { zval *object, *msg; int ZEPHIR_LAST_CALL_STATUS = 0, len; char *buffer; va_list args; ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); va_start(args, format); len = vspprintf(&buffer, 0, format, args); va_end(args); ALLOC_INIT_ZVAL(msg); ZVAL_STRINGL(msg, buffer, len, 0); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg); if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } zval_ptr_dtor(&msg); } static void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, const char *file, zend_uint line TSRMLS_DC){ zval *object; int ZEPHIR_LAST_CALL_STATUS = 0; zend_class_entry *default_exception_ce; ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, message); if (line > 0) { default_exception_ce = zend_exception_get_default(TSRMLS_C); zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC); zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC); } if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } } static void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC){ zval *object; int ZEPHIR_LAST_CALL_STATUS = 0; ALLOC_INIT_ZVAL(object); object_init_ex(object, ce); ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, message); if (ZEPHIR_LAST_CALL_STATUS != FAILURE) { zend_throw_exception_object(object TSRMLS_CC); } } #ifdef HAVE_CONFIG_H #endif #include <Zend/zend_hash.h> static int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent) { #if PHP_VERSION_ID < 50400 Bucket **tmp; #endif if (nSize >= 0x80000000) { ht->nTableSize = 0x80000000; } else { if (nSize > 3) { ht->nTableSize = nSize + (nSize >> 2); } else { ht->nTableSize = 3; } } #if ZEND_DEBUG ht->inconsistent = 0; #endif #if PHP_VERSION_ID < 50400 ht->nTableMask = ht->nTableSize - 1; #else ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */ #endif ht->pDestructor = pDestructor; ht->arBuckets = NULL; ht->pListHead = NULL; ht->pListTail = NULL; ht->nNumOfElements = 0; ht->nNextFreeElement = 0; ht->pInternalPointer = NULL; ht->persistent = persistent; ht->nApplyCount = 0; ht->bApplyProtection = 1; #if PHP_VERSION_ID < 50400 /* Uses ecalloc() so that Bucket* == NULL */ if (persistent) { tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *)); if (!tmp) { return FAILURE; } ht->arBuckets = tmp; } else { tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *)); if (tmp) { ht->arBuckets = tmp; } } #endif return SUCCESS; } static int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength) { ulong h; uint nIndex; Bucket *p; h = zend_inline_hash_func(arKey, nKeyLength); nIndex = h & ht->nTableMask; p = ht->arBuckets[nIndex]; while (p != NULL) { if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { if (!memcmp(p->arKey, arKey, nKeyLength)) { return 1; } } p = p->pNext; } return 0; } static int zephir_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h) { uint nIndex; Bucket *p; if (nKeyLength == 0) { return zend_hash_index_exists(ht, h); } nIndex = h & ht->nTableMask; p = ht->arBuckets[nIndex]; while (p != NULL) { if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { if (!memcmp(p->arKey, arKey, nKeyLength)) { return 1; } } p = p->pNext; } return 0; } static int zephir_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData) { ulong h; uint nIndex; Bucket *p; h = zend_inline_hash_func(arKey, nKeyLength); nIndex = h & ht->nTableMask; p = ht->arBuckets[nIndex]; while (p != NULL) { if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { if (!memcmp(p->arKey, arKey, nKeyLength)) { *pData = p->pData; return SUCCESS; } } p = p->pNext; } return FAILURE; } static int zephir_hash_quick_find(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h, void **pData) { uint nIndex; Bucket *p; if (nKeyLength == 0) { return zend_hash_index_find(ht, h, pData); } nIndex = h & ht->nTableMask; p = ht->arBuckets[nIndex]; while (p != NULL) { if (p->arKey == arKey || ((p->h == h) && (p->nKeyLength == nKeyLength))) { if (!memcmp(p->arKey, arKey, nKeyLength)) { *pData = p->pData; return SUCCESS; } } p = p->pNext; } return FAILURE; } static void zephir_get_current_key(zval **key, const HashTable *hash_table, HashPosition *hash_position TSRMLS_DC) { Bucket *p; ZEPHIR_INIT_NVAR_PNULL(*key); p = hash_position ? (*hash_position) : hash_table->pInternalPointer; if (p) { if (p->nKeyLength) { ZVAL_STRINGL(*key, (char *) p->arKey, p->nKeyLength - 1, 0); } else { ZVAL_LONG(*key, p->h); } } } zval zephir_get_current_key_w(const HashTable *hash_table, HashPosition *hash_position) { Bucket *p; zval result; INIT_ZVAL(result); p = hash_position ? (*hash_position) : hash_table->pInternalPointer; if (p) { if (p->nKeyLength) { ZVAL_STRINGL(&result, (char *) p->arKey, p->nKeyLength - 1, 0); } else { ZVAL_LONG(&result, p->h); } } return result; } static int zephir_has_numeric_keys(const zval *data) { HashTable *ht; if (Z_TYPE_P(data) == IS_ARRAY) { ht = Z_ARRVAL_P(data); ht->pInternalPointer = ht->pListHead; while (ht->pInternalPointer) { if (!ht->pInternalPointer->nKeyLength) { return 1; } ht->pInternalPointer = ht->pInternalPointer->pListNext; } } return 0; } static void zephir_hash_update_or_insert(HashTable *ht, zval *key, zval *value) { if (!key || Z_TYPE_P(key) == IS_NULL) { zend_hash_next_index_insert(ht, (void**)&value, sizeof(zval*), NULL); return; } switch (Z_TYPE_P(key)) { case IS_STRING: zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&value, sizeof(zval*), NULL); return; case IS_RESOURCE: case IS_DOUBLE: case IS_BOOL: case IS_LONG: zend_hash_index_update(ht, ((Z_TYPE_P(key) == IS_DOUBLE) ? (ulong)Z_DVAL_P(key) : Z_LVAL_P(key)), (void*)&value, sizeof(zval*), NULL); return; default: zend_error(E_WARNING, "Illegal offset type"); return; } } zval** zephir_hash_get(HashTable *ht, zval *key, int type) { zval **ret = NULL; switch (Z_TYPE_P(key)) { case IS_RESOURCE: zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(key), Z_LVAL_P(key)); /* no break */ case IS_LONG: case IS_DOUBLE: case IS_BOOL: { ulong index = (Z_TYPE_P(key) == IS_DOUBLE) ? ((long int)Z_DVAL_P(key)) : Z_LVAL_P(key); if (FAILURE == zend_hash_index_find(ht, index, (void**)&ret)) { switch (type) { case BP_VAR_R: zend_error(E_NOTICE, "Undefined offset: %ld", index); /* no break */ case BP_VAR_UNSET: case BP_VAR_IS: { TSRMLS_FETCH(); ret = &EG(uninitialized_zval_ptr); break; } case BP_VAR_RW: zend_error(E_NOTICE, "Undefined offset: %ld", index); /* no break */ case BP_VAR_W: { zval *value; ALLOC_INIT_ZVAL(value); zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), (void**)&ret); break; } } } return ret; } case IS_STRING: if (FAILURE == zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&ret)) { switch (type) { case BP_VAR_R: zend_error(E_NOTICE, "Undefined offset: %s", Z_STRVAL_P(key)); /* no break */ case BP_VAR_UNSET: case BP_VAR_IS: { TSRMLS_FETCH(); ret = &EG(uninitialized_zval_ptr); break; } case BP_VAR_RW: zend_error(E_NOTICE, "Undefined offset: %s", Z_STRVAL_P(key)); /* no break */ case BP_VAR_W: { zval *value; ALLOC_INIT_ZVAL(value); zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&value, sizeof(void*), (void**)&ret); break; } } } return ret; default: { TSRMLS_FETCH(); zend_error(E_WARNING, "Illegal offset type"); return (type == BP_VAR_W || type == BP_VAR_RW) ? &EG(error_zval_ptr) : &EG(uninitialized_zval_ptr); } } } static int zephir_hash_unset(HashTable *ht, zval *key) { switch (Z_TYPE_P(key)) { case IS_LONG: case IS_DOUBLE: case IS_BOOL: case IS_RESOURCE: return (zend_hash_index_del(ht, (Z_TYPE_P(key) == IS_DOUBLE) ? ((long int)Z_DVAL_P(key)) : Z_LVAL_P(key)) == SUCCESS); case IS_STRING: return (zend_symtable_del(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1) == SUCCESS); default: zend_error(E_WARNING, "Illegal offset type"); return 0; } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #ifndef ZEPHIR_RELEASE FILE *zephir_log = NULL; static int zephir_debug_trace = 0; static zephir_debug_entry *start = NULL; static zephir_debug_entry *active = NULL; static int zephir_start_debug(){ if(!zephir_log){ /*//zephir_log = fopen("/home/gutierrezandresfelipe/phalcon-debug.a", "w"); zephir_log = fopen("/tmp/phalcon-debug.a", "w"); if(!zephir_log){ fprintf(stderr, "Can't open debug log\n"); }*/ zephir_log = stderr; } return SUCCESS; } static int zephir_stop_debug(){ zephir_debug_entry *ptr = active; zephir_debug_entry *this_entry = NULL; while(ptr){ this_entry = ptr; ptr = ptr->prev; efree(this_entry); } //fclose(zephir_log); zephir_log = NULL; return SUCCESS; } static int zephir_print_r(zval *userval TSRMLS_DC){ zend_print_zval_r(userval, 0 TSRMLS_CC); return SUCCESS; } static int zephir_vdump(zval *uservar TSRMLS_DC){ zephir_start_debug(); if(!uservar){ fprintf(zephir_log, "Null pointer\n"); return SUCCESS; } switch(Z_TYPE_P(uservar)){ case IS_NULL: fprintf(zephir_log, "NULL \n"); break; case IS_BOOL: fprintf(zephir_log, "Boolean: %s\n", Z_LVAL_P(uservar) ? "TRUE" : "FALSE"); break; case IS_LONG: fprintf(zephir_log, "Long: %ld at %p, refcount=%d\n", Z_LVAL_P(uservar), uservar, Z_REFCOUNT_P(uservar)); break; case IS_DOUBLE: fprintf(zephir_log, "Double: %f\n", Z_DVAL_P(uservar)); break; case IS_STRING: fprintf(zephir_log, "String: %s(%d) at %p, refcount=%d\n", Z_STRVAL_P(uservar), Z_STRLEN_P(uservar), uservar, Z_REFCOUNT_P(uservar)); break; case IS_RESOURCE: fprintf(zephir_log, "Resource\n"); break; case IS_ARRAY: fprintf(zephir_log, "Array at %p, refcount=%d\n", uservar, Z_REFCOUNT_P(uservar)); break; case IS_OBJECT: fprintf(zephir_log, "Object <%s> at %p\n", Z_OBJCE_P(uservar)->name, uservar); break; default: fprintf(zephir_log, "Unknown\n"); } return SUCCESS; } static int zephir_dump_ce(zend_class_entry *ce TSRMLS_DC){ char *message = emalloc(sizeof(char *)*120); if(ce){ sprintf(message, "- ClassType => %d", ce->type); zephir_step_over(message); if(ce->name){ sprintf(message, "- ClassName => %s", ce->name); zephir_step_over(message); } else { zephir_step_over("- ClassName => NULL"); } } else { zephir_step_over("- NULL class entry :("); } return SUCCESS; } static int zephir_class_debug(zval *val TSRMLS_DC){ char *message = emalloc(sizeof(char *)*120); zend_class_entry *ce; if(val){ ce = Z_OBJCE_P(val); if(ce){ sprintf(message, "- MemoryAddress => %p", val); zephir_step_over(message); zephir_dump_ce(ce TSRMLS_CC); } else { zephir_step_over("- No class entry :("); } } else { zephir_step_over("- this_ptr is null :("); } return SUCCESS; } static int zephir_debug_str(char *what, char *message){ fprintf(zephir_log, "%s", what); fprintf(zephir_log, "%s", message); fprintf(zephir_log, "\n"); return SUCCESS; } static int zephir_debug_long(char *what, uint vlong){ fprintf(zephir_log, "%s", what); fprintf(zephir_log, "%u", vlong); fprintf(zephir_log, "\n"); return SUCCESS; } static int zephir_debug_screen(char *message){ zephir_debug_space(); fprintf(zephir_log, "%s\n", message); return SUCCESS; } static int zephir_debug_method_call(zval *obj, char *method_name TSRMLS_DC){ if(Z_TYPE_P(obj)==IS_OBJECT){ zephir_debug_space(); } else { zephir_error_space(); } if(Z_TYPE_P(obj)==IS_OBJECT){ fprintf(zephir_log, "Calling method %s::%s on Object at %p\n", Z_OBJCE_P(obj)->name, method_name, obj); } else { fprintf(zephir_log, "Calling method %s on non object :(\n", method_name); } return SUCCESS; } static int zephir_error_space(){ int i; fprintf(zephir_log, "[ERROR] "); for(i=0;i<zephir_debug_trace;i++){ fprintf(zephir_log, " "); } return SUCCESS; } static int zephir_debug_space(){ int i; fprintf(zephir_log, "[DEBUG] "); for(i=0;i<zephir_debug_trace;i++){ fprintf(zephir_log, " "); } return SUCCESS; } static int zephir_debug_param(zval *param TSRMLS_DC){ zephir_debug_space(); fprintf(zephir_log, "Push method Param > "); zephir_vdump(param TSRMLS_CC); return SUCCESS; } static int zephir_debug_vdump(char *preffix, zval *value TSRMLS_DC){ zephir_debug_space(); fprintf(zephir_log, "%s", preffix); zephir_vdump(value TSRMLS_CC); return SUCCESS; } static int zephir_debug_assign(char *name, zval *value TSRMLS_DC){ zephir_debug_space(); fprintf(zephir_log, "Assign on %s with ", name); zephir_vdump(value TSRMLS_CC); return SUCCESS; } static int zephir_step_over(char *message){ zephir_debug_screen(message); return SUCCESS; } static int zephir_step_into(char *message){ zephir_debug_trace++; zephir_debug_screen(message); return SUCCESS; } static int zephir_step_out(char *message){ zephir_debug_screen(message); zephir_debug_trace--; return SUCCESS; } static int zephir_debug_backtrace_internal(){ int step = 0; char *message; zephir_debug_entry *ptr = active; while(ptr){ zephir_spprintf(&message, 0, "#%d %s::%s", step, ptr->class_name, ptr->method_name); zephir_debug_screen(message); efree(message); ptr = ptr->prev; step++; } return SUCCESS; } static int zephir_step_into_entry(char *class_name, char *method_name, int lineno){ char *message; zephir_debug_entry *entry; if (!start) { start = (zephir_debug_entry *) emalloc(sizeof(zephir_debug_entry)); start->class_name = "__main__"; start->method_name = "__init__"; start->lineno = 0; start->prev = NULL; start->next = NULL; active = start; } zephir_spprintf(&message, 0, "Step Into %s::%s", class_name, method_name); zephir_debug_screen(message); efree(message); entry = emalloc(sizeof(zephir_debug_entry)); entry->class_name = class_name; entry->method_name = method_name; entry->lineno = lineno; entry->prev = active; active->next = entry; active = entry; zephir_debug_trace++; return SUCCESS; } static int zephir_step_out_entry(){ char *message; zephir_debug_entry *prev; if(active){ zephir_debug_trace--; zephir_spprintf(&message, 0, "Step out %s::%s", active->class_name, active->method_name); zephir_debug_screen(message); efree(message); prev = active->prev; efree(active); active = prev; } else { fprintf(zephir_log, "Problem, stack?"); return FAILURE; } return SUCCESS; } #endif #ifndef ZEPHIR_RELEASE #if defined(linux) || defined(DARWIN) || defined(__APPLE__) #include <execinfo.h> #include <Zend/zend.h> #include <ext/standard/php_smart_str.h> void *backtrace_buf[4096]; static void zephir_print_backtrace(void) { int i; int stack_size = backtrace(backtrace_buf, sizeof(backtrace_buf) / sizeof(void*)); char **stack_symbols = backtrace_symbols(backtrace_buf, stack_size); char buf[50]; smart_str s; s.c = NULL; for (i = 0; i < stack_size; ++i) { snprintf(buf, sizeof(buf), "#%d %p [", i, backtrace_buf[i]); smart_str_appends(&s, buf); smart_str_appends(&s, stack_symbols[i]); smart_str_appends(&s, "]\n"); } smart_str_0(&s); fprintf(stderr, "%s\n", s.c); smart_str_free(&s); } #else static void zephir_print_backtrace(void) { } #endif #endif /* ZEPHIR_RELEASE */ #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_closures.h> static int zephir_get_class_constant(zval *return_value, zend_class_entry *ce, char *constant_name, unsigned int constant_length TSRMLS_DC) { zval **result_ptr; if (zephir_hash_find(&ce->constants_table, constant_name, constant_length, (void **) &result_ptr) != SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Undefined class constant '%s::%s'", ce->name, constant_name); return FAILURE; } ZVAL_ZVAL(return_value, *result_ptr, 1, 0); return SUCCESS; } static int zephir_instance_of(zval *result, const zval *object, const zend_class_entry *ce TSRMLS_DC) { if (Z_TYPE_P(object) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "instanceof expects an object instance"); ZVAL_FALSE(result); return FAILURE; } ZVAL_BOOL(result, instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC)); return SUCCESS; } static int zephir_instance_of_ev(const zval *object, const zend_class_entry *ce TSRMLS_DC) { if (Z_TYPE_P(object) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "instanceof expects an object instance"); return 0; } return instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC); } static int zephir_is_instance_of(zval *object, const char *class_name, unsigned int class_length TSRMLS_DC) { zend_class_entry *ce, *temp_ce; if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); if (ce->name_length == class_length) { if (!zend_binary_strcasecmp(ce->name, ce->name_length, class_name, class_length)) { return 1; } } temp_ce = zend_fetch_class(class_name, class_length, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (temp_ce) { return instanceof_function(ce, temp_ce TSRMLS_CC); } } return 0; } static int zephir_zval_is_traversable(zval *object TSRMLS_DC) { zend_class_entry *ce; zend_uint i; if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); if (ce->get_iterator || (ce->parent && ce->parent->get_iterator)) { return 1; } for (i = 0; i < ce->num_interfaces; i++) { if (ce->interfaces[i] == zend_ce_aggregate || ce->interfaces[i] == zend_ce_iterator || ce->interfaces[i] == zend_ce_traversable ) { return 1; } } } return 0; } static void zephir_get_class(zval *result, zval *object, int lower TSRMLS_DC) { zend_class_entry *ce; if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); Z_STRLEN_P(result) = ce->name_length; Z_STRVAL_P(result) = (char *) emalloc(ce->name_length + 1); memcpy(Z_STRVAL_P(result), ce->name, ce->name_length); Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0; Z_TYPE_P(result) = IS_STRING; if (lower) { zend_str_tolower(Z_STRVAL_P(result), Z_STRLEN_P(result)); } } else { ZVAL_NULL(result); php_error_docref(NULL TSRMLS_CC, E_WARNING, "zephir_get_class expects an object"); } } static void zephir_get_class_ns(zval *result, zval *object, int lower TSRMLS_DC) { int found = 0; zend_class_entry *ce; unsigned int i, class_length; const char *cursor, *class_name; if (Z_TYPE_P(object) != IS_OBJECT) { if (Z_TYPE_P(object) != IS_STRING) { ZVAL_NULL(result); php_error_docref(NULL TSRMLS_CC, E_WARNING, "zephir_get_class_ns expects an object"); return; } } if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); class_name = ce->name; class_length = ce->name_length; } else { class_name = Z_STRVAL_P(object); class_length = Z_STRLEN_P(object); } if (!class_length) { ZVAL_NULL(result); return; } i = class_length; cursor = (char *) (class_name + class_length - 1); while (i > 0) { if ((*cursor) == '\\') { found = 1; break; } cursor--; i--; } if (found) { Z_STRLEN_P(result) = class_length - i; Z_STRVAL_P(result) = (char *) emalloc(class_length - i + 1); memcpy(Z_STRVAL_P(result), class_name + i, class_length - i); Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0; Z_TYPE_P(result) = IS_STRING; } else { ZVAL_STRINGL(result, class_name, class_length, 1); } if (lower) { zend_str_tolower(Z_STRVAL_P(result), Z_STRLEN_P(result)); } } static void zephir_get_ns_class(zval *result, zval *object, int lower TSRMLS_DC) { zend_class_entry *ce; int found = 0; unsigned int i, j, class_length; const char *cursor, *class_name; if (Z_TYPE_P(object) != IS_OBJECT) { if (Z_TYPE_P(object) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "zephir_get_ns_class expects an object"); ZVAL_NULL(result); return; } } if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); class_name = ce->name; class_length = ce->name_length; } else { class_name = Z_STRVAL_P(object); class_length = Z_STRLEN_P(object); } if (!class_length) { ZVAL_NULL(result); return; } j = 0; i = class_length; cursor = (char *) (class_name + class_length - 1); while (i > 0) { if ((*cursor) == '\\') { found = 1; break; } cursor--; i--; j++; } if (j > 0) { if (found) { Z_STRLEN_P(result) = class_length - j - 1; Z_STRVAL_P(result) = (char *) emalloc(class_length - j); memcpy(Z_STRVAL_P(result), class_name, class_length - j - 1); Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0; Z_TYPE_P(result) = IS_STRING; } else { ZVAL_EMPTY_STRING(result); } if (lower) { zend_str_tolower(Z_STRVAL_P(result), Z_STRLEN_P(result)); } } else { ZVAL_NULL(result); } } static void zephir_get_called_class(zval *return_value TSRMLS_DC) { if (EG(called_scope)) { RETURN_STRINGL(EG(called_scope)->name, EG(called_scope)->name_length, 1); } if (!EG(scope)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "zephir_get_called_class() called from outside a class"); } } zend_class_entry *zephir_fetch_class(const zval *class_name TSRMLS_DC) { if (Z_TYPE_P(class_name) == IS_STRING) { return zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "class name must be a string"); return zend_fetch_class("stdclass", strlen("stdclass"), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); } zend_class_entry* zephir_fetch_self_class(TSRMLS_D) { return zend_fetch_class(NULL, 0, ZEND_FETCH_CLASS_SELF TSRMLS_CC); } zend_class_entry* zephir_fetch_parent_class(TSRMLS_D) { return zend_fetch_class(NULL, 0, ZEND_FETCH_CLASS_PARENT TSRMLS_CC); } zend_class_entry* zephir_fetch_static_class(TSRMLS_D) { return zend_fetch_class(NULL, 0, ZEND_FETCH_CLASS_STATIC TSRMLS_CC); } static int zephir_class_exists(const zval *class_name, int autoload TSRMLS_DC) { zend_class_entry **ce; if (Z_TYPE_P(class_name) == IS_STRING) { if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &ce TSRMLS_CC) == SUCCESS) { #if PHP_VERSION_ID < 50400 return (((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0); #else return ((*ce)->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0; #endif } return 0; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "class name must be a string"); return 0; } static int zephir_interface_exists(const zval *class_name, int autoload TSRMLS_DC) { zend_class_entry **ce; if (Z_TYPE_P(class_name) == IS_STRING) { if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &ce TSRMLS_CC) == SUCCESS) { return (((*ce)->ce_flags & ZEND_ACC_INTERFACE) > 0); } return 0; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "interface name must be a string"); return 0; } static int zephir_clone(zval *destination, zval *obj TSRMLS_DC) { int status = SUCCESS; zend_class_entry *ce; zend_object_clone_obj_t clone_call; if (Z_TYPE_P(obj) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "__clone method called on non-object"); status = FAILURE; } else { ce = Z_OBJCE_P(obj); clone_call = Z_OBJ_HT_P(obj)->clone_obj; if (!clone_call) { if (ce) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Trying to clone an uncloneable object"); } status = FAILURE; } else { if (!EG(exception)) { Z_OBJVAL_P(destination) = clone_call(obj TSRMLS_CC); Z_TYPE_P(destination) = IS_OBJECT; Z_SET_REFCOUNT_P(destination, 1); Z_UNSET_ISREF_P(destination); if (EG(exception)) { zval_ptr_dtor(&destination); } } } } return status; } static int zephir_isset_property_quick(zval *object, const char *property_name, unsigned int property_length, unsigned long hash TSRMLS_DC) { if (Z_TYPE_P(object) == IS_OBJECT) { if (likely(zephir_hash_quick_exists(&Z_OBJCE_P(object)->properties_info, property_name, property_length, hash))) { return 1; } else { return zephir_hash_quick_exists(Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC), property_name, property_length, hash); } } return 0; } static int zephir_isset_property(zval *object, const char *property_name, unsigned int property_length TSRMLS_DC) { return zephir_isset_property_quick(object, property_name, property_length, zend_inline_hash_func(property_name, property_length) TSRMLS_CC); } static int zephir_isset_property_zval(zval *object, const zval *property TSRMLS_DC) { unsigned long hash; if (Z_TYPE_P(object) == IS_OBJECT) { if (Z_TYPE_P(property) == IS_STRING) { hash = zend_inline_hash_func(Z_STRVAL_P(property), Z_STRLEN_P(property) + 1); if (likely(zephir_hash_quick_exists(&Z_OBJCE_P(object)->properties_info, Z_STRVAL_P(property), Z_STRLEN_P(property) + 1, hash))) { return 1; } else { return zephir_hash_quick_exists(Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC), Z_STRVAL_P(property), Z_STRLEN_P(property) + 1, hash); } } } return 0; } static inline zend_class_entry *zephir_lookup_class_ce_quick(zend_class_entry *ce, const char *property_name, zend_uint property_length, ulong hash TSRMLS_DC) { zend_class_entry *original_ce = ce; while (ce) { if (zephir_hash_quick_exists(&ce->properties_info, property_name, property_length + 1, hash)) { return ce; } ce = ce->parent; } return original_ce; } static inline zend_class_entry *zephir_lookup_class_ce(zend_class_entry *ce, const char *property_name, unsigned int property_length TSRMLS_DC) { return zephir_lookup_class_ce_quick(ce, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC); } static int zephir_read_property(zval **result, zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC) { zval *property; zend_class_entry *ce, *old_scope; if (Z_TYPE_P(object) != IS_OBJECT) { if (silent == PH_NOISY) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name); } ALLOC_INIT_ZVAL(*result); ZVAL_NULL(*result); return FAILURE; } ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce(ce, property_name, property_length TSRMLS_CC); } old_scope = EG(scope); EG(scope) = ce; if (!Z_OBJ_HT_P(object)->read_property) { #if PHP_VERSION_ID < 50400 char *class_name; #else const char *class_name; #endif zend_uint class_name_len; zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC); zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", property_name, class_name); } MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, property_name, property_length, 0); #if PHP_VERSION_ID < 50400 *result = Z_OBJ_HT_P(object)->read_property(object, property, silent ? BP_VAR_IS : BP_VAR_R TSRMLS_CC); #else *result = Z_OBJ_HT_P(object)->read_property(object, property, silent ? BP_VAR_IS : BP_VAR_R, 0 TSRMLS_CC); #endif Z_ADDREF_PP(result); if (Z_REFCOUNT_P(property) > 1) { ZVAL_STRINGL(property, property_name, property_length, 1); } else { ZVAL_NULL(property); } zval_ptr_dtor(&property); EG(scope) = old_scope; return SUCCESS; } zval* zephir_fetch_property_this_quick(zval *object, const char *property_name, zend_uint property_length, ulong key, int silent TSRMLS_DC) { zval **zv = NULL; zend_object *zobj; zend_property_info *property_info; zend_class_entry *ce, *old_scope; if (likely(Z_TYPE_P(object) == IS_OBJECT)) { ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce_quick(ce, property_name, property_length, key TSRMLS_CC); } old_scope = EG(scope); EG(scope) = ce; zobj = zend_objects_get_address(object TSRMLS_CC); if (zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS) { #if PHP_VERSION_ID < 50400 if (zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length + 1, property_info->h, (void **) &zv) == SUCCESS) { EG(scope) = old_scope; return *zv; } #else int flag; if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) { if (zobj->properties) { zv = (zval**) zobj->properties_table[property_info->offset]; flag = (zv == NULL) ? 1 : 0; } else { zv = &zobj->properties_table[property_info->offset]; flag = (*zv == NULL) ? 1 : 0; } } else if (UNEXPECTED(!zobj->properties)) { flag = 1; } else if (UNEXPECTED(zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == FAILURE)) { flag = 2; } else { flag = 0; } if (unlikely(flag) && zobj->properties) { if ( (flag == 2 || zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == FAILURE) && zv && *zv ) { flag = 0; } } if (likely(!flag)) { EG(scope) = old_scope; return *zv; } #endif } EG(scope) = old_scope; } else { if (silent == PH_NOISY) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name); } } return NULL; } static int zephir_return_property_quick(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length, unsigned long key TSRMLS_DC) { zval **zv; zend_object *zobj; zend_property_info *property_info; zend_class_entry *ce, *old_scope; if (likely(Z_TYPE_P(object) == IS_OBJECT)) { ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce_quick(ce, property_name, property_length, key TSRMLS_CC); } old_scope = EG(scope); EG(scope) = ce; zobj = zend_objects_get_address(object TSRMLS_CC); if (zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS) { #if PHP_VERSION_ID < 50400 if (zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == SUCCESS) { EG(scope) = old_scope; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); Z_ADDREF_PP(zv); *return_value_ptr = *zv; } else { ZVAL_ZVAL(return_value, *zv, 1, 0); } return SUCCESS; } #else int flag; if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) { if (zobj->properties) { zv = (zval**) zobj->properties_table[property_info->offset]; flag = (zv == NULL) ? 1 : 0; } else { zv = &zobj->properties_table[property_info->offset]; flag = (*zv == NULL) ? 1 : 0; } } else if (UNEXPECTED(!zobj->properties)) { flag = 1; } else if (UNEXPECTED(zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == FAILURE)) { flag = 2; } else { flag = 0; } if (unlikely(flag) && zobj->properties) { if ( (flag == 2 || zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == FAILURE) && zv && *zv ) { flag = 0; } } if (likely(!flag)) { EG(scope) = old_scope; if (return_value_ptr) { zval_ptr_dtor(return_value_ptr); Z_ADDREF_PP(zv); *return_value_ptr = *zv; } else { ZVAL_ZVAL(return_value, *zv, 1, 0); } return SUCCESS; } #endif } EG(scope) = old_scope; } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name); } ZVAL_NULL(return_value); return FAILURE; } static int zephir_return_property(zval *return_value, zval **return_value_ptr, zval *object, char *property_name, unsigned int property_length TSRMLS_DC) { return zephir_return_property_quick(return_value, return_value_ptr, object, property_name, property_length, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC); } static int zephir_read_property_zval(zval **result, zval *object, zval *property, int flags TSRMLS_DC) { if (unlikely(Z_TYPE_P(property) != IS_STRING)) { if ((flags & PH_NOISY) == PH_NOISY) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot access empty property %d", Z_TYPE_P(property)); } *result = ZEPHIR_GLOBAL(global_null); Z_ADDREF_P(*result); return FAILURE; } return zephir_read_property(result, object, Z_STRVAL_P(property), Z_STRLEN_P(property), flags TSRMLS_CC); } static int zephir_update_property_long(zval *object, char *property_name, unsigned int property_length, long value TSRMLS_DC) { zval *v; ALLOC_ZVAL(v); Z_UNSET_ISREF_P(v); Z_SET_REFCOUNT_P(v, 0); ZVAL_LONG(v, value); return zephir_update_property_zval(object, property_name, property_length, v TSRMLS_CC); } static int zephir_update_property_string(zval *object, char *property_name, unsigned int property_length, char *str, unsigned int str_length TSRMLS_DC) { zval *value; int res; ALLOC_ZVAL(value); Z_UNSET_ISREF_P(value); Z_SET_REFCOUNT_P(value, 0); ZVAL_STRINGL(value, str, str_length, 1); res = zephir_update_property_zval(object, property_name, property_length, value TSRMLS_CC); if (res == SUCCESS) { return SUCCESS; } return FAILURE; } static int zephir_update_property_bool(zval *object, char *property_name, unsigned int property_length, int value TSRMLS_DC) { return zephir_update_property_zval(object, property_name, property_length, value ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } static int zephir_update_property_null(zval *object, char *property_name, unsigned int property_length TSRMLS_DC) { return zephir_update_property_zval(object, property_name, property_length, ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } static int zephir_update_property_zval(zval *object, const char *property_name, unsigned int property_length, zval *value TSRMLS_DC){ zend_class_entry *ce, *old_scope; zval *property; old_scope = EG(scope); if (Z_TYPE_P(object) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to assign property of non-object"); return FAILURE; } ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce(ce, property_name, property_length TSRMLS_CC); } EG(scope) = ce; if (!Z_OBJ_HT_P(object)->write_property) { #if PHP_VERSION_ID < 50400 char *class_name; #else const char *class_name; #endif zend_uint class_name_len; zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC); zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", property_name, class_name); } MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, property_name, property_length, 0); #if PHP_VERSION_ID < 50400 Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC); #else Z_OBJ_HT_P(object)->write_property(object, property, value, 0 TSRMLS_CC); #endif if (Z_REFCOUNT_P(property) > 1) { ZVAL_STRINGL(property, property_name, property_length, 1); } else { ZVAL_NULL(property); } zval_ptr_dtor(&property); EG(scope) = old_scope; return SUCCESS; } static int zephir_update_property_this_quick(zval *object, const char *property_name, zend_uint property_length, zval *value, ulong key TSRMLS_DC){ zend_class_entry *ce, *old_scope; if (unlikely(Z_TYPE_P(object) != IS_OBJECT)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to assign property of non-object"); return FAILURE; } ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce_quick(ce, property_name, property_length, key TSRMLS_CC); } old_scope = EG(scope); EG(scope) = ce; #if PHP_VERSION_ID < 50400 { zval *property; if (!Z_OBJ_HT_P(object)->write_property) { EG(scope) = old_scope; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property %s of class %s cannot be updated", property_name, ce->name); return FAILURE; } MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, property_name, property_length, 0); Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC); if (Z_REFCOUNT_P(property) > 1) { ZVAL_STRINGL(property, property_name, property_length, 1); } else { ZVAL_NULL(property); } zval_ptr_dtor(&property); } #else { zend_object *zobj; zval **variable_ptr; zend_property_info *property_info; zobj = zend_objects_get_address(object TSRMLS_CC); if (likely(zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS)) { assert(property_info != NULL); /** This is as zend_std_write_property, but we're not interesed in validate properties visibility */ if (property_info->offset >= 0 ? (zobj->properties ? ((variable_ptr = (zval**) zobj->properties_table[property_info->offset]) != NULL) : (*(variable_ptr = &zobj->properties_table[property_info->offset]) != NULL)) : (EXPECTED(zobj->properties != NULL) && EXPECTED(zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length + 1, property_info->h, (void **) &variable_ptr) == SUCCESS))) { if (EXPECTED(*variable_ptr != value)) { /* if we are assigning reference, we shouldn't move it, but instead assign variable to the same pointer */ if (PZVAL_IS_REF(*variable_ptr)) { zval garbage = **variable_ptr; /* old value should be destroyed */ /* To check: can't *variable_ptr be some system variable like error_zval here? */ Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value); (*variable_ptr)->value = value->value; if (Z_REFCOUNT_P(value) > 0) { zval_copy_ctor(*variable_ptr); } else { efree(value); } zval_dtor(&garbage); } else { zval *garbage = *variable_ptr; /* if we assign referenced variable, we should separate it */ Z_ADDREF_P(value); if (PZVAL_IS_REF(value)) { SEPARATE_ZVAL(&value); } *variable_ptr = value; zval_ptr_dtor(&garbage); } } } } else { EG(scope) = old_scope; return zephir_update_property_zval(object, property_name, property_length, value TSRMLS_CC); } } #endif EG(scope) = old_scope; return SUCCESS; } static int zephir_update_property_this(zval *object, char *property_name, unsigned int property_length, zval *value TSRMLS_DC) { return zephir_update_property_this_quick(object, property_name, property_length, value, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC); } static int zephir_update_property_zval_zval(zval *object, zval *property, zval *value TSRMLS_DC) { if (Z_TYPE_P(property) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property should be string"); return FAILURE; } return zephir_update_property_zval(object, Z_STRVAL_P(property), Z_STRLEN_P(property), value TSRMLS_CC); } static int zephir_update_property_array(zval *object, const char *property, zend_uint property_length, const zval *index, zval *value TSRMLS_DC) { zval *tmp; int separated = 0; if (Z_TYPE_P(object) == IS_OBJECT) { zephir_read_property(&tmp, object, property, property_length, PH_NOISY TSRMLS_CC); Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } /** Convert the value to array if not is an array */ if (Z_TYPE_P(tmp) != IS_ARRAY) { if (separated) { convert_to_array(tmp); } else { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); array_init(tmp); separated = 1; } } Z_ADDREF_P(value); if (Z_TYPE_P(index) == IS_STRING) { zend_symtable_update(Z_ARRVAL_P(tmp), Z_STRVAL_P(index), Z_STRLEN_P(index) + 1, &value, sizeof(zval*), NULL); } else if (Z_TYPE_P(index) == IS_LONG) { zend_hash_index_update(Z_ARRVAL_P(tmp), Z_LVAL_P(index), &value, sizeof(zval *), NULL); } else if (Z_TYPE_P(index) == IS_NULL) { zend_hash_next_index_insert(Z_ARRVAL_P(tmp), (void**)&value, sizeof(zval*), NULL); } if (separated) { zephir_update_property_zval(object, property, property_length, tmp TSRMLS_CC); } } return SUCCESS; } static int zephir_update_property_array_multi(zval *object, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...) { va_list ap; zval *tmp_arr; int separated = 0; if (Z_TYPE_P(object) == IS_OBJECT) { zephir_read_property(&tmp_arr, object, property, property_length, PH_NOISY TSRMLS_CC); Z_DELREF_P(tmp_arr); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp_arr) > 1) { if (!Z_ISREF_P(tmp_arr)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp_arr); tmp_arr = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp_arr, 0); Z_UNSET_ISREF_P(tmp_arr); separated = 1; } } /** Convert the value to array if not is an array */ if (Z_TYPE_P(tmp_arr) != IS_ARRAY) { if (separated) { convert_to_array(tmp_arr); } else { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp_arr); tmp_arr = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp_arr, 0); Z_UNSET_ISREF_P(tmp_arr); array_init(tmp_arr); separated = 1; } } va_start(ap, types_count); zephir_array_update_multi_ex(&tmp_arr, value, types, types_length, types_count, ap TSRMLS_CC); va_end(ap); if (separated) { zephir_update_property_zval(object, property, property_length, tmp_arr TSRMLS_CC); } } return SUCCESS; } static int zephir_update_property_array_string(zval *object, char *property, unsigned int property_length, char *index, unsigned int index_length, zval *value TSRMLS_DC) { zval *tmp; int separated = 0; if (likely(Z_TYPE_P(object) == IS_OBJECT)) { zephir_read_property(&tmp, object, property, property_length, PH_NOISY_CC); Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } /** Convert the value to array if not is an array */ if (Z_TYPE_P(tmp) != IS_ARRAY) { if (separated) { convert_to_array(tmp); } else { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); array_init(tmp); separated = 1; } } Z_ADDREF_P(value); zend_hash_update(Z_ARRVAL_P(tmp), index, index_length, &value, sizeof(zval *), NULL); if (separated) { zephir_update_property_zval(object, property, property_length, tmp TSRMLS_CC); } } return SUCCESS; } static int zephir_update_property_array_append(zval *object, char *property, unsigned int property_length, zval *value TSRMLS_DC) { zval *tmp; int separated = 0; if (Z_TYPE_P(object) != IS_OBJECT) { return SUCCESS; } zephir_read_property(&tmp, object, property, property_length, PH_NOISY_CC); Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } /** Convert the value to array if not is an array */ if (Z_TYPE_P(tmp) != IS_ARRAY) { if (separated) { convert_to_array(tmp); } else { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); array_init(tmp); separated = 1; } } Z_ADDREF_P(value); add_next_index_zval(tmp, value); if (separated) { zephir_update_property_zval(object, property, property_length, tmp TSRMLS_CC); } return SUCCESS; } static int zephir_update_property_empty_array(zend_class_entry *ce, zval *object, char *property_name, unsigned int property_length TSRMLS_DC) { zval *empty_array; int res; ALLOC_INIT_ZVAL(empty_array); array_init(empty_array); res = zephir_update_property_zval(object, property_name, property_length, empty_array TSRMLS_CC); zval_ptr_dtor(&empty_array); return res; } static int zephir_unset_property(zval* object, const char* name TSRMLS_DC) { if (Z_TYPE_P(object) == IS_OBJECT) { zval member; zend_class_entry *old_scope; INIT_PZVAL(&member); ZVAL_STRING(&member, name, 0); old_scope = EG(scope); EG(scope) = Z_OBJCE_P(object); #if PHP_VERSION_ID < 50400 Z_OBJ_HT_P(object)->unset_property(object, &member TSRMLS_CC); #else Z_OBJ_HT_P(object)->unset_property(object, &member, 0 TSRMLS_CC); #endif EG(scope) = old_scope; return SUCCESS; } return FAILURE; } static int zephir_unset_property_array(zval *object, char *property, unsigned int property_length, zval *index TSRMLS_DC) { zval *tmp; int separated = 0; if (Z_TYPE_P(object) == IS_OBJECT) { zephir_read_property(&tmp, object, property, property_length, PH_NOISY_CC); Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } zephir_array_unset(&tmp, index, PH_SEPARATE); if (separated) { zephir_update_property_zval(object, property, property_length, tmp TSRMLS_CC); } } return SUCCESS; } static int zephir_method_exists(const zval *object, const zval *method_name TSRMLS_DC){ char *lcname = zend_str_tolower_dup(Z_STRVAL_P(method_name), Z_STRLEN_P(method_name)); int res = zephir_method_exists_ex(object, lcname, Z_STRLEN_P(method_name) + 1 TSRMLS_CC); efree(lcname); return res; } static int zephir_method_exists_ex(const zval *object, const char *method_name, unsigned int method_len TSRMLS_DC){ return zephir_method_quick_exists_ex(object, method_name, method_len, zend_inline_hash_func(method_name, method_len) TSRMLS_CC); } static int zephir_method_quick_exists_ex(const zval *object, const char *method_name, unsigned int method_len, unsigned long hash TSRMLS_DC){ zend_class_entry *ce; if (likely(Z_TYPE_P(object) == IS_OBJECT)) { ce = Z_OBJCE_P(object); } else { if (Z_TYPE_P(object) == IS_STRING) { ce = zend_fetch_class(Z_STRVAL_P(object), Z_STRLEN_P(object), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); } else { return FAILURE; } } while (ce) { if (zephir_hash_quick_exists(&ce->function_table, method_name, method_len, hash)) { return SUCCESS; } ce = ce->parent; } return FAILURE; } zval* zephir_fetch_static_property_ce(zend_class_entry *ce, const char *property, int len TSRMLS_DC) { assert(ce != NULL); return zend_read_static_property(ce, property, len, (zend_bool) ZEND_FETCH_CLASS_SILENT TSRMLS_CC); } static int zephir_read_static_property_ce(zval **result, zend_class_entry *ce, const char *property, int len TSRMLS_DC) { zval *tmp; tmp = zephir_fetch_static_property_ce(ce, property, len TSRMLS_CC); if (tmp) { if (!Z_ISREF_P(tmp)) { *result = tmp; Z_ADDREF_PP(result); } else { ALLOC_INIT_ZVAL(*result); ZVAL_ZVAL(*result, tmp, 1, 0); } return SUCCESS; } ALLOC_INIT_ZVAL(*result); return FAILURE; } #if PHP_VERSION_ID >= 50400 static zval **zephir_std_get_static_property(zend_class_entry *ce, const char *property_name, int property_name_len, ulong hash_value, zend_bool silent, zend_property_info ** property_info TSRMLS_DC) { zend_property_info *temp_property_info; if (!hash_value) { hash_value = zend_hash_func(property_name, property_name_len + 1); } if (!property_info || !*property_info) { if (UNEXPECTED(zend_hash_quick_find(&ce->properties_info, property_name, property_name_len + 1, hash_value, (void **) &temp_property_info)==FAILURE)) { if (!silent) { zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name); } return NULL; } #ifndef ZEPHIR_RELEASE /*if (UNEXPECTED(!zend_verify_property_access(temp_property_info, ce TSRMLS_CC))) { if (!silent) { zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(temp_property_info->flags), ce->name, property_name); } return NULL; } if (UNEXPECTED((temp_property_info->flags & ZEND_ACC_STATIC) == 0)) { if (!silent) { zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name); } return NULL; }*/ #endif zend_update_class_constants(ce TSRMLS_CC); if (property_info) { *property_info = temp_property_info; } } else { temp_property_info = *property_info; } if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL) || UNEXPECTED(CE_STATIC_MEMBERS(ce)[temp_property_info->offset] == NULL)) { if (!silent) { zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name); } return NULL; } return &CE_STATIC_MEMBERS(ce)[temp_property_info->offset]; } #endif static int zephir_update_static_property_ex(zend_class_entry *scope, const char *name, int name_length, zval **value, zend_property_info **property_info TSRMLS_DC) { zval **property; zval *tmp, **safe_value; zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; zend_class_entry *old_scope = EG(scope); if (*value == zephir_globals_ptr->global_null) { ALLOC_ZVAL(tmp); Z_UNSET_ISREF_P(tmp); Z_SET_REFCOUNT_P(tmp, 0); ZVAL_NULL(tmp); safe_value = &tmp; } else { if (*value == zephir_globals_ptr->global_true) { ALLOC_ZVAL(tmp); Z_UNSET_ISREF_P(tmp); Z_SET_REFCOUNT_P(tmp, 0); ZVAL_BOOL(tmp, 1); safe_value = &tmp; } else { if (*value == zephir_globals_ptr->global_false) { ALLOC_ZVAL(tmp); Z_UNSET_ISREF_P(tmp); Z_SET_REFCOUNT_P(tmp, 0); ZVAL_BOOL(tmp, 0); safe_value = &tmp; } else { safe_value = value; } } } EG(scope) = scope; #if PHP_VERSION_ID < 50400 property = zend_std_get_static_property(scope, name, name_length, 0 TSRMLS_CC); #else property = zephir_std_get_static_property(scope, name, name_length, zend_inline_hash_func(name, name_length + 1), 0, property_info TSRMLS_CC); #endif EG(scope) = old_scope; if (!property) { return FAILURE; } else { if (*property != *safe_value) { if (PZVAL_IS_REF(*property)) { zval_dtor(*property); Z_TYPE_PP(property) = Z_TYPE_PP(safe_value); (*property)->value = (*safe_value)->value; if (Z_REFCOUNT_PP(safe_value) > 0) { zval_copy_ctor(*property); } else { efree(*safe_value); *safe_value = NULL; } } else { zval *garbage = *property; Z_ADDREF_PP(safe_value); if (Z_ISREF_PP(safe_value)) { SEPARATE_ZVAL(safe_value); } *property = *safe_value; zval_ptr_dtor(&garbage); } } return SUCCESS; } } static int zephir_read_static_property(zval **result, const char *class_name, unsigned int class_length, char *property_name, unsigned int property_length TSRMLS_DC) { zend_class_entry **ce; if (zend_lookup_class(class_name, class_length, &ce TSRMLS_CC) == SUCCESS) { return zephir_read_static_property_ce(result, *ce, property_name, property_length TSRMLS_CC); } return FAILURE; } static int zephir_update_static_property_ce(zend_class_entry *ce, const char *name, int len, zval **value TSRMLS_DC) { assert(ce != NULL); return zephir_update_static_property_ex(ce, name, len, value, NULL TSRMLS_CC); } static int zephir_update_static_property_ce_cache(zend_class_entry *ce, const char *name, int len, zval **value, zend_property_info **property_info TSRMLS_DC) { assert(ce != NULL); return zephir_update_static_property_ex(ce, name, len, value, property_info TSRMLS_CC); } static int zephir_update_static_property_array_multi_ce(zend_class_entry *ce, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...) { va_list ap; zval *tmp_arr; int separated = 0; tmp_arr = zephir_fetch_static_property_ce(ce, property, property_length TSRMLS_CC); if (!tmp_arr) { ALLOC_INIT_ZVAL(tmp_arr); array_init(tmp_arr); separated = 1; } /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp_arr) > 1) { if (!Z_ISREF_P(tmp_arr)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp_arr); tmp_arr = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp_arr, 0); Z_UNSET_ISREF_P(tmp_arr); separated = 1; } } /** Convert the value to array if not is an array */ if (Z_TYPE_P(tmp_arr) != IS_ARRAY) { if (separated) { convert_to_array(tmp_arr); } else { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp_arr); tmp_arr = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp_arr, 0); Z_UNSET_ISREF_P(tmp_arr); array_init(tmp_arr); separated = 1; } } va_start(ap, types_count); zephir_array_update_multi_ex(&tmp_arr, value, types, types_length, types_count, ap TSRMLS_CC); va_end(ap); if (separated) { zephir_update_static_property_ce(ce, property, property_length, &tmp_arr TSRMLS_CC); } return SUCCESS; } static int zephir_update_static_property(const char *class_name, unsigned int class_length, char *name, unsigned int name_length, zval **value TSRMLS_DC){ zend_class_entry **ce; if (zend_lookup_class(class_name, class_length, &ce TSRMLS_CC) == SUCCESS) { return zephir_update_static_property_ce(*ce, name, name_length, value TSRMLS_CC); } return FAILURE; } static int zephir_read_class_property(zval **result, int type, const char *property, int len TSRMLS_DC) { zend_class_entry *ce; type |= (ZEND_FETCH_CLASS_SILENT | ZEND_FETCH_CLASS_NO_AUTOLOAD); type &= ZEND_FETCH_CLASS_MASK; ce = zend_fetch_class(NULL, 0, type TSRMLS_CC); if (likely(ce != NULL)) { return zephir_read_static_property_ce(result, ce, property, len TSRMLS_CC); } return FAILURE; } static int zephir_create_instance(zval *return_value, const zval *class_name TSRMLS_DC){ zend_class_entry *ce; if (Z_TYPE_P(class_name) != IS_STRING) { zephir_throw_exception_string(spl_ce_RuntimeException, SL("Invalid class name") TSRMLS_CC); return FAILURE; } ce = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (!ce) { ZVAL_NULL(return_value); return FAILURE; } object_init_ex(return_value, ce); if (zephir_has_constructor_ce(ce)) { return zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, 0, 0, NULL TSRMLS_CC); } return SUCCESS; } static int zephir_create_instance_params(zval *return_value, const zval *class_name, zval *params TSRMLS_DC){ int outcome; zend_class_entry *ce; if (Z_TYPE_P(class_name) != IS_STRING) { zephir_throw_exception_string(spl_ce_RuntimeException, SL("Invalid class name") TSRMLS_CC); return FAILURE; } if (Z_TYPE_P(params) != IS_ARRAY) { zephir_throw_exception_string(spl_ce_RuntimeException, SL("Instantiation parameters must be an array") TSRMLS_CC); return FAILURE; } ce = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (!ce) { ZVAL_NULL(return_value); return FAILURE; } object_init_ex(return_value, ce); outcome = SUCCESS; if (zephir_has_constructor_ce(ce)) { int param_count = zend_hash_num_elements(Z_ARRVAL_P(params)); zval *static_params[10]; zval **params_ptr, **params_arr = NULL; if (param_count > 0) { HashPosition pos; zval **item; int i = 0; if (likely(param_count) <= 10) { params_ptr = static_params; } else { params_arr = emalloc(param_count * sizeof(zval*)); params_ptr = ¶ms; } for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(params), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_P(params), (void**) &item, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(params), &pos), ++i ) { params_ptr[i] = *item; } } else { params_ptr = NULL; } outcome = zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, 0, param_count, params_ptr TSRMLS_CC); if (unlikely(params_arr != NULL)) { efree(params_arr); } } return outcome; } static int zephir_property_incr(zval *object, char *property_name, unsigned int property_length TSRMLS_DC){ zval *tmp = NULL; zend_class_entry *ce; int separated = 0; if (Z_TYPE_P(object) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to assign property of non-object"); return FAILURE; } ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce(ce, property_name, property_length TSRMLS_CC); } zephir_read_property(&tmp, object, property_name, property_length, 0 TSRMLS_CC); if (tmp) { Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } zephir_increment(tmp); if (separated) { zephir_update_property_zval(object, property_name, property_length, tmp TSRMLS_CC); } } return SUCCESS; } static int zephir_property_decr(zval *object, char *property_name, unsigned int property_length TSRMLS_DC){ zval *tmp = NULL; zend_class_entry *ce; int separated = 0; if (Z_TYPE_P(object) != IS_OBJECT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to assign property of non-object"); return FAILURE; } ce = Z_OBJCE_P(object); if (ce->parent) { ce = zephir_lookup_class_ce(ce, property_name, property_length TSRMLS_CC); } zephir_read_property(&tmp, object, property_name, property_length, 0 TSRMLS_CC); if (tmp) { Z_DELREF_P(tmp); /** Separation only when refcount > 1 */ if (Z_REFCOUNT_P(tmp) > 1) { if (!Z_ISREF_P(tmp)) { zval *new_zv; ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, tmp); tmp = new_zv; zval_copy_ctor(new_zv); Z_SET_REFCOUNT_P(tmp, 0); Z_UNSET_ISREF_P(tmp); separated = 1; } } zephir_decrement(tmp); if (separated) { zephir_update_property_zval(object, property_name, property_length, tmp TSRMLS_CC); } } return SUCCESS; } static int zephir_fetch_property(zval **result, zval *object, const char *property_name, zend_uint property_length, int silent TSRMLS_DC) { if (zephir_isset_property(object, property_name, property_length + 1 TSRMLS_CC)) { zephir_read_property(result, object, property_name, property_length, 0 TSRMLS_CC); return 1; } *result = ZEPHIR_GLOBAL(global_null); Z_ADDREF_P(*result); return 0; } static int zephir_fetch_property_zval(zval **result, zval *object, zval *property, int silent TSRMLS_DC) { if (unlikely(Z_TYPE_P(property) != IS_STRING)) { *result = ZEPHIR_GLOBAL(global_null); Z_ADDREF_P(*result); return 0; } if (zephir_isset_property(object, Z_STRVAL_P(property), Z_STRLEN_P(property) + 1 TSRMLS_CC)) { zephir_read_property(result, object, Z_STRVAL_P(property), Z_STRLEN_P(property), 0 TSRMLS_CC); return 1; } *result = ZEPHIR_GLOBAL(global_null); Z_ADDREF_P(*result); return 0; } static int zephir_create_closure_ex(zval *return_value, zval *this_ptr, zend_class_entry *ce, const char *method_name, zend_uint method_length TSRMLS_DC) { zend_function *function_ptr; if (zend_hash_find(&ce->function_table, method_name, method_length, (void**) &function_ptr) == FAILURE) { ZVAL_NULL(return_value); return FAILURE; } #if PHP_VERSION_ID < 50400 zend_create_closure(return_value, function_ptr TSRMLS_CC); #else zend_create_closure(return_value, function_ptr, ce, this_ptr TSRMLS_CC); #endif return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <ext/standard/php_array.h> #include <Zend/zend_hash.h> static int zephir_array_isset_fetch(zval **fetched, const zval *arr, zval *index, int readonly TSRMLS_DC) { HashTable *h; zval **val; int result; if (Z_TYPE_P(arr) != IS_ARRAY) { *fetched = ZEPHIR_GLOBAL(global_null); if (!readonly) { Z_ADDREF_P(*fetched); } return 0; } h = Z_ARRVAL_P(arr); switch (Z_TYPE_P(index)) { case IS_NULL: result = zephir_hash_find(h, SS(""), (void**)&val); break; case IS_DOUBLE: result = zend_hash_index_find(h, (ulong)Z_DVAL_P(index), (void**)&val); break; case IS_LONG: case IS_BOOL: case IS_RESOURCE: result = zend_hash_index_find(h, Z_LVAL_P(index), (void**)&val); break; case IS_STRING: result = zend_symtable_find(h, (Z_STRLEN_P(index) ? Z_STRVAL_P(index) : ""), Z_STRLEN_P(index)+1, (void**)&val); break; default: zend_error(E_WARNING, "Illegal offset type"); *fetched = ZEPHIR_GLOBAL(global_null); if (!readonly) { Z_ADDREF_P(*fetched); } return 0; } if (result == SUCCESS) { *fetched = *val; if (!readonly) { Z_ADDREF_P(*fetched); } return 1; } *fetched = ZEPHIR_GLOBAL(global_null); if (!readonly) { Z_ADDREF_P(*fetched); } return 0; } static int zephir_array_isset_quick_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, unsigned long key, int readonly TSRMLS_DC) { zval **zv; if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { if (zephir_hash_quick_find(Z_ARRVAL_P(arr), index, index_length, key, (void**) &zv) == SUCCESS) { *fetched = *zv; if (!readonly) { Z_ADDREF_P(*fetched); } return 1; } } *fetched = ZEPHIR_GLOBAL(global_null); if (!readonly) { Z_ADDREF_P(*fetched); } return 0; } static int zephir_array_isset_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, int readonly TSRMLS_DC) { return zephir_array_isset_quick_string_fetch(fetched, arr, index, index_length, zend_inline_hash_func(index, index_length), readonly TSRMLS_CC); } static int zephir_array_isset_long_fetch(zval **fetched, zval *arr, unsigned long index, int readonly TSRMLS_DC) { zval **zv; if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { if (zend_hash_index_find(Z_ARRVAL_P(arr), index, (void**)&zv) == SUCCESS) { *fetched = *zv; if (!readonly) { Z_ADDREF_P(*fetched); } return 1; } } *fetched = ZEPHIR_GLOBAL(global_null); if (!readonly) { Z_ADDREF_P(*fetched); } return 0; } static int ZEPHIR_FASTCALL zephir_array_isset(const zval *arr, zval *index) { HashTable *h; if (Z_TYPE_P(arr) != IS_ARRAY) { return 0; } h = Z_ARRVAL_P(arr); switch (Z_TYPE_P(index)) { case IS_NULL: return zephir_hash_exists(h, SS("")); case IS_DOUBLE: return zend_hash_index_exists(h, (ulong)Z_DVAL_P(index)); case IS_BOOL: case IS_LONG: case IS_RESOURCE: return zend_hash_index_exists(h, Z_LVAL_P(index)); case IS_STRING: return zend_symtable_exists(h, Z_STRVAL_P(index), Z_STRLEN_P(index)+1); default: zend_error(E_WARNING, "Illegal offset type"); return 0; } } static int ZEPHIR_FASTCALL zephir_array_isset_string(const zval *arr, const char *index, uint index_length) { return zephir_array_isset_quick_string(arr, index, index_length, zend_inline_hash_func(index, index_length)); } static int ZEPHIR_FASTCALL zephir_array_isset_quick_string(const zval *arr, const char *index, uint index_length, unsigned long key) { if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { return zend_hash_quick_exists(Z_ARRVAL_P(arr), index, index_length, key); } return 0; } static int ZEPHIR_FASTCALL zephir_array_isset_long(const zval *arr, unsigned long index) { if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { return zend_hash_index_exists(Z_ARRVAL_P(arr), index); } return 0; } static int ZEPHIR_FASTCALL zephir_array_unset(zval **arr, zval *index, int flags) { HashTable *ht; if (Z_TYPE_PP(arr) != IS_ARRAY) { return FAILURE; } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } ht = Z_ARRVAL_PP(arr); switch (Z_TYPE_P(index)) { case IS_NULL: return (zend_hash_del(ht, "", 1) == SUCCESS); case IS_DOUBLE: return (zend_hash_index_del(ht, (ulong)Z_DVAL_P(index)) == SUCCESS); case IS_LONG: case IS_BOOL: case IS_RESOURCE: return (zend_hash_index_del(ht, Z_LVAL_P(index)) == SUCCESS); case IS_STRING: return (zend_symtable_del(ht, Z_STRVAL_P(index), Z_STRLEN_P(index)+1) == SUCCESS); default: zend_error(E_WARNING, "Illegal offset type"); return 0; } } static int ZEPHIR_FASTCALL zephir_array_unset_string(zval **arr, const char *index, uint index_length, int flags) { if (Z_TYPE_PP(arr) != IS_ARRAY) { return 0; } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } return zend_hash_del(Z_ARRVAL_PP(arr), index, index_length); } static int ZEPHIR_FASTCALL zephir_array_unset_long(zval **arr, unsigned long index, int flags) { if (Z_TYPE_PP(arr) != IS_ARRAY) { return 0; } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } return zend_hash_index_del(Z_ARRVAL_PP(arr), index); } static int zephir_array_append(zval **arr, zval *value, int flags ZEPHIR_DEBUG_PARAMS) { if (Z_TYPE_PP(arr) != IS_ARRAY) { zend_error(E_WARNING, "Cannot use a scalar value as an array in %s on line %d", file, line); return FAILURE; } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } Z_ADDREF_P(value); return add_next_index_zval(*arr, value); } static int zephir_array_append_long(zval **arr, long value, int separate) { zval *zvalue; ALLOC_INIT_ZVAL(zvalue); Z_SET_REFCOUNT_P(zvalue, 0); ZVAL_LONG(zvalue, value); return zephir_array_append(arr, zvalue, separate ZEPHIR_DEBUG_PARAMS_DUMMY); } static int zephir_array_append_string(zval **arr, char *value, uint value_length, int separate) { zval *zvalue; ALLOC_INIT_ZVAL(zvalue); Z_SET_REFCOUNT_P(zvalue, 0); ZVAL_STRINGL(zvalue, value, value_length, 1); return zephir_array_append(arr, zvalue, separate ZEPHIR_DEBUG_PARAMS_DUMMY); } static int zephir_array_update_zval(zval **arr, zval *index, zval **value, int flags) { HashTable *ht; if (Z_TYPE_PP(arr) != IS_ARRAY) { zend_error(E_WARNING, "Cannot use a scalar value as an array (2)"); return FAILURE; } if ((flags & PH_CTOR) == PH_CTOR) { zval *new_zv; Z_DELREF_PP(value); ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, *value); *value = new_zv; zval_copy_ctor(new_zv); } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } if ((flags & PH_COPY) == PH_COPY) { Z_ADDREF_PP(value); } ht = Z_ARRVAL_PP(arr); switch (Z_TYPE_P(index)) { case IS_NULL: return zend_symtable_update(ht, "", 1, value, sizeof(zval*), NULL); case IS_DOUBLE: return zend_hash_index_update(ht, (ulong)Z_DVAL_P(index), value, sizeof(zval*), NULL); case IS_LONG: case IS_BOOL: case IS_RESOURCE: return zend_hash_index_update(ht, Z_LVAL_P(index), value, sizeof(zval*), NULL); case IS_STRING: return zend_symtable_update(ht, Z_STRVAL_P(index), Z_STRLEN_P(index)+1, value, sizeof(zval*), NULL); default: zend_error(E_WARNING, "Illegal offset type"); return FAILURE; } } static int zephir_array_update_zval_bool(zval **arr, zval *index, int value, int flags) { zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_BOOL(zvalue, value); return zephir_array_update_zval(arr, index, &zvalue, flags); } static int zephir_array_update_zval_string(zval **arr, zval *index, char *value, uint value_length, int flags) { zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_STRINGL(zvalue, value, value_length, 1); return zephir_array_update_zval(arr, index, &zvalue, flags); } static int zephir_array_update_zval_long(zval **arr, zval *index, long value, int flags) { zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_LONG(zvalue, value); return zephir_array_update_zval(arr, index, &zvalue, flags); } static int zephir_array_update_quick_string(zval **arr, const char *index, uint index_length, unsigned long key, zval **value, int flags){ if (Z_TYPE_PP(arr) != IS_ARRAY) { zend_error(E_WARNING, "Cannot use a scalar value as an array (3)"); return FAILURE; } if ((flags & PH_CTOR) == PH_CTOR) { zval *new_zv; Z_DELREF_PP(value); ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, *value); *value = new_zv; zval_copy_ctor(new_zv); } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } if ((flags & PH_COPY) == PH_COPY) { Z_ADDREF_PP(value); } return zend_hash_quick_update(Z_ARRVAL_PP(arr), index, index_length, key, value, sizeof(zval *), NULL); } static int zephir_array_update_string(zval **arr, const char *index, uint index_length, zval **value, int flags) { return zephir_array_update_quick_string(arr, index, index_length + 1, zend_inline_hash_func(index, index_length + 1), value, flags); } static int zephir_array_update_string_bool(zval **arr, const char *index, uint index_length, int value, int flags){ zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_BOOL(zvalue, value); return zephir_array_update_string(arr, index, index_length, &zvalue, flags); } static int zephir_array_update_string_long(zval **arr, const char *index, uint index_length, long value, int flags){ zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_LONG(zvalue, value); return zephir_array_update_string(arr, index, index_length, &zvalue, flags); } static int zephir_array_update_string_string(zval **arr, const char *index, uint index_length, char *value, uint value_length, int flags){ zval *zvalue; ALLOC_INIT_ZVAL(zvalue); ZVAL_STRINGL(zvalue, value, value_length, 1); return zephir_array_update_string(arr, index, index_length, &zvalue, flags); } static int zephir_array_update_long(zval **arr, unsigned long index, zval **value, int flags ZEPHIR_DEBUG_PARAMS){ if (Z_TYPE_PP(arr) != IS_ARRAY) { zend_error(E_WARNING, "Cannot use a scalar value as an array in %s on line %d", file, line); return FAILURE; } if ((flags & PH_CTOR) == PH_CTOR) { zval *new_zv; Z_DELREF_PP(value); ALLOC_ZVAL(new_zv); INIT_PZVAL_COPY(new_zv, *value); *value = new_zv; zval_copy_ctor(new_zv); } if ((flags & PH_SEPARATE) == PH_SEPARATE) { SEPARATE_ZVAL_IF_NOT_REF(arr); } if ((flags & PH_COPY) == PH_COPY) { Z_ADDREF_PP(value); } return zend_hash_index_update(Z_ARRVAL_PP(arr), index, value, sizeof(zval *), NULL); } static int zephir_array_fetch(zval **return_value, zval *arr, zval *index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC){ zval **zv; HashTable *ht; int result; ulong uidx = 0; char *sidx = NULL; if (Z_TYPE_P(arr) == IS_ARRAY) { ht = Z_ARRVAL_P(arr); switch (Z_TYPE_P(index)) { case IS_NULL: result = zephir_hash_find(ht, SS(""), (void**) &zv); sidx = ""; break; case IS_DOUBLE: uidx = (ulong)Z_DVAL_P(index); result = zend_hash_index_find(ht, uidx, (void**) &zv); break; case IS_LONG: case IS_BOOL: case IS_RESOURCE: uidx = Z_LVAL_P(index); result = zend_hash_index_find(ht, uidx, (void**) &zv); break; case IS_STRING: sidx = Z_STRLEN_P(index) ? Z_STRVAL_P(index) : ""; result = zend_symtable_find(ht, Z_STRVAL_P(index), Z_STRLEN_P(index)+1, (void**) &zv); break; default: if ((flags & PH_NOISY) == PH_NOISY) { zend_error(E_WARNING, "Illegal offset type in %s on line %d", file, line); } result = FAILURE; break; } if (result != FAILURE) { *return_value = *zv; if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return SUCCESS; } if ((flags & PH_NOISY) == PH_NOISY) { if (sidx == NULL) { zend_error(E_NOTICE, "Undefined index: %ld in %s on line %d", uidx, file, line); } else { zend_error(E_NOTICE, "Undefined index: %s in %s on line %d", sidx, file, line); } } } *return_value = ZEPHIR_GLOBAL(global_null); if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return FAILURE; } static int zephir_array_fetch_quick_string(zval **return_value, zval *arr, const char *index, uint index_length, unsigned long key, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC){ zval **zv; if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { if (zephir_hash_quick_find(Z_ARRVAL_P(arr), index, index_length, key, (void**) &zv) == SUCCESS) { *return_value = *zv; if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return SUCCESS; } if ((flags & PH_NOISY) == PH_NOISY) { zend_error(E_NOTICE, "Undefined index: %s", index); } } else { if ((flags & PH_NOISY) == PH_NOISY) { zend_error(E_NOTICE, "Cannot use a scalar value as an array in %s on line %d", file, line); } } *return_value = ZEPHIR_GLOBAL(global_null); if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return FAILURE; } static int zephir_array_fetch_string(zval **return_value, zval *arr, const char *index, uint index_length, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC){ return zephir_array_fetch_quick_string(return_value, arr, index, index_length + 1, zend_inline_hash_func(index, index_length + 1), flags, file, line TSRMLS_CC); } static int zephir_array_fetch_long(zval **return_value, zval *arr, unsigned long index, int flags ZEPHIR_DEBUG_PARAMS TSRMLS_DC){ zval **zv; if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { if (zend_hash_index_find(Z_ARRVAL_P(arr), index, (void**)&zv) == SUCCESS) { *return_value = *zv; if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return SUCCESS; } if ((flags & PH_NOISY) == PH_NOISY) { zend_error(E_NOTICE, "Undefined index: %lu in %s on line %d", index, file, line); } } else { if ((flags & PH_NOISY) == PH_NOISY) { zend_error(E_NOTICE, "Cannot use a scalar value as an array in %s on line %d", file, line); } } *return_value = ZEPHIR_GLOBAL(global_null); if ((flags & PH_READONLY) != PH_READONLY) { Z_ADDREF_PP(return_value); } return FAILURE; } static void zephir_merge_append(zval *left, zval *values){ zval **tmp; HashTable *arr_values; HashPosition pos; if (Z_TYPE_P(left) != IS_ARRAY) { zend_error(E_NOTICE, "First parameter of zephir_merge_append must be an array"); return; } if (Z_TYPE_P(values) == IS_ARRAY) { arr_values = Z_ARRVAL_P(values); zend_hash_internal_pointer_reset_ex(arr_values, &pos); while (zend_hash_get_current_data_ex(arr_values, (void **) &tmp, &pos) == SUCCESS) { Z_ADDREF_PP(tmp); add_next_index_zval(left, *tmp); zend_hash_move_forward_ex(arr_values, &pos); } } else { Z_ADDREF_P(values); add_next_index_zval(left, values); } } static void zephir_array_get_current(zval *return_value, zval *array){ zval **entry; if (Z_TYPE_P(array) == IS_ARRAY) { if (zend_hash_get_current_data(Z_ARRVAL_P(array), (void **) &entry) == FAILURE) { RETURN_FALSE; } RETURN_ZVAL(*entry, 1, 0); } RETURN_FALSE; } static void zephir_array_next(zval *array){ if (Z_TYPE_P(array) == IS_ARRAY) { zend_hash_move_forward(Z_ARRVAL_P(array)); } } static int zephir_fast_in_array(zval *needle, zval *haystack TSRMLS_DC) { zval **tmp; HashTable *arr; HashPosition pos; unsigned int numelems; if (Z_TYPE_P(haystack) != IS_ARRAY) { return 0; } arr = Z_ARRVAL_P(haystack); numelems = zend_hash_num_elements(arr); if (numelems == 0) { return 0; } zend_hash_internal_pointer_reset_ex(arr, &pos); while (zend_hash_get_current_data_ex(arr, (void **) &tmp, &pos) == SUCCESS) { if (ZEPHIR_IS_EQUAL(needle, *tmp)) { return 1; } zend_hash_move_forward_ex(arr, &pos); } return 0; } static void zephir_fast_array_merge(zval *return_value, zval **array1, zval **array2 TSRMLS_DC) { int init_size, num; if (Z_TYPE_PP(array1) != IS_ARRAY) { zend_error(E_WARNING, "First argument is not an array"); RETURN_NULL(); } if (Z_TYPE_PP(array2) != IS_ARRAY) { zend_error(E_WARNING, "Second argument is not an array"); RETURN_NULL(); } init_size = zend_hash_num_elements(Z_ARRVAL_PP(array1)); num = zend_hash_num_elements(Z_ARRVAL_PP(array2)); if (num > init_size) { init_size = num; } array_init_size(return_value, init_size); php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(array1), 0 TSRMLS_CC); php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(array2), 0 TSRMLS_CC); } static void zephir_array_merge_recursive_n(zval **a1, zval *a2 TSRMLS_DC) { HashPosition hp; zval **value, key, *tmp1, *tmp2; assert(Z_TYPE_PP(a1) == IS_ARRAY); assert(Z_TYPE_P(a2) == IS_ARRAY); for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(a2), &hp); zend_hash_get_current_data_ex(Z_ARRVAL_P(a2), (void**) &value, &hp) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(a2), &hp) ) { key = zephir_get_current_key_w(Z_ARRVAL_P(a2), &hp); if (!zephir_array_isset(*a1, &key) || Z_TYPE_PP(value) != IS_ARRAY) { zephir_array_update_zval(a1, &key, value, PH_COPY | PH_SEPARATE); } else { zephir_array_fetch(&tmp1, *a1, &key, PH_NOISY ZEPHIR_DEBUG_PARAMS_DUMMY TSRMLS_CC); zephir_array_fetch(&tmp2, a2, &key, PH_NOISY ZEPHIR_DEBUG_PARAMS_DUMMY TSRMLS_CC); zephir_array_merge_recursive_n(&tmp1, tmp2 TSRMLS_CC); zval_ptr_dtor(&tmp1); zval_ptr_dtor(&tmp2); } } } static void zephir_array_unshift(zval *arr, zval *arg TSRMLS_DC) { if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { zval** args[1] = { &arg }; #if PHP_VERSION_ID < 50600 HashTable oldhash; HashTable *newhash = Z_ARRVAL_P(arr); newhash = php_splice(newhash, 0, 0, args, 1, NULL); oldhash = *Z_ARRVAL_P(arr); if (Z_ARRVAL_P(arr) == &EG(symbol_table)) { zend_reset_all_cv(&EG(symbol_table) TSRMLS_CC); } *Z_ARRVAL_P(arr) = *newhash; FREE_HASHTABLE(newhash); zend_hash_destroy(&oldhash); #else php_splice(Z_ARRVAL_P(arr), 0, 0, args, 1, NULL TSRMLS_CC); #endif } } static void zephir_array_keys(zval *return_value, zval *input TSRMLS_DC) { zval *new_val, **entry; char *string_key; uint string_key_len; ulong num_key; HashPosition pos; if (likely(Z_TYPE_P(input) == IS_ARRAY)) { array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(input))); /* Go through input array and add keys to the return array */ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(input), (void **)&entry, &pos) == SUCCESS) { MAKE_STD_ZVAL(new_val); switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 1, &pos)) { case HASH_KEY_IS_STRING: ZVAL_STRINGL(new_val, string_key, string_key_len - 1, 0); zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val, sizeof(zval *), NULL); break; case HASH_KEY_IS_LONG: Z_TYPE_P(new_val) = IS_LONG; Z_LVAL_P(new_val) = num_key; zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val, sizeof(zval *), NULL); break; } zend_hash_move_forward_ex(Z_ARRVAL_P(input), &pos); } } } static void zephir_array_values(zval *return_value, zval *arr) { if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { zval **entry; HashPosition pos; array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(arr))); for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&entry, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos) ) { Z_ADDREF_PP(entry); zend_hash_next_index_insert(Z_ARRVAL_P(return_value), entry, sizeof(zval*), NULL); } } } static int zephir_array_key_exists(zval *arr, zval *key TSRMLS_DC) { HashTable *h = HASH_OF(arr); if (h) { switch (Z_TYPE_P(key)) { case IS_STRING: return zend_symtable_exists(h, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1); case IS_LONG: return zend_hash_index_exists(h, Z_LVAL_P(key)); case IS_NULL: return zend_hash_exists(h, "", 1); default: zend_error(E_WARNING, "The key should be either a string or an integer"); return 0; } } return 0; } static int zephir_array_is_associative(zval *arr) { if (likely(Z_TYPE_P(arr) == IS_ARRAY)) { HashPosition pos; zval **entry; char *skey; uint skey_len; ulong nkey; ulong expected = 0; zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void**) &entry, &pos) == SUCCESS) { if (HASH_KEY_IS_LONG == zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &skey, &skey_len, &nkey, 1, &pos)) { if (expected != nkey) { return 1; } } else { return 1; } ++expected; zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos); } } return 0; } static void zephir_array_update_multi_ex(zval **arr, zval **value, const char *types, int types_length, int types_count, va_list ap TSRMLS_DC) { long old_l[ZEPHIR_MAX_ARRAY_LEVELS], old_ll[ZEPHIR_MAX_ARRAY_LEVELS]; char *s, *old_s[ZEPHIR_MAX_ARRAY_LEVELS], old_type[ZEPHIR_MAX_ARRAY_LEVELS]; zval *fetched, *tmp, *p, *item, *old_item[ZEPHIR_MAX_ARRAY_LEVELS], *old_p[ZEPHIR_MAX_ARRAY_LEVELS]; int i, j, l, ll, re_update, must_continue, wrap_tmp; assert(types_length < ZEPHIR_MAX_ARRAY_LEVELS); p = *arr; for (i = 0; i < types_length; ++i) { re_update = 0; must_continue = 0; wrap_tmp = 0; old_p[i] = p; switch (types[i]) { case 's': s = va_arg(ap, char*); l = va_arg(ap, int); old_s[i] = s; old_l[i] = l; if (zephir_array_isset_string_fetch(&fetched, p, s, l + 1, 0 TSRMLS_CC)) { if (Z_TYPE_P(fetched) == IS_ARRAY) { if (i == (types_length - 1)) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); zephir_array_update_string(&p, s, l, value, PH_COPY | PH_SEPARATE); } else { p = fetched; } must_continue = 1; } } else { Z_DELREF_P(fetched); } if (!must_continue) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); if (i == (types_length - 1)) { zephir_array_update_string(&p, s, l, value, PH_COPY | PH_SEPARATE); } else { MAKE_STD_ZVAL(tmp); array_init(tmp); zephir_array_update_string(&p, s, l, &tmp, PH_SEPARATE); if (re_update) { wrap_tmp = 1; } else { p = tmp; } } } break; case 'l': ll = va_arg(ap, long); old_ll[i] = ll; if (zephir_array_isset_long_fetch(&fetched, p, ll, 0 TSRMLS_CC)) { if (Z_TYPE_P(fetched) == IS_ARRAY) { if (i == (types_length - 1)) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); zephir_array_update_long(&p, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { p = fetched; } must_continue = 1; } } else { Z_DELREF_P(fetched); } if (!must_continue) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); if (i == (types_length - 1)) { zephir_array_update_long(&p, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { MAKE_STD_ZVAL(tmp); array_init(tmp); zephir_array_update_long(&p, ll, &tmp, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); if (re_update) { wrap_tmp = 1; } else { p = tmp; } } } break; case 'z': item = va_arg(ap, zval*); old_item[i] = item; if (zephir_array_isset_fetch(&fetched, p, item, 0 TSRMLS_CC)) { if (Z_TYPE_P(fetched) == IS_ARRAY) { if (i == (types_length - 1)) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); zephir_array_update_zval(&p, item, value, PH_COPY | PH_SEPARATE); } else { p = fetched; } must_continue = 1; } } else { Z_DELREF_P(fetched); } if (!must_continue) { re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); if (i == (types_length - 1)) { zephir_array_update_zval(&p, item, value, PH_COPY | PH_SEPARATE); } else { MAKE_STD_ZVAL(tmp); array_init(tmp); zephir_array_update_zval(&p, item, &tmp, PH_SEPARATE); if (re_update) { wrap_tmp = 1; } else { p = tmp; } } } break; case 'a': re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p); zephir_array_append(&p, *value, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); break; } if (re_update) { for (j = i - 1; j >= 0; j--) { if (!re_update) { break; } re_update = Z_REFCOUNT_P(old_p[j]) > 1 && !Z_ISREF_P(old_p[j]); switch (old_type[j]) { case 's': if (j == i - 1) { zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &p, PH_SEPARATE); } else { zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &old_p[j+1], PH_SEPARATE); } if (wrap_tmp) { p = tmp; wrap_tmp = 0; } break; case 'l': if (j == i - 1) { zephir_array_update_long(&(old_p[j]), old_ll[j], &p, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { zephir_array_update_long(&(old_p[j]), old_ll[j], &old_p[j+1], PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } if (wrap_tmp) { p = tmp; wrap_tmp = 0; } break; case 'z': if (j == i - 1) { zephir_array_update_zval(&(old_p[j]), old_item[j], &p, PH_SEPARATE); } else { zephir_array_update_zval(&(old_p[j]), old_item[j], &old_p[j+1], PH_SEPARATE); } if (wrap_tmp) { p = tmp; wrap_tmp = 0; } break; } } } if (i != (types_length - 1)) { old_type[i] = types[i]; } } } static int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...) { va_list ap; va_start(ap, types_count); SEPARATE_ZVAL_IF_NOT_REF(arr); zephir_array_update_multi_ex(arr, value, types, types_length, types_count, ap TSRMLS_CC); va_end(ap); return 0; } static void ZEPHIR_FASTCALL zephir_create_array(zval *return_value, uint size, int initialize TSRMLS_DC) { uint i; zval *null_value; HashTable *hashTable; if (size > 0) { hashTable = (HashTable *) emalloc(sizeof(HashTable)); zephir_hash_init(hashTable, size, NULL, ZVAL_PTR_DTOR, 0); if (initialize) { MAKE_STD_ZVAL(null_value); ZVAL_NULL(null_value); Z_SET_REFCOUNT_P(null_value, size); for (i = 0; i < size; i++) { zend_hash_next_index_insert(hashTable, &null_value, sizeof(zval *), NULL); } } Z_ARRVAL_P(return_value) = hashTable; Z_TYPE_P(return_value) = IS_ARRAY; } else { array_init(return_value); } } #include <php.h> #include <Zend/zend_API.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_execute.h> #if PHP_VERSION_ID >= 50600 #if ZEND_MODULE_API_NO >= 20141001 static void zephir_clean_and_cache_symbol_table(zend_array *symbol_table) { if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) { zend_array_destroy(symbol_table); } else { zend_symtable_clean(symbol_table); *(++EG(symtable_cache_ptr)) = symbol_table; } } #else static void zephir_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) { if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) { zend_hash_destroy(symbol_table); FREE_HASHTABLE(symbol_table); } else { zend_hash_clean(symbol_table); *(++EG(symtable_cache_ptr)) = symbol_table; } } #endif static void zephir_throw_exception_internal(zval *exception TSRMLS_DC) { if (exception != NULL) { zval *previous = EG(exception); zend_exception_set_previous(exception, EG(exception) TSRMLS_CC); EG(exception) = exception; if (previous) { return; } } if (!EG(current_execute_data)) { if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } zend_error(E_ERROR, "Exception thrown without a stack frame"); } if (zend_throw_exception_hook) { zend_throw_exception_hook(exception TSRMLS_CC); } if (EG(current_execute_data)->opline == NULL || (EG(current_execute_data)->opline + 1)->opcode == ZEND_HANDLE_EXCEPTION) { /* no need to rethrow the exception */ return; } EG(opline_before_exception) = EG(current_execute_data)->opline; EG(current_execute_data)->opline = EG(exception_op); } static int zephir_call_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, zend_uint param_count, zval *pparams[] TSRMLS_DC) { zend_uint i; zval **original_return_value; HashTable *calling_symbol_table; zend_op_array *original_op_array; zend_op **original_opline_ptr; zend_class_entry *current_scope; zend_class_entry *current_called_scope; zend_class_entry *calling_scope = NULL; zend_class_entry *called_scope = NULL; zend_execute_data execute_data; zval ***params, ***params_array = NULL; zval **static_params_array[10]; zend_class_entry *old_scope = EG(scope); zend_function_state *function_state = &EX(function_state); zend_function *func; zval *rv = NULL, **retval_ptr_ptr = return_value_ptr ? return_value_ptr : &rv; if (retval_ptr_ptr && *retval_ptr_ptr) { zval_ptr_dtor(retval_ptr_ptr); *retval_ptr_ptr = NULL; } if (param_count) { if (UNEXPECTED(param_count > 10)) { params_array = (zval***) emalloc(param_count * sizeof(zval**)); params = params_array; for (i = 0; i < param_count; ++i) { params_array[i] = &pparams[i]; } } else { params = static_params_array; for (i = 0; i < param_count; ++i) { static_params_array[i] = &pparams[i]; } } } else { params = NULL; } if (!EG(active)) { return FAILURE; /* executor is already inactive */ } if (EG(exception)) { return FAILURE; /* we would result in an instable executor otherwise */ } /* Initialize execute_data */ if (EG(current_execute_data)) { execute_data = *EG(current_execute_data); EX(op_array) = NULL; EX(opline) = NULL; EX(object) = NULL; } else { /* This only happens when we're called outside any execute()'s * It shouldn't be strictly necessary to NULL execute_data out, * but it may make bugs easier to spot */ memset(&execute_data, 0, sizeof(zend_execute_data)); } #ifndef ZEPHIR_RELEASE function_state->function = (*cache_entry)->f; ++(*cache_entry)->times; #else function_state->function = *cache_entry; #endif func = function_state->function; calling_scope = NULL; called_scope = NULL; EX(object) = NULL; ZEND_VM_STACK_GROW_IF_NEEDED(param_count + 1); for (i = 0; i < param_count; i++) { zval *param; if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) { if (!PZVAL_IS_REF(*params[i]) && Z_REFCOUNT_PP(params[i]) > 1) { zval *new_zval; if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) { /* hack to clean up the stack */ zend_vm_stack_push((void *) (zend_uintptr_t)i TSRMLS_CC); zend_vm_stack_clear_multiple(0 TSRMLS_CC); } zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, func->common.scope ? func->common.scope->name : "", func->common.scope ? "::" : "", func->common.function_name); return FAILURE; } ALLOC_ZVAL(new_zval); *new_zval = **params[i]; zval_copy_ctor(new_zval); Z_SET_REFCOUNT_P(new_zval, 1); Z_DELREF_PP(params[i]); *params[i] = new_zval; } Z_ADDREF_PP(params[i]); Z_SET_ISREF_PP(params[i]); param = *params[i]; } else if (PZVAL_IS_REF(*params[i]) && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) { ALLOC_ZVAL(param); *param = **(params[i]); INIT_PZVAL(param); zval_copy_ctor(param); } else if (*params[i] != &EG(uninitialized_zval)) { Z_ADDREF_PP(params[i]); param = *params[i]; } else { ALLOC_ZVAL(param); *param = **(params[i]); INIT_PZVAL(param); } zend_vm_stack_push(param TSRMLS_CC); } function_state->arguments = zend_vm_stack_top(TSRMLS_C); zend_vm_stack_push((void*)(zend_uintptr_t)param_count TSRMLS_CC); current_scope = EG(scope); EG(scope) = calling_scope; current_called_scope = EG(called_scope); if (called_scope) { EG(called_scope) = called_scope; } else if (func->type != ZEND_INTERNAL_FUNCTION) { EG(called_scope) = NULL; } EX(prev_execute_data) = EG(current_execute_data); EG(current_execute_data) = &execute_data; if (func->type == ZEND_USER_FUNCTION) { calling_symbol_table = EG(active_symbol_table); EG(scope) = func->common.scope; EG(active_symbol_table) = NULL; original_return_value = EG(return_value_ptr_ptr); original_op_array = EG(active_op_array); EG(return_value_ptr_ptr) = retval_ptr_ptr; EG(active_op_array) = (zend_op_array *) function_state->function; original_opline_ptr = EG(opline_ptr); zend_execute(EG(active_op_array) TSRMLS_CC); if (EG(active_symbol_table)) { zephir_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; EG(return_value_ptr_ptr)=original_return_value; EG(opline_ptr) = original_opline_ptr; } else if (func->type == ZEND_INTERNAL_FUNCTION) { ALLOC_INIT_ZVAL(*retval_ptr_ptr); if (func->common.scope) { EG(scope) = func->common.scope; } func->internal_function.handler(param_count, *retval_ptr_ptr, retval_ptr_ptr, NULL, 1 TSRMLS_CC); if (EG(exception) && retval_ptr_ptr) { zval_ptr_dtor(retval_ptr_ptr); *retval_ptr_ptr = NULL; } } else { /* ZEND_OVERLOADED_FUNCTION */ ALLOC_INIT_ZVAL(*retval_ptr_ptr); /* Not sure what should be done here if it's a static method */ zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { efree((char*)func->common.function_name); } efree(function_state->function); if (EG(exception) && retval_ptr_ptr) { zval_ptr_dtor(retval_ptr_ptr); *retval_ptr_ptr = NULL; } } zend_vm_stack_clear_multiple(0 TSRMLS_CC); EG(called_scope) = current_called_scope; EG(scope) = current_scope; EG(current_execute_data) = EX(prev_execute_data); if (EG(exception)) { zephir_throw_exception_internal(NULL TSRMLS_CC); } EG(scope) = old_scope; if (UNEXPECTED(params_array != NULL)) { efree(params_array); } if (rv) { zval_ptr_dtor(&rv); } return SUCCESS; } static int zephir_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, int *strict_class, char **error TSRMLS_DC) /* {{{ */ { int ret = 0; zend_class_entry **pce; char *lcname = zend_str_tolower_dup(name, name_len); *strict_class = 0; if (name_len == sizeof("self") - 1 && !memcmp(lcname, "self", sizeof("self") - 1)) { if (!EG(scope)) { if (error) *error = estrdup("cannot access self:: when no class scope is active"); } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope); if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } ret = 1; } } else if (name_len == sizeof("parent") - 1 && !memcmp(lcname, "parent", sizeof("parent") - 1)) { if (!EG(scope)) { if (error) *error = estrdup("cannot access parent:: when no class scope is active"); } else if (!EG(scope)->parent) { if (error) *error = estrdup("cannot access parent:: when current class scope has no parent"); } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope)->parent; if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } *strict_class = 1; ret = 1; } } else if (name_len == sizeof("static") - 1 && !memcmp(lcname, "static", sizeof("static") - 1)) { if (!EG(called_scope)) { if (error) *error = estrdup("cannot access static:: when no class scope is active"); } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(called_scope); if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } *strict_class = 1; ret = 1; } } else if (zend_lookup_class_ex(name, name_len, NULL, 1, &pce TSRMLS_CC) == SUCCESS) { zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL; fcc->calling_scope = *pce; if (scope && !fcc->object_ptr && EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) && instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) { fcc->object_ptr = EG(This); fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } else { fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope; } *strict_class = 1; ret = 1; } else { if (error) zephir_spprintf(error, 0, "class '%.*s' not found", name_len, name); } efree(lcname); return ret; } static int zephir_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, int strict_class, char **error TSRMLS_DC) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; int retval = 0; char *mname, *lmname; const char *colon; int clen, mlen; zend_class_entry *last_scope; HashTable *ftable; int call_via_handler = 0; if (error) { *error = NULL; } fcc->calling_scope = NULL; fcc->function_handler = NULL; if (!ce_org) { /* Skip leading \ */ if (Z_STRVAL_P(callable)[0] == '\\') { mlen = Z_STRLEN_P(callable) - 1; lmname = zend_str_tolower_dup(Z_STRVAL_P(callable) + 1, mlen); } else { mlen = Z_STRLEN_P(callable); lmname = zend_str_tolower_dup(Z_STRVAL_P(callable), mlen); } /* Check if function with given name exists. * This may be a compound name that includes namespace name */ if (zend_hash_find(EG(function_table), lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) { efree(lmname); return 1; } efree(lmname); } /* Split name into class/namespace and method/function names */ if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL && colon > Z_STRVAL_P(callable) && *(colon-1) == ':' ) { colon--; clen = colon - Z_STRVAL_P(callable); mlen = Z_STRLEN_P(callable) - clen - 2; if (colon == Z_STRVAL_P(callable)) { if (error) zephir_spprintf(error, 0, "invalid function name"); return 0; } /* This is a compound name. * Try to fetch class and then find static method. */ last_scope = EG(scope); if (ce_org) { EG(scope) = ce_org; } if (!zephir_is_callable_check_class(Z_STRVAL_P(callable), clen, fcc, &strict_class, error TSRMLS_CC)) { EG(scope) = last_scope; return 0; } EG(scope) = last_scope; ftable = &fcc->calling_scope->function_table; if (ce_org && !instanceof_function(ce_org, fcc->calling_scope TSRMLS_CC)) { if (error) zephir_spprintf(error, 0, "class '%s' is not a subclass of '%s'", ce_org->name, fcc->calling_scope->name); return 0; } mname = Z_STRVAL_P(callable) + clen + 2; } else if (ce_org) { /* Try to fetch find static method of given class. */ mlen = Z_STRLEN_P(callable); mname = Z_STRVAL_P(callable); ftable = &ce_org->function_table; fcc->calling_scope = ce_org; } else { /* We already checked for plain function before. */ if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) { zephir_spprintf(error, 0, "function '%s' not found or invalid function name", Z_STRVAL_P(callable)); } return 0; } lmname = zend_str_tolower_dup(mname, mlen); if (strict_class && fcc->calling_scope && mlen == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 && !memcmp(lmname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME) - 1)) { fcc->function_handler = fcc->calling_scope->constructor; if (fcc->function_handler) { retval = 1; } } else if (zend_hash_find(ftable, lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) { retval = 1; if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) && !strict_class && EG(scope) && instanceof_function(fcc->function_handler->common.scope, EG(scope) TSRMLS_CC)) { zend_function *priv_fbc; if (zend_hash_find(&EG(scope)->function_table, lmname, mlen+1, (void **) &priv_fbc)==SUCCESS && priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE && priv_fbc->common.scope == EG(scope)) { fcc->function_handler = priv_fbc; } } } else { if (fcc->object_ptr && fcc->calling_scope == ce_org) { if (strict_class && ce_org->__call) { fcc->function_handler = emalloc(sizeof(zend_internal_function)); fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION; fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL; fcc->function_handler->internal_function.handler = zend_std_call_user_call; fcc->function_handler->internal_function.arg_info = NULL; fcc->function_handler->internal_function.num_args = 0; fcc->function_handler->internal_function.scope = ce_org; fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER; fcc->function_handler->internal_function.function_name = estrndup(mname, mlen); call_via_handler = 1; retval = 1; } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) { fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen, NULL TSRMLS_CC); if (fcc->function_handler) { if (strict_class && (!fcc->function_handler->common.scope || !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) { if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } } else { retval = 1; call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; } } } } else if (fcc->calling_scope) { if (fcc->calling_scope->get_static_method) { fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC); } else { fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, mname, mlen, NULL TSRMLS_CC); } if (fcc->function_handler) { retval = 1; call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; if (call_via_handler && !fcc->object_ptr && EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) { fcc->object_ptr = EG(This); } } } } if (retval) { if (fcc->calling_scope && !call_via_handler) { if (!fcc->object_ptr && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) { if (error) { zephir_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name); retval = 0; } else { zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name); } } else if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { int severity; char *verb; if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; verb = "should not"; } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ severity = E_ERROR; verb = "cannot"; } if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) { retval = 0; } if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) { fcc->object_ptr = EG(This); if (error) { zephir_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb, Z_OBJCE_P(EG(This))->name); if (severity == E_ERROR) { retval = 0; } } else if (retval) { zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb, Z_OBJCE_P(EG(This))->name); } } else { if (error) { zephir_spprintf(error, 0, "non-static method %s::%s() %s be called statically", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb); if (severity == E_ERROR) { retval = 0; } } else if (retval) { zend_error(severity, "Non-static method %s::%s() %s be called statically", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb); } } } } } else if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) { if (fcc->calling_scope) { if (error) zephir_spprintf(error, 0, "class '%s' does not have a method '%s'", fcc->calling_scope->name, mname); } else { if (error) zephir_spprintf(error, 0, "function '%s' does not exist", mname); } } efree(lmname); if (fcc->object_ptr) { fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } if (retval) { fcc->initialized = 1; } return retval; } static zend_bool zephir_is_callable_ex(zval *callable, zval *object_ptr, uint check_flags, char **callable_name, int *callable_name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ { zend_bool ret; int callable_name_len_local; zend_fcall_info_cache fcc_local; if (callable_name) { *callable_name = NULL; } if (callable_name_len == NULL) { callable_name_len = &callable_name_len_local; } if (fcc == NULL) { fcc = &fcc_local; } if (error) { *error = NULL; } fcc->initialized = 0; fcc->calling_scope = NULL; fcc->called_scope = NULL; fcc->function_handler = NULL; fcc->object_ptr = NULL; if (object_ptr && Z_TYPE_P(object_ptr) != IS_OBJECT) { object_ptr = NULL; } if (object_ptr && (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)].valid)) { return 0; } switch (Z_TYPE_P(callable)) { case IS_STRING: if (object_ptr) { fcc->object_ptr = object_ptr; fcc->calling_scope = Z_OBJCE_P(object_ptr); if (callable_name) { char *ptr; *callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_P(callable) + sizeof("::") - 1; ptr = *callable_name = emalloc(*callable_name_len + 1); memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length); ptr += fcc->calling_scope->name_length; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); } } else if (callable_name) { *callable_name = estrndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable)); *callable_name_len = Z_STRLEN_P(callable); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { fcc->called_scope = fcc->calling_scope; return 1; } ret = zephir_is_callable_check_func(check_flags, callable, fcc, 0, error TSRMLS_CC); if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } return ret; case IS_ARRAY: { zval **method = NULL; zval **obj = NULL; int strict_class = 0; if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) { zend_hash_index_find(Z_ARRVAL_P(callable), 0, (void **) &obj); zend_hash_index_find(Z_ARRVAL_P(callable), 1, (void **) &method); } if (obj && method && (Z_TYPE_PP(obj) == IS_OBJECT || Z_TYPE_PP(obj) == IS_STRING) && Z_TYPE_PP(method) == IS_STRING) { if (Z_TYPE_PP(obj) == IS_STRING) { if (callable_name) { char *ptr; *callable_name_len = Z_STRLEN_PP(obj) + Z_STRLEN_PP(method) + sizeof("::") - 1; ptr = *callable_name = emalloc(*callable_name_len + 1); memcpy(ptr, Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); ptr += Z_STRLEN_PP(obj); memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { return 1; } if (!zephir_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), fcc, &strict_class, error TSRMLS_CC)) { return 0; } } else { if (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(obj)].valid) { return 0; } fcc->calling_scope = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */ fcc->object_ptr = *obj; if (callable_name) { char *ptr; *callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_PP(method) + sizeof("::") - 1; ptr = *callable_name = emalloc(*callable_name_len + 1); memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length); ptr += fcc->calling_scope->name_length; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { fcc->called_scope = fcc->calling_scope; return 1; } } ret = zephir_is_callable_check_func(check_flags, *method, fcc, strict_class, error TSRMLS_CC); if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } return ret; } else { if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) { if (!obj || (Z_TYPE_PP(obj) != IS_STRING && Z_TYPE_PP(obj) != IS_OBJECT)) { if (error) zephir_spprintf(error, 0, "first array member is not a valid class name or object"); } else { if (error) zephir_spprintf(error, 0, "second array member is not a valid method"); } } else { if (error) zephir_spprintf(error, 0, "array must have exactly two members"); } if (callable_name) { *callable_name = estrndup("Array", sizeof("Array")-1); *callable_name_len = sizeof("Array") - 1; } } } return 0; case IS_OBJECT: if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object_ptr TSRMLS_CC) == SUCCESS) { fcc->called_scope = fcc->calling_scope; if (callable_name) { zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ *callable_name_len = ce->name_length + sizeof("::__invoke") - 1; *callable_name = emalloc(*callable_name_len + 1); memcpy(*callable_name, ce->name, ce->name_length); memcpy((*callable_name) + ce->name_length, "::__invoke", sizeof("::__invoke")); } return 1; } /* break missing intentionally */ default: if (callable_name) { zval expr_copy; int use_copy; zend_make_printable_zval(callable, &expr_copy, &use_copy); *callable_name = estrndup(Z_STRVAL(expr_copy), Z_STRLEN(expr_copy)); *callable_name_len = Z_STRLEN(expr_copy); zval_dtor(&expr_copy); } if (error) zephir_spprintf(error, 0, "no array or string given"); return 0; } } static zend_bool zephir_is_info_dynamic_callable(zephir_fcall_info *info, zend_fcall_info_cache *fcc, zend_class_entry *ce_org, int strict_class TSRMLS_DC) { int call_via_handler = 0, retval = 0; char *lcname = zend_str_tolower_dup(info->func_name, info->func_length); if (fcc->object_ptr && fcc->calling_scope == ce_org) { if (strict_class && ce_org->__call) { fcc->function_handler = emalloc(sizeof(zend_internal_function)); fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION; fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL; fcc->function_handler->internal_function.handler = zend_std_call_user_call; fcc->function_handler->internal_function.arg_info = NULL; fcc->function_handler->internal_function.num_args = 0; fcc->function_handler->internal_function.scope = ce_org; fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER; fcc->function_handler->internal_function.function_name = estrndup(lcname, info->func_length); call_via_handler = 1; retval = 1; } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) { fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, lcname, info->func_length, NULL TSRMLS_CC); if (fcc->function_handler) { if (strict_class && (!fcc->function_handler->common.scope || !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) { if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } } else { call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; retval = 1; } } } } else if (fcc->calling_scope) { if (fcc->calling_scope->get_static_method) { fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, lcname, info->func_length TSRMLS_CC); } else { fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, lcname, info->func_length, NULL TSRMLS_CC); } if (fcc->function_handler) { call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; if (call_via_handler && !fcc->object_ptr && EG(This) && Z_OBJ_HT_P(EG(This))->get_class_entry && instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) { fcc->object_ptr = EG(This); } retval = 1; } } efree(lcname); return retval; } static zend_bool zephir_is_info_callable_ex(zephir_fcall_info *info, zend_fcall_info_cache *fcc TSRMLS_DC) { int retval = 0; zend_class_entry *ce_org = fcc->calling_scope; zend_fcall_info_cache fcc_local; if (fcc == NULL) { fcc = &fcc_local; } fcc->initialized = 0; fcc->calling_scope = NULL; fcc->called_scope = NULL; fcc->function_handler = NULL; fcc->object_ptr = NULL; switch (info->type) { case ZEPHIR_FCALL_TYPE_FUNC: if (zend_hash_find(EG(function_table), info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } fcc->initialized = 1; return 1; } break; case ZEPHIR_FCALL_TYPE_ZVAL_METHOD: if (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(info->object_ptr)].valid) { return 0; } fcc->calling_scope = Z_OBJCE_P(info->object_ptr); /* TBFixed: what if it's overloaded? */ fcc->called_scope = fcc->calling_scope; fcc->object_ptr = info->object_ptr; if (!ce_org) { ce_org = fcc->calling_scope; } if (zend_hash_find(&info->ce->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } retval = 1; } if (!retval) { retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 0 TSRMLS_CC); } break; case ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD: if (!EG(scope)) { return 0; // cannot access self:: when no class scope is active } fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope); if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } retval = 1; } if (!retval) { retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 0 TSRMLS_CC); } break; case ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD: if (!EG(scope)) { return 0; // cannot access parent:: when no class scope is active } if (!EG(scope)->parent) { return 0; // cannot access parent:: when current class scope has no parent } fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope)->parent; if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } retval = 1; } if (!retval) { retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC); } break; case ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD: if (!EG(called_scope)) { return 0; // cannot access static:: when no class scope is active } fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(called_scope); if (!fcc->object_ptr) { fcc->object_ptr = EG(This); } if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } retval = 1; } if (!retval) { retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC); } break; case ZEPHIR_FCALL_TYPE_CE_METHOD: { zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL; fcc->calling_scope = info->ce; if (scope && !fcc->object_ptr && EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) && instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) { fcc->object_ptr = EG(This); fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } else { fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope; } if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) { if (fcc == &fcc_local && fcc->function_handler && ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION && (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { efree((char*)fcc->function_handler->common.function_name); } efree(fcc->function_handler); } retval = 1; } if (!retval) { retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC); } } break; } if (fcc->object_ptr) { fcc->called_scope = Z_OBJCE_P(fcc->object_ptr); } if (retval) { fcc->initialized = 1; } return retval; } static int zephir_call_function_opt(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zephir_fcall_info *info TSRMLS_DC) { zend_uint i; zval **original_return_value; HashTable *calling_symbol_table; zend_op_array *original_op_array; zend_op **original_opline_ptr; zend_class_entry *current_scope; zend_class_entry *current_called_scope; zend_class_entry *calling_scope = NULL; zend_class_entry *called_scope = NULL; zval *current_this; zend_execute_data execute_data; zend_fcall_info_cache fci_cache_local; zend_uint fn_flags; *fci->retval_ptr_ptr = NULL; if (!EG(active)) { return FAILURE; /* executor is already inactive */ } if (EG(exception)) { return FAILURE; /* we would result in an instable executor otherwise */ } /* Initialize execute_data */ if (EG(current_execute_data)) { execute_data = *EG(current_execute_data); EX(op_array) = NULL; EX(opline) = NULL; EX(object) = NULL; } else { /* This only happens when we're called outside any execute()'s * It shouldn't be strictly necessary to NULL execute_data out, * but it may make bugs easier to spot */ memset(&execute_data, 0, sizeof(zend_execute_data)); } if (!fci_cache || !fci_cache->initialized) { char *callable_name; char *error = NULL; if (!fci_cache) { fci_cache = &fci_cache_local; } if (!info) { if (!zephir_is_callable_ex(fci->function_name, fci->object_ptr, IS_CALLABLE_CHECK_SILENT, &callable_name, NULL, fci_cache, &error TSRMLS_CC)) { if (error) { zend_error(E_WARNING, "Invalid callback %s, %s", callable_name, error); efree(error); } if (callable_name) { efree(callable_name); } return FAILURE; } else { if (error) { zend_error(E_STRICT, "%s", error); efree(error); } } efree(callable_name); } else { if (!zephir_is_info_callable_ex(info, fci_cache TSRMLS_CC)) { return FAILURE; } } } #ifndef ZEPHIR_RELEASE /*fprintf(stderr, "initialized: %d\n", fci_cache->initialized); if (fci_cache->function_handler) { if (fci_cache->function_handler->type == ZEND_INTERNAL_FUNCTION) { fprintf(stderr, "function handler: %s\n", fci_cache->function_handler->common.function_name); } else { fprintf(stderr, "function handler: %s\n", "unknown"); } } else { fprintf(stderr, "function handler: NONE\n"); } if (fci_cache->calling_scope) { fprintf(stderr, "real calling_scope: %s (%p)\n", fci_cache->calling_scope->name, fci_cache->calling_scope); } else { fprintf(stderr, "real calling_scope: NONE\n"); } if (fci_cache->called_scope) { fprintf(stderr, "real called_scope: %s (%p)\n", fci_cache->called_scope->name, fci_cache->called_scope); } else { fprintf(stderr, "real called_scope: NONE\n"); }*/ #endif EX(function_state).function = fci_cache->function_handler; calling_scope = fci_cache->calling_scope; called_scope = fci_cache->called_scope; fci->object_ptr = fci_cache->object_ptr; EX(object) = fci->object_ptr; if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT && (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)].valid)) { return FAILURE; } fn_flags = EX(function_state).function->common.fn_flags; if (fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) { if (fn_flags & ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); } if (fn_flags & ZEND_ACC_DEPRECATED) { zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated", EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "", EX(function_state).function->common.scope ? "::" : "", EX(function_state).function->common.function_name); } } ZEND_VM_STACK_GROW_IF_NEEDED(fci->param_count + 1); for (i = 0; i < fci->param_count; i++) { zval *param; if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { if (!PZVAL_IS_REF(*fci->params[i]) && Z_REFCOUNT_PP(fci->params[i]) > 1) { zval *new_zval; if (fci->no_separation && !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) { /* hack to clean up the stack */ zend_vm_stack_push((void *) (zend_uintptr_t)i TSRMLS_CC); zend_vm_stack_clear_multiple(0 TSRMLS_CC); } zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "", EX(function_state).function->common.scope ? "::" : "", EX(function_state).function->common.function_name); return FAILURE; } ALLOC_ZVAL(new_zval); *new_zval = **fci->params[i]; zval_copy_ctor(new_zval); Z_SET_REFCOUNT_P(new_zval, 1); Z_DELREF_PP(fci->params[i]); *fci->params[i] = new_zval; } Z_ADDREF_PP(fci->params[i]); Z_SET_ISREF_PP(fci->params[i]); param = *fci->params[i]; } else if (PZVAL_IS_REF(*fci->params[i]) && /* don't separate references for __call */ (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) { ALLOC_ZVAL(param); *param = **(fci->params[i]); INIT_PZVAL(param); zval_copy_ctor(param); } else if (*fci->params[i] != &EG(uninitialized_zval)) { Z_ADDREF_PP(fci->params[i]); param = *fci->params[i]; } else { ALLOC_ZVAL(param); *param = **(fci->params[i]); INIT_PZVAL(param); } zend_vm_stack_push(param TSRMLS_CC); } EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); zend_vm_stack_push((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC); current_scope = EG(scope); EG(scope) = calling_scope; current_this = EG(This); current_called_scope = EG(called_scope); if (called_scope) { EG(called_scope) = called_scope; } else if (EX(function_state).function->type != ZEND_INTERNAL_FUNCTION) { EG(called_scope) = NULL; } if (fci->object_ptr) { if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { EG(This) = NULL; } else { EG(This) = fci->object_ptr; if (!PZVAL_IS_REF(EG(This))) { Z_ADDREF_P(EG(This)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); *this_ptr = *EG(This); INIT_PZVAL(this_ptr); zval_copy_ctor(this_ptr); EG(This) = this_ptr; } } } else { EG(This) = NULL; } EX(prev_execute_data) = EG(current_execute_data); EG(current_execute_data) = &execute_data; if (EX(function_state).function->type == ZEND_USER_FUNCTION) { calling_symbol_table = EG(active_symbol_table); EG(scope) = EX(function_state).function->common.scope; if (fci->symbol_table) { EG(active_symbol_table) = fci->symbol_table; } else { EG(active_symbol_table) = NULL; } original_return_value = EG(return_value_ptr_ptr); original_op_array = EG(active_op_array); EG(return_value_ptr_ptr) = fci->retval_ptr_ptr; EG(active_op_array) = (zend_op_array *) EX(function_state).function; original_opline_ptr = EG(opline_ptr); //if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) { // *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC); //} else { zend_execute(EG(active_op_array) TSRMLS_CC); //} if (!fci->symbol_table && EG(active_symbol_table)) { zephir_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; EG(return_value_ptr_ptr)=original_return_value; EG(opline_ptr) = original_opline_ptr; } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); if (EX(function_state).function->common.scope) { EG(scope) = EX(function_state).function->common.scope; } if (EXPECTED(zend_execute_internal == NULL)) { /* saves one function call if zend_execute_internal is not used */ EX(function_state).function->internal_function.handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); } else { zend_execute_internal(&execute_data, fci, 1 TSRMLS_CC); } /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) { INIT_PZVAL(*fci->retval_ptr_ptr); }*/ if (EG(exception) && fci->retval_ptr_ptr) { zval_ptr_dtor(fci->retval_ptr_ptr); *fci->retval_ptr_ptr = NULL; } if (call_via_handler) { /* We must re-initialize function again */ fci_cache->initialized = 0; } } else { /* ZEND_OVERLOADED_FUNCTION */ ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); /* Not sure what should be done here if it's a static method */ if (fci->object_ptr) { Z_OBJ_HT_P(fci->object_ptr)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { efree((char*)EX(function_state).function->common.function_name); } efree(EX(function_state).function); if (EG(exception) && fci->retval_ptr_ptr) { zval_ptr_dtor(fci->retval_ptr_ptr); *fci->retval_ptr_ptr = NULL; } } zend_vm_stack_clear_multiple(0 TSRMLS_CC); if (EG(This)) { zval_ptr_dtor(&EG(This)); } EG(called_scope) = current_called_scope; EG(scope) = current_scope; EG(This) = current_this; EG(current_execute_data) = EX(prev_execute_data); if (EG(exception)) { zephir_throw_exception_internal(NULL TSRMLS_CC); } return SUCCESS; } #endif #ifdef HAVE_CONFIG_H #endif #include <ctype.h> #include <php.h> #include <ext/standard/php_smart_str.h> #include <ext/standard/php_string.h> #include <ext/standard/php_rand.h> #include <ext/standard/php_lcg.h> #include <ext/standard/php_http.h> #ifdef ZEPHIR_USE_PHP_PCRE #include <ext/pcre/php_pcre.h> #endif #ifdef ZEPHIR_USE_PHP_JSON #include <ext/json/php_json.h> #endif #define PH_RANDOM_ALNUM 0 #define PH_RANDOM_ALPHA 1 #define PH_RANDOM_HEXDEC 2 #define PH_RANDOM_NUMERIC 3 #define PH_RANDOM_NOZERO 4 static void zephir_fast_strlen(zval *return_value, zval *str){ zval copy; int use_copy = 0; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } ZVAL_LONG(return_value, Z_STRLEN_P(str)); if (use_copy) { zval_dtor(str); } } static int zephir_fast_strlen_ev(zval *str){ zval copy; int use_copy = 0, length; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } length = Z_STRLEN_P(str); if (use_copy) { zval_dtor(str); } return length; } static void zephir_fast_strtolower(zval *return_value, zval *str){ zval copy; int use_copy = 0; char *lower_str; unsigned int length; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } length = Z_STRLEN_P(str); lower_str = estrndup(Z_STRVAL_P(str), length); php_strtolower(lower_str, length); if (use_copy) { zval_dtor(str); } ZVAL_STRINGL(return_value, lower_str, length, 0); } static void zephir_strtolower_inplace(zval *s) { if (likely(Z_TYPE_P(s) == IS_STRING)) { php_strtolower(Z_STRVAL_P(s), Z_STRLEN_P(s)); } } static void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC) { if (Z_TYPE_P(glue) != IS_STRING || Z_TYPE_P(pieces) != IS_ARRAY) { ZVAL_NULL(result); zend_error(E_WARNING, "Invalid arguments supplied for join()"); return; } php_implode(glue, pieces, result TSRMLS_CC); } static void zephir_append_printable_zval(smart_str *implstr, zval **tmp TSRMLS_DC) { zval tmp_val; unsigned int str_len; switch (Z_TYPE_PP(tmp)) { case IS_STRING: smart_str_appendl(implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); break; case IS_LONG: smart_str_append_long(implstr, Z_LVAL_PP(tmp)); break; case IS_BOOL: if (Z_LVAL_PP(tmp) == 1) { smart_str_appendl(implstr, "1", sizeof("1") - 1); } break; case IS_NULL: break; case IS_DOUBLE: { char *stmp; str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_PP(tmp)); smart_str_appendl(implstr, stmp, str_len); efree(stmp); } break; case IS_OBJECT: { int copy; zval expr; zend_make_printable_zval(*tmp, &expr, ©); smart_str_appendl(implstr, Z_STRVAL(expr), Z_STRLEN(expr)); if (copy) { zval_dtor(&expr); } } break; default: tmp_val = **tmp; zval_copy_ctor(&tmp_val); convert_to_string(&tmp_val); smart_str_appendl(implstr, Z_STRVAL(tmp_val), Z_STRLEN(tmp_val)); zval_dtor(&tmp_val); break; } } static void zephir_fast_join_str(zval *return_value, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC) { zval **tmp; HashTable *arr; HashPosition pos; smart_str implstr = {0}; unsigned int numelems, i = 0; if (Z_TYPE_P(pieces) != IS_ARRAY) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for fast_join()"); RETURN_EMPTY_STRING(); } arr = Z_ARRVAL_P(pieces); numelems = zend_hash_num_elements(arr); if (numelems == 0) { RETURN_EMPTY_STRING(); } zend_hash_internal_pointer_reset_ex(arr, &pos); while (zend_hash_get_current_data_ex(arr, (void **) &tmp, &pos) == SUCCESS) { zephir_append_printable_zval(&implstr, tmp TSRMLS_CC); if (++i != numelems) { smart_str_appendl(&implstr, glue, glue_length); } zend_hash_move_forward_ex(arr, &pos); } smart_str_0(&implstr); if (implstr.len) { RETURN_STRINGL(implstr.c, implstr.len, 0); } else { smart_str_free(&implstr); RETURN_EMPTY_STRING(); } } static void zephir_camelize(zval *return_value, const zval *str) { int i, len, first = 0; smart_str camelize_str = {0}; char *marker, ch; if (unlikely(Z_TYPE_P(str) != IS_STRING)) { zend_error(E_WARNING, "Invalid arguments supplied for camelize()"); RETURN_EMPTY_STRING(); } marker = Z_STRVAL_P(str); len = Z_STRLEN_P(str); for (i = 0; i < len; i++) { ch = marker[i]; if (first == 0) { if (ch == '-' || ch == '_') { continue; } first = 1; smart_str_appendc(&camelize_str, toupper(ch)); continue; } if (ch == '-' || ch == '_') { if (i != (len - 1)) { i++; ch = marker[i]; smart_str_appendc(&camelize_str, toupper(ch)); } continue; } smart_str_appendc(&camelize_str, tolower(ch)); } smart_str_0(&camelize_str); if (camelize_str.c) { RETURN_STRINGL(camelize_str.c, camelize_str.len, 0); } RETURN_EMPTY_STRING(); } static void zephir_uncamelize(zval *return_value, const zval *str) { unsigned int i; smart_str uncamelize_str = {0}; char *marker, ch; if (Z_TYPE_P(str) != IS_STRING) { zend_error(E_WARNING, "Invalid arguments supplied for camelize()"); return; } marker = Z_STRVAL_P(str); for (i = 0; i < Z_STRLEN_P(str); i++) { ch = *marker; if (ch == '\0') { break; } if (ch >= 'A' && ch <= 'Z') { if (i > 0) { smart_str_appendc(&uncamelize_str, '_'); } smart_str_appendc(&uncamelize_str, (*marker) + 32); } else { smart_str_appendc(&uncamelize_str, (*marker)); } marker++; } smart_str_0(&uncamelize_str); if (uncamelize_str.c) { RETURN_STRINGL(uncamelize_str.c, uncamelize_str.len, 0); } else { RETURN_EMPTY_STRING(); } } static void zephir_fast_explode(zval *return_value, zval *delimiter, zval *str, long limit TSRMLS_DC) { if (unlikely(Z_TYPE_P(str) != IS_STRING || Z_TYPE_P(delimiter) != IS_STRING)) { zend_error(E_WARNING, "Invalid arguments supplied for explode()"); RETURN_EMPTY_STRING(); } array_init(return_value); php_explode(delimiter, str, return_value, limit); } static void zephir_fast_explode_str(zval *return_value, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC) { zval delimiter_zval; if (unlikely(Z_TYPE_P(str) != IS_STRING)) { zend_error(E_WARNING, "Invalid arguments supplied for explode()"); RETURN_EMPTY_STRING(); } ZVAL_STRINGL(&delimiter_zval, delimiter, delimiter_length, 0); array_init(return_value); php_explode(&delimiter_zval, str, return_value, limit); } static int zephir_memnstr(const zval *haystack, const zval *needle ZEPHIR_DEBUG_PARAMS) { if (Z_TYPE_P(haystack) != IS_STRING || Z_TYPE_P(needle) != IS_STRING) { #ifndef ZEPHIR_RELEASE zend_error(E_WARNING, "Invalid arguments supplied for memnstr in %s on line %d", file, line); #else zend_error(E_WARNING, "Invalid arguments supplied for memnstr()"); #endif return 0; } if (Z_STRLEN_P(haystack) >= Z_STRLEN_P(needle)) { return php_memnstr(Z_STRVAL_P(haystack), Z_STRVAL_P(needle), Z_STRLEN_P(needle), Z_STRVAL_P(haystack) + Z_STRLEN_P(haystack)) ? 1 : 0; } return 0; } static int zephir_memnstr_str(const zval *haystack, char *needle, unsigned int needle_length ZEPHIR_DEBUG_PARAMS) { if (Z_TYPE_P(haystack) != IS_STRING) { #ifndef ZEPHIR_RELEASE zend_error(E_WARNING, "Invalid arguments supplied for memnstr in %s on line %d", file, line); #else zend_error(E_WARNING, "Invalid arguments supplied for memnstr()"); #endif return 0; } if (Z_STRLEN_P(haystack) >= needle_length) { return php_memnstr(Z_STRVAL_P(haystack), needle, needle_length, Z_STRVAL_P(haystack) + Z_STRLEN_P(haystack)) ? 1 : 0; } return 0; } static void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset) { const char *found = NULL; if (unlikely(Z_TYPE_P(haystack) != IS_STRING || Z_TYPE_P(needle) != IS_STRING)) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Invalid arguments supplied for strpos()"); return; } if (offset > Z_STRLEN_P(haystack)) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Offset not contained in string"); return; } if (!Z_STRLEN_P(needle)) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Empty delimiter"); return; } found = php_memnstr(Z_STRVAL_P(haystack)+offset, Z_STRVAL_P(needle), Z_STRLEN_P(needle), Z_STRVAL_P(haystack) + Z_STRLEN_P(haystack)); if (found) { ZVAL_LONG(return_value, found-Z_STRVAL_P(haystack)); } else { ZVAL_BOOL(return_value, 0); } } static void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length) { const char *found = NULL; if (unlikely(Z_TYPE_P(haystack) != IS_STRING)) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Invalid arguments supplied for strpos()"); return; } found = php_memnstr(Z_STRVAL_P(haystack), needle, needle_length, Z_STRVAL_P(haystack) + Z_STRLEN_P(haystack)); if (found) { ZVAL_LONG(return_value, found-Z_STRVAL_P(haystack)); } else { ZVAL_BOOL(return_value, 0); } } static void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length) { const char *found = NULL; char *needle_dup, *haystack_dup; if (unlikely(Z_TYPE_P(haystack) != IS_STRING)) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Invalid arguments supplied for stripos()"); return; } haystack_dup = estrndup(Z_STRVAL_P(haystack), Z_STRLEN_P(haystack)); php_strtolower(haystack_dup, Z_STRLEN_P(haystack)); needle_dup = estrndup(needle, needle_length); php_strtolower(needle_dup, needle_length); found = php_memnstr(haystack_dup, needle, needle_length, haystack_dup + Z_STRLEN_P(haystack)); efree(haystack_dup); efree(needle_dup); if (found) { ZVAL_LONG(return_value, found-Z_STRVAL_P(haystack)); } else { ZVAL_BOOL(return_value, 0); } } static void zephir_fast_str_replace(zval **return_value_ptr, zval *search, zval *replace, zval *subject TSRMLS_DC) { zval replace_copy, search_copy; zval *return_value = *return_value_ptr; int copy_replace = 0, copy_search = 0; if (Z_TYPE_P(subject) != IS_STRING) { ZVAL_NULL(return_value); zend_error(E_WARNING, "Invalid arguments supplied for str_replace()"); return; } if (Z_TYPE_P(search) == IS_ARRAY) { do { zval *params[] = { search, replace, subject }; zval_ptr_dtor(return_value_ptr); *return_value_ptr = NULL; zephir_call_func_aparams(return_value_ptr, "str_replace", sizeof("str_replace")-1, NULL, 0, 3, params TSRMLS_CC); return; } while(0); } if (Z_TYPE_P(replace) != IS_STRING) { zend_make_printable_zval(replace, &replace_copy, ©_replace); if (copy_replace) { replace = &replace_copy; } } if (Z_TYPE_P(search) != IS_STRING) { zend_make_printable_zval(search, &search_copy, ©_search); if (copy_search) { search = &search_copy; } } Z_TYPE_P(return_value) = IS_STRING; if (Z_STRLEN_P(subject) == 0) { ZVAL_STRINGL(return_value, "", 0, 1); return; } if (Z_STRLEN_P(search) == 1) { php_char_to_str_ex(Z_STRVAL_P(subject), Z_STRLEN_P(subject), Z_STRVAL_P(search)[0], Z_STRVAL_P(replace), Z_STRLEN_P(replace), return_value, 1, NULL); } else { if (Z_STRLEN_P(search) > 1) { Z_STRVAL_P(return_value) = php_str_to_str_ex(Z_STRVAL_P(subject), Z_STRLEN_P(subject), Z_STRVAL_P(search), Z_STRLEN_P(search), Z_STRVAL_P(replace), Z_STRLEN_P(replace), &Z_STRLEN_P(return_value), 1, NULL); } else { MAKE_COPY_ZVAL(&subject, return_value); } } if (copy_replace) { zval_dtor(replace); } if (copy_search) { zval_dtor(search); } } static void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC) { zval copy; int use_copy = 0; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } if (charlist && Z_TYPE_P(charlist) == IS_STRING) { php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), Z_STRVAL_P(charlist), Z_STRLEN_P(charlist), return_value, where TSRMLS_CC); } else { php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), NULL, 0, return_value, where TSRMLS_CC); } if (use_copy) { zval_dtor(©); } } static void zephir_fast_strip_tags(zval *return_value, zval *str) { zval copy; int use_copy = 0; char *stripped; size_t len; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } stripped = estrndup(Z_STRVAL_P(str), Z_STRLEN_P(str)); len = php_strip_tags(stripped, Z_STRLEN_P(str), NULL, NULL, 0); if (use_copy) { zval_dtor(©); } ZVAL_STRINGL(return_value, stripped, len, 0); } static void zephir_fast_strtoupper(zval *return_value, zval *str) { zval copy; int use_copy = 0; char *lower_str; unsigned int length; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } length = Z_STRLEN_P(str); lower_str = estrndup(Z_STRVAL_P(str), length); php_strtoupper(lower_str, length); if (use_copy) { zval_dtor(str); } ZVAL_STRINGL(return_value, lower_str, length, 0); } static int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive) { int i; int sensitive = 0; char *op1_cursor, *op2_cursor; if (Z_TYPE_P(str) != IS_STRING || Z_TYPE_P(compared) != IS_STRING) { return 0; } if (!Z_STRLEN_P(compared) || !Z_STRLEN_P(str) || Z_STRLEN_P(compared) > Z_STRLEN_P(str)) { return 0; } if (case_sensitive) { sensitive = zend_is_true(case_sensitive); } if (!sensitive) { return !memcmp(Z_STRVAL_P(str), Z_STRVAL_P(compared), Z_STRLEN_P(compared)); } op1_cursor = Z_STRVAL_P(str); op2_cursor = Z_STRVAL_P(compared); for (i = 0; i < Z_STRLEN_P(compared); i++) { if (tolower(*op1_cursor) != tolower(*op2_cursor)) { return 0; } op1_cursor++; op2_cursor++; } return 1; } static int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length) { if (Z_TYPE_P(str) != IS_STRING || compared_length > Z_STRLEN_P(str)) { return 0; } return !memcmp(Z_STRVAL_P(str), compared, compared_length); } static int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length) { if (compared_length > str_length) { return 0; } return !memcmp(str, compared, compared_length); } static int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive) { int sensitive = 0; int i; char *op1_cursor, *op2_cursor; if (Z_TYPE_P(str) != IS_STRING || Z_TYPE_P(compared) != IS_STRING) { return 0; } if (!Z_STRLEN_P(compared) || !Z_STRLEN_P(str) || Z_STRLEN_P(compared) > Z_STRLEN_P(str)) { return 0; } if (case_sensitive) { sensitive = zend_is_true(case_sensitive); } if (!sensitive) { return !memcmp(Z_STRVAL_P(str) + Z_STRLEN_P(str) - Z_STRLEN_P(compared), Z_STRVAL_P(compared), Z_STRLEN_P(compared)); } op1_cursor = Z_STRVAL_P(str) + Z_STRLEN_P(str) - Z_STRLEN_P(compared); op2_cursor = Z_STRVAL_P(compared); for (i = 0; i < Z_STRLEN_P(compared); ++i) { if (tolower(*op1_cursor) != tolower(*op2_cursor)) { return 0; } ++op1_cursor; ++op2_cursor; } return 1; } static int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length) { if (Z_TYPE_P(str) != IS_STRING) { return 0; } if (!compared_length || !Z_STRLEN_P(str) || compared_length > Z_STRLEN_P(str)) { return 0; } return !memcmp(Z_STRVAL_P(str) + Z_STRLEN_P(str) - compared_length, compared, compared_length); } static void zephir_random_string(zval *return_value, const zval *type, const zval *length TSRMLS_DC) { long i, rand_type, ch; smart_str random_str = {0}; if (Z_TYPE_P(type) != IS_LONG) { return; } if (Z_LVAL_P(type) > PH_RANDOM_NOZERO) { return; } if (Z_TYPE_P(length) != IS_LONG) { return; } /** Generate seed */ if (!BG(mt_rand_is_seeded)) { php_mt_srand(GENERATE_SEED() TSRMLS_CC); } for (i = 0; i < Z_LVAL_P(length); i++) { switch (Z_LVAL_P(type)) { case PH_RANDOM_ALNUM: rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(rand_type, 0, 3, PHP_MT_RAND_MAX); break; case PH_RANDOM_ALPHA: rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(rand_type, 1, 2, PHP_MT_RAND_MAX); break; case PH_RANDOM_HEXDEC: rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(rand_type, 0, 1, PHP_MT_RAND_MAX); break; case PH_RANDOM_NUMERIC: rand_type = 0; break; case PH_RANDOM_NOZERO: rand_type = 5; break; default: continue; } switch (rand_type) { case 0: ch = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(ch, '0', '9', PHP_MT_RAND_MAX); break; case 1: ch = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(ch, 'a', 'f', PHP_MT_RAND_MAX); break; case 2: ch = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(ch, 'a', 'z', PHP_MT_RAND_MAX); break; case 3: ch = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(ch, 'A', 'Z', PHP_MT_RAND_MAX); break; case 5: ch = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(ch, '1', '9', PHP_MT_RAND_MAX); break; default: continue; } smart_str_appendc(&random_str, (unsigned int) ch); } smart_str_0(&random_str); if (random_str.len) { RETURN_STRINGL(random_str.c, random_str.len, 0); } else { smart_str_free(&random_str); RETURN_EMPTY_STRING(); } } static void zephir_remove_extra_slashes(zval *return_value, const zval *str) { char *cursor, *removed_str; unsigned int i; if (Z_TYPE_P(str) != IS_STRING) { RETURN_EMPTY_STRING(); } if (Z_STRLEN_P(str) > 1) { cursor = Z_STRVAL_P(str); cursor += (Z_STRLEN_P(str) - 1); for (i = Z_STRLEN_P(str); i > 0; i--) { if ((*cursor) == '/') { cursor--; continue; } break; } } else { i = Z_STRLEN_P(str); } removed_str = emalloc(i + 1); memcpy(removed_str, Z_STRVAL_P(str), i); removed_str[i] = '\0'; RETURN_STRINGL(removed_str, i, 0); } static int zephir_spprintf(char **message, int max_len, char *format, ...) { va_list arg; int len; va_start(arg, format); len = vspprintf(message, max_len, format, arg); va_end(arg); return len; } static void zephir_substr(zval *return_value, zval *str, long f, long l, int flags) { zval copy; int use_copy = 0; int str_len; if (Z_TYPE_P(str) != IS_STRING) { if (Z_TYPE_P(str) == IS_NULL || Z_TYPE_P(str) == IS_BOOL) { RETURN_FALSE; } if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } } str_len = Z_STRLEN_P(str); if ((flags & ZEPHIR_SUBSTR_NO_LENGTH) == ZEPHIR_SUBSTR_NO_LENGTH) { l = str_len; } if ((l < 0 && -l > str_len)) { if (use_copy) { zval_dtor(str); } RETURN_FALSE; } else { if (l > str_len) { l = str_len; } } if (f > str_len) { if (use_copy) { zval_dtor(str); } RETURN_FALSE; } else { if (f < 0 && -f > str_len) { f = 0; } } if (l < 0 && (l + str_len - f) < 0) { if (use_copy) { zval_dtor(str); } RETURN_FALSE; } /* if "from" position is negative, count start position from the end * of the string */ if (f < 0) { f = str_len + f; if (f < 0) { f = 0; } } /* if "length" position is negative, set it to the length * needed to stop that many chars from the end of the string */ if (l < 0) { l = (str_len - f) + l; if (l < 0) { l = 0; } } if (f >= str_len) { if (use_copy) { zval_dtor(str); } RETURN_FALSE; } if ((f + l) > str_len) { l = str_len - f; } if (!l) { if (use_copy) { zval_dtor(str); } RETURN_EMPTY_STRING(); } ZVAL_STRINGL(return_value, Z_STRVAL_P(str) + f, l, 1); if (use_copy) { zval_dtor(str); } return; } static void zephir_append_printable_array(smart_str *implstr, zval *value TSRMLS_DC) { zval **tmp; HashTable *arr; HashPosition pos; unsigned int numelems, i = 0, str_len; arr = Z_ARRVAL_P(value); numelems = zend_hash_num_elements(arr); smart_str_appendc(implstr, '['); if (numelems > 0) { zend_hash_internal_pointer_reset_ex(arr, &pos); while (zend_hash_get_current_data_ex(arr, (void **) &tmp, &pos) == SUCCESS) { if (Z_TYPE_PP(tmp) == IS_OBJECT) { smart_str_appendc(implstr, 'O'); { char stmp[MAX_LENGTH_OF_LONG + 1]; str_len = slprintf(stmp, sizeof(stmp), "%ld", Z_OBJVAL_PP(tmp).handle); smart_str_appendl(implstr, stmp, str_len); } } else { if (Z_TYPE_PP(tmp) == IS_ARRAY) { zephir_append_printable_array(implstr, *tmp TSRMLS_CC); } else { zephir_append_printable_zval(implstr, tmp TSRMLS_CC); } } if (++i != numelems) { smart_str_appendc(implstr, ','); } zend_hash_move_forward_ex(arr, &pos); } } smart_str_appendc(implstr, ']'); } static void zephir_unique_key(zval *return_value, zval *prefix, zval *value TSRMLS_DC) { smart_str implstr = {0}; if (Z_TYPE_P(prefix) == IS_STRING) { smart_str_appendl(&implstr, Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)); } if (Z_TYPE_P(value) == IS_ARRAY) { zephir_append_printable_array(&implstr, value TSRMLS_CC); } else { zephir_append_printable_zval(&implstr, &value TSRMLS_CC); } smart_str_0(&implstr); if (implstr.len) { RETURN_STRINGL(implstr.c, implstr.len, 0); } else { smart_str_free(&implstr); RETURN_NULL(); } } zval *zephir_eol(int eol TSRMLS_DC) { zval *local_eol; ZEPHIR_INIT_VAR(local_eol); if (eol) { ZVAL_STRING(local_eol, PHP_EOL, 1); } else { ZVAL_EMPTY_STRING(local_eol); } return local_eol; } static void zephir_base64_encode(zval *return_value, zval *data) { zval copy; char *encoded; int use_copy = 0, length; if (Z_TYPE_P(data) != IS_STRING) { zend_make_printable_zval(data, ©, &use_copy); if (use_copy) { data = © } } encoded = (char *) php_base64_encode((unsigned char *)(Z_STRVAL_P(data)), Z_STRLEN_P(data), &length); if (use_copy) { zval_dtor(data); } if (encoded) { RETURN_STRINGL(encoded, length, 0); } else { RETURN_NULL(); } } static void zephir_base64_decode(zval *return_value, zval *data) { zval copy; char *decoded; int use_copy = 0, length; if (Z_TYPE_P(data) != IS_STRING) { zend_make_printable_zval(data, ©, &use_copy); if (use_copy) { data = © } } decoded = (char *) php_base64_decode((unsigned char *)(Z_STRVAL_P(data)), Z_STRLEN_P(data), &length); if (use_copy) { zval_dtor(data); } if (decoded) { RETURN_STRINGL(decoded, length, 0); } else { RETURN_NULL(); } } static void zephir_md5(zval *return_value, zval *str) { PHP_MD5_CTX ctx; unsigned char digest[16]; char hexdigest[33]; zval copy; int use_copy = 0; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } PHP_MD5Init(&ctx); PHP_MD5Update(&ctx, Z_STRVAL_P(str), Z_STRLEN_P(str)); PHP_MD5Final(digest, &ctx); make_digest(hexdigest, digest); ZVAL_STRINGL(return_value, hexdigest, 32, 1); } static void zephir_crc32(zval *return_value, zval *str TSRMLS_DC) { zval copy; int use_copy = 0; size_t nr; char *p; php_uint32 crc; php_uint32 crcinit = 0; if (Z_TYPE_P(str) != IS_STRING) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } p = Z_STRVAL_P(str); nr = Z_STRLEN_P(str); crc = crcinit^0xFFFFFFFF; for (; nr--; ++p) { crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF]; } if (use_copy) { zval_dtor(str); } RETVAL_LONG(crc ^ 0xFFFFFFFF); } #ifdef ZEPHIR_USE_PHP_PCRE static void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC) { zval copy; int use_copy = 0; pcre_cache_entry *pce; if (Z_TYPE_P(regex) != IS_STRING) { zend_error(E_WARNING, "Invalid arguments supplied for zephir_preg_match()"); RETURN_FALSE; } if (Z_TYPE_P(subject) != IS_STRING) { zend_make_printable_zval(subject, ©, &use_copy); if (use_copy) { subject = © } } /* Compile regex or get it from cache. */ if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(regex), Z_STRLEN_P(regex) TSRMLS_CC)) == NULL) { if (use_copy) { zval_dtor(subject); } RETURN_FALSE; } if (flags != 0 || offset != 0) { php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 1, flags, offset TSRMLS_CC); } else { php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 0, 0, 0 TSRMLS_CC); } if (use_copy) { zval_dtor(©); } } #else static void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC) { zval tmp_flags; zval tmp_offset; zval *rv = NULL; zval **rvp = &rv; if (matches) { Z_SET_ISREF_P(matches); } ZEPHIR_SINIT_VAR(tmp_flags); ZEPHIR_SINIT_VAR(tmp_offset); ZVAL_LONG(&tmp_flags, flags); ZVAL_LONG(&tmp_offset, offset); { zval *tmp_params[5] = { regex, subject, matches, &tmp_flags, &tmp_offset }; if (global) { zephir_call_func_aparams(rvp, SL("preg_match_all"), NULL, 0, 5, tmp_params TSRMLS_CC); } else { zephir_call_func_aparams(rvp, SL("preg_match"), NULL, 0, 5, tmp_params TSRMLS_CC); } } if (matches) { Z_UNSET_ISREF_P(matches); } if (return_value) { COPY_PZVAL_TO_ZVAL(*return_value, rv); } } #endif /* ZEPHIR_USE_PHP_PCRE */ #ifdef ZEPHIR_USE_PHP_JSON static int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC) { smart_str buf = { NULL, 0, 0 }; php_json_encode(&buf, v, opts TSRMLS_CC); smart_str_0(&buf); ZVAL_STRINGL(return_value, buf.c, buf.len, 0); return SUCCESS; } static int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC) { zval copy; int use_copy = 0; if (unlikely(Z_TYPE_P(v) != IS_STRING)) { zend_make_printable_zval(v, ©, &use_copy); if (use_copy) { v = © } } php_json_decode(return_value, Z_STRVAL_P(v), Z_STRLEN_P(v), assoc, 512 /* JSON_PARSER_DEFAULT_DEPTH */ TSRMLS_CC); if (unlikely(use_copy)) { zval_dtor(©); } return SUCCESS; } #else static int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC) { zval zopts; zval *params[2]; ZEPHIR_SINIT_VAR(zopts); ZVAL_LONG(&zopts, opts); params[0] = v; params[1] = &zopts; return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_encode"), NULL, 0, 2, params TSRMLS_CC); } static int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC) { zval zassoc; zval *params[2]; ZEPHIR_SINIT_VAR(zassoc); ZVAL_BOOL(&zassoc, assoc); params[0] = v; params[1] = &zassoc; return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_decode"), NULL, 0, 2, params TSRMLS_CC); } #endif /* ZEPHIR_USE_PHP_JSON */ static void zephir_lcfirst(zval *return_value, zval *s) { zval copy; char *c; int use_copy = 0; if (unlikely(Z_TYPE_P(s) != IS_STRING)) { zend_make_printable_zval(s, ©, &use_copy); if (use_copy) { s = © } } if (!Z_STRLEN_P(s)) { ZVAL_EMPTY_STRING(return_value); } else { ZVAL_STRINGL(return_value, Z_STRVAL_P(s), Z_STRLEN_P(s), 1); c = Z_STRVAL_P(return_value); *c = tolower((unsigned char)*c); } if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_ucfirst(zval *return_value, zval *s) { zval copy; char *c; int use_copy = 0; if (unlikely(Z_TYPE_P(s) != IS_STRING)) { zend_make_printable_zval(s, ©, &use_copy); if (use_copy) { s = © } } if (!Z_STRLEN_P(s)) { ZVAL_EMPTY_STRING(return_value); } else { ZVAL_STRINGL(return_value, Z_STRVAL_P(s), Z_STRLEN_P(s), 1); c = Z_STRVAL_P(return_value); *c = toupper((unsigned char)*c); } if (unlikely(use_copy)) { zval_dtor(©); } } static int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC) { if (Z_TYPE_P(params) == IS_ARRAY || Z_TYPE_P(params) == IS_OBJECT) { smart_str formstr = { NULL, 0, 0 }; int res; #if PHP_VERSION_ID < 50400 res = php_url_encode_hash_ex(HASH_OF(params), &formstr, NULL, 0, NULL, 0, NULL, 0, (Z_TYPE_P(params) == IS_OBJECT ? params : NULL), sep TSRMLS_CC); #else res = php_url_encode_hash_ex(HASH_OF(params), &formstr, NULL, 0, NULL, 0, NULL, 0, (Z_TYPE_P(params) == IS_OBJECT ? params : NULL), sep, PHP_QUERY_RFC1738 TSRMLS_CC); #endif if (res == SUCCESS) { if (!formstr.c) { ZVAL_EMPTY_STRING(return_value); } else { smart_str_0(&formstr); ZVAL_STRINGL(return_value, formstr.c, formstr.len, 0); } return SUCCESS; } smart_str_free(&formstr); ZVAL_FALSE(return_value); } else { ZVAL_NULL(return_value); } return FAILURE; } static void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC) { zval copy; char *escaped, *cs; int qs, use_copy = 0; #if PHP_VERSION_ID < 50400 int escaped_len; #else size_t escaped_len; #endif if (unlikely(Z_TYPE_P(string) != IS_STRING)) { zend_make_printable_zval(string, ©, &use_copy); if (use_copy) { string = © } } cs = (charset && Z_TYPE_P(charset) == IS_STRING) ? Z_STRVAL_P(charset) : NULL; qs = (quoting && Z_TYPE_P(quoting) == IS_LONG) ? Z_LVAL_P(quoting) : ENT_COMPAT; escaped = php_escape_html_entities_ex((unsigned char *)(Z_STRVAL_P(string)), Z_STRLEN_P(string), &escaped_len, 0, qs, cs, 1 TSRMLS_CC); ZVAL_STRINGL(return_value, escaped, escaped_len, 0); if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_htmlentities(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC) { zval copy; char *escaped, *cs; int qs, use_copy = 0; #if PHP_VERSION_ID < 50400 int escaped_len; #else size_t escaped_len; #endif if (unlikely(Z_TYPE_P(string) != IS_STRING)) { zend_make_printable_zval(string, ©, &use_copy); if (use_copy) { string = © } } cs = (charset && Z_TYPE_P(charset) == IS_STRING) ? Z_STRVAL_P(charset) : NULL; qs = (quoting && Z_TYPE_P(quoting) == IS_LONG) ? Z_LVAL_P(quoting) : ENT_COMPAT; escaped = php_escape_html_entities_ex((unsigned char *)(Z_STRVAL_P(string)), Z_STRLEN_P(string), &escaped_len, 1, qs, cs, 1 TSRMLS_CC); ZVAL_STRINGL(return_value, escaped, escaped_len, 0); if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_strval(zval *return_value, zval *v) { zval copy; int use_copy = 0; zend_make_printable_zval(v, ©, &use_copy); if (use_copy) { zval *tmp = © ZVAL_ZVAL(return_value, tmp, 0, 0); } else { ZVAL_ZVAL(return_value, v, 1, 0); } } static void zephir_date(zval *return_value, zval *format, zval *timestamp TSRMLS_DC) { long int ts; zval copy; int use_copy = 0; char *formatted; if (unlikely(Z_TYPE_P(format) != IS_STRING)) { zend_make_printable_zval(format, ©, &use_copy); if (use_copy) { format = © } } ts = (timestamp) ? zephir_get_intval(timestamp) : time(NULL); formatted = php_format_date(Z_STRVAL_P(format), Z_STRLEN_P(format), ts, 1 TSRMLS_CC); ZVAL_STRING(return_value, formatted, 0); if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_addslashes(zval *return_value, zval *str TSRMLS_DC) { zval copy; int use_copy = 0; if (unlikely(Z_TYPE_P(str) != IS_STRING)) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } ZVAL_STRING(return_value, php_addslashes(Z_STRVAL_P(str), Z_STRLEN_P(str), &Z_STRLEN_P(return_value), 0 TSRMLS_CC), 0); if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_stripslashes(zval *return_value, zval *str TSRMLS_DC) { zval copy; int use_copy = 0; if (unlikely(Z_TYPE_P(str) != IS_STRING)) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } ZVAL_STRINGL(return_value, Z_STRVAL_P(str), Z_STRLEN_P(str), 1); php_stripslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value) TSRMLS_CC); if (unlikely(use_copy)) { zval_dtor(©); } } static void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC) { zval copy; int use_copy = 0; if (unlikely(Z_TYPE_P(str) != IS_STRING)) { zend_make_printable_zval(str, ©, &use_copy); if (use_copy) { str = © } } ZVAL_STRINGL(return_value, Z_STRVAL_P(str), Z_STRLEN_P(str), 1); php_stripcslashes(Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value)); if (unlikely(use_copy)) { zval_dtor(©); } } #if PHP_VERSION_ID < 50400 const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC) { return arKey; } #endif #include <php.h> #include <Zend/zend_API.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_execute.h> #if PHP_VERSION_ID >= 50500 static const unsigned char tolower_map[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; #endif static int zephir_has_constructor_ce(const zend_class_entry *ce) { while (ce) { if (ce->constructor) { return 1; } ce = ce->parent; } return 0; } #if 0 static inline ulong zephir_update_hash(const char *arKey, uint nKeyLength, ulong hash) { for (; nKeyLength >= 8; nKeyLength -= 8) { hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; } switch (nKeyLength) { case 7: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 6: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 5: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 4: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 3: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 2: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 1: hash = ((hash << 5) + hash) + *arKey++; /* no break */ default: break; } return hash; } #endif static char *zephir_fcall_possible_method(zend_class_entry *ce, const char *wrong_name TSRMLS_DC) { HashTable *methods; HashPosition pos; zend_function *method; char *possible_method = NULL; zval *left = NULL, *right = NULL, method_name; zval *params[1]; int count; count = zend_hash_num_elements(&ce->function_table); if (count > 0) { ZEPHIR_SINIT_VAR(method_name); ZVAL_STRING(&method_name, wrong_name, 0); params[0] = &method_name; zephir_call_func_aparams(&right, SL("metaphone"), NULL, 0, 1, params TSRMLS_CC); methods = &ce->function_table; zend_hash_internal_pointer_reset_ex(methods, &pos); while (zend_hash_get_current_data_ex(methods, (void **) &method, &pos) == SUCCESS) { ZEPHIR_SINIT_VAR(method_name); ZVAL_STRING(&method_name, method->common.function_name, 0); if (left) { zephir_ptr_dtor(&left); } left = NULL; params[0] = &method_name; zephir_call_func_aparams(&left, SL("metaphone"), NULL, 0, 1, params TSRMLS_CC); if (zephir_is_equal(left, right TSRMLS_CC)) { possible_method = (char *) method->common.function_name; break; } zend_hash_move_forward_ex(methods, &pos); } if (left) { zephir_ptr_dtor(&left); } if (right) { zephir_ptr_dtor(&right); } } return possible_method; } static ulong zephir_make_fcall_key(char **result, size_t *length, const zend_class_entry *obj_ce, zephir_call_type type, zval *function_name TSRMLS_DC) { const zend_class_entry *calling_scope = EG(scope); char *buf = NULL, *c; size_t l = 0, len = 0; const size_t ppzce_size = sizeof(zend_class_entry**); ulong hash = 5381; *result = NULL; *length = 0; if (calling_scope && type == zephir_fcall_parent) { calling_scope = calling_scope->parent; if (UNEXPECTED(!calling_scope)) { return 0; } } else if (type == zephir_fcall_static) { calling_scope = EG(called_scope); if (UNEXPECTED(!calling_scope)) { return 0; } } if ( calling_scope && obj_ce && calling_scope != obj_ce && !instanceof_function(obj_ce, calling_scope TSRMLS_CC) && !instanceof_function(calling_scope, obj_ce TSRMLS_CC) ) { calling_scope = NULL; } if (Z_TYPE_P(function_name) == IS_STRING) { l = (size_t)(Z_STRLEN_P(function_name)) + 1; c = Z_STRVAL_P(function_name); len = 2 * ppzce_size + l + 1; buf = emalloc(len); memcpy(buf, c, l); memcpy(buf + l, &calling_scope, ppzce_size); memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size); buf[len - 1] = '\0'; } else if (Z_TYPE_P(function_name) == IS_ARRAY) { zval **method; HashTable *function_hash = Z_ARRVAL_P(function_name); if ( function_hash->nNumOfElements == 2 && zend_hash_index_find(function_hash, 1, (void**)&method) == SUCCESS && Z_TYPE_PP(method) == IS_STRING ) { l = (size_t)(Z_STRLEN_PP(method)) + 1; c = Z_STRVAL_PP(method); len = 2 * ppzce_size + l + 1; buf = emalloc(len); memcpy(buf, c, l); memcpy(buf + l, &calling_scope, ppzce_size); memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size); buf[len - 1] = '\0'; } } if (EXPECTED(buf != NULL)) { size_t i; for (i = 0; i < l; ++i) { char c = buf[i]; #if PHP_VERSION_ID >= 50500 c = tolower_map[(unsigned char)c]; #else c = tolower(c); #endif buf[i] = c; hash = (hash << 5) + hash + c; } for (i = l; i < len; ++i) { char c = buf[i]; hash = (hash << 5) + hash + c; } } *result = buf; *length = len; return hash; } static ulong zephir_make_fcall_info_key(char **result, size_t *length, const zend_class_entry *obj_ce, zephir_call_type type, zephir_fcall_info *info TSRMLS_DC) { const zend_class_entry *calling_scope = EG(scope); char *buf = NULL, *c; size_t l = 0, len = 0; const size_t ppzce_size = sizeof(zend_class_entry**); ulong hash = 5381; *result = NULL; *length = 0; if (calling_scope && type == zephir_fcall_parent) { calling_scope = calling_scope->parent; if (UNEXPECTED(!calling_scope)) { return 0; } } else if (type == zephir_fcall_static) { calling_scope = EG(called_scope); if (UNEXPECTED(!calling_scope)) { return 0; } } if ( calling_scope && obj_ce && calling_scope != obj_ce && !instanceof_function(obj_ce, calling_scope TSRMLS_CC) && !instanceof_function(calling_scope, obj_ce TSRMLS_CC) ) { calling_scope = NULL; } switch (info->type) { case ZEPHIR_FCALL_TYPE_FUNC: l = (size_t)(info->func_length) + 1; c = (char*) info->func_name; len = 2 * ppzce_size + l + 1; buf = emalloc(len); memcpy(buf, c, l); memcpy(buf + l, &calling_scope, ppzce_size); memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size); buf[len - 1] = '\0'; break; case ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD: case ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD: case ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD: l = (size_t)(info->func_length) + 2; /* reserve 1 char for fcall-type */ c = (char*) info->func_name; len = 2 * ppzce_size + l + 1; buf = emalloc(len); buf[0] = info->type; memcpy(buf + 1, c, l - 1); memcpy(buf + l, &calling_scope, ppzce_size); memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size); buf[len - 1] = '\0'; break; case ZEPHIR_FCALL_TYPE_CE_METHOD: case ZEPHIR_FCALL_TYPE_ZVAL_METHOD: l = (size_t)(info->func_length) + 1; c = (char*) info->func_name; len = 2 * ppzce_size + l + 1; buf = emalloc(len); memcpy(buf, c, l); memcpy(buf + l, &calling_scope, ppzce_size); memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size); buf[len - 1] = '\0'; break; } if (EXPECTED(buf != NULL)) { size_t i; for (i = 0; i < l; ++i) { char c = buf[i]; #if PHP_VERSION_ID >= 50500 c = tolower_map[(unsigned char)c]; #else c = tolower(c); #endif buf[i] = c; hash = (hash << 5) + hash + c; } for (i = l; i < len; ++i) { char c = buf[i]; hash = (hash << 5) + hash + c; } } *result = buf; *length = len; return hash; } ZEPHIR_ATTR_NONNULL static void zephir_fcall_populate_fci_cache(zend_fcall_info_cache *fcic, zend_fcall_info *fci, zephir_call_type type TSRMLS_DC) { switch (type) { case zephir_fcall_parent: if (EG(scope) && EG(scope)->parent) { fcic->calling_scope = EG(scope)->parent; fcic->called_scope = EG(called_scope); fcic->object_ptr = fci->object_ptr ? fci->object_ptr : EG(This); fcic->initialized = 1; } break; case zephir_fcall_self: if (EG(scope)) { fcic->calling_scope = EG(scope); fcic->called_scope = EG(called_scope); fcic->object_ptr = fci->object_ptr ? fci->object_ptr : EG(This); fcic->initialized = 1; } break; case zephir_fcall_static: if (EG(called_scope)) { fcic->calling_scope = EG(called_scope); fcic->called_scope = EG(called_scope); fcic->object_ptr = fci->object_ptr ? fci->object_ptr : EG(This); fcic->initialized = 1; } break; case zephir_fcall_function: fcic->calling_scope = NULL; fcic->called_scope = NULL; fcic->object_ptr = NULL; fcic->initialized = 1; break; case zephir_fcall_ce: { zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL; fcic->initialized = 1; fcic->calling_scope = EG(scope); fcic->object_ptr = NULL; if (scope && EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) && instanceof_function(scope, fcic->calling_scope TSRMLS_CC)) { fcic->object_ptr = EG(This); fcic->called_scope = Z_OBJCE_P(fcic->object_ptr); } else { fcic->called_scope = fcic->calling_scope; } break; } case zephir_fcall_method: fcic->initialized = 1; fcic->calling_scope = EG(scope); fcic->object_ptr = fci->object_ptr; if (fci->object_ptr) { fcic->called_scope = Z_OBJCE_P(fci->object_ptr); } else if (EG(scope) && !(EG(called_scope) && instanceof_function(EG(called_scope), EG(scope) TSRMLS_CC))) { fcic->called_scope = EG(scope); } else { fcic->called_scope = EG(called_scope); } break; default: #ifndef ZEPHIR_RELEASE fprintf(stderr, "%s: unknown call type (%d)\n", __func__, (int) type); abort(); #endif fcic->initialized = 0; /* not strictly necessary but just to be safe */ break; } } static int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir_call_type type, zval *function_name, zval **retval_ptr_ptr, zephir_fcall_cache_entry **cache_entry, int cache_slot, zend_uint param_count, zval *params[], zephir_fcall_info *info TSRMLS_DC) { zval ***params_ptr, ***params_array = NULL; zval **static_params_array[10]; zval *local_retval_ptr = NULL; int status; zend_fcall_info fci; zend_fcall_info_cache fcic /* , clone */; zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL; char *fcall_key = NULL; size_t fcall_key_len; ulong fcall_key_hash; zephir_fcall_cache_entry **temp_cache_entry = NULL; zend_class_entry *old_scope = EG(scope); int reload_cache = 1; assert(obj_ce || !object_pp); if (retval_ptr_ptr && *retval_ptr_ptr) { zval_ptr_dtor(retval_ptr_ptr); *retval_ptr_ptr = NULL; } ++zephir_globals_ptr->recursive_lock; if (UNEXPECTED(zephir_globals_ptr->recursive_lock > 2048)) { zend_error(E_ERROR, "Maximum recursion depth exceeded"); return FAILURE; } if (param_count) { zend_uint i; if (UNEXPECTED(param_count > 10)) { params_array = (zval***) emalloc(param_count * sizeof(zval**)); params_ptr = params_array; for (i = 0; i < param_count; ++i) { params_array[i] = ¶ms[i]; } } else { params_ptr = static_params_array; for (i = 0; i < param_count; ++i) { static_params_array[i] = ¶ms[i]; } } } else { params_ptr = NULL; } if (type != zephir_fcall_function && !object_pp) { object_pp = EG(This) ? &EG(This) : NULL; if (!obj_ce && object_pp) { obj_ce = Z_OBJCE_PP(object_pp); } } if (obj_ce) { EG(scope) = obj_ce; } if (!cache_entry || !*cache_entry) { if (zephir_globals_ptr->cache_enabled) { if (cache_slot > 0) { if (zephir_globals_ptr->scache[cache_slot]) { reload_cache = 0; temp_cache_entry = &zephir_globals_ptr->scache[cache_slot]; if (cache_entry) { *cache_entry = *temp_cache_entry; } } } if (reload_cache) { if (info) { fcall_key_hash = zephir_make_fcall_info_key(&fcall_key, &fcall_key_len, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_PP(object_pp) : obj_ce), type, info TSRMLS_CC); } else { fcall_key_hash = zephir_make_fcall_key(&fcall_key, &fcall_key_len, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_PP(object_pp) : obj_ce), type, function_name TSRMLS_CC); } } } } fci.size = sizeof(fci); fci.function_table = obj_ce ? &obj_ce->function_table : EG(function_table); fci.object_ptr = object_pp ? *object_pp : NULL; fci.function_name = function_name; fci.retval_ptr_ptr = retval_ptr_ptr ? retval_ptr_ptr : &local_retval_ptr; fci.param_count = param_count; fci.params = params_ptr; fci.no_separation = 1; fci.symbol_table = NULL; fcic.initialized = 0; fcic.function_handler = NULL; fcic.calling_scope = NULL; fcic.called_scope = NULL; if (!cache_entry || !*cache_entry) { if (fcall_key && zend_hash_quick_find(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, (void**)&temp_cache_entry) != FAILURE) { zephir_fcall_populate_fci_cache(&fcic, &fci, type TSRMLS_CC); #ifndef ZEPHIR_RELEASE fcic.function_handler = (*temp_cache_entry)->f; ++(*temp_cache_entry)->times; #else fcic.function_handler = *temp_cache_entry; #endif /*memcpy(&clone, &fcic, sizeof(clone));*/ } } else { zephir_fcall_populate_fci_cache(&fcic, &fci, type TSRMLS_CC); #ifndef ZEPHIR_RELEASE fcic.function_handler = (*cache_entry)->f; ++(*cache_entry)->times; #else fcic.function_handler = *cache_entry; #endif } /* Xdebug fix */ //if (fcic.function_handler && fcic.function_handler->type == ZEND_INTERNAL_FUNCTION && fcic.function_handler->op_array) { // fcic.function_handler->op_array.filename = "?"; // fcic.function_handler->op_array.line_start = 0; // fcic.function_handler->op_array.line_end = 0; //} /* fcic.initialized = 0; */ #if PHP_VERSION_ID >= 50600 status = ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER(&fci, &fcic, info TSRMLS_CC); #else status = ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER(&fci, &fcic TSRMLS_CC); #endif EG(scope) = old_scope; if (!cache_entry || !*cache_entry) { if (EXPECTED(status != FAILURE) && fcall_key && !temp_cache_entry && fcic.initialized) { #ifndef ZEPHIR_RELEASE zephir_fcall_cache_entry *cache_entry_temp = malloc(sizeof(zephir_fcall_cache_entry)); cache_entry_temp->f = fcic.function_handler; cache_entry_temp->times = 0; #else zephir_fcall_cache_entry *cache_entry_temp = fcic.function_handler; #endif if (FAILURE == zend_hash_quick_add(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, &cache_entry_temp, sizeof(zephir_fcall_cache_entry*), NULL)) { #ifndef ZEPHIR_RELEASE free(temp_cache_entry); #endif } else { if (cache_entry) { *cache_entry = cache_entry_temp; if (cache_slot > 0) { zephir_globals_ptr->scache[cache_slot] = *cache_entry; } } } } } if (fcall_key) { efree(fcall_key); } if (UNEXPECTED(params_array != NULL)) { efree(params_array); } if (!retval_ptr_ptr) { if (local_retval_ptr) { zval_ptr_dtor(&local_retval_ptr); } } --zephir_globals_ptr->recursive_lock; return status; } static int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uint func_length, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { int status; zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; zval *func = NULL; #if PHP_VERSION_ID >= 50600 zephir_fcall_info info; #endif #ifndef ZEPHIR_RELEASE if (return_value_ptr && *return_value_ptr) { fprintf(stderr, "%s: *return_value_ptr must be NULL\n", __func__); zephir_print_backtrace(); abort(); } #endif #if PHP_VERSION_ID >= 50600 info.type = ZEPHIR_FCALL_TYPE_FUNC; info.class_name = NULL; info.func_name = func_name; info.func_length = func_length; status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func, rvp, cache_entry, cache_slot, param_count, params, &info TSRMLS_CC); #else ALLOC_INIT_ZVAL(func); ZVAL_STRINGL(func, func_name, func_length, 0); status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func, rvp, cache_entry, 0, param_count, params, NULL TSRMLS_CC); #endif if (status == FAILURE && !EG(exception)) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined function %s()", func_name); if (return_value_ptr) { *return_value_ptr = NULL; } } else { if (EG(exception)) { status = FAILURE; if (return_value_ptr) { *return_value_ptr = NULL; } } } if (rv) { zval_ptr_dtor(&rv); } #if PHP_VERSION_ID < 50600 if (Z_REFCOUNT_P(func) > 1) { zval_copy_ctor(func); } else { ZVAL_NULL(func); } zval_ptr_dtor(&func); #endif return status; } static int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { int status; zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; #ifndef ZEPHIR_RELEASE if (return_value_ptr && *return_value_ptr) { fprintf(stderr, "%s: *return_value_ptr must be NULL\n", __func__); zephir_print_backtrace(); abort(); } #endif status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func_name, rvp, cache_entry, cache_slot, param_count, params, NULL TSRMLS_CC); if (status == FAILURE && !EG(exception)) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined function %s()", Z_TYPE_P(func_name) ? Z_STRVAL_P(func_name) : "undefined"); if (return_value_ptr) { *return_value_ptr = NULL; } } else { if (EG(exception)) { status = FAILURE; if (return_value_ptr) { *return_value_ptr = NULL; } } } if (rv) { zval_ptr_dtor(&rv); } return status; } static int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object, const char *method_name, uint method_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC) { char *possible_method; zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv; zval *fn = NULL; #if PHP_VERSION_ID < 50600 zval *mn; #endif int status; #if PHP_VERSION_ID >= 50600 zephir_fcall_info info; #endif #ifndef ZEPHIR_RELEASE if (return_value_ptr && *return_value_ptr) { fprintf(stderr, "%s: *return_value_ptr must be NULL\n", __func__); zephir_print_backtrace(); abort(); } #endif if (object) { if (Z_TYPE_P(object) != IS_OBJECT) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Trying to call method %s on a non-object", method_name); if (return_value_ptr) { *return_value_ptr = NULL; } return FAILURE; } } #if PHP_VERSION_ID >= 50600 if (!cache_entry || !*cache_entry) { switch (type) { case zephir_fcall_parent: info.type = ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD; break; case zephir_fcall_self: assert(!ce); info.type = ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD; break; case zephir_fcall_static: assert(!ce); info.type = ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD; break; case zephir_fcall_ce: assert(ce != NULL); info.type = ZEPHIR_FCALL_TYPE_CE_METHOD; info.ce = ce; break; case zephir_fcall_method: default: assert(object != NULL); info.type = ZEPHIR_FCALL_TYPE_ZVAL_METHOD; info.object_ptr = object; info.ce = ce; break; } info.func_name = method_name; info.func_length = method_len; } status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, cache_slot, param_count, params, &info TSRMLS_CC); #else ALLOC_INIT_ZVAL(fn); if (!cache_entry || !*cache_entry) { array_init_size(fn, 2); switch (type) { case zephir_fcall_parent: add_next_index_stringl(fn, ZEND_STRL("parent"), 1); break; case zephir_fcall_self: assert(!ce); add_next_index_stringl(fn, ZEND_STRL("self"), 1); break; case zephir_fcall_static: assert(!ce); add_next_index_stringl(fn, ZEND_STRL("static"), 1); break; case zephir_fcall_ce: assert(ce != NULL); add_next_index_stringl(fn, ce->name, ce->name_length, 1); break; case zephir_fcall_method: default: assert(object != NULL); Z_ADDREF_P(object); add_next_index_zval(fn, object); break; } ALLOC_INIT_ZVAL(mn); ZVAL_STRINGL(mn, method_name, method_len, 1); add_next_index_zval(fn, mn); } else { ZVAL_STRINGL(fn, "undefined", sizeof("undefined")-1, 1); } status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, cache_slot, param_count, params, NULL TSRMLS_CC); #endif if (status == FAILURE && !EG(exception)) { if (ce) { possible_method = zephir_fcall_possible_method(ce, method_name TSRMLS_CC); } else { possible_method = "undefined"; } switch (type) { case zephir_fcall_parent: if (possible_method) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method parent::%s(), did you mean '%s'?", method_name, possible_method); } else { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method parent::%s()", method_name); } break; case zephir_fcall_self: if (possible_method) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method self::%s(), did you mean '%s'?", method_name, possible_method); } else { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method self::%s()", method_name); } break; case zephir_fcall_static: zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method static::%s()", method_name); break; case zephir_fcall_ce: zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method %s::%s()", ce->name, method_name); break; case zephir_fcall_method: if (possible_method) { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method %s::%s(), did you mean '%s'?", ce->name, method_name, possible_method); } else { zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method %s::%s()", ce->name, method_name); } break; default: zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined method ?::%s()", method_name); } if (return_value_ptr) { *return_value_ptr = NULL; } } else { if (EG(exception)) { status = FAILURE; if (return_value_ptr) { *return_value_ptr = NULL; } } } if (rv) { zval_ptr_dtor(&rv); } #if PHP_VERSION_ID < 50600 zval_ptr_dtor(&fn); #endif return status; } static int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *params TSRMLS_DC){ zval *retval_ptr = NULL; zend_fcall_info fci; zend_fcall_info_cache fci_cache; char *is_callable_error = NULL; int status = FAILURE; if (params && Z_TYPE_P(params) != IS_ARRAY) { ZVAL_NULL(return_value); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_call_user_func_array_noex()"); return FAILURE; } if (zend_fcall_info_init(handler, 0, &fci, &fci_cache, NULL, &is_callable_error TSRMLS_CC) == SUCCESS) { if (is_callable_error) { zend_error(E_STRICT, "%s", is_callable_error); efree(is_callable_error); } status = SUCCESS; } else { if (is_callable_error) { zend_error(E_WARNING, "%s", is_callable_error); efree(is_callable_error); } else { status = SUCCESS; } } if (status == SUCCESS) { zend_fcall_info_args(&fci, params TSRMLS_CC); fci.retval_ptr_ptr = &retval_ptr; if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && fci.retval_ptr_ptr && *fci.retval_ptr_ptr) { COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr); } if (fci.params) { efree(fci.params); } } if (EG(exception)) { status = SUCCESS; } return status; } #if PHP_VERSION_ID <= 50309 static void zephir_throw_exception_internal(zval *exception TSRMLS_DC) { if (exception != NULL) { zval *previous = EG(exception); zend_exception_set_previous(exception, EG(exception) TSRMLS_CC); EG(exception) = exception; if (previous) { return; } } if (!EG(current_execute_data)) { if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); } zend_error(E_ERROR, "Exception thrown without a stack frame"); } if (zend_throw_exception_hook) { zend_throw_exception_hook(exception TSRMLS_CC); } if (EG(current_execute_data)->opline == NULL || (EG(current_execute_data)->opline + 1)->opcode == ZEND_HANDLE_EXCEPTION) { /* no need to rethrow the exception */ return; } EG(opline_before_exception) = EG(current_execute_data)->opline; EG(current_execute_data)->opline = EG(exception_op); } static int zephir_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) { zend_uint i; zval **original_return_value; HashTable *calling_symbol_table; zend_op_array *original_op_array; zend_op **original_opline_ptr; zend_class_entry *current_scope; zend_class_entry *current_called_scope; zend_class_entry *calling_scope = NULL; zend_class_entry *called_scope = NULL; zval *current_this; zend_execute_data execute_data; *fci->retval_ptr_ptr = NULL; if (!EG(active)) { return FAILURE; /* executor is already inactive */ } if (EG(exception)) { return FAILURE; /* we would result in an instable executor otherwise */ } switch (fci->size) { case sizeof(zend_fcall_info): break; /* nothing to do currently */ default: zend_error(E_ERROR, "Corrupted fcall_info provided to zephir_call_function()"); break; } /* Initialize execute_data */ if (EG(current_execute_data)) { execute_data = *EG(current_execute_data); EX(op_array) = NULL; EX(opline) = NULL; EX(object) = NULL; } else { /* This only happens when we're called outside any execute()'s * It shouldn't be strictly necessary to NULL execute_data out, * but it may make bugs easier to spot */ memset(&execute_data, 0, sizeof(zend_execute_data)); } if (!fci_cache || !fci_cache->initialized) { zend_fcall_info_cache fci_cache_local; char *callable_name; char *error = NULL; if (!fci_cache) { fci_cache = &fci_cache_local; } if (!zend_is_callable_ex(fci->function_name, fci->object_ptr, IS_CALLABLE_CHECK_SILENT, &callable_name, NULL, fci_cache, &error TSRMLS_CC)) { if (error) { zend_error(E_WARNING, "Invalid callback %s, %s", callable_name, error); efree(error); } if (callable_name) { efree(callable_name); } return FAILURE; } else { if (error) { /* Capitalize the first latter of the error message */ if (error[0] >= 'a' && error[0] <= 'z') { error[0] += ('A' - 'a'); } zend_error(E_STRICT, "%s", error); efree(error); } } efree(callable_name); } EX(function_state).function = fci_cache->function_handler; calling_scope = fci_cache->calling_scope; called_scope = fci_cache->called_scope; fci->object_ptr = fci_cache->object_ptr; EX(object) = fci->object_ptr; if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT && (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)].valid)) { return FAILURE; } #ifndef ZEPHIR_RELEASE if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); return FAILURE; } #endif ZEND_VM_STACK_GROW_IF_NEEDED(fci->param_count + 1); for (i = 0; i < fci->param_count; i++) { zval *param; if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION && (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 && !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) && PZVAL_IS_REF(*fci->params[i])) { ALLOC_ZVAL(param); *param = **(fci->params[i]); INIT_PZVAL(param); zval_copy_ctor(param); } else if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) && !PZVAL_IS_REF(*fci->params[i])) { if (Z_REFCOUNT_PP(fci->params[i]) > 1) { zval *new_zval; if (fci->no_separation && !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == EG(argument_stack)->top)) { /* hack to clean up the stack */ zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC); #if PHP_VERSION_ID <= 50500 zend_vm_stack_clear_multiple(TSRMLS_C); #else zend_vm_stack_clear_multiple(0 TSRMLS_C); #endif } zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", i+1, EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "", EX(function_state).function->common.scope ? "::" : "", EX(function_state).function->common.function_name); return FAILURE; } ALLOC_ZVAL(new_zval); *new_zval = **fci->params[i]; zval_copy_ctor(new_zval); Z_SET_REFCOUNT_P(new_zval, 1); Z_DELREF_PP(fci->params[i]); *fci->params[i] = new_zval; } Z_ADDREF_PP(fci->params[i]); Z_SET_ISREF_PP(fci->params[i]); param = *fci->params[i]; } else if (*fci->params[i] != &EG(uninitialized_zval)) { Z_ADDREF_PP(fci->params[i]); param = *fci->params[i]; } else { ALLOC_ZVAL(param); *param = **(fci->params[i]); INIT_PZVAL(param); } zend_vm_stack_push_nocheck(param TSRMLS_CC); } EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); zend_vm_stack_push_nocheck((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC); current_scope = EG(scope); EG(scope) = calling_scope; current_this = EG(This); current_called_scope = EG(called_scope); if (called_scope) { EG(called_scope) = called_scope; } else { if (EX(function_state).function->type != ZEND_INTERNAL_FUNCTION) { EG(called_scope) = NULL; } } if (fci->object_ptr) { if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { EG(This) = NULL; } else { EG(This) = fci->object_ptr; if (!PZVAL_IS_REF(EG(This))) { Z_ADDREF_P(EG(This)); /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); *this_ptr = *EG(This); INIT_PZVAL(this_ptr); zval_copy_ctor(this_ptr); EG(This) = this_ptr; } } } else { EG(This) = NULL; } EX(prev_execute_data) = EG(current_execute_data); EG(current_execute_data) = &execute_data; if (EX(function_state).function->type == ZEND_USER_FUNCTION) { calling_symbol_table = EG(active_symbol_table); EG(scope) = EX(function_state).function->common.scope; if (fci->symbol_table) { EG(active_symbol_table) = fci->symbol_table; } else { EG(active_symbol_table) = NULL; } original_return_value = EG(return_value_ptr_ptr); original_op_array = EG(active_op_array); EG(return_value_ptr_ptr) = fci->retval_ptr_ptr; EG(active_op_array) = (zend_op_array *) EX(function_state).function; original_opline_ptr = EG(opline_ptr); zend_execute(EG(active_op_array) TSRMLS_CC); if (!fci->symbol_table && EG(active_symbol_table)) { if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { zend_hash_destroy(EG(active_symbol_table)); FREE_HASHTABLE(EG(active_symbol_table)); } else { /* clean before putting into the cache, since clean could call dtors, which could use cached hash */ zend_hash_clean(EG(active_symbol_table)); *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); } } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; EG(return_value_ptr_ptr)=original_return_value; EG(opline_ptr) = original_opline_ptr; } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); if (EX(function_state).function->common.scope) { EG(scope) = EX(function_state).function->common.scope; } ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) if (!EX(function_state).function->common.return_reference) { INIT_PZVAL(*fci->retval_ptr_ptr); }*/ if (EG(exception) && fci->retval_ptr_ptr) { zval_ptr_dtor(fci->retval_ptr_ptr); *fci->retval_ptr_ptr = NULL; } if (call_via_handler) { /* We must re-initialize function again */ fci_cache->initialized = 0; } } else { ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); if (fci->object_ptr) { Z_OBJ_HT_P(fci->object_ptr)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); return FAILURE; } if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { efree(EX(function_state).function->common.function_name); } efree(EX(function_state).function); if (EG(exception) && fci->retval_ptr_ptr) { zval_ptr_dtor(fci->retval_ptr_ptr); *fci->retval_ptr_ptr = NULL; } } #if PHP_VERSION_ID <= 50500 zend_vm_stack_clear_multiple(TSRMLS_C); #else zend_vm_stack_clear_multiple(0 TSRMLS_C); #endif if (EG(This)) { zval_ptr_dtor(&EG(This)); } EG(called_scope) = current_called_scope; EG(scope) = current_scope; EG(This) = current_this; EG(current_execute_data) = EX(prev_execute_data); if (EG(exception)) { zephir_throw_exception_internal(NULL TSRMLS_CC); } return SUCCESS; } #endif static void zephir_eval_php(zval *str, zval *retval_ptr, char *context TSRMLS_DC) { zend_op_array *new_op_array = NULL; zend_uint original_compiler_options; zend_op_array *original_active_op_array = EG(active_op_array); original_compiler_options = CG(compiler_options); CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL; new_op_array = zend_compile_string(str, context TSRMLS_CC); CG(compiler_options) = original_compiler_options; if (new_op_array) { zval *local_retval_ptr = NULL; zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr); zend_op **original_opline_ptr = EG(opline_ptr); int orig_interactive = CG(interactive); EG(return_value_ptr_ptr) = &local_retval_ptr; EG(active_op_array) = new_op_array; EG(no_extensions) = 1; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); } CG(interactive) = 0; zend_try { zend_execute(new_op_array TSRMLS_CC); } zend_catch { destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); zend_bailout(); } zend_end_try(); CG(interactive) = orig_interactive; if (local_retval_ptr) { if (retval_ptr) { COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr); } else { zval_ptr_dtor(&local_retval_ptr); } } else if (retval_ptr) { INIT_ZVAL(*retval_ptr); } EG(no_extensions) = 0; EG(opline_ptr) = original_opline_ptr; EG(active_op_array) = original_active_op_array; destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); EG(return_value_ptr_ptr) = original_return_value_ptr_ptr; } } #ifdef HAVE_CONFIG_H #endif #include <main/php_main.h> #include <Zend/zend_exceptions.h> #ifndef ENFORCE_SAFE_MODE #define ENFORCE_SAFE_MODE 0 #endif static int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_DC) { zend_file_handle file_handle; int ret, use_ret; zend_op_array *new_op_array; #ifndef ZEPHIR_RELEASE if (return_value_ptr && *return_value_ptr) { fprintf(stderr, "%s: *return_value_ptr is expected to be NULL", __func__); zephir_print_backtrace(); abort(); } #endif if (!require_path) { /* @TODO, throw an exception here */ return FAILURE; } use_ret = !!return_value_ptr; file_handle.filename = require_path; file_handle.free_filename = 0; file_handle.type = ZEND_HANDLE_FILENAME; file_handle.opened_path = NULL; file_handle.handle.fp = NULL; new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC); if (new_op_array) { if (file_handle.handle.stream.handle) { int dummy = 1; if (!file_handle.opened_path) { file_handle.opened_path = estrdup(require_path); } zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path) + 1, (void *)&dummy, sizeof(int), NULL); zend_destroy_file_handle(&file_handle TSRMLS_CC); } { zval **original_return_value = EG(return_value_ptr_ptr); zend_op_array *original_active_op_array = EG(active_op_array); zend_op **original_opline_ptr = EG(opline_ptr); EG(return_value_ptr_ptr) = return_value_ptr; EG(active_op_array) = new_op_array; zend_execute(new_op_array TSRMLS_CC); zend_exception_restore(TSRMLS_C); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (EG(exception)) { assert(!return_value_ptr || !*return_value_ptr); ret = FAILURE; } else { ret = SUCCESS; } EG(return_value_ptr_ptr) = original_return_value; EG(active_op_array) = original_active_op_array; EG(opline_ptr) = original_opline_ptr; return ret; } } else { zend_destroy_file_handle(&file_handle TSRMLS_CC); } return FAILURE; } #ifdef HAVE_CONFIG_H #endif #define PHP_STREAM_TO_ZVAL(stream, arg) \ php_stream_from_zval_no_verify(stream, arg); \ if (stream == NULL) { \ if (return_value) { \ RETURN_FALSE; \ } else { \ return; \ } \ } static int zephir_file_exists(zval *filename TSRMLS_DC){ zval return_value; if (Z_TYPE_P(filename) != IS_STRING) { return FAILURE; } php_stat(Z_STRVAL_P(filename), (php_stat_len) Z_STRLEN_P(filename), FS_EXISTS, &return_value TSRMLS_CC); if (ZEPHIR_IS_FALSE((&return_value))) { return FAILURE; } if (ZEPHIR_IS_EMPTY((&return_value))) { return FAILURE; } return SUCCESS; } static int zephir_compare_mtime(zval *filename1, zval *filename2 TSRMLS_DC){ php_stream_statbuf statbuffer1, statbuffer2; if (Z_TYPE_P(filename1) != IS_STRING || Z_TYPE_P(filename2) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for compare_mtime()"); return 0; } if (php_stream_stat_path_ex(Z_STRVAL_P(filename1), 0, &statbuffer1, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "mstat failed for %s", Z_STRVAL_P(filename1)); return 0; } if (php_stream_stat_path_ex(Z_STRVAL_P(filename2), 0, &statbuffer2, NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "mstat failed for %s", Z_STRVAL_P(filename2)); return 0; } return (int) (statbuffer1.sb.st_mtime >= statbuffer2.sb.st_mtime); } static void zephir_fast_filemtime(zval *return_value, zval *filename TSRMLS_DC){ if (Z_TYPE_P(filename) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for fast_filemtime()"); return; } php_stat(Z_STRVAL_P(filename), (php_stat_len) Z_STRLEN_P(filename), FS_MTIME, return_value TSRMLS_CC); } static void zephir_fix_path(zval **return_value, zval *path, zval *directory_separator TSRMLS_DC) { if (Z_TYPE_P(path) != IS_STRING || Z_TYPE_P(directory_separator) != IS_STRING) { return; } if (Z_STRLEN_P(path) > 0 && Z_STRLEN_P(directory_separator) > 0) { if (Z_STRVAL_P(path)[Z_STRLEN_P(path) - 1] != Z_STRVAL_P(directory_separator)[0]) { ZEPHIR_CONCAT_VV(*return_value, path, directory_separator); return; } } zval_ptr_dtor(return_value); *return_value = path; Z_ADDREF_P(path); } static void zephir_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_separator TSRMLS_DC) { unsigned int i; unsigned char ch; smart_str virtual_str = {0}; if (Z_TYPE_P(path) != IS_STRING || Z_TYPE_P(virtual_separator) != IS_STRING) { if (Z_TYPE_P(path) == IS_STRING) { RETURN_STRINGL(Z_STRVAL_P(path), Z_STRLEN_P(path), 1); } else { RETURN_EMPTY_STRING(); } return; } for (i = 0; i < Z_STRLEN_P(path); i++) { ch = Z_STRVAL_P(path)[i]; if (ch == '\0') { break; } if (ch == '/' || ch == '\\' || ch == ':') { smart_str_appendl(&virtual_str, Z_STRVAL_P(virtual_separator), Z_STRLEN_P(virtual_separator)); } else { smart_str_appendc(&virtual_str, tolower(ch)); } } smart_str_0(&virtual_str); if (virtual_str.c) { RETURN_STRINGL(virtual_str.c, virtual_str.len, 0); } else { RETURN_EMPTY_STRING(); } } static void zephir_unique_path_key(zval *return_value, zval *path TSRMLS_DC) { unsigned long h; char *strKey; if (Z_TYPE_P(path) != IS_STRING) { return; } h = zend_hash_func(Z_STRVAL_P(path), Z_STRLEN_P(path) + 1); strKey = emalloc(24); sprintf(strKey, "v%lu", h); RETURN_STRING(strKey, 0); } static void zephir_realpath(zval *return_value, zval *filename TSRMLS_DC) { char resolved_path_buff[MAXPATHLEN]; if (Z_TYPE_P(filename) != IS_STRING) { RETURN_FALSE; } if (strlen(Z_STRVAL_P(filename)) != Z_STRLEN_P(filename)) { RETURN_FALSE; } if (VCWD_REALPATH(Z_STRVAL_P(filename), resolved_path_buff)) { RETURN_STRING(resolved_path_buff, 1); } RETURN_FALSE; } static void zephir_possible_autoload_filepath(zval *return_value, zval *prefix, zval *class_name, zval *virtual_separator, zval *separator TSRMLS_DC) { unsigned int i, length; unsigned char ch; smart_str virtual_str = {0}; if (Z_TYPE_P(prefix) != IS_STRING || Z_TYPE_P(class_name) != IS_STRING || Z_TYPE_P(virtual_separator) != IS_STRING) { RETURN_FALSE; } length = Z_STRLEN_P(prefix); if (!length) { RETURN_FALSE; } if (length > Z_STRLEN_P(class_name)) { RETURN_FALSE; } if (separator) { if (Z_STRVAL_P(prefix)[Z_STRLEN_P(prefix) - 1] == Z_STRVAL_P(separator)[0]) { length--; } } for (i = length + 1; i < Z_STRLEN_P(class_name); i++) { ch = Z_STRVAL_P(class_name)[i]; if (ch == '\0') { break; } if (ch == '\\') { smart_str_appendl(&virtual_str, Z_STRVAL_P(virtual_separator), Z_STRLEN_P(virtual_separator)); continue; } if (separator) { if (ch == Z_STRVAL_P(separator)[0]) { smart_str_appendl(&virtual_str, Z_STRVAL_P(virtual_separator), Z_STRLEN_P(virtual_separator)); continue; } } if ((ch == '_') || (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { smart_str_appendc(&virtual_str, ch); continue; } if (ch > 127) { smart_str_appendc(&virtual_str, ch); continue; } } smart_str_0(&virtual_str); if (virtual_str.len) { RETURN_STRINGL(virtual_str.c, virtual_str.len, 0); } else { smart_str_free(&virtual_str); RETURN_FALSE; } } static void zephir_file_get_contents(zval *return_value, zval *filename TSRMLS_DC) { char *contents; php_stream *stream; int len; long maxlen = PHP_STREAM_COPY_ALL; zval *zcontext = NULL; php_stream_context *context = NULL; if (Z_TYPE_P(filename) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_file_get_contents()"); RETVAL_FALSE; return; } context = php_stream_context_from_zval(zcontext, 0); stream = php_stream_open_wrapper_ex(Z_STRVAL_P(filename), "rb", 0 | REPORT_ERRORS, NULL, context); if (!stream) { RETURN_FALSE; } if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) { RETVAL_STRINGL(contents, len, 0); } else { if (len == 0) { RETVAL_EMPTY_STRING(); } else { RETVAL_FALSE; } } php_stream_close(stream); } static void zephir_file_put_contents(zval *return_value, zval *filename, zval *data TSRMLS_DC) { php_stream *stream; int numbytes = 0, use_copy = 0; zval *zcontext = NULL; zval copy; php_stream_context *context = NULL; if (Z_TYPE_P(filename) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_file_put_contents()"); if (return_value) { RETVAL_FALSE; } return; } context = php_stream_context_from_zval(zcontext, 0 & PHP_FILE_NO_DEFAULT_CONTEXT); stream = php_stream_open_wrapper_ex(Z_STRVAL_P(filename), "wb", ((0 & PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | REPORT_ERRORS, NULL, context); if (stream == NULL) { if (return_value) { RETURN_FALSE; } return; } switch (Z_TYPE_P(data)) { case IS_NULL: case IS_LONG: case IS_DOUBLE: case IS_BOOL: case IS_CONSTANT: zend_make_printable_zval(data, ©, &use_copy); if (use_copy) { data = © } /* no break */ case IS_STRING: if (Z_STRLEN_P(data)) { numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data)); if (numbytes != Z_STRLEN_P(data)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data)); numbytes = -1; } } break; default: numbytes = -1; break; } php_stream_close(stream); if (use_copy) { zval_dtor(data); } if (numbytes < 0) { if (return_value) { RETURN_FALSE; } else { return; } } if (return_value) { RETURN_LONG(numbytes); } return; } static void zephir_is_dir(zval *return_value, zval *path TSRMLS_DC) { if (likely(Z_TYPE_P(path) == IS_STRING)) { php_stat(Z_STRVAL_P(path), (php_stat_len)(Z_STRLEN_P(path)), FS_IS_DIR, return_value TSRMLS_CC); } else { ZVAL_FALSE(return_value); } } static void zephir_unlink(zval *return_value, zval *path TSRMLS_DC) { if (likely(Z_TYPE_P(path) == IS_STRING)) { php_stream_context *context; php_stream_wrapper *wrapper; zval *zctx = NULL; if (unlikely(strlen(Z_STRVAL_P(path)) != Z_STRLEN_P(path))) { ZVAL_FALSE(return_value); return; } context = php_stream_context_from_zval(zctx, 0); wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(path), NULL, 0 TSRMLS_CC); if (!wrapper || !wrapper->wops || !wrapper->wops->unlink) { ZVAL_FALSE(return_value); return; } ZVAL_BOOL(return_value, wrapper->wops->unlink(wrapper, Z_STRVAL_P(path), REPORT_ERRORS, context TSRMLS_CC)); return; } ZVAL_FALSE(return_value); return; } static void zephir_filemtime(zval *return_value, zval *path TSRMLS_DC) { if (likely(Z_TYPE_P(path) == IS_STRING)) { php_stat(Z_STRVAL_P(path), (php_stat_len)(Z_STRLEN_P(path)), FS_MTIME, return_value TSRMLS_CC); } else { ZVAL_FALSE(return_value); } } static void zephir_basename(zval *return_value, zval *path TSRMLS_DC) { if (likely(Z_TYPE_P(path) == IS_STRING)) { char *ret; size_t ret_len; php_basename(Z_STRVAL_P(path), Z_STRLEN_P(path), NULL, 0, &ret, &ret_len TSRMLS_CC); ZVAL_STRINGL(return_value, ret, (int)ret_len, 0); } else { ZVAL_FALSE(return_value); } } static void zephir_fwrite(zval *return_value, zval *stream_zval, zval *data TSRMLS_DC) { int num_bytes; php_stream *stream; if (Z_TYPE_P(stream_zval) != IS_RESOURCE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_fwrite()"); if (return_value) { RETVAL_FALSE; } else { return; } } if (Z_TYPE_P(data) != IS_STRING) { /* @todo convert data to string */ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_fwrite()"); if (return_value) { RETVAL_FALSE; } else { return; } } if (!Z_STRLEN_P(data)) { if (return_value) { RETURN_LONG(0); } else { return; } } PHP_STREAM_TO_ZVAL(stream, &stream_zval); num_bytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data)); if (return_value) { RETURN_LONG(num_bytes); } } static int zephir_feof(zval *stream_zval TSRMLS_DC) { php_stream *stream; if (Z_TYPE_P(stream_zval) != IS_RESOURCE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_feof()"); return 0; } php_stream_from_zval_no_verify(stream, &stream_zval); if (stream == NULL) { return 0; } return php_stream_eof(stream); } static int zephir_fclose(zval *stream_zval TSRMLS_DC) { php_stream *stream; if (Z_TYPE_P(stream_zval) != IS_RESOURCE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for zephir_fwrite()"); return 0; } php_stream_from_zval_no_verify(stream, &stream_zval); if (stream == NULL) { return 0; } if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id); return 0; } if (!stream->is_persistent) { php_stream_close(stream); } else { php_stream_pclose(stream); } return 1; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <ext/standard/php_string.h> #include <ext/standard/php_math.h> static void zephir_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy){ zend_make_printable_zval(expr, expr_copy, use_copy); if (use_copy) { Z_SET_REFCOUNT_P(expr_copy, 1); Z_UNSET_ISREF_P(expr_copy); } } static int zephir_and_function(zval *result, zval *left, zval *right){ int istrue = zend_is_true(left) && zend_is_true(right); ZVAL_BOOL(result, istrue); return SUCCESS; } static void zephir_concat_self(zval **left, zval *right TSRMLS_DC){ zval left_copy, right_copy; uint length; int use_copy_left = 0, use_copy_right = 0; if (Z_TYPE_P(right) != IS_STRING) { zephir_make_printable_zval(right, &right_copy, &use_copy_right); if (use_copy_right) { right = &right_copy; } } if (Z_TYPE_PP(left) == IS_NULL) { Z_STRVAL_PP(left) = emalloc(Z_STRLEN_P(right) + 1); memcpy(Z_STRVAL_PP(left), Z_STRVAL_P(right), Z_STRLEN_P(right)); Z_STRVAL_PP(left)[Z_STRLEN_P(right)] = 0; Z_STRLEN_PP(left) = Z_STRLEN_P(right); Z_TYPE_PP(left) = IS_STRING; if (use_copy_right) { zval_dtor(&right_copy); } return; } if (Z_TYPE_PP(left) != IS_STRING) { zephir_make_printable_zval(*left, &left_copy, &use_copy_left); if (use_copy_left) { ZEPHIR_CPY_WRT_CTOR(*left, (&left_copy)); } } SEPARATE_ZVAL_IF_NOT_REF(left); length = Z_STRLEN_PP(left) + Z_STRLEN_P(right); Z_STRVAL_PP(left) = str_erealloc(Z_STRVAL_PP(left), length + 1); memcpy(Z_STRVAL_PP(left) + Z_STRLEN_PP(left), Z_STRVAL_P(right), Z_STRLEN_P(right)); Z_STRVAL_PP(left)[length] = 0; Z_STRLEN_PP(left) = length; Z_TYPE_PP(left) = IS_STRING; if (use_copy_left) { zval_dtor(&left_copy); } if (use_copy_right) { zval_dtor(&right_copy); } } static void zephir_concat_self_str(zval **left, const char *right, int right_length TSRMLS_DC){ zval left_copy; uint length; int use_copy = 0; if (Z_TYPE_PP(left) == IS_NULL) { Z_STRVAL_PP(left) = emalloc(right_length + 1); memcpy(Z_STRVAL_PP(left), right, right_length); Z_STRVAL_PP(left)[right_length] = 0; Z_STRLEN_PP(left) = right_length; Z_TYPE_PP(left) = IS_STRING; return; } if (Z_TYPE_PP(left) != IS_STRING) { zephir_make_printable_zval(*left, &left_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*left, (&left_copy)); } } SEPARATE_ZVAL_IF_NOT_REF(left); length = Z_STRLEN_PP(left) + right_length; Z_STRVAL_PP(left) = str_erealloc(Z_STRVAL_PP(left), length + 1); memcpy(Z_STRVAL_PP(left) + Z_STRLEN_PP(left), right, right_length); Z_STRVAL_PP(left)[length] = 0; Z_STRLEN_PP(left) = length; Z_TYPE_PP(left) = IS_STRING; if (use_copy) { zval_dtor(&left_copy); } } static void zephir_concat_self_long(zval **left, const long right TSRMLS_DC) { zval left_copy; uint length; char *right_char; int use_copy = 0, right_length = 0; right_length = zephir_spprintf(&right_char, 0, "%ld", right); if (Z_TYPE_PP(left) == IS_NULL) { Z_STRVAL_PP(left) = emalloc(right_length + 1); if (right_length > 0) { memcpy(Z_STRVAL_PP(left), right_char, right_length); } else { memcpy(Z_STRVAL_PP(left), "", 0); } Z_STRVAL_PP(left)[right_length] = 0; Z_STRLEN_PP(left) = right_length; Z_TYPE_PP(left) = IS_STRING; return; } if (Z_TYPE_PP(left) != IS_STRING) { zephir_make_printable_zval(*left, &left_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*left, (&left_copy)); } } if (right_length > 0) { SEPARATE_ZVAL_IF_NOT_REF(left); length = Z_STRLEN_PP(left) + right_length; Z_STRVAL_PP(left) = str_erealloc(Z_STRVAL_PP(left), length + 1); memcpy(Z_STRVAL_PP(left) + Z_STRLEN_PP(left), right_char, right_length); Z_STRVAL_PP(left)[length] = 0; Z_STRLEN_PP(left) = length; Z_TYPE_PP(left) = IS_STRING; } if (use_copy) { zval_dtor(&left_copy); } } static void zephir_concat_self_char(zval **left, unsigned char right TSRMLS_DC) { zval left_copy; int use_copy = 0; if (Z_TYPE_PP(left) == IS_NULL) { Z_STRVAL_PP(left) = emalloc(2); Z_STRVAL_PP(left)[0] = right; Z_STRVAL_PP(left)[1] = 0; Z_STRLEN_PP(left) = 1; Z_TYPE_PP(left) = IS_STRING; return; } if (Z_TYPE_PP(left) != IS_STRING) { zephir_make_printable_zval(*left, &left_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*left, (&left_copy)); } } SEPARATE_ZVAL_IF_NOT_REF(left); Z_STRLEN_PP(left)++; Z_STRVAL_PP(left) = str_erealloc(Z_STRVAL_PP(left), Z_STRLEN_PP(left) + 1); Z_STRVAL_PP(left)[Z_STRLEN_PP(left) - 1] = right; Z_STRVAL_PP(left)[Z_STRLEN_PP(left)] = 0; Z_TYPE_PP(left) = IS_STRING; if (use_copy) { zval_dtor(&left_copy); } } static int zephir_compare_strict_string(zval *op1, const char *op2, int op2_length) { switch (Z_TYPE_P(op1)) { case IS_STRING: if (!Z_STRLEN_P(op1) && !op2_length) { return 1; } if (Z_STRLEN_P(op1) != op2_length) { return 0; } return !zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRLEN_P(op1), op2, op2_length); case IS_NULL: return !zend_binary_strcmp("", 0, op2, op2_length); case IS_BOOL: if (!Z_BVAL_P(op1)) { return !zend_binary_strcmp("0", strlen("0"), op2, op2_length); } else { return !zend_binary_strcmp("1", strlen("1"), op2, op2_length); } } return 0; } static int zephir_compare_strict_long(zval *op1, long op2 TSRMLS_DC) { int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return Z_LVAL_P(op1) == op2; case IS_DOUBLE: return Z_DVAL_P(op1) == (double) op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 1 == op2; } else { return 0 == op2; } default: { zval result, op2_tmp; ZVAL_LONG(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; } static int zephir_compare_strict_double(zval *op1, double op2 TSRMLS_DC) { int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return Z_LVAL_P(op1) == (long) op2; case IS_DOUBLE: return Z_DVAL_P(op1) == op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 1 == op2; } else { return 0 == op2; } default: { zval result, op2_tmp; ZVAL_DOUBLE(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; } static int zephir_compare_strict_bool(zval *op1, zend_bool op2 TSRMLS_DC) { int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return (Z_LVAL_P(op1) ? 1 : 0) == op2; case IS_DOUBLE: return (Z_DVAL_P(op1) ? 1 : 0) == op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 1 == op2; } else { return 0 == op2; } default: { zval result, op2_tmp; ZVAL_BOOL(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; } static int zephir_add_function_ex(zval *result, zval *op1, zval *op2 TSRMLS_DC) { int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); #if PHP_VERSION_ID < 50400 status = add_function(result, op1, op2 TSRMLS_CC); #else status = fast_add_function(result, op1, op2 TSRMLS_CC); #endif Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } static void zephir_negate(zval *z TSRMLS_DC) { while (1) { switch (Z_TYPE_P(z)) { case IS_LONG: case IS_BOOL: ZVAL_LONG(z, -Z_LVAL_P(z)); return; case IS_DOUBLE: ZVAL_DOUBLE(z, -Z_DVAL_P(z)); return; case IS_NULL: ZVAL_LONG(z, 0); return; default: convert_scalar_to_number(z TSRMLS_CC); assert(Z_TYPE_P(z) == IS_LONG || Z_TYPE_P(z) == IS_DOUBLE); } } } static void zephir_convert_to_object(zval *op) { convert_to_object(op); } static void zephir_cast(zval *result, zval *var, zend_uint type){ ZVAL_ZVAL(result, var, 1, 0); switch (type) { case IS_STRING: convert_to_string(result); break; case IS_LONG: convert_to_long(result); break; case IS_DOUBLE: convert_to_double(result); break; /*case IS_BOOL: convert_to_bool(result); break;*/ case IS_ARRAY: if (Z_TYPE_P(result) != IS_ARRAY) { convert_to_array(result); } break; } } long zephir_get_intval_ex(const zval *op) { switch (Z_TYPE_P(op)) { case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? 1 : 0; break; #if PHP_VERSION_ID > 50400 case IS_CALLABLE: #endif case IS_RESOURCE: case IS_OBJECT: return 1; case IS_LONG: return Z_LVAL_P(op); case IS_BOOL: return Z_BVAL_P(op); case IS_DOUBLE: return (long) Z_DVAL_P(op); case IS_STRING: { long long_value = 0; double double_value = 0; zend_uchar type; ASSUME(Z_STRVAL_P(op) != NULL); type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &long_value, &double_value, 0); if (type == IS_LONG) { return long_value; } if (type == IS_DOUBLE) { return (long) double_value; } return 0; } } return 0; } double zephir_get_doubleval_ex(const zval *op) { int type; long long_value = 0; double double_value = 0; switch (Z_TYPE_P(op)) { case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? (double) 1 : 0; break; #if PHP_VERSION_ID > 50400 case IS_CALLABLE: #endif case IS_RESOURCE: case IS_OBJECT: return (double) 1; case IS_LONG: return (double) Z_LVAL_P(op); case IS_BOOL: return (double) Z_BVAL_P(op); case IS_DOUBLE: return Z_DVAL_P(op); case IS_STRING: if ((type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &long_value, &double_value, 0))) { if (type == IS_LONG) { return (double) long_value; } else { if (type == IS_DOUBLE) { return double_value; } else { return 0; } } } } return 0; } zend_bool zephir_get_boolval_ex(const zval *op) { int type; long long_value = 0; double double_value = 0; switch (Z_TYPE_P(op)) { case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? (zend_bool) 1 : 0; break; #if PHP_VERSION_ID > 50400 case IS_CALLABLE: #endif case IS_RESOURCE: case IS_OBJECT: return (zend_bool) 1; case IS_LONG: return (Z_LVAL_P(op) ? (zend_bool) 1 : 0); case IS_BOOL: return Z_BVAL_P(op); case IS_DOUBLE: return (Z_DVAL_P(op) ? (zend_bool) 1 : 0); case IS_STRING: if ((type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &long_value, &double_value, 0))) { if (type == IS_LONG) { return (long_value ? (zend_bool) 1 : 0); } else { if (type == IS_DOUBLE) { return (double_value ? (zend_bool) 1 : 0); } else { return 0; } } } } return 0; } static int zephir_is_numeric_ex(const zval *op) { int type; switch (Z_TYPE_P(op)) { case IS_LONG: return 1; case IS_BOOL: return 0; case IS_DOUBLE: return 1; case IS_STRING: if ((type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), NULL, NULL, 0))) { if (type == IS_LONG || type == IS_DOUBLE) { return 1; } } } return 0; } static int zephir_is_equal(zval *op1, zval *op2 TSRMLS_DC) { zval result; #if PHP_VERSION_ID < 50400 is_equal_function(&result, op1, op2 TSRMLS_CC); return Z_BVAL(result); #else return fast_equal_function(&result, op1, op2 TSRMLS_CC); #endif } static int zephir_less(zval *op1, zval *op2 TSRMLS_DC) { zval result; #if PHP_VERSION_ID < 50400 is_smaller_function(&result, op1, op2 TSRMLS_CC); return Z_BVAL(result); #else return fast_is_smaller_function(&result, op1, op2 TSRMLS_CC); #endif } static int zephir_less_equal(zval *op1, zval *op2 TSRMLS_DC) { zval result; is_smaller_or_equal_function(&result, op1, op2 TSRMLS_CC); return Z_BVAL(result); } static int zephir_less_long(zval *op1, long op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_LONG(&op2_zval, op2); is_smaller_function(&result, op1, &op2_zval TSRMLS_CC); return Z_BVAL(result); } static int zephir_less_double(zval *op1, double op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_DOUBLE(&op2_zval, op2); is_smaller_function(&result, op1, &op2_zval TSRMLS_CC); return Z_BVAL(result); } static int zephir_less_equal_long(zval *op1, long op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_LONG(&op2_zval, op2); is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC); return Z_BVAL(result); } static int zephir_greater(zval *op1, zval *op2 TSRMLS_DC) { zval result; is_smaller_or_equal_function(&result, op1, op2 TSRMLS_CC); return !Z_BVAL(result); } static int zephir_greater_long(zval *op1, long op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_LONG(&op2_zval, op2); is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC); return !Z_BVAL(result); } static int zephir_greater_double(zval *op1, double op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_DOUBLE(&op2_zval, op2); is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC); return !Z_BVAL(result); } static int zephir_greater_equal(zval *op1, zval *op2 TSRMLS_DC) { zval result; is_smaller_function(&result, op1, op2 TSRMLS_CC); return !Z_BVAL(result); } static int zephir_greater_equal_long(zval *op1, long op2 TSRMLS_DC) { zval result, op2_zval; ZVAL_LONG(&op2_zval, op2); is_smaller_function(&result, op1, &op2_zval TSRMLS_CC); return !Z_BVAL(result); } static int zephir_is_identical(zval *op1, zval *op2 TSRMLS_DC) { zval result; is_identical_function(&result, op1, op2 TSRMLS_CC); return Z_BVAL(result); } static int zephir_bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC){ int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); status = bitwise_and_function(result, op1, op2 TSRMLS_CC); Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } static int zephir_bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC){ int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); status = bitwise_or_function(result, op1, op2 TSRMLS_CC); Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } static int zephir_bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC){ int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); status = bitwise_xor_function(result, op1, op2 TSRMLS_CC); Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } static int zephir_shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC){ int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); status = shift_left_function(result, op1, op2 TSRMLS_CC); Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } static int zephir_shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC){ int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); status = shift_right_function(result, op1, op2 TSRMLS_CC); Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; } double zephir_safe_div_long_long(long op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return (double) op1 / (double) op2; } double zephir_safe_div_long_double(long op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return (double) op1 / op2; } double zephir_safe_div_double_long(double op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return op1 / (double) op2; } double zephir_safe_div_double_double(double op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return op1 / op2; } double zephir_safe_div_zval_long(zval *op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op1)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return ((double) zephir_get_numberval(op1)) / (double) op2; } double zephir_safe_div_zval_double(zval *op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op1)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return ((double) zephir_get_numberval(op1)) / op2; } double zephir_safe_div_long_zval(long op1, zval *op2 TSRMLS_DC) { if (!zephir_get_numberval(op2)) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op2)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return (double) op1 / ((double) zephir_get_numberval(op2)); } double zephir_safe_div_double_zval(double op1, zval *op2 TSRMLS_DC) { if (!zephir_get_numberval(op2)) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op2)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return op1 / ((double) zephir_get_numberval(op2)); } long zephir_safe_mod_long_long(long op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return op1 % op2; } long zephir_safe_mod_long_double(long op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return op1 % (long) op2; } long zephir_safe_mod_double_long(double op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return (long) op1 % op2; } long zephir_safe_mod_double_double(double op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } return (long) op1 % (long) op2; } long zephir_safe_mod_zval_long(zval *op1, long op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op1)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return ((long) zephir_get_numberval(op1)) % (long) op2; } long zephir_safe_mod_zval_double(zval *op1, double op2 TSRMLS_DC) { if (!op2) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op1)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return ((long) zephir_get_numberval(op1)) % (long) op2; } long zephir_safe_mod_long_zval(long op1, zval *op2 TSRMLS_DC) { if (!zephir_get_numberval(op2)) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op2)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return op1 % ((long) zephir_get_numberval(op2)); } long zephir_safe_mod_double_zval(double op1, zval *op2 TSRMLS_DC) { if (!zephir_get_numberval(op2)) { zend_error(E_WARNING, "Division by zero"); return 0; } switch (Z_TYPE_P(op2)) { case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return (long) op1 % ((long) zephir_get_numberval(op2)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <ext/standard/php_string.h> static void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC){ zval result_copy, op2_copy; int use_copy = 0, use_copy2 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } length = op1_len + Z_STRLEN_P(op2); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy; int use_copy = 0, use_copy2 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvssvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op7_copy, op9_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy7 = 0, use_copy9 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op7) != IS_STRING) { zend_make_printable_zval(op7, &op7_copy, &use_copy7); if (use_copy7) { op7 = &op7_copy; } } if (Z_TYPE_P(op9) != IS_STRING) { zend_make_printable_zval(op9, &op9_copy, &use_copy9); if (use_copy9) { op9 = &op9_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + op6_len + Z_STRLEN_P(op7) + op8_len + Z_STRLEN_P(op9) + op10_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, op6, op6_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + op6_len + Z_STRLEN_P(op7), op8, op8_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + op6_len + Z_STRLEN_P(op7) + op8_len, Z_STRVAL_P(op9), Z_STRLEN_P(op9)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + op6_len + Z_STRLEN_P(op7) + op8_len + Z_STRLEN_P(op9), op10, op10_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy7) { zval_dtor(op7); } if (use_copy9) { zval_dtor(op9); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), op7, op7_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsvssvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, zval *op11, const char *op12, zend_uint op12_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy, op9_copy, op11_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0, use_copy9 = 0, use_copy11 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } if (Z_TYPE_P(op9) != IS_STRING) { zend_make_printable_zval(op9, &op9_copy, &use_copy9); if (use_copy9) { op9 = &op9_copy; } } if (Z_TYPE_P(op11) != IS_STRING) { zend_make_printable_zval(op11, &op11_copy, &use_copy11); if (use_copy11) { op11 = &op11_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + op8_len + Z_STRLEN_P(op9) + op10_len + Z_STRLEN_P(op11) + op12_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), op7, op7_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len, op8, op8_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + op8_len, Z_STRVAL_P(op9), Z_STRLEN_P(op9)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + op8_len + Z_STRLEN_P(op9), op10, op10_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + op8_len + Z_STRLEN_P(op9) + op10_len, Z_STRVAL_P(op11), Z_STRLEN_P(op11)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + op8_len + Z_STRLEN_P(op9) + op10_len + Z_STRLEN_P(op11), op12, op12_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy9) { zval_dtor(op9); } if (use_copy11) { zval_dtor(op11); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy, op8_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0, use_copy8 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } if (Z_TYPE_P(op8) != IS_STRING) { zend_make_printable_zval(op8, &op8_copy, &use_copy8); if (use_copy8) { op8 = &op8_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), op7, op7_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len, Z_STRVAL_P(op8), Z_STRLEN_P(op8)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy8) { zval_dtor(op8); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, const char *op9, zend_uint op9_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy, op8_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0, use_copy8 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } if (Z_TYPE_P(op8) != IS_STRING) { zend_make_printable_zval(op8, &op8_copy, &use_copy8); if (use_copy8) { op8 = &op8_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8) + op9_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), op7, op7_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len, Z_STRVAL_P(op8), Z_STRLEN_P(op8)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8), op9, op9_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy8) { zval_dtor(op8); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvsvsvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, const char *op5, zend_uint op5_len, zval *op6, const char *op7, zend_uint op7_len, zval *op8, const char *op9, zend_uint op9_len, zval *op10, const char *op11, zend_uint op11_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op6_copy, op8_copy, op10_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy6 = 0, use_copy8 = 0, use_copy10 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } if (Z_TYPE_P(op8) != IS_STRING) { zend_make_printable_zval(op8, &op8_copy, &use_copy8); if (use_copy8) { op8 = &op8_copy; } } if (Z_TYPE_P(op10) != IS_STRING) { zend_make_printable_zval(op10, &op10_copy, &use_copy10); if (use_copy10) { op10 = &op10_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8) + op9_len + Z_STRLEN_P(op10) + op11_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), op7, op7_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len, Z_STRVAL_P(op8), Z_STRLEN_P(op8)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8), op9, op9_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8) + op9_len, Z_STRVAL_P(op10), Z_STRLEN_P(op10)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + op7_len + Z_STRLEN_P(op8) + op9_len + Z_STRLEN_P(op10), op11, op11_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy8) { zval_dtor(op8); } if (use_copy10) { zval_dtor(op10); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op5_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy5 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), Z_STRVAL_P(op5), Z_STRLEN_P(op5)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy5) { zval_dtor(op5); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvvsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op5_copy, op7_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy5 = 0, use_copy7 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } if (Z_TYPE_P(op7) != IS_STRING) { zend_make_printable_zval(op7, &op7_copy, &use_copy7); if (use_copy7) { op7 = &op7_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), Z_STRVAL_P(op5), Z_STRLEN_P(op5)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5), op6, op6_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy5) { zval_dtor(op5); } if (use_copy7) { zval_dtor(op7); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svsvvsvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, zval *op5, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op4_copy, op5_copy, op7_copy; int use_copy = 0, use_copy2 = 0, use_copy4 = 0, use_copy5 = 0, use_copy7 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } if (Z_TYPE_P(op7) != IS_STRING) { zend_make_printable_zval(op7, &op7_copy, &use_copy7); if (use_copy7) { op7 = &op7_copy; } } length = op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7) + op8_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4), Z_STRVAL_P(op5), Z_STRLEN_P(op5)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5), op6, op6_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4) + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7), op8, op8_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy5) { zval_dtor(op5); } if (use_copy7) { zval_dtor(op7); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svv(zval **result, const char *op1, zend_uint op1_len, zval *op2, zval *op3, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op3_copy; int use_copy = 0, use_copy2 = 0, use_copy3 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } length = op1_len + Z_STRLEN_P(op2) + Z_STRLEN_P(op3); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_svvs(zval **result, const char *op1, zend_uint op1_len, zval *op2, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC){ zval result_copy, op2_copy, op3_copy; int use_copy = 0, use_copy2 = 0, use_copy3 = 0; uint offset = 0, length; if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } length = op1_len + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + op4_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len); memcpy(Z_STRVAL_PP(result) + offset + op1_len, Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + op1_len + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), op4, op4_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vs(zval **result, zval *op1, const char *op2, zend_uint op2_len, int self_var TSRMLS_DC){ zval result_copy, op1_copy; int use_copy = 0, use_copy1 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } length = Z_STRLEN_P(op1) + op2_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy, op5_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy5 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy5) { zval_dtor(op5); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsvsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy, op5_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy5 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy5) { zval_dtor(op5); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy, op5_copy, op7_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy5 = 0, use_copy7 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } if (Z_TYPE_P(op7) != IS_STRING) { zend_make_printable_zval(op7, &op7_copy, &use_copy7); if (use_copy7) { op7 = &op7_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy5) { zval_dtor(op5); } if (use_copy7) { zval_dtor(op7); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op3_copy, op4_copy; int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy4 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + Z_STRLEN_P(op4); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), Z_STRVAL_P(op4), Z_STRLEN_P(op4)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy3) { zval_dtor(op3); } if (use_copy4) { zval_dtor(op4); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvs(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + op3_len; if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), op3, op3_len); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvsv(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy, op4_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy4 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + op3_len + Z_STRLEN_P(op4); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), op3, op3_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + op3_len, Z_STRVAL_P(op4), Z_STRLEN_P(op4)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy4) { zval_dtor(op4); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvv(zval **result, zval *op1, zval *op2, zval *op3, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy, op3_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy, op3_copy, op4_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0, use_copy4 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), Z_STRVAL_P(op4), Z_STRLEN_P(op4)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy4) { zval_dtor(op4); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvvvsvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, const char *op5, zend_uint op5_len, zval *op6, zval *op7, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy, op3_copy, op4_copy, op6_copy, op7_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0, use_copy4 = 0, use_copy6 = 0, use_copy7 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op6) != IS_STRING) { zend_make_printable_zval(op6, &op6_copy, &use_copy6); if (use_copy6) { op6 = &op6_copy; } } if (Z_TYPE_P(op7) != IS_STRING) { zend_make_printable_zval(op7, &op7_copy, &use_copy7); if (use_copy7) { op7 = &op7_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6) + Z_STRLEN_P(op7); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4), op5, op5_len); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4) + op5_len, Z_STRVAL_P(op6), Z_STRLEN_P(op6)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4) + op5_len + Z_STRLEN_P(op6), Z_STRVAL_P(op7), Z_STRLEN_P(op7)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy4) { zval_dtor(op4); } if (use_copy6) { zval_dtor(op6); } if (use_copy7) { zval_dtor(op7); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_vvvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC){ zval result_copy, op1_copy, op2_copy, op3_copy, op4_copy, op5_copy; int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0, use_copy4 = 0, use_copy5 = 0; uint offset = 0, length; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); if (use_copy1) { op1 = &op1_copy; } } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); if (use_copy2) { op2 = &op2_copy; } } if (Z_TYPE_P(op3) != IS_STRING) { zend_make_printable_zval(op3, &op3_copy, &use_copy3); if (use_copy3) { op3 = &op3_copy; } } if (Z_TYPE_P(op4) != IS_STRING) { zend_make_printable_zval(op4, &op4_copy, &use_copy4); if (use_copy4) { op4 = &op4_copy; } } if (Z_TYPE_P(op5) != IS_STRING) { zend_make_printable_zval(op5, &op5_copy, &use_copy5); if (use_copy5) { op5 = &op5_copy; } } length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4) + Z_STRLEN_P(op5); if (self_var) { if (Z_TYPE_PP(result) != IS_STRING) { zend_make_printable_zval(*result, &result_copy, &use_copy); if (use_copy) { ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy)); } } offset = Z_STRLEN_PP(result); length += offset; Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1); } else { Z_STRVAL_PP(result) = (char *) emalloc(length + 1); } memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), Z_STRVAL_P(op4), Z_STRLEN_P(op4)); memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + Z_STRLEN_P(op4), Z_STRVAL_P(op5), Z_STRLEN_P(op5)); Z_STRVAL_PP(result)[length] = 0; Z_TYPE_PP(result) = IS_STRING; Z_STRLEN_PP(result) = length; if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } if (use_copy3) { zval_dtor(op3); } if (use_copy4) { zval_dtor(op4); } if (use_copy5) { zval_dtor(op5); } if (use_copy) { zval_dtor(&result_copy); } } static void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { #if PHP_VERSION_ID < 50400 zval op1_copy, op2_copy; int use_copy1 = 0, use_copy2 = 0; if (Z_TYPE_P(op1) != IS_STRING) { zend_make_printable_zval(op1, &op1_copy, &use_copy1); } if (Z_TYPE_P(op2) != IS_STRING) { zend_make_printable_zval(op2, &op2_copy, &use_copy2); } if (use_copy1) { /* We have created a converted copy of op1. Therefore, op1 won't become the result so * we have to free it. */ if (result == op1) { zval_dtor(op1); } op1 = &op1_copy; } if (use_copy2) { op2 = &op2_copy; } if (result == op1 && !IS_INTERNED(Z_STRVAL_P(op1))) { /* special case, perform operations on result */ uint res_len = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); if (Z_STRLEN_P(result) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) { str_efree(Z_STRVAL_P(result)); ZVAL_EMPTY_STRING(result); zend_error(E_ERROR, "String size overflow"); } Z_STRVAL_P(result) = str_erealloc(Z_STRVAL_P(result), res_len+1); memcpy(Z_STRVAL_P(result) + Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); Z_STRVAL_P(result)[res_len] = 0; Z_STRLEN_P(result) = res_len; } else { int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2); char *buf = (char *) emalloc(length + 1); memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1)); memcpy(buf + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2)); buf[length] = 0; ZVAL_STRINGL(result, buf, length, 0); } if (use_copy1) { zval_dtor(op1); } if (use_copy2) { zval_dtor(op2); } #else concat_function(result, op1, op2 TSRMLS_CC); #endif } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <ext/standard/php_string.h> #include <ext/standard/php_math.h> #include <ext/standard/php_rand.h> double zephir_floor(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return (double) Z_LVAL_P(op1); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return floor(zephir_get_numberval(op1)); } double zephir_sin(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return sin(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return sin(zephir_get_numberval(op1)); } double zephir_asin(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return asin(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return asin(zephir_get_numberval(op1)); } double zephir_cos(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return cos(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return cos(zephir_get_numberval(op1)); } double zephir_acos(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return acos(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return acos(zephir_get_numberval(op1)); } double zephir_sqrt(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return sqrt(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return sqrt(zephir_get_numberval(op1)); } double zephir_tan(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return tan(Z_LVAL_P(op1)); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return tan(zephir_get_numberval(op1)); } double zephir_ceil(zval *op1 TSRMLS_DC) { switch (Z_TYPE_P(op1)) { case IS_LONG: return (double) Z_LVAL_P(op1); case IS_ARRAY: case IS_OBJECT: case IS_RESOURCE: zend_error(E_WARNING, "Unsupported operand types"); break; } return ceil(zephir_get_numberval(op1)); } double _php_math_round(double value, int places, int mode); static void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC) { int places = 0; long mode = PHP_ROUND_HALF_UP; double return_val; convert_scalar_to_number_ex(&op1); if (op2) { places = zephir_get_intval_ex(op2); } if (op3) { mode = zephir_get_intval_ex(op3); } switch (Z_TYPE_PP(&op1)) { case IS_LONG: /* Simple case - long that doesn't need to be rounded. */ if (places >= 0) { RETURN_DOUBLE((double) Z_LVAL_PP(&op1)); } /* break omitted intentionally */ case IS_DOUBLE: return_val = (Z_TYPE_PP(&op1) == IS_LONG) ? (double)Z_LVAL_PP(&op1) : Z_DVAL_PP(&op1); return_val = _php_math_round(return_val, places, mode); RETURN_DOUBLE(return_val); break; default: RETURN_FALSE; break; } } #if PHP_VERSION_ID < 50600 static void zephir_pow_function_ex(zval *return_value, zval *zbase, zval *zexp TSRMLS_DC) { /* make sure we're dealing with numbers */ convert_scalar_to_number(zbase TSRMLS_CC); convert_scalar_to_number(zexp TSRMLS_CC); /* if both base and exponent were longs, we'll try to get a long out */ if (Z_TYPE_P(zbase) == IS_LONG && Z_TYPE_P(zexp) == IS_LONG && Z_LVAL_P(zexp) >= 0) { long l1 = 1, l2 = Z_LVAL_P(zbase), i = Z_LVAL_P(zexp); if (i == 0) { RETURN_LONG(1L); } else if (l2 == 0) { RETURN_LONG(0); } /* calculate pow(long,long) in O(log exp) operations, bail if overflow */ while (i >= 1) { int overflow; double dval = 0.0; if (i % 2) { --i; ZEND_SIGNED_MULTIPLY_LONG(l1, l2, l1, dval, overflow); if (overflow) RETURN_DOUBLE(dval * pow(l2, i)); } else { i /= 2; ZEND_SIGNED_MULTIPLY_LONG(l2, l2, l2, dval,overflow); if (overflow) RETURN_DOUBLE((double)l1 * pow(dval, i)); } if (i == 0) { RETURN_LONG(l1); } } } convert_to_double(zbase); convert_to_double(zexp); RETURN_DOUBLE(pow(Z_DVAL_P(zbase), Z_DVAL_P(zexp))); } #endif long zephir_mt_rand(long min, long max TSRMLS_DC) { long number; if (max < min) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min); return 0; } if (!BG(mt_rand_is_seeded)) { php_mt_srand(GENERATE_SEED() TSRMLS_CC); } number = (long) (php_mt_rand(TSRMLS_C) >> 1); RAND_RANGE(number, min, max, PHP_MT_RAND_MAX); return number; } #ifdef HAVE_CONFIG_H #endif static void zephir_serialize(zval *return_value, zval **var TSRMLS_DC) { php_serialize_data_t var_hash; smart_str buf = {0}; PHP_VAR_SERIALIZE_INIT(var_hash); php_var_serialize(&buf, var, &var_hash TSRMLS_CC); PHP_VAR_SERIALIZE_DESTROY(var_hash); if (EG(exception)) { smart_str_free(&buf); RETURN_FALSE; } if (buf.c) { RETURN_STRINGL(buf.c, buf.len, 0); } else { RETURN_NULL(); } } static void zephir_unserialize(zval *return_value, zval *var TSRMLS_DC) { const unsigned char *p; php_unserialize_data_t var_hash; if (Z_TYPE_P(var) != IS_STRING) { RETURN_FALSE; } if (Z_STRLEN_P(var) == 0) { RETURN_FALSE; } p = (const unsigned char*) Z_STRVAL_P(var); PHP_VAR_UNSERIALIZE_INIT(var_hash); if (!php_var_unserialize(&return_value, &p, p + Z_STRLEN_P(var), &var_hash TSRMLS_CC)) { PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); ZVAL_NULL(return_value); if (!EG(exception)) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - Z_STRVAL_P(var)), Z_STRLEN_P(var)); } RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); } static void zephir_var_export(zval **var TSRMLS_DC) { php_var_export(var, 1 TSRMLS_CC); } static void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC) { smart_str buf = { NULL, 0, 0 }; php_var_export_ex(var, 1, &buf TSRMLS_CC); smart_str_0(&buf); ZVAL_STRINGL(return_value, buf.c, buf.len, 0); } static void zephir_var_dump(zval **var TSRMLS_DC) { php_var_dump(var, 1 TSRMLS_CC); } #ifdef HAVE_CONFIG_H #endif #include <ctype.h> static void zephir_filter_alphanum(zval *return_value, zval *param) { unsigned int i; unsigned char ch; smart_str filtered_str = {0}; zval copy; int use_copy = 0; if (Z_TYPE_P(param) != IS_STRING) { zend_make_printable_zval(param, ©, &use_copy); if (use_copy) { param = © } } for (i = 0; i < Z_STRLEN_P(param); i++) { ch = Z_STRVAL_P(param)[i]; if (ch == '\0') { break; } if (isalnum(ch)) { smart_str_appendc(&filtered_str, ch); } } if (use_copy) { zval_dtor(param); } smart_str_0(&filtered_str); if (filtered_str.c) { RETURN_STRINGL(filtered_str.c, filtered_str.len, 0); } else { RETURN_EMPTY_STRING(); } } static void zephir_filter_identifier(zval *return_value, zval *param){ unsigned int i; unsigned char ch; zval copy; smart_str filtered_str = {0}; int use_copy = 0; if (Z_TYPE_P(param) != IS_STRING) { zend_make_printable_zval(param, ©, &use_copy); if (use_copy) { param = © } } for (i = 0; i < Z_STRLEN_P(param); i++) { ch = Z_STRVAL_P(param)[i]; if (ch == '\0') { break; } if (isalnum(ch) || ch == '_') { smart_str_appendc(&filtered_str, ch); } } if (use_copy) { zval_dtor(param); } smart_str_0(&filtered_str); if (filtered_str.c) { RETURN_STRINGL(filtered_str.c, filtered_str.len, 0); } else { RETURN_EMPTY_STRING(); } } static void zephir_is_basic_charset(zval *return_value, const zval *param){ unsigned int i; unsigned int ch; int iso88591 = 0; for (i = 0; i < Z_STRLEN_P(param); i++) { ch = Z_STRVAL_P(param)[i]; if (ch != '\0') { if (ch == 172 || (ch >= 128 && ch <= 159)) { continue; } if (ch >= 160 && ch <= 255) { iso88591 = 1; continue; } } RETURN_FALSE; } if (!iso88591) { RETURN_STRING("ASCII", 1); } RETURN_STRING("ISO-8859-1", 1); } static long zephir_unpack(char *data, int size, int issigned, int *map) { long result; char *cresult = (char *) &result; int i; result = issigned ? -1 : 0; for (i = 0; i < size; i++) { cresult[map[i]] = *data++; } return result; } static inline char *zephir_longtohex(unsigned long value) { static char digits[] = "0123456789abcdef"; char buf[(sizeof(unsigned long) << 3) + 1]; char *ptr, *end; end = ptr = buf + sizeof(buf) - 1; *ptr = '\0'; do { *--ptr = digits[value & 0x0F]; value >>= 4; } while (ptr > buf && value); return estrndup(ptr, end - ptr); } static void zephir_escape_multi(zval *return_value, zval *param, const char *escape_char, unsigned int escape_length, char escape_extra, int use_whitelist) { unsigned int i; zval copy; smart_str escaped_str = {0}; char machine_little_endian, *hex; int big_endian_long_map[4]; int use_copy = 0, machine_endian_check = 1; int issigned = 0; long value; if (Z_TYPE_P(param) != IS_STRING) { zend_make_printable_zval(param, ©, &use_copy); if (use_copy) { param = © } } if (Z_STRLEN_P(param) <= 0) { RETURN_FALSE; } machine_little_endian = ((char *) &machine_endian_check)[0]; if (machine_little_endian) { big_endian_long_map[0] = 3; big_endian_long_map[1] = 2; big_endian_long_map[2] = 1; big_endian_long_map[3] = 0; } else { int size = sizeof(Z_LVAL_P(param)); big_endian_long_map[0] = size - 4; big_endian_long_map[1] = size - 3; big_endian_long_map[2] = size - 2; big_endian_long_map[3] = size - 1; } if ((Z_STRLEN_P(param) % 4) != 0) { RETURN_FALSE; } for (i = 0; i < Z_STRLEN_P(param); i += 4) { issigned = Z_STRVAL_P(param)[i] & 0x80; value = 0; if (sizeof(long) > 4 && issigned) { value = ~INT_MAX; } value |= zephir_unpack(&Z_STRVAL_P(param)[i], 4, issigned, big_endian_long_map); if (sizeof(long) > 4) { value = (unsigned int) value; } if (value == '\0') { RETURN_FALSE; } if (value < 256 && isalnum(value)) { smart_str_appendc(&escaped_str, (unsigned char) value); continue; } if (use_whitelist) { switch (value) { case ' ': case '/': case '*': case '+': case '-': case '\t': case '\n': case '^': case '$': case '!': case '?': case '\\': case '#': case '}': case '{': case ')': case '(': case ']': case '[': case '.': case ',': case ':': case ';': case '_': case '|': smart_str_appendc(&escaped_str, (unsigned char) value); continue; } } hex = zephir_longtohex(value); smart_str_appendl(&escaped_str, escape_char, escape_length); smart_str_appendl(&escaped_str, hex, strlen(hex)); if (escape_extra != '\0') { smart_str_appendc(&escaped_str, escape_extra); } efree(hex); } if (use_copy) { zval_dtor(param); } smart_str_0(&escaped_str); if (escaped_str.c) { RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); } else { RETURN_EMPTY_STRING(); } } static void zephir_escape_css(zval *return_value, zval *param) { zephir_escape_multi(return_value, param, "\\", sizeof("\\")-1, ' ', 0); } static void zephir_escape_js(zval *return_value, zval *param) { zephir_escape_multi(return_value, param, "\\x", sizeof("\\x")-1, '\0', 1); } static void zephir_escape_htmlattr(zval *return_value, zval *param) { zephir_escape_multi(return_value, param, "&#x", sizeof("&#x")-1, ';', 1); } static void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC) { #if PHP_VERSION_ID < 50400 int length; #else size_t length; #endif char *escaped; if (Z_TYPE_P(str) != IS_STRING) { /* Nothing to escape */ RETURN_ZVAL(str, 1, 0); } if (Z_TYPE_P(quote_style) != IS_LONG) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid quote_style supplied for zephir_escape_html()"); RETURN_ZVAL(str, 1, 0); } if (Z_TYPE_P(charset) != IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid charset supplied for zephir_escape_html()"); RETURN_ZVAL(str, 1, 0); } escaped = php_escape_html_entities((unsigned char*) Z_STRVAL_P(str), Z_STRLEN_P(str), &length, 0, Z_LVAL_P(quote_style), Z_STRVAL_P(charset) TSRMLS_CC); RETURN_STRINGL(escaped, length, 0); } #ifdef HAVE_CONFIG_H #endif zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC) { zend_class_entry *ce; zend_object_iterator *it; if (Z_TYPE_P(iterator) != IS_OBJECT) { return NULL; } ce = Z_OBJCE_P(iterator); it = ce->get_iterator(ce, iterator, 0 TSRMLS_CC); if (!it || EG(exception)) { return NULL; } if (it->funcs->get_current_key == NULL) { return NULL; } if (it->funcs->rewind == NULL) { return NULL; } return it; } #ifdef HAVE_CONFIG_H #endif #ifdef PHP_WIN32 #elif defined(NETWARE) #include <sys/timeval.h> #include <sys/time.h> #else #include <sys/time.h> #endif #include <ctype.h> static void zephir_time(zval *return_value) { RETURN_LONG(time(NULL)); } static void zephir_microtime(zval *return_value, zval *get_as_float TSRMLS_DC) { struct timeval tp = {0}; char ret[100]; if (gettimeofday(&tp, NULL)) { RETURN_FALSE; } if (get_as_float && ZEPHIR_IS_TRUE(get_as_float)) { RETURN_DOUBLE((double)(tp.tv_sec + tp.tv_usec / MICRO_IN_SEC)); } snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec); RETURN_STRING(ret, 1); } #ifdef HAVE_CONFIG_H #endif static void zephir_exit_empty() { TSRMLS_FETCH(); zend_bailout(); } static void zephir_exit(zval *ptr) { TSRMLS_FETCH(); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); } else { zend_print_variable(ptr); } zephir_exit_empty(); } /* cssmin.c Copyright (c) 2010 (www.ryanday.org) w3c css spec: http://www.w3.org/TR/CSS2/syndata.html this parser makes no attempt to understand css as such it does not interpret css to spec. ** cannot handle nested { blocks but will ignore aditional { in parens () ** no in quote detection for ( or } function get, peek and general lookahead structure taken from.. jsmin.c Copyright (c) 2002 Douglas Crockford (www.crockford.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software shall be used for Good, not Evil. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef HAVE_CONFIG_H #endif #define STATE_FREE 1 #define STATE_ATRULE 2 #define STATE_SELECTOR 3 #define STATE_BLOCK 4 #define STATE_DECLARATION 5 #define STATE_COMMENT 6 typedef struct _cssmin_parser { int tmp_state; int state; int last_state; int in_paren; zval *style; const char *error; smart_str *minified; int style_pointer; } cssmin_parser; /* get -- return the next character from stdin. Watch out for lookahead. If the character is a control character, translate it to a space or linefeed. */ static char cssmin_peek(cssmin_parser *parser){ char ch; if (parser->style_pointer < Z_STRLEN_P(parser->style)) { ch = Z_STRVAL_P(parser->style)[parser->style_pointer]; return ch; } return EOF; } static char cssmin_back_peek(cssmin_parser *parser){ char ch; if (parser->style_pointer > 1) { ch = Z_STRVAL_P(parser->style)[parser->style_pointer - 1]; return ch; } return EOF; } /* machine */ static int phalcon_cssmin_machine(cssmin_parser *parser, unsigned char c TSRMLS_DC){ unsigned char p; if (parser->state != STATE_COMMENT) { if (c == '/' && cssmin_peek(parser) == '*') { parser->tmp_state = parser->state; parser->state = STATE_COMMENT; } } switch (parser->state) { case STATE_FREE: if (c == ' ' && c == '\t' && c == '\n' && c == '\r') { c = 0; } else if (c == '@'){ parser->state = STATE_ATRULE; break; } else if(c > 0){ //fprintf(stdout,"one to 3 - %c %i",c,c); parser->state = STATE_SELECTOR; } /* no break */ case STATE_SELECTOR: if (c == '{') { parser->state = STATE_BLOCK; } else { if(c == '\n' || c == '\r') { c = 0; } else { if(c == '@'){ parser->state = STATE_ATRULE; } else { if ((c == ' ' || c == '\t')) { p = cssmin_peek(parser); if (p == '{' || p == '\t' || p == ' ' || p == '>' || p == ',') { c = 0; } else { p = cssmin_back_peek(parser); if (p == ',' || p == '>' || p == ':') { c = 0; } else { c = ' '; } } } } } } break; case STATE_ATRULE: /* support @import etc. @font-face{ */ if (c == '\r' || c == '\n' || c == ';') { c = ';'; parser->state = STATE_FREE; } else { if(c == '{') { parser->state = STATE_BLOCK; } } break; case STATE_BLOCK: if (c == ' ' || c == '\t' || c == '\n' || c == '\r' ) { c = 0; break; } else { if (c == '}') { parser->state = STATE_FREE; //fprintf(stdout,"closing bracket found in block\n"); break; } else { parser->state = STATE_DECLARATION; } } /* no break */ case STATE_DECLARATION: if (c == '(') { parser->in_paren = 1; } if (parser->in_paren == 0) { if (c == ';') { parser->state = STATE_BLOCK; if (cssmin_peek(parser) == '}') { c = 0; } } else if (c == '}') { parser->state = STATE_FREE; } else { if (c == '\n' || c == '\r') { c = 0; } else { if (c == ' ' || c == '\t') { p = cssmin_peek(parser); if (p == ' ' || p == '\t') { c = 0; } else { c = ' '; } } } } } else { if (c == ')') { parser->in_paren = 0; } } break; case STATE_COMMENT: if (c == '*' && cssmin_peek(parser) == '/'){ parser->style_pointer += 2; parser->state = parser->tmp_state; } c = 0; break; } return c; } static int phalcon_cssmin_internal(zval *return_value, zval *style, const char **error TSRMLS_DC) { int i; unsigned char c; cssmin_parser parser; smart_str minified = {0}; parser.tmp_state = 0; parser.state = 1; parser.last_state = 1; parser.in_paren = 0; parser.style = style; parser.error = NULL; parser.minified = &minified; for (i = 0; i < Z_STRLEN_P(style); i++) { parser.style_pointer = i + 1; c = phalcon_cssmin_machine(&parser, Z_STRVAL_P(style)[i] TSRMLS_CC); if (c != 0) { smart_str_appendc(parser.minified, c); } i = parser.style_pointer - 1; } smart_str_0(&minified); if (minified.len) { ZVAL_STRINGL(return_value, minified.c, minified.len, 0); } else { ZVAL_EMPTY_STRING(return_value); } *error = parser.error; return SUCCESS; } /* cssmin -- minify the css removes comments removes newlines and line feeds keeping removes last semicolon from last property */ static int phalcon_cssmin(zval *return_value, zval *style TSRMLS_DC) { const char *error = NULL; ZVAL_NULL(return_value); if (Z_TYPE_P(style) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Style must be a string"); return FAILURE; } if (phalcon_cssmin_internal(return_value, style, &error TSRMLS_CC) == FAILURE) { if (error) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, error); } else { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Unknown error"); } return FAILURE; } return SUCCESS; } /* jsmin.c 2013-03-29 Copyright (c) 2002 Douglas Crockford (www.crockford.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software shall be used for Good, not Evil. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef HAVE_CONFIG_H #endif #define JSMIN_ACTION_OUTPUT_NEXT 1 #define JSMIN_ACTION_NEXT_DELETE 2 #define JSMIN_ACTION_NEXT 3 typedef struct _jsmin_parser { zval *script; const char *error; int script_pointer; int inside_string; smart_str *minified; unsigned char theA; unsigned char theB; unsigned char theC; unsigned char theX; unsigned char theY; } jsmin_parser; static void jsmin_error(jsmin_parser *parser, const char* s, int s_length TSRMLS_DC) { parser->error = s; } /* isAlphanum -- return true if the character is a letter, digit, underscore, dollar sign, or non-ASCII character. */ static int jsmin_isAlphanum(int c) { return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c == '\\' || c > 126); } /* get -- return the next character from stdin. Watch out for lookahead. If the character is a control character, translate it to a space or linefeed. */ static unsigned char jsmin_peek(jsmin_parser *parser){ unsigned char ch; if (parser->script_pointer < Z_STRLEN_P(parser->script)) { ch = Z_STRVAL_P(parser->script)[parser->script_pointer]; return ch; } return '\0'; } static unsigned char jsmin_get(jsmin_parser *parser) { unsigned char c; if (parser->script_pointer < Z_STRLEN_P(parser->script)) { c = Z_STRVAL_P(parser->script)[parser->script_pointer]; parser->script_pointer++; } else { c = '\0'; } parser->theC = c; if (parser->inside_string == 1) { if (c >= ' ' || c == '\n' || c == '\t' || c == '\0') { return c; } } else { if (c >= ' ' || c == '\n' || c == '\0') { return c; } } if (c == '\r') { return '\n'; } return ' '; } /* next -- get the next character, excluding comments. peek() is used to see if a '/' is followed by a '/' or '*'. */ static int jsmin_next(jsmin_parser *parser TSRMLS_DC) { unsigned char c = jsmin_get(parser); if (c == '/') { switch (jsmin_peek(parser)) { case '/': for (;;) { c = jsmin_get(parser); if (c <= '\n') { break; } } break; case '*': jsmin_get(parser); while (c != ' ') { switch (jsmin_get(parser)) { case '*': if (jsmin_peek(parser) == '/') { jsmin_get(parser); c = ' '; } break; case '\0': jsmin_error(parser, SL("Unterminated comment.") TSRMLS_CC); return FAILURE; } } break; } } parser->theY = parser->theX; parser->theX = c; return c; } /* action -- do something! What you do is determined by the argument: 1 Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B. (Delete A). 3 Get the next B. (Delete B). action treats a string as a single character. Wow! action recognizes a regular expression if it is preceded by ( or , or =. */ static int jsmin_action(jsmin_parser *parser, unsigned char d TSRMLS_DC) { switch (d) { case JSMIN_ACTION_OUTPUT_NEXT: smart_str_appendc(parser->minified, parser->theA); if ( (parser->theY == '\n' || parser->theY == ' ') && (parser->theA == '+' || parser->theA == '-' || parser->theA == '*' || parser->theA == '/') && (parser->theB == '+' || parser->theB == '-' || parser->theB == '*' || parser->theB == '/') ) { smart_str_appendc(parser->minified, parser->theY); } /* no break */ case JSMIN_ACTION_NEXT_DELETE: parser->theA = parser->theB; if (parser->theA == '\'' || parser->theA == '"' || parser->theA == '`') { parser->inside_string = 1; for (;;) { smart_str_appendc(parser->minified, parser->theA); parser->theA = jsmin_get(parser); if (parser->theA == parser->theB) { break; } if (parser->theA == '\\') { smart_str_appendc(parser->minified, parser->theA); parser->theA = jsmin_get(parser); } if (parser->theA == '\0') { jsmin_error(parser, SL("Unterminated string literal.") TSRMLS_CC); return FAILURE; } } parser->inside_string = 0; } /* no break */ case JSMIN_ACTION_NEXT: parser->theB = jsmin_next(parser TSRMLS_CC); if (parser->error != NULL) { return FAILURE; } if (parser->theB == '/' && ( parser->theA == '(' || parser->theA == ',' || parser->theA == '=' || parser->theA == ':' || parser->theA == '[' || parser->theA == '!' || parser->theA == '&' || parser->theA == '|' || parser->theA == '?' || parser->theA == '+' || parser->theA == '-' || parser->theA == '~' || parser->theA == '*' || parser->theA == '/' || parser->theA == '{' || parser->theA == '\n' )) { smart_str_appendc(parser->minified, parser->theA); if (parser->theA == '/' || parser->theA == '*') { smart_str_appendc(parser->minified, ' '); } smart_str_appendc(parser->minified, parser->theB); for (;;) { parser->theA = jsmin_get(parser); if (parser->theA == '[') { for (;;) { smart_str_appendc(parser->minified, parser->theA); parser->theA = jsmin_get(parser); if (parser->theA == ']') { break; } if (parser->theA == '\\') { smart_str_appendc(parser->minified, parser->theA); parser->theA = jsmin_get(parser); } if (parser->theA == '\0') { jsmin_error(parser, SL("Unterminated set in Regular Expression literal.") TSRMLS_CC); return FAILURE; } } } else { if (parser->theA == '/') { switch (jsmin_peek(parser)) { case '/': case '*': jsmin_error(parser, SL("Unterminated set in Regular Expression literal.") TSRMLS_CC); return FAILURE; } break; } else { if (parser->theA == '\\') { smart_str_appendc(parser->minified, parser->theA); parser->theA = jsmin_get(parser); } } } if (parser->theA == '\0') { jsmin_error(parser, SL("Unterminated Regular Expression literal.") TSRMLS_CC); return FAILURE; } smart_str_appendc(parser->minified, parser->theA); } parser->theB = jsmin_next(parser TSRMLS_CC); if (parser->error != NULL) { return FAILURE; } } } return SUCCESS; } /* jsmin -- Copy the input to the output, deleting the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed. */ static int phalcon_jsmin_internal(zval *return_value, zval *script, const char **error TSRMLS_DC) { jsmin_parser parser; smart_str minified = {0}; int status = SUCCESS; parser.theA = '\n'; parser.theX = '\0'; parser.theY = '\0'; parser.script = script; parser.error = NULL; parser.script_pointer = 0; parser.inside_string = 0; parser.minified = &minified; if (jsmin_action(&parser, JSMIN_ACTION_NEXT TSRMLS_CC) == FAILURE) { *error = parser.error; return FAILURE; } while (parser.theA != '\0') { if (status == FAILURE) { break; } switch (parser.theA) { case ' ': if (jsmin_action(&parser, jsmin_isAlphanum(parser.theB) ? JSMIN_ACTION_OUTPUT_NEXT : JSMIN_ACTION_NEXT_DELETE TSRMLS_CC)) { status = FAILURE; break; } break; case '\n': switch (parser.theB) { case '{': case '[': case '(': case '+': case '-': case '!': case '~': if (jsmin_action(&parser, JSMIN_ACTION_OUTPUT_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } break; case ' ': if (jsmin_action(&parser, JSMIN_ACTION_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } break; default: if (jsmin_action(&parser, jsmin_isAlphanum(parser.theB) ? JSMIN_ACTION_OUTPUT_NEXT : JSMIN_ACTION_NEXT_DELETE TSRMLS_CC) == FAILURE) { status = FAILURE; break; } } break; default: switch (parser.theB) { case ' ': if (jsmin_action(&parser, jsmin_isAlphanum(parser.theA) ? JSMIN_ACTION_OUTPUT_NEXT : JSMIN_ACTION_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } break; case '\n': switch (parser.theA) { case '}': case ']': case ')': case '+': case '-': case '"': case '\'': case '`': if (jsmin_action(&parser, JSMIN_ACTION_OUTPUT_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } break; default: if (jsmin_action(&parser, jsmin_isAlphanum(parser.theA) ? JSMIN_ACTION_OUTPUT_NEXT : JSMIN_ACTION_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } } break; default: if (jsmin_action(&parser, JSMIN_ACTION_OUTPUT_NEXT TSRMLS_CC) == FAILURE) { status = FAILURE; break; } break; } } } if (status == FAILURE) { smart_str_free(&minified); *error = parser.error; return FAILURE; } smart_str_0(&minified); if (minified.len) { ZVAL_STRINGL(return_value, minified.c, minified.len, 0); } else { ZVAL_STRING(return_value, "", 1); } return SUCCESS; } static int phalcon_jsmin(zval *return_value, zval *script TSRMLS_DC) { const char *error = NULL; ZVAL_NULL(return_value); if (Z_TYPE_P(script) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Script must be a string"); return FAILURE; } if (phalcon_jsmin_internal(return_value, script, &error TSRMLS_CC) == FAILURE){ if (error) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, error); } else { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_assets_exception_ce, "Unknown error"); } return FAILURE; } return SUCCESS; } #ifndef PHALCON_MVC_URL_UTILS_H #define PHALCON_MVC_URL_UTILS_H #include <Zend/zend.h> /* Extract named parameters */ static void phalcon_get_uri(zval *return_value, zval *path); static void phalcon_extract_named_params(zval *return_value, zval *str, zval *matches); static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths, zval *uri TSRMLS_DC); #endif /* PHALCON_MVC_URL_UTILS_H */ static void phalcon_orm_destroy_cache(TSRMLS_D); static void phalcon_orm_singlequotes(zval *return_value, zval *str TSRMLS_DC); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(phalcon_0__closure) { ZEPHIR_REGISTER_CLASS(phalcon, 0__closure, phalcon, 0__closure, phalcon_0__closure_method_entry, ZEND_ACC_FINAL_CLASS); return SUCCESS; } static PHP_METHOD(phalcon_0__closure, __invoke) { int ZEPHIR_LAST_CALL_STATUS; zval *matches, *words, *_0, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &matches); zephir_array_fetch_long(&_0, matches, 1, PH_NOISY | PH_READONLY, "phalcon/text.zep", 272 TSRMLS_CC); ZEPHIR_INIT_VAR(words); zephir_fast_explode_str(words, SL("|"), _0, LONG_MAX TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_2, "array_rand", NULL, 445, words); zephir_check_call_status(); zephir_array_fetch(&_1, words, _2, PH_NOISY | PH_READONLY, "phalcon/text.zep", 273 TSRMLS_CC); RETURN_CTOR(_1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl) { ZEPHIR_REGISTER_CLASS(Phalcon, Acl, phalcon, acl, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_class_constant_long(phalcon_acl_ce, SL("ALLOW"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_acl_ce, SL("DENY"), 0 TSRMLS_CC); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config) { ZEPHIR_REGISTER_CLASS(Phalcon, Config, phalcon, config, phalcon_config_method_entry, 0); zend_class_implements(phalcon_config_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_config_ce TSRMLS_CC, 1, spl_ce_Countable); return SUCCESS; } static PHP_METHOD(Phalcon_Config, __construct) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *arrayConfig_param = NULL, *key = NULL, *value = NULL, **_2; zval *arrayConfig = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arrayConfig_param); if (!arrayConfig_param) { ZEPHIR_INIT_VAR(arrayConfig); array_init(arrayConfig); } else { arrayConfig = arrayConfig_param; } zephir_is_iterable(arrayConfig, &_1, &_0, 0, 0, "phalcon/config.zep", 62); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CALL_METHOD(NULL, this_ptr, "offsetset", &_3, 0, key, value); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Config, offsetExists) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_SEPARATE_PARAM(index); ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 21, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); RETURN_MM_BOOL(zephir_isset_property_zval(this_ptr, index TSRMLS_CC)); } static PHP_METHOD(Phalcon_Config, get) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *defaultValue = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &index, &defaultValue); ZEPHIR_SEPARATE_PARAM(index); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 21, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); if (zephir_isset_property_zval(this_ptr, index TSRMLS_CC)) { ZEPHIR_OBS_VAR(_1); zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); RETURN_CCTOR(_1); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Config, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_SEPARATE_PARAM(index); ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 21, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); ZEPHIR_OBS_VAR(_1); zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); RETURN_CCTOR(_1); } static PHP_METHOD(Phalcon_Config, offsetSet) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *value, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &index, &value); ZEPHIR_SEPARATE_PARAM(index); ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 21, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_config_ce); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 22, value); zephir_check_call_status(); zephir_update_property_zval_zval(this_ptr, index, _1 TSRMLS_CC); } else { zephir_update_property_zval_zval(this_ptr, index, value TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Config, offsetUnset) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_SEPARATE_PARAM(index); ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 21, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); zephir_update_property_zval_zval(this_ptr, index, ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Config, merge) { int ZEPHIR_LAST_CALL_STATUS; zval *config; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &config); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_merge", NULL, 23, config); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Config, toArray) { HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *key = NULL, *value = NULL, *arrayConfig, *_0 = NULL, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(arrayConfig); array_init(arrayConfig); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/config.zep", 180); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); if (Z_TYPE_P(value) == IS_OBJECT) { if ((zephir_method_exists_ex(value, SS("toarray") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_4, value, "toarray", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&arrayConfig, key, &_4, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&arrayConfig, key, &value, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&arrayConfig, key, &value, PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(arrayConfig); } static PHP_METHOD(Phalcon_Config, count) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); RETURN_MM_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Config, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); data = data_param; object_init_ex(return_value, phalcon_config_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 22, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Config, _merge) { zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; zend_bool _4, _5; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *config, *instance = NULL, *key = NULL, *value = NULL, *number = NULL, *localObject = NULL, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &config, &instance); if (!instance) { ZEPHIR_CPY_WRT(instance, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(instance); } if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_CPY_WRT(instance, this_ptr); } ZEPHIR_CALL_METHOD(&number, instance, "count", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 24, config); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/config.zep", 245); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_OBS_NVAR(localObject); if (zephir_fetch_property_zval(&localObject, instance, key, PH_SILENT_CC)) { _4 = Z_TYPE_P(localObject) == IS_OBJECT; if (_4) { _4 = Z_TYPE_P(value) == IS_OBJECT; } if (_4) { _5 = zephir_instance_of_ev(localObject, phalcon_config_ce TSRMLS_CC); if (_5) { _5 = zephir_instance_of_ev(value, phalcon_config_ce TSRMLS_CC); } if (_5) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_merge", &_6, 23, value, localObject); zephir_check_call_status(); continue; } } } if (Z_TYPE_P(key) == IS_LONG) { ZEPHIR_CALL_FUNCTION(&key, "strval", &_7, 21, number); zephir_check_call_status(); ZEPHIR_SEPARATE(number); zephir_increment(number); } zephir_update_property_zval_zval(instance, key, value TSRMLS_CC); } RETVAL_ZVAL(instance, 1, 0); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Crypt) { ZEPHIR_REGISTER_CLASS(Phalcon, Crypt, phalcon, crypt, phalcon_crypt_method_entry, 0); zend_declare_property_null(phalcon_crypt_ce, SL("_key"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_crypt_ce, SL("_padding"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_crypt_ce, SL("_mode"), "cbc", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_crypt_ce, SL("_cipher"), "rijndael-256", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_DEFAULT"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_ANSI_X_923"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_PKCS7"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_ISO_10126"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_ISO_IEC_7816_4"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_ZERO"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_crypt_ce, SL("PADDING_SPACE"), 6 TSRMLS_CC); zend_class_implements(phalcon_crypt_ce TSRMLS_CC, 1, phalcon_cryptinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Crypt, setPadding) { zval *scheme_param = NULL, *_0; int scheme; zephir_fetch_params(0, 1, 0, &scheme_param); if (unlikely(Z_TYPE_P(scheme_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'scheme' must be a int") TSRMLS_CC); RETURN_NULL(); } scheme = Z_LVAL_P(scheme_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, scheme); zephir_update_property_this(this_ptr, SL("_padding"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Crypt, setCipher) { zval *cipher_param = NULL; zval *cipher = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &cipher_param); if (unlikely(Z_TYPE_P(cipher_param) != IS_STRING && Z_TYPE_P(cipher_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cipher' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(cipher_param) == IS_STRING)) { zephir_get_strval(cipher, cipher_param); } else { ZEPHIR_INIT_VAR(cipher); ZVAL_EMPTY_STRING(cipher); } zephir_update_property_this(this_ptr, SL("_cipher"), cipher TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Crypt, getCipher) { RETURN_MEMBER(this_ptr, "_cipher"); } static PHP_METHOD(Phalcon_Crypt, setMode) { zval *mode_param = NULL; zval *mode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &mode_param); if (unlikely(Z_TYPE_P(mode_param) != IS_STRING && Z_TYPE_P(mode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'mode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(mode_param) == IS_STRING)) { zephir_get_strval(mode, mode_param); } else { ZEPHIR_INIT_VAR(mode); ZVAL_EMPTY_STRING(mode); } zephir_update_property_this(this_ptr, SL("_mode"), mode TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Crypt, getMode) { RETURN_MEMBER(this_ptr, "_mode"); } static PHP_METHOD(Phalcon_Crypt, setKey) { zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_this(this_ptr, SL("_key"), key TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Crypt, getKey) { RETURN_MEMBER(this_ptr, "_key"); } static PHP_METHOD(Phalcon_Crypt, _cryptPadText) { zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_10 = NULL; zend_bool _0, _7; int blockSize, paddingType, i, paddingSize = 0, ZEPHIR_LAST_CALL_STATUS, _8, _9; zval *text_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, *padding = NULL, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_6 = NULL, _11 = zval_used_for_init, *_12; zval *text = NULL, *mode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &text_param, &mode_param, &blockSize_param, &paddingType_param); zephir_get_strval(text, text_param); if (unlikely(Z_TYPE_P(mode_param) != IS_STRING && Z_TYPE_P(mode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'mode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(mode_param) == IS_STRING)) { zephir_get_strval(mode, mode_param); } else { ZEPHIR_INIT_VAR(mode); ZVAL_EMPTY_STRING(mode); } if (unlikely(Z_TYPE_P(blockSize_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'blockSize' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } blockSize = Z_LVAL_P(blockSize_param); if (unlikely(Z_TYPE_P(paddingType_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'paddingType' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } paddingType = Z_LVAL_P(paddingType_param); ZEPHIR_INIT_VAR(padding); ZVAL_NULL(padding); _0 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_0)) { _0 = ZEPHIR_IS_STRING(mode, "ecb"); } if (_0) { paddingSize = (blockSize - (zephir_safe_mod_long_long(zephir_fast_strlen_ev(text), blockSize TSRMLS_CC))); if (paddingSize >= 256) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Block size is bigger than 256", "phalcon/crypt.zep", 142); return; } do { if (paddingType == 1) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_CALL_FUNCTION(&_2, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (paddingSize - 1)); ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", &_5, 132, _2, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, paddingSize); ZEPHIR_CALL_FUNCTION(&_6, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(padding); ZEPHIR_CONCAT_VV(padding, _4, _6); break; } if (paddingType == 2) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, paddingSize); ZEPHIR_CALL_FUNCTION(&_2, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_5, 132, _2, &_1); zephir_check_call_status(); break; } if (paddingType == 3) { ZEPHIR_INIT_NVAR(padding); ZVAL_STRING(padding, "", 1); _9 = (paddingSize - 2); _8 = 0; _7 = 0; if (_8 <= _9) { while (1) { if (_7) { _8++; if (!(_8 <= _9)) { break; } } else { _7 = 1; } i = _8; ZEPHIR_CALL_FUNCTION(&_2, "rand", &_10, 110); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_4, "chr", &_3, 131, _2); zephir_check_call_status(); zephir_concat_self(&padding, _4 TSRMLS_CC); } } ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, paddingSize); ZEPHIR_CALL_FUNCTION(&_6, "chr", &_3, 131, &_1); zephir_check_call_status(); zephir_concat_self(&padding, _6 TSRMLS_CC); break; } if (paddingType == 4) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0x80); ZEPHIR_CALL_FUNCTION(&_2, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_CALL_FUNCTION(&_4, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (paddingSize - 1)); ZEPHIR_CALL_FUNCTION(&_6, "str_repeat", &_5, 132, _4, &_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(padding); ZEPHIR_CONCAT_VV(padding, _2, _6); break; } if (paddingType == 5) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_CALL_FUNCTION(&_2, "chr", &_3, 131, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_5, 132, _2, &_1); zephir_check_call_status(); break; } if (paddingType == 6) { ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, " ", 0); ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_5, 132, &_1, &_11); zephir_check_call_status(); break; } paddingSize = 0; break; } while(0); } if (!(paddingSize)) { RETURN_CTOR(text); } if (paddingSize > blockSize) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Invalid padding size", "phalcon/crypt.zep", 186); return; } ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, paddingSize); ZEPHIR_INIT_VAR(_12); zephir_substr(_12, padding, 0 , zephir_get_intval(&_11), 0); ZEPHIR_CONCAT_VV(return_value, text, _12); RETURN_MM(); } static PHP_METHOD(Phalcon_Crypt, _cryptUnpadText) { unsigned char _14, _16; zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL, *_11 = NULL; zend_bool _0, _1, _2, _13, _15; long length; int blockSize, paddingType, i, paddingSize = 0, ord, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, *padding = NULL, *last = NULL, _3 = zval_used_for_init, _4 = zval_used_for_init, *_5 = NULL, _7 = zval_used_for_init, *_8 = NULL, *_10 = NULL, *_12 = NULL; zval *text = NULL, *mode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &text_param, &mode_param, &blockSize_param, &paddingType_param); zephir_get_strval(text, text_param); if (unlikely(Z_TYPE_P(mode_param) != IS_STRING && Z_TYPE_P(mode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'mode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(mode_param) == IS_STRING)) { zephir_get_strval(mode, mode_param); } else { ZEPHIR_INIT_VAR(mode); ZVAL_EMPTY_STRING(mode); } if (unlikely(Z_TYPE_P(blockSize_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'blockSize' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } blockSize = Z_LVAL_P(blockSize_param); if (unlikely(Z_TYPE_P(paddingType_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'paddingType' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } paddingType = Z_LVAL_P(paddingType_param); length = zephir_fast_strlen_ev(text); _0 = length > 0; if (_0) { _0 = (zephir_safe_mod_long_long(length, blockSize TSRMLS_CC) == 0); } _1 = _0; if (_1) { _2 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_2)) { _2 = ZEPHIR_IS_STRING(mode, "ecb"); } _1 = _2; } if (_1) { do { if (paddingType == 1) { ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, 133, last); zephir_check_call_status(); ord = zephir_get_intval(_5); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_CALL_FUNCTION(&_8, "chr", &_9, 131, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (paddingSize - 1)); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, _8, &_7); zephir_check_call_status(); ZEPHIR_INIT_VAR(padding); ZEPHIR_CONCAT_VV(padding, _10, last); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (length - paddingSize)); ZEPHIR_INIT_VAR(_12); zephir_substr(_12, text, zephir_get_intval(&_7), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_12, padding)) { paddingSize = 0; } } break; } if (paddingType == 2) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, 133, last); zephir_check_call_status(); ord = zephir_get_intval(_5); if (ord <= blockSize) { paddingSize = ord; ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, paddingSize); ZEPHIR_CALL_FUNCTION(&_8, "chr", &_9, 131, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, paddingSize); ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", &_11, 132, _8, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, (length - paddingSize)); ZEPHIR_INIT_NVAR(_12); zephir_substr(_12, text, zephir_get_intval(&_7), 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_EQUAL(_12, padding)) { paddingSize = 0; } } break; } if (paddingType == 3) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, (length - 1)); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(last); zephir_substr(last, text, zephir_get_intval(&_3), 1 , 0); ZEPHIR_CALL_FUNCTION(&_5, "ord", &_6, 133, last); zephir_check_call_status(); paddingSize = zephir_get_intval(_5); break; } if (paddingType == 4) { i = (length - 1); while (1) { _13 = i > 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x00; } _15 = _13; if (_15) { _15 = paddingSize < blockSize; } if (!(_15)) { break; } paddingSize++; i--; } _16 = ZEPHIR_STRING_OFFSET(text, i); if (_16 == 0x80) { paddingSize++; } else { paddingSize = 0; } break; } if (paddingType == 5) { i = (length - 1); while (1) { _13 = i >= 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x00; } _15 = _13; if (_15) { _15 = paddingSize <= blockSize; } if (!(_15)) { break; } paddingSize++; i--; } break; } if (paddingType == 6) { i = (length - 1); while (1) { _13 = i >= 0; if (_13) { _14 = ZEPHIR_STRING_OFFSET(text, i); _13 = _14 == 0x20; } _15 = _13; if (_15) { _15 = paddingSize <= blockSize; } if (!(_15)) { break; } paddingSize++; i--; } break; } break; } while(0); _13 = (paddingSize) ? 1 : 0; if (_13) { _13 = paddingSize <= blockSize; } if (_13) { if (paddingSize < length) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, (length - paddingSize)); zephir_substr(return_value, text, 0 , zephir_get_intval(&_4), 0); RETURN_MM(); } RETURN_MM_STRING("", 1); } else { paddingSize = 0; } } if (!(paddingSize)) { RETURN_CTOR(text); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Crypt, encrypt) { zend_bool _3, _4; int ZEPHIR_LAST_CALL_STATUS, _2; zval *text_param = NULL, *key_param = NULL, *encryptKey = NULL, *ivSize = NULL, *iv = NULL, *cipher, *mode, *blockSize = NULL, *paddingType, *padded = NULL, _0, *_1 = NULL; zval *text = NULL, *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &text_param, &key_param); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key_param) { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } else { if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } } if (!((zephir_function_exists_ex(SS("mcrypt_get_iv_size") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "mcrypt extension is required", "phalcon/crypt.zep", 302); return; } if (ZEPHIR_IS_STRING_IDENTICAL(key, "")) { ZEPHIR_OBS_VAR(encryptKey); zephir_read_property_this(&encryptKey, this_ptr, SL("_key"), PH_NOISY_CC); } else { ZEPHIR_CPY_WRT(encryptKey, key); } if (ZEPHIR_IS_EMPTY(encryptKey)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Encryption key cannot be empty", "phalcon/crypt.zep", 312); return; } ZEPHIR_OBS_VAR(cipher); zephir_read_property_this(&cipher, this_ptr, SL("_cipher"), PH_NOISY_CC); ZEPHIR_OBS_VAR(mode); zephir_read_property_this(&mode, this_ptr, SL("_mode"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&ivSize, "mcrypt_get_iv_size", NULL, 134, cipher, mode); zephir_check_call_status(); if (ZEPHIR_LT_LONG(ivSize, zephir_fast_strlen_ev(encryptKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Size of key is too large for this algorithm", "phalcon/crypt.zep", 320); return; } ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 2); ZEPHIR_CALL_FUNCTION(&iv, "mcrypt_create_iv", NULL, 135, ivSize, &_0); zephir_check_call_status(); if (Z_TYPE_P(iv) != IS_STRING) { ZEPHIR_CALL_FUNCTION(&_1, "strval", NULL, 21, iv); zephir_check_call_status(); ZEPHIR_CPY_WRT(iv, _1); } ZEPHIR_CALL_FUNCTION(&blockSize, "mcrypt_get_block_size", NULL, 136, cipher, mode); zephir_check_call_status(); if (Z_TYPE_P(blockSize) != IS_LONG) { _2 = zephir_get_intval(blockSize); ZEPHIR_INIT_NVAR(blockSize); ZVAL_LONG(blockSize, _2); } ZEPHIR_OBS_VAR(paddingType); zephir_read_property_this(&paddingType, this_ptr, SL("_padding"), PH_NOISY_CC); _3 = !ZEPHIR_IS_LONG(paddingType, 0); if (_3) { _4 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_4)) { _4 = ZEPHIR_IS_STRING(mode, "ecb"); } _3 = _4; } if (_3) { ZEPHIR_CALL_METHOD(&padded, this_ptr, "_cryptpadtext", NULL, 0, text, mode, blockSize, paddingType); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(padded, text); } ZEPHIR_CALL_FUNCTION(&_1, "mcrypt_encrypt", NULL, 137, cipher, encryptKey, padded, mode, iv); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, iv, _1); RETURN_MM(); } static PHP_METHOD(Phalcon_Crypt, decrypt) { zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *key = NULL, *decryptKey = NULL, *ivSize = NULL, *cipher, *mode, *keySize, *length, *blockSize = NULL, *paddingType, *decrypted = NULL, *_0, _1, *_2; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &text_param, &key); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!((zephir_function_exists_ex(SS("mcrypt_get_iv_size") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "mcrypt extension is required", "phalcon/crypt.zep", 356); return; } if (Z_TYPE_P(key) == IS_NULL) { ZEPHIR_OBS_VAR(decryptKey); zephir_read_property_this(&decryptKey, this_ptr, SL("_key"), PH_NOISY_CC); } else { ZEPHIR_CPY_WRT(decryptKey, key); } if (ZEPHIR_IS_EMPTY(decryptKey)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Decryption key cannot be empty", "phalcon/crypt.zep", 366); return; } ZEPHIR_OBS_VAR(cipher); zephir_read_property_this(&cipher, this_ptr, SL("_cipher"), PH_NOISY_CC); ZEPHIR_OBS_VAR(mode); zephir_read_property_this(&mode, this_ptr, SL("_mode"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&ivSize, "mcrypt_get_iv_size", NULL, 134, cipher, mode); zephir_check_call_status(); ZEPHIR_INIT_VAR(keySize); ZVAL_LONG(keySize, zephir_fast_strlen_ev(decryptKey)); if (ZEPHIR_GT(keySize, ivSize)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Size of key is too large for this algorithm", "phalcon/crypt.zep", 375); return; } ZEPHIR_INIT_VAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(text)); if (ZEPHIR_GT(keySize, length)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_crypt_exception_ce, "Size of IV is larger than text to decrypt", "phalcon/crypt.zep", 380); return; } ZEPHIR_INIT_VAR(_0); zephir_substr(_0, text, zephir_get_intval(ivSize), 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_INIT_VAR(_2); zephir_substr(_2, text, 0 , zephir_get_intval(ivSize), 0); ZEPHIR_CALL_FUNCTION(&decrypted, "mcrypt_decrypt", NULL, 138, cipher, decryptKey, _0, mode, _2); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&blockSize, "mcrypt_get_block_size", NULL, 136, cipher, mode); zephir_check_call_status(); ZEPHIR_OBS_VAR(paddingType); zephir_read_property_this(&paddingType, this_ptr, SL("_padding"), PH_NOISY_CC); _3 = ZEPHIR_IS_STRING(mode, "cbc"); if (!(_3)) { _3 = ZEPHIR_IS_STRING(mode, "ecb"); } if (_3) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_cryptunpadtext", NULL, 0, decrypted, mode, blockSize, paddingType); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(decrypted); } static PHP_METHOD(Phalcon_Crypt, encryptBase64) { zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool safe; zval *text_param = NULL, *key = NULL, *safe_param = NULL, *_0 = NULL, *_2 = NULL, _4, _5; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &text_param, &key, &safe_param); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!safe_param) { safe = 0; } else { if (unlikely(Z_TYPE_P(safe_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'safe' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } safe = Z_BVAL_P(safe_param); } if (safe == 1) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "encrypt", &_1, 0, text, key); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_2, "base64_encode", &_3, 115, _0); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "+/", 0); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "-_", 0); ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 54, _2, &_4, &_5); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "encrypt", &_1, 0, text, key); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", &_3, 115, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Crypt, decryptBase64) { zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool safe; zval *text_param = NULL, *key = NULL, *safe_param = NULL, _0, _1, *_2 = NULL, *_3 = NULL; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &text_param, &key, &safe_param); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!safe_param) { safe = 0; } else { if (unlikely(Z_TYPE_P(safe_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'safe' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } safe = Z_BVAL_P(safe_param); } if (safe == 1) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "-_", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "+/", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, text, &_0, &_1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_3, "base64_decode", &_4, 116, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", &_5, 0, _3, key); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_FUNCTION(&_2, "base64_decode", &_4, 116, text); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", &_5, 0, _2, key); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Crypt, getAvailableCiphers) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("mcrypt_list_algorithms", NULL, 139); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Crypt, getAvailableModes) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("mcrypt_list_modes", NULL, 140); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_CryptInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, CryptInterface, phalcon, cryptinterface, phalcon_cryptinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, setCipher); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, getCipher); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, setMode); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, getMode); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, setKey); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, getKey); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, encrypt); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, decrypt); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, encryptBase64); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, decryptBase64); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, getAvailableCiphers); ZEPHIR_DOC_METHOD(Phalcon_CryptInterface, getAvailableModes); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db) { ZEPHIR_REGISTER_CLASS(Phalcon, Db, phalcon, db, phalcon_db_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_LAZY"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_ASSOC"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_NAMED"), 11 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_NUM"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_BOTH"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_OBJ"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_BOUND"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_COLUMN"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_CLASS"), 8 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_INTO"), 9 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_FUNC"), 10 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_GROUP"), 65536 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_UNIQUE"), 196608 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_KEY_PAIR"), 12 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_CLASSTYPE"), 262144 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_SERIALIZE"), 524288 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_ce, SL("FETCH_PROPS_LATE"), 1048576 TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db, setup) { zval *options_param = NULL, *escapeIdentifiers, *forceCasting; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_OBS_VAR(escapeIdentifiers); if (zephir_array_isset_string_fetch(&escapeIdentifiers, options, SS("escapeSqlIdentifiers"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(db).escape_identifiers = zend_is_true(escapeIdentifiers); } ZEPHIR_OBS_VAR(forceCasting); if (zephir_array_isset_string_fetch(&forceCasting, options, SS("forceCasting"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(db).force_casting = zend_is_true(forceCasting); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Debug) { ZEPHIR_REGISTER_CLASS(Phalcon, Debug, phalcon, debug, phalcon_debug_method_entry, 0); zend_declare_property_string(phalcon_debug_ce, SL("_uri"), "//static.phalconphp.com/www/debug/2.0.0/", ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_string(phalcon_debug_ce, SL("_theme"), "default", ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_bool(phalcon_debug_ce, SL("_hideDocumentRoot"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_debug_ce, SL("_showBackTrace"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_debug_ce, SL("_showFiles"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_debug_ce, SL("_showFileFragment"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_debug_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_debug_ce, SL("_isActive"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Debug, setUri) { zval *uri_param = NULL; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &uri_param); if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { zephir_get_strval(uri, uri_param); } else { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } zephir_update_property_this(this_ptr, SL("_uri"), uri TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Debug, setShowBackTrace) { zval *showBackTrace_param = NULL; zend_bool showBackTrace; zephir_fetch_params(0, 1, 0, &showBackTrace_param); showBackTrace = zephir_get_boolval(showBackTrace_param); if (showBackTrace) { zephir_update_property_this(this_ptr, SL("_showBackTrace"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_showBackTrace"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Debug, setShowFiles) { zval *showFiles_param = NULL; zend_bool showFiles; zephir_fetch_params(0, 1, 0, &showFiles_param); showFiles = zephir_get_boolval(showFiles_param); if (showFiles) { zephir_update_property_this(this_ptr, SL("_showFiles"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_showFiles"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Debug, setShowFileFragment) { zval *showFileFragment_param = NULL; zend_bool showFileFragment; zephir_fetch_params(0, 1, 0, &showFileFragment_param); showFileFragment = zephir_get_boolval(showFileFragment_param); if (showFileFragment) { zephir_update_property_this(this_ptr, SL("_showFileFragment"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_showFileFragment"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Debug, listen) { int ZEPHIR_LAST_CALL_STATUS; zval *exceptions_param = NULL, *lowSeverity_param = NULL; zend_bool exceptions, lowSeverity; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &exceptions_param, &lowSeverity_param); if (!exceptions_param) { exceptions = 1; } else { exceptions = zephir_get_boolval(exceptions_param); } if (!lowSeverity_param) { lowSeverity = 0; } else { lowSeverity = zephir_get_boolval(lowSeverity_param); } if (exceptions) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenexceptions", NULL, 0); zephir_check_call_status(); } if (lowSeverity) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenlowseverity", NULL, 0); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Debug, listenExceptions) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "onUncaughtException", 1); zephir_array_fast_append(_0, _1); ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 150, _0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Debug, listenLowSeverity) { int ZEPHIR_LAST_CALL_STATUS; zval *_1 = NULL; zval *_0, *_2; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "onUncaughtLowSeverity", 1); zephir_array_fast_append(_0, _1); ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 151, _0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, this_ptr); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "onUncaughtException", 1); zephir_array_fast_append(_2, _1); ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 150, _2); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Debug, halt) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_exception_ce, "Halted request", "phalcon/debug.zep", 120); return; } static PHP_METHOD(Phalcon_Debug, debugVar) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; zval *key = NULL; zval *varz, *key_param = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &varz, &key_param); if (!key_param) { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } else { zephir_get_strval(key, key_param); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 3, 0 TSRMLS_CC); zephir_array_fast_append(_0, varz); ZEPHIR_CALL_FUNCTION(&_1, "debug_backtrace", NULL, 152); zephir_check_call_status(); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_VAR(_2); zephir_time(_2); zephir_array_fast_append(_0, _2); zephir_update_property_array_append(this_ptr, SL("_data"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Debug, clearVars) { zephir_update_property_this(this_ptr, SL("_data"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Debug, _escapeString) { int ZEPHIR_LAST_CALL_STATUS; zval *value, *_0, _1, _2, _3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value); if (Z_TYPE_P(value) == IS_STRING) { ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "\n", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "\\n", 0); zephir_fast_str_replace(&_0, &_1, &_2, value TSRMLS_CC); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 2); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "utf-8", 0); ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", NULL, 153, _0, &_3, &_4); zephir_check_call_status(); RETURN_MM(); } RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug, _getArrayDump) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool _0; zval *argument_param = NULL, *n = NULL, *numberArguments, *dump, *varDump = NULL, *k = NULL, *v = NULL, **_3, *_4 = NULL, *_6 = NULL, *_8 = NULL; zval *argument = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &argument_param, &n); argument = argument_param; if (!n) { ZEPHIR_INIT_VAR(n); ZVAL_LONG(n, 0); } ZEPHIR_INIT_VAR(numberArguments); ZVAL_LONG(numberArguments, zephir_fast_count_int(argument TSRMLS_CC)); _0 = ZEPHIR_GE_LONG(n, 3); if (!(_0)) { _0 = ZEPHIR_IS_LONG(numberArguments, 0); } if (_0) { RETURN_MM_NULL(); } if (ZEPHIR_GE_LONG(numberArguments, 10)) { RETURN_CCTOR(numberArguments); } ZEPHIR_INIT_VAR(dump); array_init(dump); zephir_is_iterable(argument, &_2, &_1, 0, 0, "phalcon/debug.zep", 200); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(k, _2, _1); ZEPHIR_GET_HVALUE(v, _3); if (zephir_is_scalar(v)) { ZEPHIR_INIT_NVAR(varDump); if (ZEPHIR_IS_STRING(v, "")) { ZEPHIR_CONCAT_SVS(varDump, "[", k, "] => (empty string)"); } else { ZEPHIR_CALL_METHOD(&_4, this_ptr, "_escapestring", &_5, 0, v); zephir_check_call_status(); ZEPHIR_CONCAT_SVSV(varDump, "[", k, "] => ", _4); } zephir_array_append(&dump, varDump, PH_SEPARATE, "phalcon/debug.zep", 178); continue; } if (Z_TYPE_P(v) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, (zephir_get_numberval(n) + 1)); ZEPHIR_CALL_METHOD(&_4, this_ptr, "_getarraydump", &_7, 154, v, _6); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "[", k, "] => Array(", _4, ")"); zephir_array_append(&dump, _8, PH_SEPARATE, "phalcon/debug.zep", 183); continue; } if (Z_TYPE_P(v) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_6); zephir_get_class(_6, v, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "[", k, "] => Object(", _6, ")"); zephir_array_append(&dump, _8, PH_SEPARATE, "phalcon/debug.zep", 188); continue; } if (Z_TYPE_P(v) == IS_NULL) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "[", k, "] => null"); zephir_array_append(&dump, _8, PH_SEPARATE, "phalcon/debug.zep", 193); continue; } ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSV(_8, "[", k, "] => ", v); zephir_array_append(&dump, _8, PH_SEPARATE, "phalcon/debug.zep", 197); } zephir_fast_join_str(return_value, SL(", "), dump TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug, _getVarDump) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *variable, *className, *dumpedObject = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &variable); if (zephir_is_scalar(variable)) { if (Z_TYPE_P(variable) == IS_BOOL) { if (zephir_is_true(variable)) { RETURN_MM_STRING("true", 1); } else { RETURN_MM_STRING("false", 1); } } if (Z_TYPE_P(variable) == IS_STRING) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_escapestring", NULL, 0, variable); zephir_check_call_status(); RETURN_MM(); } RETVAL_ZVAL(variable, 1, 0); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_OBJECT) { ZEPHIR_INIT_VAR(className); zephir_get_class(className, variable, 0 TSRMLS_CC); if ((zephir_method_exists_ex(variable, SS("dump") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getarraydump", &_1, 0, dumpedObject); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "Object(", className, ": ", _0, ")"); RETURN_MM(); } else { ZEPHIR_CONCAT_SVS(return_value, "Object(", className, ")"); RETURN_MM(); } } if (Z_TYPE_P(variable) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getarraydump", &_1, 154, variable); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "Array(", _0, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_NULL) { RETURN_MM_STRING("null", 1); } zephir_gettype(return_value, variable TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug, getMajorVersion) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *parts, *_0 = NULL, *_2; ZEPHIR_MM_GROW(); ZEPHIR_CALL_CE_STATIC(&_0, phalcon_version_ce, "get", &_1, 155); zephir_check_call_status(); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL(" "), _0, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_2, parts, 0, PH_NOISY | PH_READONLY, "phalcon/debug.zep", 289 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Debug, getVersion) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmajorversion", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_1, phalcon_version_ce, "get", &_2, 155); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "<div class=\"version\">Phalcon Framework <a target=\"_new\" href=\"//docs.phalconphp.com/en/", _0, "/\">", _1, "</a></div>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug, getCssSources) { zval *uri, *sources, *_0; ZEPHIR_MM_GROW(); uri = zephir_fetch_nproperty_this(this_ptr, SL("_uri"), PH_NOISY_CC); ZEPHIR_INIT_VAR(sources); ZEPHIR_CONCAT_SVS(sources, "<link href=\"", uri, "jquery/jquery-ui.css\" type=\"text/css\" rel=\"stylesheet\" />"); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVS(_0, "<link href=\"", uri, "themes/default/style.css\" type=\"text/css\" rel=\"stylesheet\" />"); zephir_concat_self(&sources, _0 TSRMLS_CC); RETURN_CCTOR(sources); } static PHP_METHOD(Phalcon_Debug, getJsSources) { zval *uri, *sources, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); uri = zephir_fetch_nproperty_this(this_ptr, SL("_uri"), PH_NOISY_CC); ZEPHIR_INIT_VAR(sources); ZEPHIR_CONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery.js\"></script>"); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVS(_0, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery-ui.js\"></script>"); zephir_concat_self(&sources, _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery.scrollTo.js\"></script>"); zephir_concat_self(&sources, _1 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "<script type=\"text/javascript\" src=\"", uri, "prettify/prettify.js\"></script>"); zephir_concat_self(&sources, _2 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVS(_3, "<script type=\"text/javascript\" src=\"", uri, "pretty.js\"></script>"); zephir_concat_self(&sources, _3 TSRMLS_CC); RETURN_CCTOR(sources); } static PHP_METHOD(Phalcon_Debug, showTraceItem) { zend_bool _24; zephir_fcall_cache_entry *_15 = NULL, *_26 = NULL; HashTable *_13; HashPosition _12; zval *_1, *_17 = NULL; zval *trace = NULL; zval *n_param = NULL, *trace_param = NULL, *className, *prepareInternalClass, *preparedFunctionName, *html = NULL, *classReflection, *prepareUriClass, *functionName, *functionReflection, *traceArgs, *arguments, *argument = NULL, *filez, *line = NULL, *showFiles, *lines = NULL, *numberLines, *showFileFragment, *beforeLine, *afterLine, *lastLine = NULL, linePosition = zval_used_for_init, *currentLine = NULL, _0, *_2, *_3 = NULL, _4 = zval_used_for_init, _5 = zval_used_for_init, _6 = zval_used_for_init, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11, **_14, *_16, *_18, *_19 = NULL, _20 = zval_used_for_init, *_21 = NULL, _22 = zval_used_for_init, _23 = zval_used_for_init, _25 = zval_used_for_init; int n, firstLine, i, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &n_param, &trace_param); n = zephir_get_intval(n_param); trace = trace_param; ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, n); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "<tr><td align=\"right\" valign=\"top\" class=\"error-number\">#", &_0, "</td><td>"); ZEPHIR_CPY_WRT(html, _1); ZEPHIR_OBS_VAR(className); if (zephir_array_isset_string_fetch(&className, trace, SS("class"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "/^Phalcon/", 0); zephir_preg_match(_3, &_4, className, _2, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_3)) { ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "\\", 0); ZEPHIR_SINIT_VAR(_6); ZVAL_STRING(&_6, "/", 0); ZEPHIR_INIT_VAR(prepareUriClass); zephir_fast_str_replace(&prepareUriClass, &_5, &_6, className TSRMLS_CC); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "<span class=\"error-class\"><a target=\"_new\" href=\"//api.phalconphp.com/class/", prepareUriClass, ".html\">", className, "</a></span>"); zephir_concat_self(&html, _7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(classReflection); object_init_ex(classReflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, classReflection, "__construct", NULL, 65, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, classReflection, "isinternal", NULL, 156); zephir_check_call_status(); if (zephir_is_true(_8)) { ZEPHIR_INIT_VAR(_9); zephir_fast_strtolower(_9, className); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "_", 0); ZEPHIR_SINIT_NVAR(_6); ZVAL_STRING(&_6, "-", 0); ZEPHIR_INIT_VAR(prepareInternalClass); zephir_fast_str_replace(&prepareInternalClass, &_5, &_6, _9 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "<span class=\"error-class\"><a target=\"_new\" href=\"http://php.net/manual/en/class.", prepareInternalClass, ".php\">", className, "</a></span>"); zephir_concat_self(&html, _7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_SVS(_10, "<span class=\"error-class\">", className, "</span>"); zephir_concat_self(&html, _10 TSRMLS_CC); } } zephir_array_fetch_string(&_11, trace, SL("type"), PH_NOISY | PH_READONLY, "phalcon/debug.zep", 385 TSRMLS_CC); zephir_concat_self(&html, _11 TSRMLS_CC); } ZEPHIR_OBS_VAR(functionName); zephir_array_fetch_string(&functionName, trace, SL("function"), PH_NOISY, "phalcon/debug.zep", 391 TSRMLS_CC); if (zephir_array_isset_string(trace, SS("class"))) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _7 TSRMLS_CC); } else { if ((zephir_function_exists(functionName TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(functionReflection); object_init_ex(functionReflection, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, functionReflection, "__construct", NULL, 157, functionName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, functionReflection, "isinternal", NULL, 158); zephir_check_call_status(); if (zephir_is_true(_8)) { ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "_", 0); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "-", 0); ZEPHIR_INIT_VAR(preparedFunctionName); zephir_fast_str_replace(&preparedFunctionName, &_4, &_5, functionName TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSVS(_10, "<span class=\"error-function\"><a target=\"_new\" href=\"http://php.net/manual/en/function.", preparedFunctionName, ".php\">", functionName, "</a></span>"); zephir_concat_self(&html, _10 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVS(_10, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _10 TSRMLS_CC); } } else { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "<span class=\"error-function\">", functionName, "</span>"); zephir_concat_self(&html, _7 TSRMLS_CC); } } ZEPHIR_OBS_VAR(traceArgs); if (zephir_array_isset_string_fetch(&traceArgs, trace, SS("args"), 0 TSRMLS_CC)) { if (zephir_fast_count_int(traceArgs TSRMLS_CC)) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); zephir_is_iterable(traceArgs, &_13, &_12, 0, 0, "phalcon/debug.zep", 439); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HVALUE(argument, _14); ZEPHIR_CALL_METHOD(&_8, this_ptr, "_getvardump", &_15, 0, argument); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "<span class=\"error-parameter\">", _8, "</span>"); zephir_array_append(&arguments, _7, PH_SEPARATE, "phalcon/debug.zep", 433); } ZEPHIR_INIT_NVAR(_3); zephir_fast_join_str(_3, SL(", "), arguments TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVS(_10, "(", _3, ")"); zephir_concat_self(&html, _10 TSRMLS_CC); } else { zephir_concat_self_str(&html, SL("()") TSRMLS_CC); } } ZEPHIR_OBS_VAR(filez); if (zephir_array_isset_string_fetch(&filez, trace, SS("file"), 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(_16); zephir_array_fetch_string(&_16, trace, SL("line"), PH_NOISY, "phalcon/debug.zep", 450 TSRMLS_CC); zephir_get_strval(_17, _16); ZEPHIR_CPY_WRT(line, _17); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "<br/><div class=\"error-file\">", filez, " (", line, ")</div>"); zephir_concat_self(&html, _7 TSRMLS_CC); ZEPHIR_OBS_VAR(showFiles); zephir_read_property_this(&showFiles, this_ptr, SL("_showFiles"), PH_NOISY_CC); if (zephir_is_true(showFiles)) { ZEPHIR_CALL_FUNCTION(&lines, "file", NULL, 159, filez); zephir_check_call_status(); ZEPHIR_INIT_VAR(numberLines); ZVAL_LONG(numberLines, zephir_fast_count_int(lines TSRMLS_CC)); ZEPHIR_OBS_VAR(showFileFragment); zephir_read_property_this(&showFileFragment, this_ptr, SL("_showFileFragment"), PH_NOISY_CC); if (zephir_is_true(showFileFragment)) { ZEPHIR_INIT_VAR(beforeLine); ZVAL_LONG(beforeLine, (zephir_get_numberval(line) - 7)); if (ZEPHIR_LT_LONG(beforeLine, 1)) { firstLine = 1; } else { firstLine = zephir_get_numberval(beforeLine); } ZEPHIR_INIT_VAR(afterLine); ZVAL_LONG(afterLine, (zephir_get_numberval(line) + 5)); if (ZEPHIR_GT(afterLine, numberLines)) { ZEPHIR_CPY_WRT(lastLine, numberLines); } else { ZEPHIR_CPY_WRT(lastLine, afterLine); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, firstLine); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, firstLine); ZEPHIR_INIT_VAR(_18); ZEPHIR_CONCAT_SVSVSVS(_18, "<pre class=\"prettyprint highlight:", &_4, ":", line, " linenums:", &_5, "\">"); zephir_concat_self(&html, _18 TSRMLS_CC); } else { firstLine = 1; ZEPHIR_CPY_WRT(lastLine, numberLines); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, firstLine); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSVS(_10, "<pre class=\"prettyprint highlight:", &_6, ":", line, " linenums error-scroll\">"); zephir_concat_self(&html, _10 TSRMLS_CC); } i = firstLine; while (1) { if (!(ZEPHIR_GE_LONG(lastLine, i))) { break; } ZEPHIR_SINIT_NVAR(linePosition); ZVAL_LONG(&linePosition, (i - 1)); ZEPHIR_OBS_NVAR(currentLine); zephir_array_fetch(¤tLine, lines, &linePosition, PH_NOISY, "phalcon/debug.zep", 523 TSRMLS_CC); if (zephir_is_true(showFileFragment)) { if (i == firstLine) { ZEPHIR_INIT_NVAR(_19); ZEPHIR_INIT_NVAR(_3); ZEPHIR_INIT_NVAR(_9); zephir_fast_trim(_9, currentLine, NULL , ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_SINIT_NVAR(_20); ZVAL_STRING(&_20, "#\\*\\/#", 0); zephir_preg_match(_3, &_20, _9, _19, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_3)) { ZEPHIR_INIT_NVAR(_21); ZEPHIR_SINIT_NVAR(_22); ZVAL_STRING(&_22, "* /", 0); ZEPHIR_SINIT_NVAR(_23); ZVAL_STRING(&_23, " ", 0); zephir_fast_str_replace(&_21, &_22, &_23, currentLine TSRMLS_CC); ZEPHIR_CPY_WRT(currentLine, _21); } } } _24 = ZEPHIR_IS_STRING(currentLine, "\n"); if (!(_24)) { _24 = ZEPHIR_IS_STRING(currentLine, "\r\n"); } if (_24) { zephir_concat_self_str(&html, SL(" \n") TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_21); ZEPHIR_SINIT_NVAR(_20); ZVAL_STRING(&_20, "\t", 0); ZEPHIR_SINIT_NVAR(_22); ZVAL_STRING(&_22, " ", 0); zephir_fast_str_replace(&_21, &_20, &_22, currentLine TSRMLS_CC); ZEPHIR_SINIT_NVAR(_23); ZVAL_LONG(&_23, 2); ZEPHIR_SINIT_NVAR(_25); ZVAL_STRING(&_25, "UTF-8", 0); ZEPHIR_CALL_FUNCTION(&_8, "htmlentities", &_26, 153, _21, &_23, &_25); zephir_check_call_status(); zephir_concat_self(&html, _8 TSRMLS_CC); } i++; } zephir_concat_self_str(&html, SL("</pre>") TSRMLS_CC); } } zephir_concat_self_str(&html, SL("</td></tr>") TSRMLS_CC); RETURN_CCTOR(html); } static PHP_METHOD(Phalcon_Debug, onUncaughtLowSeverity) { int ZEPHIR_LAST_CALL_STATUS; zval *severity, *message, *file, *line, *_0 = NULL, _1, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &severity, &message, &file, &line); ZEPHIR_CALL_FUNCTION(&_0, "error_reporting", NULL, 160); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); zephir_bitwise_and_function(&_1, _0, severity TSRMLS_CC); if (zephir_is_true(&_1)) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, zephir_get_internal_ce(SS("errorexception") TSRMLS_CC)); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 161, message, _3, severity, file, line); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/debug.zep", 566 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Debug, onUncaughtException) { zephir_fcall_cache_entry *_14 = NULL, *_19 = NULL, *_23 = NULL; HashTable *_11, *_16, *_21, *_25, *_29; HashPosition _10, _15, _20, _24, _28; int ZEPHIR_LAST_CALL_STATUS; zval *exception, *obLevel = NULL, *className, *escapedMessage = NULL, *html, *showBackTrace, *dataVars, *n = NULL, *traceItem = NULL, *keyRequest = NULL, *value = NULL, *keyServer = NULL, *keyFile = NULL, *keyVar = NULL, *dataVar = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_8, *_9 = NULL, **_12, *_13 = NULL, *_REQUEST, **_17, *_18 = NULL, *_SERVER, **_22, **_26, *_27 = NULL, **_30, *_31 = NULL, *_32, *_33 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_get_global(&_REQUEST, SS("_REQUEST") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &exception); ZEPHIR_CALL_FUNCTION(&obLevel, "ob_get_level", NULL, 162); zephir_check_call_status(); if (ZEPHIR_GT_LONG(obLevel, 0)) { ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); } _0 = zephir_fetch_static_property_ce(phalcon_debug_ce, SL("_isActive") TSRMLS_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_METHOD(&_1, exception, "getmessage", NULL, 0); zephir_check_call_status(); zend_print_zval(_1, 0); RETURN_MM_NULL(); } zephir_update_static_property_ce(phalcon_debug_ce, SL("_isActive"), &ZEPHIR_GLOBAL(global_true) TSRMLS_CC); ZEPHIR_INIT_VAR(className); zephir_get_class(className, exception, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, exception, "getmessage", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&escapedMessage, this_ptr, "_escapestring", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_VAR(html); ZEPHIR_CONCAT_SVSVS(html, "<html><head><title>", className, ": ", escapedMessage, "</title>"); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcsssources", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VS(_3, _2, "</head><body>"); zephir_concat_self(&html, _3 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getversion", NULL, 0); zephir_check_call_status(); zephir_concat_self(&html, _4 TSRMLS_CC); zephir_concat_self_str(&html, SL("<div align=\"center\"><div class=\"error-main\">") TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVSVS(_5, "<h1>", className, ": ", escapedMessage, "</h1>"); zephir_concat_self(&html, _5 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_6, exception, "getfile", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, exception, "getline", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "<span class=\"error-file\">", _6, " (", _7, ")</span>"); zephir_concat_self(&html, _8 TSRMLS_CC); zephir_concat_self_str(&html, SL("</div>") TSRMLS_CC); ZEPHIR_OBS_VAR(showBackTrace); zephir_read_property_this(&showBackTrace, this_ptr, SL("_showBackTrace"), PH_NOISY_CC); if (zephir_is_true(showBackTrace)) { ZEPHIR_OBS_VAR(dataVars); zephir_read_property_this(&dataVars, this_ptr, SL("_data"), PH_NOISY_CC); zephir_concat_self_str(&html, SL("<div class=\"error-info\"><div id=\"tabs\"><ul>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-1\">Backtrace</a></li>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-2\">Request</a></li>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-3\">Server</a></li>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-4\">Included Files</a></li>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-5\">Memory</a></li>") TSRMLS_CC); if (Z_TYPE_P(dataVars) == IS_ARRAY) { zephir_concat_self_str(&html, SL("<li><a href=\"#error-tabs-6\">Variables</a></li>") TSRMLS_CC); } zephir_concat_self_str(&html, SL("</ul>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<div id=\"error-tabs-1\"><table cellspacing=\"0\" align=\"center\" width=\"100%\">") TSRMLS_CC); ZEPHIR_CALL_METHOD(&_9, exception, "gettrace", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_9, &_11, &_10, 0, 0, "phalcon/debug.zep", 660); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HMKEY(n, _11, _10); ZEPHIR_GET_HVALUE(traceItem, _12); ZEPHIR_CALL_METHOD(&_13, this_ptr, "showtraceitem", &_14, 163, n, traceItem); zephir_check_call_status(); zephir_concat_self(&html, _13 TSRMLS_CC); } zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<div id=\"error-tabs-2\"><table cellspacing=\"0\" align=\"center\" class=\"superglobal-detail\">") TSRMLS_CC); zephir_concat_self_str(&html, SL("<tr><th>Key</th><th>Value</th></tr>") TSRMLS_CC); zephir_is_iterable(_REQUEST, &_16, &_15, 0, 0, "phalcon/debug.zep", 674); for ( ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HMKEY(keyRequest, _16, _15); ZEPHIR_GET_HVALUE(value, _17); if (Z_TYPE_P(value) != IS_ARRAY) { ZEPHIR_INIT_LNVAR(_18); ZEPHIR_CONCAT_SVSVS(_18, "<tr><td class=\"key\">", keyRequest, "</td><td>", value, "</td></tr>"); zephir_concat_self(&html, _18 TSRMLS_CC); } else { ZEPHIR_CALL_FUNCTION(&_13, "print_r", &_19, 164, value, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_18); ZEPHIR_CONCAT_SVSVS(_18, "<tr><td class=\"key\">", keyRequest, "</td><td>", _13, "</td></tr>"); zephir_concat_self(&html, _18 TSRMLS_CC); } } zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<div id=\"error-tabs-3\"><table cellspacing=\"0\" align=\"center\" class=\"superglobal-detail\">") TSRMLS_CC); zephir_concat_self_str(&html, SL("<tr><th>Key</th><th>Value</th></tr>") TSRMLS_CC); zephir_is_iterable(_SERVER, &_21, &_20, 0, 0, "phalcon/debug.zep", 684); for ( ; zephir_hash_get_current_data_ex(_21, (void**) &_22, &_20) == SUCCESS ; zephir_hash_move_forward_ex(_21, &_20) ) { ZEPHIR_GET_HMKEY(keyServer, _21, _20); ZEPHIR_GET_HVALUE(value, _22); ZEPHIR_CALL_METHOD(&_13, this_ptr, "_getvardump", &_23, 0, value); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_18); ZEPHIR_CONCAT_SVSVS(_18, "<tr><td class=\"key\">", keyServer, "</td><td>", _13, "</td></tr>"); zephir_concat_self(&html, _18 TSRMLS_CC); } zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<div id=\"error-tabs-4\"><table cellspacing=\"0\" align=\"center\" class=\"superglobal-detail\">") TSRMLS_CC); zephir_concat_self_str(&html, SL("<tr><th>#</th><th>Path</th></tr>") TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_13, "get_included_files", NULL, 165); zephir_check_call_status(); zephir_is_iterable(_13, &_25, &_24, 0, 0, "phalcon/debug.zep", 694); for ( ; zephir_hash_get_current_data_ex(_25, (void**) &_26, &_24) == SUCCESS ; zephir_hash_move_forward_ex(_25, &_24) ) { ZEPHIR_GET_HMKEY(keyFile, _25, _24); ZEPHIR_GET_HVALUE(value, _26); ZEPHIR_INIT_LNVAR(_27); ZEPHIR_CONCAT_SVSVS(_27, "<tr><td>", keyFile, "</th><td>", value, "</td></tr>"); zephir_concat_self(&html, _27 TSRMLS_CC); } zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); zephir_concat_self_str(&html, SL("<div id=\"error-tabs-5\"><table cellspacing=\"0\" align=\"center\" class=\"superglobal-detail\">") TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_13, "memory_get_usage", NULL, 166, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_27); ZEPHIR_CONCAT_SVS(_27, "<tr><th colspan=\"2\">Memory</th></tr><tr><td>Usage</td><td>", _13, "</td></tr>"); zephir_concat_self(&html, _27 TSRMLS_CC); zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); if (Z_TYPE_P(dataVars) == IS_ARRAY) { zephir_concat_self_str(&html, SL("<div id=\"error-tabs-6\"><table cellspacing=\"0\" align=\"center\" class=\"superglobal-detail\">") TSRMLS_CC); zephir_concat_self_str(&html, SL("<tr><th>Key</th><th>Value</th></tr>") TSRMLS_CC); zephir_is_iterable(dataVars, &_29, &_28, 0, 0, "phalcon/debug.zep", 712); for ( ; zephir_hash_get_current_data_ex(_29, (void**) &_30, &_28) == SUCCESS ; zephir_hash_move_forward_ex(_29, &_28) ) { ZEPHIR_GET_HMKEY(keyVar, _29, _28); ZEPHIR_GET_HVALUE(dataVar, _30); zephir_array_fetch_long(&_32, dataVar, 0, PH_NOISY | PH_READONLY, "phalcon/debug.zep", 710 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_31, this_ptr, "_getvardump", &_23, 0, _32); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_33); ZEPHIR_CONCAT_SVSVS(_33, "<tr><td class=\"key\">", keyVar, "</td><td>", _31, "</td></tr>"); zephir_concat_self(&html, _33 TSRMLS_CC); } zephir_concat_self_str(&html, SL("</table></div>") TSRMLS_CC); } zephir_concat_self_str(&html, SL("</div>") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "getjssources", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_18); ZEPHIR_CONCAT_VS(_18, _1, "</div></body></html>"); zephir_concat_self(&html, _18 TSRMLS_CC); zend_print_zval(html, 0); zephir_update_static_property_ce(phalcon_debug_ce, SL("_isActive"), &ZEPHIR_GLOBAL(global_false) TSRMLS_CC); RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di) { ZEPHIR_REGISTER_CLASS(Phalcon, Di, phalcon, di, phalcon_di_method_entry, 0); zend_declare_property_null(phalcon_di_ce, SL("_services"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_ce, SL("_sharedInstances"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_di_ce, SL("_freshInstance"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_ce, SL("_default"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_di_ce TSRMLS_CC, 1, phalcon_diinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Di, __construct) { zval *di; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(di); zephir_read_static_property_ce(&di, phalcon_di_ce, SL("_default") TSRMLS_CC); if (!(zephir_is_true(di))) { zephir_update_static_property_ce(phalcon_di_ce, SL("_default"), &this_ptr TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Di, setInternalEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Di, getInternalEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Di, set) { int ZEPHIR_LAST_CALL_STATUS; zend_bool shared; zval *name_param = NULL, *definition, *shared_param = NULL, *service, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!shared_param) { shared = 0; } else { shared = zephir_get_boolval(shared_param); } ZEPHIR_INIT_VAR(service); object_init_ex(service, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_0); if (shared) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(NULL, service, "__construct", NULL, 64, name, definition, _0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_services"), name, service TSRMLS_CC); RETURN_CCTOR(service); } static PHP_METHOD(Phalcon_Di, setShared) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *definition, *service, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_INIT_VAR(service); object_init_ex(service, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, service, "__construct", NULL, 64, name, definition, _0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_services"), name, service TSRMLS_CC); RETURN_CCTOR(service); } static PHP_METHOD(Phalcon_Di, remove) { zval *name_param = NULL, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); zephir_array_unset(&_0, name, PH_SEPARATE); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_sharedInstances"), PH_NOISY_CC); zephir_array_unset(&_1, name, PH_SEPARATE); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Di, attempt) { int ZEPHIR_LAST_CALL_STATUS; zend_bool shared; zval *name_param = NULL, *definition, *shared_param = NULL, *service, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!shared_param) { shared = 0; } else { shared = zephir_get_boolval(shared_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); if (!(zephir_array_isset(_0, name))) { ZEPHIR_INIT_VAR(service); object_init_ex(service, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_1); if (shared) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, service, "__construct", NULL, 64, name, definition, _1); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_services"), name, service TSRMLS_CC); RETURN_CCTOR(service); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Di, setRaw) { zval *name_param = NULL, *rawDefinition; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &rawDefinition); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_services"), name, rawDefinition TSRMLS_CC); RETVAL_ZVAL(rawDefinition, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Di, getRaw) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *service, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(service); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); if (zephir_array_isset_fetch(&service, _0, name, 0 TSRMLS_CC)) { ZEPHIR_RETURN_CALL_METHOD(service, "getdefinition", NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_di_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Service '", name, "' wasn't found in the dependency injection container"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/di.zep", 189 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Di, getService) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *service, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(service); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); if (zephir_array_isset_fetch(&service, _0, name, 0 TSRMLS_CC)) { RETURN_CCTOR(service); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_di_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Service '", name, "' wasn't found in the dependency injection container"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/di.zep", 203 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Di, get) { int ZEPHIR_LAST_CALL_STATUS; zval *_1 = NULL; zval *name_param = NULL, *parameters = NULL, *service, *instance = NULL, *reflection = NULL, *eventsManager = NULL, *_0, *_2 = NULL; zval *name = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, ¶meters); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL("name"), &name, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("parameters"), ¶meters, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "di:beforeServiceResolve", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_OBS_VAR(service); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); if (zephir_array_isset_fetch(&service, _0, name, 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&instance, service, "resolve", NULL, 0, parameters, this_ptr); zephir_check_call_status(); } else { if (!(zephir_class_exists(name, 1 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVS(_3, "Service '", name, "' wasn't found in the dependency injection container"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/di.zep", 230 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { if (zephir_is_php_version(50600)) { ZEPHIR_INIT_VAR(reflection); object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 65, name); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&instance, reflection, "newinstanceargs", NULL, 66, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, name, parameters TSRMLS_CC); zephir_check_call_status(); } } else { if (zephir_is_php_version(50600)) { ZEPHIR_INIT_NVAR(reflection); object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 65, name); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&instance, reflection, "newinstance", NULL, 67); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, name TSRMLS_CC); zephir_check_call_status(); } } } else { if (zephir_is_php_version(50600)) { ZEPHIR_INIT_NVAR(reflection); object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 65, name); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&instance, reflection, "newinstance", NULL, 67); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, name TSRMLS_CC); zephir_check_call_status(); } } } if (Z_TYPE_P(instance) == IS_OBJECT) { if (zephir_instance_of_ev(instance, phalcon_di_injectionawareinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, instance, "setdi", NULL, 0, this_ptr); zephir_check_call_status(); } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL("name"), &name, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("parameters"), ¶meters, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("instance"), &instance, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "di:afterServiceResolve", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_CCTOR(instance); } static PHP_METHOD(Phalcon_Di, getShared) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *parameters = NULL, *instance = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, ¶meters); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(instance); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_sharedInstances"), PH_NOISY_CC); if (zephir_array_isset_fetch(&instance, _0, name, 0 TSRMLS_CC)) { if (0) { zephir_update_property_this(this_ptr, SL("_freshInstance"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_freshInstance"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", NULL, 0, name, parameters); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_sharedInstances"), name, instance TSRMLS_CC); if (1) { zephir_update_property_this(this_ptr, SL("_freshInstance"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_freshInstance"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } RETURN_CCTOR(instance); } static PHP_METHOD(Phalcon_Di, has) { zval *name_param = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_services"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, name)); } static PHP_METHOD(Phalcon_Di, wasFreshInstance) { RETURN_MEMBER(this_ptr, "_freshInstance"); } static PHP_METHOD(Phalcon_Di, getServices) { RETURN_MEMBER(this_ptr, "_services"); } static PHP_METHOD(Phalcon_Di, offsetExists) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Di, offsetSet) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *definition; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setshared", NULL, 0, name, definition); zephir_check_call_status(); RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Di, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getshared", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Di, offsetUnset) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Di, __call) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL; zval *method_param = NULL, *arguments = NULL, *instance = NULL, *possibleService = NULL, *services, *definition, _0 = zval_used_for_init, *_1 = NULL, *_4 = NULL; zval *method = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &method_param, &arguments); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } if (zephir_start_with_str(method, SL("get"))) { ZEPHIR_OBS_VAR(services); zephir_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 3); ZEPHIR_INIT_VAR(_1); zephir_substr(_1, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_CALL_FUNCTION(&possibleService, "lcfirst", &_2, 68, _1); zephir_check_call_status(); if (zephir_array_isset(services, possibleService)) { if (zephir_fast_count_int(arguments TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", &_3, 0, possibleService, arguments); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", &_3, 0, possibleService); zephir_check_call_status(); } RETURN_CCTOR(instance); } } if (zephir_start_with_str(method, SL("set"))) { ZEPHIR_OBS_VAR(definition); if (zephir_array_isset_long_fetch(&definition, arguments, 0, 0 TSRMLS_CC)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 3); ZEPHIR_INIT_NVAR(_1); zephir_substr(_1, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_CALL_FUNCTION(&_4, "lcfirst", &_2, 68, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, _4, definition); zephir_check_call_status(); RETURN_MM_NULL(); } } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_di_exception_ce); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Call to undefined method or service '", method, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/di.zep", 428 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Di, setDefault) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_static_property_ce(phalcon_di_ce, SL("_default"), &dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Di, getDefault) { zval *_0; _0 = zephir_fetch_static_property_ce(phalcon_di_ce, SL("_default") TSRMLS_CC); RETURN_CTORW(_0); } static PHP_METHOD(Phalcon_Di, reset) { zephir_update_static_property_ce(phalcon_di_ce, SL("_default"), &ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_DiInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, DiInterface, phalcon, diinterface, phalcon_diinterface_method_entry); zend_class_implements(phalcon_diinterface_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_DiInterface, set); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, setShared); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, remove); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, attempt); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, get); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, getShared); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, setRaw); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, getRaw); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, getService); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, has); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, wasFreshInstance); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, getServices); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, setDefault); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, getDefault); ZEPHIR_DOC_METHOD(Phalcon_DiInterface, reset); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Dispatcher) { ZEPHIR_REGISTER_CLASS(Phalcon, Dispatcher, phalcon, dispatcher, phalcon_dispatcher_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_dispatcher_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_activeHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_finished"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_dispatcher_ce, SL("_forwarded"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_moduleName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_namespaceName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_handlerName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_actionName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_returnedValue"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_lastHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_defaultNamespace"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_defaultHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_dispatcher_ce, SL("_defaultAction"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_dispatcher_ce, SL("_handlerSuffix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_dispatcher_ce, SL("_actionSuffix"), "Action", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_previousHandlerName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_dispatcher_ce, SL("_previousActionName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_NO_DI"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_CYCLIC_ROUTING"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_HANDLER_NOT_FOUND"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_INVALID_HANDLER"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_INVALID_PARAMS"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_dispatcher_ce, SL("EXCEPTION_ACTION_NOT_FOUND"), 5 TSRMLS_CC); zend_class_implements(phalcon_dispatcher_ce TSRMLS_CC, 1, phalcon_dispatcherinterface_ce); zend_class_implements(phalcon_dispatcher_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_dispatcher_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Dispatcher, __construct) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Dispatcher, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Dispatcher, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Dispatcher, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Dispatcher, setActionSuffix) { zval *actionSuffix_param = NULL; zval *actionSuffix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionSuffix_param); zephir_get_strval(actionSuffix, actionSuffix_param); zephir_update_property_this(this_ptr, SL("_actionSuffix"), actionSuffix TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, setModuleName) { zval *moduleName_param = NULL; zval *moduleName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &moduleName_param); zephir_get_strval(moduleName, moduleName_param); zephir_update_property_this(this_ptr, SL("_moduleName"), moduleName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, getModuleName) { RETURN_MEMBER(this_ptr, "_moduleName"); } static PHP_METHOD(Phalcon_Dispatcher, setNamespaceName) { zval *namespaceName_param = NULL; zval *namespaceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &namespaceName_param); zephir_get_strval(namespaceName, namespaceName_param); zephir_update_property_this(this_ptr, SL("_namespaceName"), namespaceName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, getNamespaceName) { RETURN_MEMBER(this_ptr, "_namespaceName"); } static PHP_METHOD(Phalcon_Dispatcher, setDefaultNamespace) { zval *namespaceName_param = NULL; zval *namespaceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &namespaceName_param); zephir_get_strval(namespaceName, namespaceName_param); zephir_update_property_this(this_ptr, SL("_defaultNamespace"), namespaceName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, getDefaultNamespace) { RETURN_MEMBER(this_ptr, "_defaultNamespace"); } static PHP_METHOD(Phalcon_Dispatcher, setDefaultAction) { zval *actionName_param = NULL; zval *actionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionName_param); zephir_get_strval(actionName, actionName_param); zephir_update_property_this(this_ptr, SL("_defaultAction"), actionName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, setActionName) { zval *actionName_param = NULL; zval *actionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionName_param); zephir_get_strval(actionName, actionName_param); zephir_update_property_this(this_ptr, SL("_actionName"), actionName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, getActionName) { RETURN_MEMBER(this_ptr, "_actionName"); } static PHP_METHOD(Phalcon_Dispatcher, setParams) { int ZEPHIR_LAST_CALL_STATUS; zval *params, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶ms); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_NULL(); } zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, getParams) { RETURN_MEMBER(this_ptr, "_params"); } static PHP_METHOD(Phalcon_Dispatcher, setParam) { zval *param, *value; zephir_fetch_params(0, 2, 0, ¶m, &value); zephir_update_property_array(this_ptr, SL("_params"), param, value TSRMLS_CC); } static PHP_METHOD(Phalcon_Dispatcher, getParam) { int ZEPHIR_LAST_CALL_STATUS; zval *param, *filters = NULL, *defaultValue = NULL, *params, *filter = NULL, *paramValue, *dependencyInjector, *_0 = NULL, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); ZEPHIR_OBS_VAR(paramValue); if (!(zephir_array_isset_fetch(¶mValue, params, param, 0 TSRMLS_CC))) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } if (Z_TYPE_P(filters) == IS_NULL) { RETURN_CCTOR(paramValue); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "A dependency injection object is required to access the 'filter' service", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _0, _1); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CPY_WRT(filter, _2); ZEPHIR_RETURN_CALL_METHOD(filter, "sanitize", NULL, 0, paramValue, filters); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Dispatcher, getActiveMethod) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_actionName"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); ZEPHIR_CONCAT_VV(return_value, _0, _1); return; } static PHP_METHOD(Phalcon_Dispatcher, isFinished) { RETURN_MEMBER(this_ptr, "_finished"); } static PHP_METHOD(Phalcon_Dispatcher, setReturnedValue) { zval *value; zephir_fetch_params(0, 1, 0, &value); zephir_update_property_this(this_ptr, SL("_returnedValue"), value TSRMLS_CC); } static PHP_METHOD(Phalcon_Dispatcher, getReturnedValue) { RETURN_MEMBER(this_ptr, "_returnedValue"); } static PHP_METHOD(Phalcon_Dispatcher, dispatch) { zval *_23 = NULL; zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_10 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_18 = NULL, *_19 = NULL, *_21 = NULL, *_22 = NULL, *_24 = NULL, *_25 = NULL, *_26 = NULL; zval *value, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *e = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_8, *_9 = NULL, *_11 = NULL, *_17 = NULL, *_20; int numberDispatches, ZEPHIR_LAST_CALL_STATUS; zend_bool hasService, wasFresh = 0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM_BOOL(0); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); numberDispatches = 0; ZEPHIR_OBS_VAR(actionSuffix); zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); if (0) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_0)))) { break; } numberDispatches++; if (numberDispatches == 256) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_4, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); break; } if (1) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_5, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_6, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, eventsManager, "fire", &_7, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } ZEPHIR_CALL_METHOD(&_9, dependencyInjector, "has", &_10, 0, handlerClass); zephir_check_call_status(); hasService = zephir_get_boolval(_9); if (!(hasService)) { hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC); } if (!(hasService)) { ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_VS(_11, handlerClass, " handler class cannot be loaded"); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_12, 0, _11, _1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } break; } ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_13, 0, handlerClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, dependencyInjector, "wasfreshinstance", &_14, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_9)) { wasFresh = 1; } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 3); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_15, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } break; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); ZEPHIR_OBS_NVAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 4); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_16, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } break; } ZEPHIR_INIT_NVAR(actionMethod); ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix); if (!((zephir_method_exists(handler, actionMethod TSRMLS_CC) == SUCCESS))) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_17, eventsManager, "fire", &_18, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSVS(_11, "Action '", actionName, "' was not found on handler '", handlerName, "'"); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 5); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_19, 0, _11, _1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_20)) { continue; } } break; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_17, eventsManager, "fire", &_21, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_17, handler, "beforeexecuteroute", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } if (wasFresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(eventsManager)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_17, eventsManager, "fire", &_22, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } } /* try_start_1: */ ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_NVAR(_23); zephir_create_array(_23, 2, 0 TSRMLS_CC); zephir_array_fast_append(_23, handler); zephir_array_fast_append(_23, actionMethod); ZEPHIR_CALL_USER_FUNC_ARRAY(_1, _23, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(&_17, this_ptr, "_handleexception", &_24, 0, e); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } else { zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 518 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_17, eventsManager, "fire", &_25, 0, _2, this_ptr, value); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_26, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_17, handler, "afterexecuteroute", NULL, 0, this_ptr, value); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_17)) { continue; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { continue; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_CCTOR(handler); } static PHP_METHOD(Phalcon_Dispatcher, forward) { int ZEPHIR_LAST_CALL_STATUS; zval *forward, *namespaceName, *controllerName, *params, *actionName, *taskName, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &forward); if (Z_TYPE_P(forward) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Forward parameter must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_NULL(); } if (zephir_array_isset_string_fetch(&namespaceName, forward, SS("namespace"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_namespaceName"), namespaceName TSRMLS_CC); } if (zephir_array_isset_string_fetch(&controllerName, forward, SS("controller"), 1 TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_handlerName"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_previousHandlerName"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_handlerName"), controllerName TSRMLS_CC); } else { if (zephir_array_isset_string_fetch(&taskName, forward, SS("task"), 1 TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_handlerName"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_previousHandlerName"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_handlerName"), taskName TSRMLS_CC); } } if (zephir_array_isset_string_fetch(&actionName, forward, SS("action"), 1 TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionName"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_previousActionName"), _1 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_actionName"), actionName TSRMLS_CC); } if (zephir_array_isset_string_fetch(¶ms, forward, SS("params"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); } if (0) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_forwarded"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_forwarded"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Dispatcher, wasForwarded) { RETURN_MEMBER(this_ptr, "_forwarded"); } static PHP_METHOD(Phalcon_Dispatcher, getHandlerClass) { int ZEPHIR_LAST_CALL_STATUS; zval *handlerSuffix, *handlerName, *namespaceName, *camelizedClass = NULL, *handlerClass = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(handlerSuffix); zephir_read_property_this(&handlerSuffix, this_ptr, SL("_handlerSuffix"), PH_NOISY_CC); ZEPHIR_OBS_VAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); ZEPHIR_OBS_VAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); if (!(zephir_memnstr_str(handlerName, SL("\\"), "phalcon/dispatcher.zep", 631))) { ZEPHIR_INIT_VAR(camelizedClass); zephir_camelize(camelizedClass, handlerName); } else { ZEPHIR_CPY_WRT(camelizedClass, handlerName); } if (zephir_is_true(namespaceName)) { ZEPHIR_INIT_VAR(handlerClass); if (zephir_end_with_str(namespaceName, SL("\\"))) { ZEPHIR_CONCAT_VVV(handlerClass, namespaceName, camelizedClass, handlerSuffix); } else { ZEPHIR_CONCAT_VSVV(handlerClass, namespaceName, "\\", camelizedClass, handlerSuffix); } } else { ZEPHIR_INIT_NVAR(handlerClass); ZEPHIR_CONCAT_VV(handlerClass, camelizedClass, handlerSuffix); } RETURN_CCTOR(handlerClass); } static PHP_METHOD(Phalcon_Dispatcher, _resolveEmptyProperties) { zval *_0, *_1, *_2; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_namespaceName"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespaceName"), _1 TSRMLS_CC); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_handlerName"), PH_NOISY_CC); if (!(zephir_is_true(_1))) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultHandler"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_handlerName"), _2 TSRMLS_CC); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionName"), PH_NOISY_CC); if (!(zephir_is_true(_1))) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_actionName"), _2 TSRMLS_CC); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_DispatcherInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, DispatcherInterface, phalcon, dispatcherinterface, phalcon_dispatcherinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setActionSuffix); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setDefaultNamespace); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setDefaultAction); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setNamespaceName); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setModuleName); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setActionName); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, getActionName); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setParams); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, getParams); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, setParam); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, getParam); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, isFinished); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, getReturnedValue); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, dispatch); ZEPHIR_DOC_METHOD(Phalcon_DispatcherInterface, forward); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Escaper) { ZEPHIR_REGISTER_CLASS(Phalcon, Escaper, phalcon, escaper, phalcon_escaper_method_entry, 0); zend_declare_property_string(phalcon_escaper_ce, SL("_encoding"), "utf-8", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_escaper_ce, SL("_htmlEscapeMap"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_escaper_ce, SL("_htmlQuoteType"), 3, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_escaper_ce TSRMLS_CC, 1, phalcon_escaperinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Escaper, setEncoding) { zval *encoding_param = NULL; zval *encoding = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &encoding_param); zephir_get_strval(encoding, encoding_param); zephir_update_property_this(this_ptr, SL("_encoding"), encoding TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Escaper, getEncoding) { RETURN_MEMBER(this_ptr, "_encoding"); } static PHP_METHOD(Phalcon_Escaper, setHtmlQuoteType) { zval *quoteType_param = NULL, *_0; int quoteType; zephir_fetch_params(0, 1, 0, "eType_param); quoteType = zephir_get_intval(quoteType_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, quoteType); zephir_update_property_this(this_ptr, SL("_htmlQuoteType"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Escaper, detectEncoding) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_6 = NULL; HashTable *_3; HashPosition _2; zval *_0; zval *str_param = NULL, *charset = NULL, *_1 = NULL, **_4, *_5 = NULL; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); zephir_get_strval(str, str_param); ZEPHIR_INIT_VAR(charset); zephir_is_basic_charset(charset, str); if (Z_TYPE_P(charset) == IS_STRING) { RETURN_CCTOR(charset); } if (!((zephir_function_exists_ex(SS("mb_detect_encoding") TSRMLS_CC) == SUCCESS))) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "UTF-32", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "UTF-8", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ISO-8859-1", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ASCII", 1); zephir_array_fast_append(_0, _1); zephir_is_iterable(_0, &_3, &_2, 0, 0, "phalcon/escaper.zep", 116); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(charset, _4); ZEPHIR_CALL_FUNCTION(&_5, "mb_detect_encoding", &_6, 179, str, charset, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (zephir_is_true(_5)) { RETURN_CCTOR(charset); } } ZEPHIR_RETURN_CALL_FUNCTION("mb_detect_encoding", &_6, 179, str); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, normalizeEncoding) { int ZEPHIR_LAST_CALL_STATUS; zval *str_param = NULL, *_0 = NULL, _1; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); zephir_get_strval(str, str_param); if (!((zephir_function_exists_ex(SS("mb_convert_encoding") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_escaper_exception_ce, "Extension 'mbstring' is required", "phalcon/escaper.zep", 128); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "detectencoding", NULL, 180, str); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "UTF-32", 0); ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_encoding", NULL, 181, str, &_1, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, escapeHtml) { int ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *_0, *_1; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &text_param); zephir_get_strval(text, text_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_htmlQuoteType"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_encoding"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 182, text, _0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, escapeHtmlAttr) { int ZEPHIR_LAST_CALL_STATUS; zval *attribute_param = NULL, *_0, _1; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attribute_param); zephir_get_strval(attribute, attribute_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_encoding"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 3); ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 182, attribute, &_1, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, escapeCss) { int ZEPHIR_LAST_CALL_STATUS; zval *css_param = NULL, *_0 = NULL; zval *css = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &css_param); zephir_get_strval(css, css_param); ZEPHIR_CALL_METHOD(&_0, this_ptr, "normalizeencoding", NULL, 183, css); zephir_check_call_status(); zephir_escape_css(return_value, _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, escapeJs) { int ZEPHIR_LAST_CALL_STATUS; zval *js_param = NULL, *_0 = NULL; zval *js = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &js_param); zephir_get_strval(js, js_param); ZEPHIR_CALL_METHOD(&_0, this_ptr, "normalizeencoding", NULL, 183, js); zephir_check_call_status(); zephir_escape_js(return_value, _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Escaper, escapeUrl) { int ZEPHIR_LAST_CALL_STATUS; zval *url_param = NULL; zval *url = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &url_param); zephir_get_strval(url, url_param); ZEPHIR_RETURN_CALL_FUNCTION("rawurlencode", NULL, 184, url); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_EscaperInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, EscaperInterface, phalcon, escaperinterface, phalcon_escaperinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, setEncoding); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, getEncoding); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, setHtmlQuoteType); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, escapeHtml); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, escapeHtmlAttr); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, escapeCss); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, escapeJs); ZEPHIR_DOC_METHOD(Phalcon_EscaperInterface, escapeUrl); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon, Exception, phalcon, exception, zend_exception_get_default(TSRMLS_C), NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Filter) { ZEPHIR_REGISTER_CLASS(Phalcon, Filter, phalcon, filter, phalcon_filter_method_entry, 0); zend_declare_property_null(phalcon_filter_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_EMAIL"), "email" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_ABSINT"), "absint" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_INT"), "int" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_INT_CAST"), "int!" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_STRING"), "string" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_FLOAT"), "float" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_FLOAT_CAST"), "float!" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_ALPHANUM"), "alphanum" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_TRIM"), "trim" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_STRIPTAGS"), "striptags" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_LOWER"), "lower" TSRMLS_CC); zend_declare_class_constant_string(phalcon_filter_ce, SL("FILTER_UPPER"), "upper" TSRMLS_CC); zend_class_implements(phalcon_filter_ce TSRMLS_CC, 1, phalcon_filterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Filter, add) { zend_bool _0; zval *name_param = NULL, *handler; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &handler); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = Z_TYPE_P(handler) != IS_OBJECT; if (_0) { _0 = !(zephir_is_callable(handler TSRMLS_CC)); } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_exception_ce, "Filter must be an object or callable", "phalcon/filter.zep", 74); return; } zephir_update_property_array(this_ptr, SL("_filters"), name, handler TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Filter, sanitize) { zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_5, *_10; HashPosition _0, _4, _9; zend_bool noRecursive, _3; zval *value = NULL, *filters, *noRecursive_param = NULL, *filter = NULL, *arrayValue = NULL, *itemKey = NULL, *itemValue = NULL, *sanitizedValue, **_2, **_6, *_7 = NULL, **_11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &value, &filters, &noRecursive_param); ZEPHIR_SEPARATE_PARAM(value); if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } if (Z_TYPE_P(filters) == IS_ARRAY) { if (Z_TYPE_P(value) != IS_NULL) { zephir_is_iterable(filters, &_1, &_0, 0, 0, "phalcon/filter.zep", 107); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(filter, _2); _3 = Z_TYPE_P(value) == IS_ARRAY; if (_3) { _3 = !noRecursive; } if (_3) { ZEPHIR_INIT_NVAR(arrayValue); array_init(arrayValue); zephir_is_iterable(value, &_5, &_4, 0, 0, "phalcon/filter.zep", 102); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(itemKey, _5, _4); ZEPHIR_GET_HVALUE(itemValue, _6); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_sanitize", &_8, 0, itemValue, filter); zephir_check_call_status(); zephir_array_update_zval(&arrayValue, itemKey, &_7, PH_COPY | PH_SEPARATE); } ZEPHIR_CPY_WRT(value, arrayValue); } else { ZEPHIR_CALL_METHOD(&_7, this_ptr, "_sanitize", &_8, 0, value, filter); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _7); } } } RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } _3 = Z_TYPE_P(value) == IS_ARRAY; if (_3) { _3 = !noRecursive; } if (_3) { ZEPHIR_INIT_VAR(sanitizedValue); array_init(sanitizedValue); zephir_is_iterable(value, &_10, &_9, 0, 0, "phalcon/filter.zep", 119); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HMKEY(itemKey, _10, _9); ZEPHIR_GET_HVALUE(itemValue, _11); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_sanitize", &_8, 0, itemValue, filters); zephir_check_call_status(); zephir_array_update_zval(&sanitizedValue, itemKey, &_7, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(sanitizedValue); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_sanitize", &_8, 0, value, filters); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Filter, _sanitize) { zephir_fcall_cache_entry *_5 = NULL; zval *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool _1; zval *filter = NULL, *_8; zval *value, *filter_param = NULL, *filterObject, *_0, _3 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &value, &filter_param); if (unlikely(Z_TYPE_P(filter_param) != IS_STRING && Z_TYPE_P(filter_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filter_param) == IS_STRING)) { zephir_get_strval(filter, filter_param); } else { ZEPHIR_INIT_VAR(filter); ZVAL_EMPTY_STRING(filter); } ZEPHIR_OBS_VAR(filterObject); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); if (zephir_array_isset_fetch(&filterObject, _0, filter, 0 TSRMLS_CC)) { _1 = zephir_instance_of_ev(filterObject, zend_ce_closure TSRMLS_CC); if (!(_1)) { _1 = zephir_is_callable(filterObject TSRMLS_CC); } if (_1) { ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_fast_append(_2, value); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, filterObject, _2); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(filterObject, "filter", NULL, 0, value); zephir_check_call_status(); RETURN_MM(); } do { if (ZEPHIR_IS_STRING(filter, "email")) { ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "FILTER_SANITIZE_EMAIL", 0); ZEPHIR_CALL_FUNCTION(&_4, "constant", NULL, 191, &_3); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 192, value, _4); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "int")) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 519); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 192, value, &_3); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "int!")) { RETURN_MM_LONG(zephir_get_intval(value)); } if (ZEPHIR_IS_STRING(filter, "absint")) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, zephir_get_intval(value)); ZEPHIR_RETURN_CALL_FUNCTION("abs", NULL, 193, &_3); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "string")) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 513); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 192, value, &_3); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "float")) { ZEPHIR_INIT_NVAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); add_assoc_long_ex(_2, SS("flags"), 4096); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 520); ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_5, 192, value, &_3, _2); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "float!")) { RETURN_MM_DOUBLE(zephir_get_doubleval(value)); } if (ZEPHIR_IS_STRING(filter, "alphanum")) { ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "/[^A-Za-z0-9]/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 29, _6, _7, value); zephir_check_temp_parameter(_6); zephir_check_temp_parameter(_7); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "trim")) { zephir_fast_trim(return_value, value, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "striptags")) { ZEPHIR_RETURN_CALL_FUNCTION("strip_tags", NULL, 194, value); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "lower")) { if ((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 195, value); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtolower(return_value, value); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "upper")) { if ((zephir_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtoupper", NULL, 196, value); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtoupper(return_value, value); RETURN_MM(); } ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_filter_exception_ce); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVS(_8, "Sanitize filter '", filter, "' is not supported"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/filter.zep", 213 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Filter, getFilters) { RETURN_MEMBER(this_ptr, "_filters"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_FilterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, FilterInterface, phalcon, filterinterface, phalcon_filterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_FilterInterface, add); ZEPHIR_DOC_METHOD(Phalcon_FilterInterface, sanitize); ZEPHIR_DOC_METHOD(Phalcon_FilterInterface, getFilters); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Flash) { ZEPHIR_REGISTER_CLASS(Phalcon, Flash, phalcon, flash, phalcon_flash_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_flash_ce, SL("_cssClasses"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_flash_ce, SL("_implicitFlush"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_flash_ce, SL("_automaticHtml"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_flash_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Flash, __construct) { zval *cssClasses = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &cssClasses); if (!cssClasses) { ZEPHIR_CPY_WRT(cssClasses, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(cssClasses); } if (Z_TYPE_P(cssClasses) != IS_ARRAY) { ZEPHIR_INIT_NVAR(cssClasses); zephir_create_array(cssClasses, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(cssClasses, SS("error"), SL("errorMessage"), 1); add_assoc_stringl_ex(cssClasses, SS("notice"), SL("noticeMessage"), 1); add_assoc_stringl_ex(cssClasses, SS("success"), SL("successMessage"), 1); add_assoc_stringl_ex(cssClasses, SS("warning"), SL("warningMessage"), 1); } zephir_update_property_this(this_ptr, SL("_cssClasses"), cssClasses TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Flash, setImplicitFlush) { zval *implicitFlush_param = NULL; zend_bool implicitFlush; zephir_fetch_params(0, 1, 0, &implicitFlush_param); implicitFlush = zephir_get_boolval(implicitFlush_param); if (implicitFlush) { zephir_update_property_this(this_ptr, SL("_implicitFlush"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_implicitFlush"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Flash, setAutomaticHtml) { zval *automaticHtml_param = NULL; zend_bool automaticHtml; zephir_fetch_params(0, 1, 0, &automaticHtml_param); automaticHtml = zephir_get_boolval(automaticHtml_param); if (automaticHtml) { zephir_update_property_this(this_ptr, SL("_automaticHtml"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_automaticHtml"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Flash, setCssClasses) { zval *cssClasses_param = NULL; zval *cssClasses = NULL; zephir_fetch_params(0, 1, 0, &cssClasses_param); cssClasses = cssClasses_param; zephir_update_property_this(this_ptr, SL("_cssClasses"), cssClasses TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Flash, error) { int ZEPHIR_LAST_CALL_STATUS; zval *message, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "error", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Flash, notice) { int ZEPHIR_LAST_CALL_STATUS; zval *message, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "notice", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Flash, success) { int ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); zephir_get_strval(message, message_param); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "success", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Flash, warning) { int ZEPHIR_LAST_CALL_STATUS; zval *message, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "warning", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Flash, outputMessage) { HashTable *_3; HashPosition _2; zend_bool automaticHtml, implicitFlush; zval *type_param = NULL, *message, *content, *cssClasses = NULL, *classes, *typeClasses, *eol = NULL, *msg = NULL, *htmlMessage = NULL, *_0 = NULL, *_1, **_4; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &message); zephir_get_strval(type, type_param); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_automaticHtml"), PH_NOISY_CC); automaticHtml = zephir_get_boolval(_0); if (automaticHtml == 1) { ZEPHIR_OBS_VAR(classes); zephir_read_property_this(&classes, this_ptr, SL("_cssClasses"), PH_NOISY_CC); ZEPHIR_OBS_VAR(typeClasses); if (zephir_array_isset_fetch(&typeClasses, classes, type, 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(cssClasses); if (Z_TYPE_P(typeClasses) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_fast_join_str(_1, SL(" "), typeClasses TSRMLS_CC); ZEPHIR_CONCAT_SVS(cssClasses, " class=\"", _1, "\""); } else { ZEPHIR_CONCAT_SVS(cssClasses, " class=\"", typeClasses, "\""); } } else { ZEPHIR_INIT_NVAR(cssClasses); ZVAL_STRING(cssClasses, "", 1); } ZEPHIR_INIT_VAR(eol); ZEPHIR_GET_CONSTANT(eol, "PHP_EOL"); } ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_implicitFlush"), PH_NOISY_CC); implicitFlush = zephir_get_boolval(_0); if (Z_TYPE_P(message) == IS_ARRAY) { if (implicitFlush == 0) { ZEPHIR_INIT_VAR(content); ZVAL_STRING(content, "", 1); } zephir_is_iterable(message, &_3, &_2, 0, 0, "phalcon/flash.zep", 203); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(msg, _4); if (automaticHtml == 1) { ZEPHIR_INIT_NVAR(htmlMessage); ZEPHIR_CONCAT_SVSVSV(htmlMessage, "<div", cssClasses, ">", msg, "</div>", eol); } else { ZEPHIR_CPY_WRT(htmlMessage, msg); } if (implicitFlush == 1) { zend_print_zval(htmlMessage, 0); } else { zephir_concat_self(&content, htmlMessage TSRMLS_CC); zephir_update_property_array_append(this_ptr, SL("_messages"), htmlMessage TSRMLS_CC); } } if (implicitFlush == 0) { RETURN_CCTOR(content); } } else { if (automaticHtml == 1) { ZEPHIR_INIT_NVAR(htmlMessage); ZEPHIR_CONCAT_SVSVSV(htmlMessage, "<div", cssClasses, ">", message, "</div>", eol); } else { ZEPHIR_CPY_WRT(htmlMessage, message); } if (implicitFlush == 1) { zend_print_zval(htmlMessage, 0); } else { zephir_update_property_array_append(this_ptr, SL("_messages"), htmlMessage TSRMLS_CC); RETURN_CCTOR(htmlMessage); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Flash, clear) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_messages"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_FlashInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon, FlashInterface, phalcon, flashinterface, phalcon_flashinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_FlashInterface, error); ZEPHIR_DOC_METHOD(Phalcon_FlashInterface, notice); ZEPHIR_DOC_METHOD(Phalcon_FlashInterface, success); ZEPHIR_DOC_METHOD(Phalcon_FlashInterface, warning); ZEPHIR_DOC_METHOD(Phalcon_FlashInterface, message); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Image) { ZEPHIR_REGISTER_CLASS(Phalcon, Image, phalcon, image, NULL, 0); zend_declare_class_constant_long(phalcon_image_ce, SL("NONE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("WIDTH"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("HEIGHT"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("AUTO"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("INVERSE"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("PRECISE"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("TENSILE"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("HORIZONTAL"), 11 TSRMLS_CC); zend_declare_class_constant_long(phalcon_image_ce, SL("VERTICAL"), 12 TSRMLS_CC); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Kernel) { ZEPHIR_REGISTER_CLASS(Phalcon, Kernel, phalcon, kernel, phalcon_kernel_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Kernel, preComputeHashKey) { zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } { char *arKey = Z_STRVAL_P(key), *strKey; int nKeyLength = strlen(arKey); register ulong hash = 5381; nKeyLength++; /* variant with the hash unrolled eight times */ for (; nKeyLength >= 8; nKeyLength -= 8) { hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; hash = ((hash << 5) + hash) + *arKey++; } switch (nKeyLength) { case 7: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 6: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 5: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 4: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 3: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 2: hash = ((hash << 5) + hash) + *arKey++; /* no break */ case 1: hash = ((hash << 5) + hash) + *arKey++; break; } strKey = emalloc(24); snprintf(strKey, 24, "%lu", hash); RETURN_MM_STRING(strKey, 0); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Loader) { ZEPHIR_REGISTER_CLASS(Phalcon, Loader, phalcon, loader, phalcon_loader_method_entry, 0); zend_declare_property_null(phalcon_loader_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_foundPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_checkedPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_prefixes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_classes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_extensions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_namespaces"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_loader_ce, SL("_directories"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_loader_ce, SL("_registered"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_loader_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Loader, __construct) { zval *_1; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "php", 1); zephir_array_fast_append(_0, _1); zephir_update_property_this(this_ptr, SL("_extensions"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Loader, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Loader, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Loader, setExtensions) { zval *extensions_param = NULL; zval *extensions = NULL; zephir_fetch_params(0, 1, 0, &extensions_param); extensions = extensions_param; zephir_update_property_this(this_ptr, SL("_extensions"), extensions TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Loader, getExtensions) { RETURN_MEMBER(this_ptr, "_extensions"); } static PHP_METHOD(Phalcon_Loader, registerNamespaces) { zend_bool merge; zval *namespaces_param = NULL, *merge_param = NULL, *currentNamespaces, *mergedNamespaces = NULL; zval *namespaces = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &namespaces_param, &merge_param); namespaces = namespaces_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(currentNamespaces); zephir_read_property_this(¤tNamespaces, this_ptr, SL("_namespaces"), PH_NOISY_CC); if (Z_TYPE_P(currentNamespaces) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedNamespaces); zephir_fast_array_merge(mergedNamespaces, &(currentNamespaces), &(namespaces) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedNamespaces, namespaces); } zephir_update_property_this(this_ptr, SL("_namespaces"), mergedNamespaces TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_namespaces"), namespaces TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, getNamespaces) { RETURN_MEMBER(this_ptr, "_namespaces"); } static PHP_METHOD(Phalcon_Loader, registerPrefixes) { zend_bool merge; zval *prefixes_param = NULL, *merge_param = NULL, *currentPrefixes, *mergedPrefixes = NULL; zval *prefixes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &prefixes_param, &merge_param); prefixes = prefixes_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(currentPrefixes); zephir_read_property_this(¤tPrefixes, this_ptr, SL("_prefixes"), PH_NOISY_CC); if (Z_TYPE_P(currentPrefixes) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedPrefixes); zephir_fast_array_merge(mergedPrefixes, &(currentPrefixes), &(prefixes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedPrefixes, prefixes); } zephir_update_property_this(this_ptr, SL("_prefixes"), mergedPrefixes TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_prefixes"), prefixes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, getPrefixes) { RETURN_MEMBER(this_ptr, "_prefixes"); } static PHP_METHOD(Phalcon_Loader, registerDirs) { zend_bool merge; zval *directories_param = NULL, *merge_param = NULL, *currentDirectories, *mergedDirectories = NULL; zval *directories = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &directories_param, &merge_param); directories = directories_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(currentDirectories); zephir_read_property_this(¤tDirectories, this_ptr, SL("_directories"), PH_NOISY_CC); if (Z_TYPE_P(currentDirectories) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedDirectories); zephir_fast_array_merge(mergedDirectories, &(currentDirectories), &(directories) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedDirectories, directories); } zephir_update_property_this(this_ptr, SL("_directories"), mergedDirectories TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_directories"), directories TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, getDirs) { RETURN_MEMBER(this_ptr, "_directories"); } static PHP_METHOD(Phalcon_Loader, registerClasses) { zend_bool merge; zval *classes_param = NULL, *merge_param = NULL, *mergedClasses = NULL, *currentClasses; zval *classes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &classes_param, &merge_param); classes = classes_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(currentClasses); zephir_read_property_this(¤tClasses, this_ptr, SL("_classes"), PH_NOISY_CC); if (Z_TYPE_P(currentClasses) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedClasses); zephir_fast_array_merge(mergedClasses, &(currentClasses), &(classes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedClasses, classes); } zephir_update_property_this(this_ptr, SL("_classes"), mergedClasses TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_classes"), classes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, getClasses) { RETURN_MEMBER(this_ptr, "_classes"); } static PHP_METHOD(Phalcon_Loader, register) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *_0, *_2; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_registered"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, this_ptr); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "autoLoad", 1); zephir_array_fast_append(_1, _2); ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_register", NULL, 286, _1); zephir_check_call_status(); if (1) { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, unregister) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *_0, *_2; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_registered"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_0)) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, this_ptr); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "autoLoad", 1); zephir_array_fast_append(_1, _2); ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_unregister", NULL, 287, _1); zephir_check_call_status(); if (0) { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_registered"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Loader, autoLoad) { zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL, *_13 = NULL, *_23 = NULL, *_24 = NULL, *_31 = NULL, *_32 = NULL; HashTable *_2, *_7, *_15, *_21, *_26, *_29; HashPosition _1, _6, _14, _20, _25, _28; int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *eventsManager, *classes, *extensions, *filePath = NULL, *ds, *fixedDirectory = NULL, *prefixes, *directories, *namespaceSeparator, *namespaces, *nsPrefix = NULL, *directory = NULL, *fileName = NULL, *extension = NULL, *prefix = NULL, *dsClassName, *nsClassName, *_0 = NULL, **_3, *_4 = NULL, _5 = zval_used_for_init, **_8, *_9 = NULL, *_11 = NULL, **_16, *_17 = NULL, _18 = zval_used_for_init, _19 = zval_used_for_init, **_22, **_27, **_30; zval *className = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className_param); if (unlikely(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(className_param) == IS_STRING)) { zephir_get_strval(className, className_param); } else { ZEPHIR_INIT_VAR(className); ZVAL_EMPTY_STRING(className); } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "loader:beforeCheckClass", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _0, this_ptr, className); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(classes); zephir_read_property_this(&classes, this_ptr, SL("_classes"), PH_NOISY_CC); if (Z_TYPE_P(classes) == IS_ARRAY) { ZEPHIR_OBS_VAR(filePath); if (zephir_array_isset_fetch(&filePath, classes, className, 0 TSRMLS_CC)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_foundPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "loader:pathFound", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _0, this_ptr, filePath); zephir_check_temp_parameter(_0); zephir_check_call_status(); } if (zephir_require_zval(filePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_MM_BOOL(1); } } ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); ZEPHIR_INIT_VAR(ds); ZVAL_STRING(ds, "/", 1); ZEPHIR_INIT_VAR(namespaceSeparator); ZVAL_STRING(namespaceSeparator, "\\", 1); ZEPHIR_OBS_VAR(namespaces); zephir_read_property_this(&namespaces, this_ptr, SL("_namespaces"), PH_NOISY_CC); if (Z_TYPE_P(namespaces) == IS_ARRAY) { zephir_is_iterable(namespaces, &_2, &_1, 0, 0, "phalcon/loader.zep", 349); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(nsPrefix, _2, _1); ZEPHIR_GET_HVALUE(directory, _3); if (zephir_start_with(className, nsPrefix, NULL)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VV(_4, nsPrefix, namespaceSeparator); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, zephir_fast_strlen_ev(_4)); ZEPHIR_INIT_NVAR(fileName); zephir_substr(fileName, className, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_INIT_NVAR(_0); zephir_fast_str_replace(&_0, namespaceSeparator, ds, fileName TSRMLS_CC); ZEPHIR_CPY_WRT(fileName, _0); if (zephir_is_true(fileName)) { ZEPHIR_INIT_NVAR(_0); zephir_fast_trim(_0, directory, ds, ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_INIT_NVAR(fixedDirectory); ZEPHIR_CONCAT_VV(fixedDirectory, _0, ds); zephir_is_iterable(extensions, &_7, &_6, 0, 0, "phalcon/loader.zep", 346); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(extension, _8); ZEPHIR_INIT_NVAR(filePath); ZEPHIR_CONCAT_VVSV(filePath, fixedDirectory, fileName, ".", extension); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_checkedPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:beforeCheckPath", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_10, 0, _9, this_ptr); zephir_check_temp_parameter(_9); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_11, "is_file", &_12, 288, filePath); zephir_check_call_status(); if (zephir_is_true(_11)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_foundPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:pathFound", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_13, 0, _9, this_ptr, filePath); zephir_check_temp_parameter(_9); zephir_check_call_status(); } if (zephir_require_zval(filePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_MM_BOOL(1); } } } } } } ZEPHIR_OBS_VAR(prefixes); zephir_read_property_this(&prefixes, this_ptr, SL("_prefixes"), PH_NOISY_CC); if (Z_TYPE_P(prefixes) == IS_ARRAY) { zephir_is_iterable(prefixes, &_15, &_14, 0, 0, "phalcon/loader.zep", 404); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HMKEY(prefix, _15, _14); ZEPHIR_GET_HVALUE(directory, _16); if (zephir_start_with(className, prefix, NULL)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VV(_4, prefix, namespaceSeparator); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "", 0); ZEPHIR_INIT_NVAR(fileName); zephir_fast_str_replace(&fileName, _4, &_5, className TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); ZEPHIR_INIT_LNVAR(_17); ZEPHIR_CONCAT_VS(_17, prefix, "_"); ZEPHIR_SINIT_NVAR(_18); ZVAL_STRING(&_18, "", 0); zephir_fast_str_replace(&_0, _17, &_18, fileName TSRMLS_CC); ZEPHIR_CPY_WRT(fileName, _0); ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_19); ZVAL_STRING(&_19, "_", 0); zephir_fast_str_replace(&_0, &_19, ds, fileName TSRMLS_CC); ZEPHIR_CPY_WRT(fileName, _0); if (zephir_is_true(fileName)) { ZEPHIR_INIT_NVAR(_0); zephir_fast_trim(_0, directory, ds, ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_INIT_NVAR(fixedDirectory); ZEPHIR_CONCAT_VV(fixedDirectory, _0, ds); zephir_is_iterable(extensions, &_21, &_20, 0, 0, "phalcon/loader.zep", 401); for ( ; zephir_hash_get_current_data_ex(_21, (void**) &_22, &_20) == SUCCESS ; zephir_hash_move_forward_ex(_21, &_20) ) { ZEPHIR_GET_HVALUE(extension, _22); ZEPHIR_INIT_NVAR(filePath); ZEPHIR_CONCAT_VVSV(filePath, fixedDirectory, fileName, ".", extension); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_checkedPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:beforeCheckPath", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_23, 0, _9, this_ptr, filePath); zephir_check_temp_parameter(_9); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_11, "is_file", &_12, 288, filePath); zephir_check_call_status(); if (zephir_is_true(_11)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_foundPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:pathFound", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_24, 0, _9, this_ptr, filePath); zephir_check_temp_parameter(_9); zephir_check_call_status(); } if (zephir_require_zval(filePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_MM_BOOL(1); } } } } } } ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "_", 0); ZEPHIR_INIT_VAR(dsClassName); zephir_fast_str_replace(&dsClassName, &_5, ds, className TSRMLS_CC); ZEPHIR_SINIT_NVAR(_18); ZVAL_STRING(&_18, "\\", 0); ZEPHIR_INIT_VAR(nsClassName); zephir_fast_str_replace(&nsClassName, &_18, ds, dsClassName TSRMLS_CC); ZEPHIR_OBS_VAR(directories); zephir_read_property_this(&directories, this_ptr, SL("_directories"), PH_NOISY_CC); if (Z_TYPE_P(directories) == IS_ARRAY) { zephir_is_iterable(directories, &_26, &_25, 0, 0, "phalcon/loader.zep", 466); for ( ; zephir_hash_get_current_data_ex(_26, (void**) &_27, &_25) == SUCCESS ; zephir_hash_move_forward_ex(_26, &_25) ) { ZEPHIR_GET_HVALUE(directory, _27); ZEPHIR_INIT_NVAR(_0); zephir_fast_trim(_0, directory, ds, ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_INIT_NVAR(fixedDirectory); ZEPHIR_CONCAT_VV(fixedDirectory, _0, ds); zephir_is_iterable(extensions, &_29, &_28, 0, 0, "phalcon/loader.zep", 465); for ( ; zephir_hash_get_current_data_ex(_29, (void**) &_30, &_28) == SUCCESS ; zephir_hash_move_forward_ex(_29, &_28) ) { ZEPHIR_GET_HVALUE(extension, _30); ZEPHIR_INIT_NVAR(filePath); ZEPHIR_CONCAT_VVSV(filePath, fixedDirectory, nsClassName, ".", extension); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_checkedPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:beforeCheckPath", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_31, 0, _9, this_ptr, filePath); zephir_check_temp_parameter(_9); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_11, "is_file", &_12, 288, filePath); zephir_check_call_status(); if (zephir_is_true(_11)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_foundPath"), filePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "loader:pathFound", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_32, 0, _9, this_ptr, filePath); zephir_check_temp_parameter(_9); zephir_check_call_status(); } if (zephir_require_zval(filePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_MM_BOOL(1); } } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "loader:afterCheckClass", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _0, this_ptr, className); zephir_check_temp_parameter(_0); zephir_check_call_status(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Loader, getFoundPath) { RETURN_MEMBER(this_ptr, "_foundPath"); } static PHP_METHOD(Phalcon_Loader, getCheckedPath) { RETURN_MEMBER(this_ptr, "_checkedPath"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger) { ZEPHIR_REGISTER_CLASS(Phalcon, Logger, phalcon, logger, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_class_constant_long(phalcon_logger_ce, SL("SPECIAL"), 9 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("CUSTOM"), 8 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("DEBUG"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("INFO"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("NOTICE"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("WARNING"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("ERROR"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("ALERT"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("CRITICAL"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("EMERGENCE"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_logger_ce, SL("EMERGENCY"), 0 TSRMLS_CC); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Registry) { ZEPHIR_REGISTER_CLASS(Phalcon, Registry, phalcon, registry, phalcon_registry_method_entry, ZEND_ACC_FINAL_CLASS); zend_declare_property_null(phalcon_registry_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_registry_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_registry_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_registry_ce TSRMLS_CC, 1, zend_ce_iterator); return SUCCESS; } static PHP_METHOD(Phalcon_Registry, __construct) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_data"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, offsetExists) { zval *offset_param = NULL, *_0; zval *offset = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &offset_param); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(offset_param) == IS_STRING)) { zephir_get_strval(offset, offset_param); } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, offset)); } static PHP_METHOD(Phalcon_Registry, offsetGet) { zval *offset_param = NULL, *_0, *_1; zval *offset = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &offset_param); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(offset_param) == IS_STRING)) { zephir_get_strval(offset, offset_param); } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); zephir_array_fetch(&_1, _0, offset, PH_NOISY | PH_READONLY, "phalcon/registry.zep", 98 TSRMLS_CC); RETURN_CTOR(_1); } static PHP_METHOD(Phalcon_Registry, offsetSet) { zval *offset_param = NULL, *value; zval *offset = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &offset_param, &value); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(offset_param) == IS_STRING)) { zephir_get_strval(offset, offset_param); } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } zephir_update_property_array(this_ptr, SL("_data"), offset, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, offsetUnset) { zval *offset_param = NULL, *_0; zval *offset = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &offset_param); if (unlikely(Z_TYPE_P(offset_param) != IS_STRING && Z_TYPE_P(offset_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'offset' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(offset_param) == IS_STRING)) { zephir_get_strval(offset, offset_param); } else { ZEPHIR_INIT_VAR(offset); ZVAL_EMPTY_STRING(offset); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); zephir_array_unset(&_0, offset, PH_SEPARATE); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, count) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Registry, next) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_MAKE_REF(_0); ZEPHIR_CALL_FUNCTION(NULL, "next", NULL, 393, _0); ZEPHIR_UNREF(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, key) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_MAKE_REF(_0); ZEPHIR_RETURN_CALL_FUNCTION("key", NULL, 394, _0); ZEPHIR_UNREF(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Registry, rewind) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_MAKE_REF(_0); ZEPHIR_CALL_FUNCTION(NULL, "reset", NULL, 395, _0); ZEPHIR_UNREF(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, valid) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_MAKE_REF(_0); ZEPHIR_CALL_FUNCTION(&_1, "key", NULL, 394, _0); ZEPHIR_UNREF(_0); zephir_check_call_status(); RETURN_MM_BOOL(Z_TYPE_P(_1) != IS_NULL); } static PHP_METHOD(Phalcon_Registry, current) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_MAKE_REF(_0); ZEPHIR_RETURN_CALL_FUNCTION("current", NULL, 396, _0); ZEPHIR_UNREF(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Registry, __set) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "offsetset", NULL, 397, key, value); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Registry, __get) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "offsetget", NULL, 398, key); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Registry, __isset) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "offsetexists", NULL, 399, key); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Registry, __unset) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "offsetunset", NULL, 400, key); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Security) { ZEPHIR_REGISTER_CLASS(Phalcon, Security, phalcon, security, phalcon_security_method_entry, 0); zend_declare_property_null(phalcon_security_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_security_ce, SL("_workFactor"), 8, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_security_ce, SL("_numberBytes"), 16, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_security_ce, SL("_tokenKeySessionID"), "$PHALCON/CSRF/KEY$", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_security_ce, SL("_tokenValueSessionID"), "$PHALCON/CSRF$", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_security_ce, SL("_csrf"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_security_ce, SL("_defaultHash"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_DEFAULT"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_STD_DES"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_EXT_DES"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_MD5"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_BLOWFISH"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_BLOWFISH_X"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_BLOWFISH_Y"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_SHA256"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_security_ce, SL("CRYPT_SHA512"), 8 TSRMLS_CC); zend_class_implements(phalcon_security_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Security, setWorkFactor) { zval *workFactor; zephir_fetch_params(0, 1, 0, &workFactor); zephir_update_property_this(this_ptr, SL("_workFactor"), workFactor TSRMLS_CC); } static PHP_METHOD(Phalcon_Security, getWorkFactor) { RETURN_MEMBER(this_ptr, "_workFactor"); } static PHP_METHOD(Phalcon_Security, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Security, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Security, setRandomBytes) { zval *randomBytes_param = NULL, *_0; long randomBytes; zephir_fetch_params(0, 1, 0, &randomBytes_param); if (unlikely(Z_TYPE_P(randomBytes_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'randomBytes' must be a long") TSRMLS_CC); RETURN_NULL(); } randomBytes = Z_LVAL_P(randomBytes_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, randomBytes); zephir_update_property_this(this_ptr, SL("_numberBytes"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Security, getRandomBytes) { RETURN_MEMBER(this_ptr, "_numberBytes"); } static PHP_METHOD(Phalcon_Security, getSaltBytes) { zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; zval *numberBytes_param = NULL, *safeBytes = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4 = NULL; int numberBytes, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &numberBytes_param); if (!numberBytes_param) { numberBytes = 0; } else { numberBytes = zephir_get_intval(numberBytes_param); } if (!((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Openssl extension must be loaded", "phalcon/security.zep", 119); return; } if (!(numberBytes)) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_numberBytes"), PH_NOISY_CC); numberBytes = zephir_get_intval(_0); } while (1) { ZEPHIR_INIT_NVAR(safeBytes); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, numberBytes); ZEPHIR_CALL_FUNCTION(&_2, "openssl_random_pseudo_bytes", &_3, 401, _1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_4, "base64_encode", &_5, 115, _2); zephir_check_call_status(); zephir_filter_alphanum(safeBytes, _4); if (!(zephir_is_true(safeBytes))) { continue; } if (zephir_fast_strlen_ev(safeBytes) < numberBytes) { continue; } break; } RETURN_CCTOR(safeBytes); } static PHP_METHOD(Phalcon_Security, hash) { zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL; int workFactor, hash, ZEPHIR_LAST_CALL_STATUS; zval *password_param = NULL, *workFactor_param = NULL, *saltBytes = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, _5, _6, *_7 = NULL; zval *password = NULL, *variant = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &password_param, &workFactor_param); zephir_get_strval(password, password_param); if (!workFactor_param) { workFactor = 0; } else { workFactor = zephir_get_intval(workFactor_param); } if (!(workFactor)) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_workFactor"), PH_NOISY_CC); workFactor = zephir_get_intval(_0); } ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultHash"), PH_NOISY_CC); hash = zephir_get_intval(_0); do { if (hash == 5) { ZEPHIR_INIT_VAR(variant); ZVAL_STRING(variant, "x", 1); break; } if (hash == 6) { ZEPHIR_INIT_NVAR(variant); ZVAL_STRING(variant, "y", 1); break; } if (hash == 7) { ZEPHIR_INIT_NVAR(variant); ZVAL_STRING(variant, "5", 1); break; } if (hash == 8) { ZEPHIR_INIT_NVAR(variant); ZVAL_STRING(variant, "6", 1); break; } ZEPHIR_INIT_NVAR(variant); ZVAL_STRING(variant, "a", 1); break; } while(0); do { if (hash == 1) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 2); ZEPHIR_CALL_METHOD(&saltBytes, this_ptr, "getsaltbytes", &_2, 0, _1); zephir_check_call_status(); if (Z_TYPE_P(saltBytes) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Unable to get random bytes for the salt", "phalcon/security.zep", 195); return; } break; } if (hash == 8) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 8); ZEPHIR_CALL_METHOD(&saltBytes, this_ptr, "getsaltbytes", &_2, 0, _1); zephir_check_call_status(); if (Z_TYPE_P(saltBytes) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Unable to get random bytes for the salt", "phalcon/security.zep", 203); return; } ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "$", variant, "$", saltBytes); ZEPHIR_RETURN_CALL_FUNCTION("crypt", &_4, 402, password, _3); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 22); ZEPHIR_CALL_METHOD(&saltBytes, this_ptr, "getsaltbytes", &_2, 0, _1); zephir_check_call_status(); if (Z_TYPE_P(saltBytes) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Unable to get random bytes for the salt", "phalcon/security.zep", 225); return; } if (workFactor < 4) { workFactor = 4; } else { if (workFactor > 31) { workFactor = 31; } } ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "%02s", 0); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, workFactor); ZEPHIR_CALL_FUNCTION(&_7, "sprintf", NULL, 188, &_5, &_6); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVSVSV(_3, "$2", variant, "$", _7, "$", saltBytes); ZEPHIR_RETURN_CALL_FUNCTION("crypt", &_4, 402, password, _3); zephir_check_call_status(); RETURN_MM(); } while(0); RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Security, checkHash) { unsigned char _4; long _3; zend_bool _0; char ch; int maxPassLength, i, sum, cryptedLength, passwordLength, ZEPHIR_LAST_CALL_STATUS; zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL, *_1 = NULL; zval *password = NULL, *passwordHash = NULL, *cryptedHash = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); zephir_get_strval(password, password_param); zephir_get_strval(passwordHash, passwordHash_param); if (!maxPassLength_param) { maxPassLength = 0; } else { maxPassLength = zephir_get_intval(maxPassLength_param); } if (maxPassLength) { _0 = maxPassLength > 0; if (_0) { _0 = zephir_fast_strlen_ev(password) > maxPassLength; } if (_0) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_FUNCTION(&_1, "crypt", NULL, 402, password, passwordHash); zephir_check_call_status(); zephir_get_strval(_2, _1); ZEPHIR_CPY_WRT(cryptedHash, _2); cryptedLength = zephir_fast_strlen_ev(cryptedHash); passwordLength = zephir_fast_strlen_ev(passwordHash); zephir_concat_self(&cryptedHash, passwordHash TSRMLS_CC); sum = (cryptedLength - passwordLength); for (_3 = 0; _3 < Z_STRLEN_P(passwordHash); _3++) { i = _3; ch = ZEPHIR_STRING_OFFSET(passwordHash, _3); _4 = ZEPHIR_STRING_OFFSET(cryptedHash, i); sum = (sum | ((_4 ^ ch))); } RETURN_MM_BOOL(0 == sum); } static PHP_METHOD(Phalcon_Security, isLegacyHash) { zval *passwordHash_param = NULL; zval *passwordHash = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &passwordHash_param); zephir_get_strval(passwordHash, passwordHash_param); RETURN_MM_BOOL(zephir_start_with_str(passwordHash, SL("$2a$"))); } static PHP_METHOD(Phalcon_Security, getTokenKey) { zval *numberBytes_param = NULL, *safeBytes, *dependencyInjector = NULL, *session = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL; int numberBytes, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &numberBytes_param); if (!numberBytes_param) { numberBytes = 0; } else { numberBytes = zephir_get_intval(numberBytes_param); } if (!(numberBytes)) { numberBytes = 12; } if (!((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Openssl extension must be loaded", "phalcon/security.zep", 292); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/security.zep", 297); return; } ZEPHIR_INIT_VAR(safeBytes); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, numberBytes); ZEPHIR_CALL_FUNCTION(&_2, "openssl_random_pseudo_bytes", NULL, 401, _1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_3, "base64_encode", NULL, 115, _2); zephir_check_call_status(); zephir_filter_alphanum(safeBytes, _3); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _4); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenKeySessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "set", NULL, 0, _0, safeBytes); zephir_check_call_status(); RETURN_CCTOR(safeBytes); } static PHP_METHOD(Phalcon_Security, getToken) { zval *numberBytes_param = NULL, *token = NULL, *dependencyInjector = NULL, *session = NULL, *_0 = NULL, *_1 = NULL, *_2; int numberBytes, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &numberBytes_param); if (!numberBytes_param) { numberBytes = 0; } else { numberBytes = zephir_get_intval(numberBytes_param); } if (!(numberBytes)) { numberBytes = 12; } if (!((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Openssl extension must be loaded", "phalcon/security.zep", 319); return; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, numberBytes); ZEPHIR_CALL_FUNCTION(&token, "openssl_random_pseudo_bytes", NULL, 401, _0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_1, "base64_encode", NULL, 115, token); zephir_check_call_status(); ZEPHIR_CPY_WRT(token, _1); ZEPHIR_INIT_NVAR(_0); zephir_filter_alphanum(_0, token); ZEPHIR_CPY_WRT(token, _0); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _2); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/security.zep", 329); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenValueSessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "set", NULL, 0, _2, token); zephir_check_call_status(); RETURN_CCTOR(token); } static PHP_METHOD(Phalcon_Security, checkToken) { int ZEPHIR_LAST_CALL_STATUS; zend_bool destroyIfValid, returnValue, _4; zval *tokenKey = NULL, *tokenValue = NULL, *destroyIfValid_param = NULL, *dependencyInjector = NULL, *session = NULL, *request = NULL, *token = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &tokenKey, &tokenValue, &destroyIfValid_param); if (!tokenKey) { ZEPHIR_CPY_WRT(tokenKey, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(tokenKey); } if (!tokenValue) { tokenValue = ZEPHIR_GLOBAL(global_null); } if (!destroyIfValid_param) { destroyIfValid = 1; } else { destroyIfValid = zephir_get_boolval(destroyIfValid_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/security.zep", 348); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); if (!(zephir_is_true(tokenKey))) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenKeySessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&tokenKey, session, "get", NULL, 0, _0); zephir_check_call_status(); } if (!(zephir_is_true(tokenKey))) { RETURN_MM_BOOL(0); } if (!(zephir_is_true(tokenValue))) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&request, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&token, request, "getpost", NULL, 0, tokenKey); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(token, tokenValue); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenValueSessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, session, "get", NULL, 0, _3); zephir_check_call_status(); returnValue = ZEPHIR_IS_EQUAL(token, _1); _4 = returnValue; if (_4) { _4 = destroyIfValid; } if (_4) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenKeySessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _5); zephir_check_call_status(); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenValueSessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _6); zephir_check_call_status(); } RETURN_MM_BOOL(returnValue); } static PHP_METHOD(Phalcon_Security, getSessionToken) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector = NULL, *session = NULL, *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/security.zep", 401); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenValueSessionID"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(session, "get", NULL, 0, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Security, destroyToken) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector = NULL, *session = NULL, *_0, *_1 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/security.zep", 418); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenKeySessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _0); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_tokenValueSessionID"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Security, computeHmac) { int ZEPHIR_LAST_CALL_STATUS; zend_bool raw; zval *data, *key, *algo, *raw_param = NULL, *hmac = NULL, _0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &data, &key, &algo, &raw_param); if (!raw_param) { raw = 0; } else { raw = zephir_get_boolval(raw_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_BOOL(&_0, (raw ? 1 : 0)); ZEPHIR_CALL_FUNCTION(&hmac, "hash_hmac", NULL, 403, algo, data, key, &_0); zephir_check_call_status(); if (!(zephir_is_true(hmac))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_security_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "Unknown hashing algorithm: %s", algo); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/security.zep", 441 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(hmac); } static PHP_METHOD(Phalcon_Security, setDefaultHash) { zval *defaultHash; zephir_fetch_params(0, 1, 0, &defaultHash); zephir_update_property_this(this_ptr, SL("_defaultHash"), defaultHash TSRMLS_CC); } static PHP_METHOD(Phalcon_Security, getDefaultHash) { RETURN_MEMBER(this_ptr, "_defaultHash"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session) { ZEPHIR_REGISTER_CLASS(Phalcon, Session, phalcon, session, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Tag) { ZEPHIR_REGISTER_CLASS(Phalcon, Tag, phalcon, tag, phalcon_tag_method_entry, 0); zend_declare_property_null(phalcon_tag_ce, SL("_displayValues"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_documentTitle"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_documentTitleSeparator"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_long(phalcon_tag_ce, SL("_documentType"), 11, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_urlService"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_dispatcherService"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_tag_ce, SL("_escaperService"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_bool(phalcon_tag_ce, SL("_autoEscape"), 1, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("HTML32"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("HTML401_STRICT"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("HTML401_TRANSITIONAL"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("HTML401_FRAMESET"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("HTML5"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML10_STRICT"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML10_TRANSITIONAL"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML10_FRAMESET"), 8 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML11"), 9 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML20"), 10 TSRMLS_CC); zend_declare_class_constant_long(phalcon_tag_ce, SL("XHTML5"), 11 TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Tag, getEscaper) { int ZEPHIR_LAST_CALL_STATUS; zval *params_param = NULL, *result = NULL, *autoescape = NULL; zval *params = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶ms_param); params = params_param; ZEPHIR_OBS_VAR(autoescape); if (!(zephir_array_isset_string_fetch(&autoescape, params, SS("escape"), 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(autoescape); zephir_read_static_property_ce(&autoescape, phalcon_tag_ce, SL("_autoEscape") TSRMLS_CC); } if (zephir_is_true(autoescape)) { ZEPHIR_CALL_SELF(&result, "getescaperservice", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(result); ZVAL_NULL(result); } RETURN_CCTOR(result); } static PHP_METHOD(Phalcon_Tag, renderAttributes) { zephir_fcall_cache_entry *_15 = NULL, *_16 = NULL; zend_bool _10, _11; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_4, *_8; HashPosition _0, _3, _7; zval *attributes = NULL; zval *code_param = NULL, *attributes_param = NULL, *order, *escaper = NULL, *attrs, *attribute = NULL, *value = NULL, *escaped = NULL, *key = NULL, *newCode = NULL, **_2, **_5, *_6 = NULL, **_9, *_12 = NULL, *_13 = NULL, *_14 = NULL; zval *code = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &code_param, &attributes_param); if (unlikely(Z_TYPE_P(code_param) != IS_STRING && Z_TYPE_P(code_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'code' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(code_param) == IS_STRING)) { zephir_get_strval(code, code_param); } else { ZEPHIR_INIT_VAR(code); ZVAL_EMPTY_STRING(code); } attributes = attributes_param; ZEPHIR_INIT_VAR(order); zephir_create_array(order, 10, 0 TSRMLS_CC); zephir_array_update_string(&order, SL("rel"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("type"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("for"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("src"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("href"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("action"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("id"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("name"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("value"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); zephir_array_update_string(&order, SL("class"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(attrs); array_init(attrs); zephir_is_iterable(order, &_1, &_0, 0, 0, "phalcon/tag.zep", 135); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_OBS_NVAR(attribute); if (zephir_array_isset_fetch(&attribute, attributes, key, 0 TSRMLS_CC)) { zephir_array_update_zval(&attrs, key, &attribute, PH_COPY | PH_SEPARATE); } } zephir_is_iterable(attributes, &_4, &_3, 0, 0, "phalcon/tag.zep", 141); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(key, _4, _3); ZEPHIR_GET_HVALUE(value, _5); if (!(zephir_array_isset(attrs, key))) { zephir_array_update_zval(&attrs, key, &value, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_SELF(&_6, "getescaper", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_CPY_WRT(escaper, _6); zephir_array_unset_string(&attrs, SS("escape"), PH_SEPARATE); ZEPHIR_CPY_WRT(newCode, code); zephir_is_iterable(attrs, &_8, &_7, 0, 0, "phalcon/tag.zep", 160); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(key, _8, _7); ZEPHIR_GET_HVALUE(value, _9); _10 = Z_TYPE_P(key) == IS_STRING; if (_10) { _10 = Z_TYPE_P(value) != IS_NULL; } if (_10) { _11 = Z_TYPE_P(value) == IS_ARRAY; if (!(_11)) { _11 = Z_TYPE_P(value) == IS_RESOURCE; } if (_11) { ZEPHIR_INIT_NVAR(_12); object_init_ex(_12, phalcon_tag_exception_ce); ZEPHIR_INIT_NVAR(_13); zephir_gettype(_13, value TSRMLS_CC); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_SVSVS(_14, "Value at index: '", key, "' type: '", _13, "' cannot be rendered"); ZEPHIR_CALL_METHOD(NULL, _12, "__construct", &_15, 9, _14); zephir_check_call_status(); zephir_throw_exception_debug(_12, "phalcon/tag.zep", 149 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(escaper)) { ZEPHIR_CALL_METHOD(&escaped, escaper, "escapehtmlattr", &_16, 0, value); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(escaped, value); } ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_SVSVS(_14, " ", key, "=\"", escaped, "\""); zephir_concat_self(&newCode, _14 TSRMLS_CC); } } RETURN_CCTOR(newCode); } static PHP_METHOD(Phalcon_Tag, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_static_property_ce(phalcon_tag_ce, SL("_dependencyInjector"), &dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Tag, getDI) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *di = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(di); zephir_read_static_property_ce(&di, phalcon_tag_ce, SL("_dependencyInjector") TSRMLS_CC); if (Z_TYPE_P(di) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&di, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); } RETURN_CCTOR(di); } static PHP_METHOD(Phalcon_Tag, getUrlService) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *url = NULL, *dependencyInjector = NULL, *_0, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(url); zephir_read_static_property_ce(&url, phalcon_tag_ce, SL("_urlService") TSRMLS_CC); if (Z_TYPE_P(url) != IS_OBJECT) { _0 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_dependencyInjector") TSRMLS_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "A dependency injector container is required to obtain the 'url' service", "phalcon/tag.zep", 200); return; } ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(url, _2); zephir_update_static_property_ce(phalcon_tag_ce, SL("_urlService"), &url TSRMLS_CC); } RETURN_CCTOR(url); } static PHP_METHOD(Phalcon_Tag, getEscaperService) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *escaper = NULL, *dependencyInjector = NULL, *_0, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(escaper); zephir_read_static_property_ce(&escaper, phalcon_tag_ce, SL("_escaperService") TSRMLS_CC); if (Z_TYPE_P(escaper) != IS_OBJECT) { _0 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_dependencyInjector") TSRMLS_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "A dependency injector container is required to obtain the 'escaper' service", "phalcon/tag.zep", 225); return; } ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(escaper, _2); zephir_update_static_property_ce(phalcon_tag_ce, SL("_escaperService"), &escaper TSRMLS_CC); } RETURN_CCTOR(escaper); } static PHP_METHOD(Phalcon_Tag, setAutoescape) { zval *autoescape_param = NULL, *_0; zend_bool autoescape; zephir_fetch_params(0, 1, 0, &autoescape_param); autoescape = zephir_get_boolval(autoescape_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_BOOL(_0, autoescape); zephir_update_static_property_ce(phalcon_tag_ce, SL("_autoEscape"), &_0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Tag, setDefault) { zend_bool _0; zval *id_param = NULL, *value; zval *id = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &id_param, &value); if (unlikely(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(id_param) == IS_STRING)) { zephir_get_strval(id, id_param); } else { ZEPHIR_INIT_VAR(id); ZVAL_EMPTY_STRING(id); } if (Z_TYPE_P(value) != IS_NULL) { _0 = Z_TYPE_P(value) == IS_ARRAY; if (!(_0)) { _0 = Z_TYPE_P(value) == IS_OBJECT; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "Only scalar values can be assigned to UI components", "phalcon/tag.zep", 260); return; } } zephir_update_static_property_array_multi_ce(phalcon_tag_ce, SL("_displayValues"), &value TSRMLS_CC, SL("z"), 1, id); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, setDefaults) { zend_bool merge; zval *values_param = NULL, *merge_param = NULL, *displayValues, *_0; zval *values = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &values_param, &merge_param); values = values_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(displayValues); zephir_read_static_property_ce(&displayValues, phalcon_tag_ce, SL("_displayValues") TSRMLS_CC); if (Z_TYPE_P(displayValues) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(displayValues), &(values) TSRMLS_CC); zephir_update_static_property_ce(phalcon_tag_ce, SL("_displayValues"), &_0 TSRMLS_CC); } else { zephir_update_static_property_ce(phalcon_tag_ce, SL("_displayValues"), &values TSRMLS_CC); } } else { zephir_update_static_property_ce(phalcon_tag_ce, SL("_displayValues"), &values TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, displayTo) { int ZEPHIR_LAST_CALL_STATUS; zval *id, *value; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &id, &value); ZEPHIR_RETURN_CALL_SELF("setdefault", NULL, 0, id, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, hasValue) { zend_bool _1; zval *name, *_0, *_POST; zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_fetch_params(0, 1, 0, &name); _0 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_displayValues") TSRMLS_CC); _1 = zephir_array_isset(_0, name); if (!(_1)) { _1 = zephir_array_isset(_POST, name); } RETURN_BOOL(_1); } static PHP_METHOD(Phalcon_Tag, getValue) { zend_bool _0; zval *name, *params = NULL, *value = NULL, *_1, *_POST; ZEPHIR_MM_GROW(); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_fetch_params(1, 1, 1, &name, ¶ms); if (!params) { params = ZEPHIR_GLOBAL(global_null); } _0 = !zephir_is_true(params); if (!(_0)) { ZEPHIR_OBS_VAR(value); _0 = !(zephir_array_isset_string_fetch(&value, params, SS("value"), 0 TSRMLS_CC)); } if (_0) { ZEPHIR_OBS_NVAR(value); _1 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_displayValues") TSRMLS_CC); if (!(zephir_array_isset_fetch(&value, _1, name, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(value); if (!(zephir_array_isset_fetch(&value, _POST, name, 0 TSRMLS_CC))) { RETURN_MM_NULL(); } } } RETURN_CCTOR(value); } static PHP_METHOD(Phalcon_Tag, resetInput) { zval *_0, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_static_property_ce(phalcon_tag_ce, SL("_displayValues"), &_0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); array_init(_1); ZEPHIR_INIT_VAR(_2); if (zephir_set_symbol_str(SS("_POST"), _2 TSRMLS_CC) == FAILURE){ return; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, linkTo) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters, *text = NULL, *local = NULL, *params = NULL, *action = NULL, *query = NULL, *url = NULL, *code = NULL, *_0 = NULL, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, ¶meters, &text, &local); if (!text) { ZEPHIR_CPY_WRT(text, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(text); } if (!local) { ZEPHIR_CPY_WRT(local, ZEPHIR_GLOBAL(global_true)); } else { ZEPHIR_SEPARATE_PARAM(local); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 3, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); zephir_array_fast_append(params, text); zephir_array_fast_append(params, local); } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_OBS_VAR(action); if (!(zephir_array_isset_long_fetch(&action, params, 0, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(action); if (!(zephir_array_isset_string_fetch(&action, params, SS("action"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(action); ZVAL_STRING(action, "", 1); } else { zephir_array_unset_string(¶ms, SS("action"), PH_SEPARATE); } } ZEPHIR_OBS_NVAR(text); if (!(zephir_array_isset_long_fetch(&text, params, 1, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(text); if (!(zephir_array_isset_string_fetch(&text, params, SS("text"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(text); ZVAL_STRING(text, "", 1); } else { zephir_array_unset_string(¶ms, SS("text"), PH_SEPARATE); } } ZEPHIR_OBS_NVAR(local); if (!(zephir_array_isset_long_fetch(&local, params, 2, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(local); if (!(zephir_array_isset_string_fetch(&local, params, SS("local"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(local); ZVAL_BOOL(local, 1); } else { zephir_array_unset_string(¶ms, SS("local"), PH_SEPARATE); } } ZEPHIR_OBS_VAR(query); if (zephir_array_isset_string_fetch(&query, params, SS("query"), 0 TSRMLS_CC)) { zephir_array_unset_string(¶ms, SS("query"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(query); ZVAL_NULL(query); } ZEPHIR_CALL_SELF(&url, "geturlservice", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, url, "get", NULL, 0, action, query, local); zephir_check_call_status(); zephir_array_update_string(¶ms, SL("href"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "<a", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _1, params); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, ">", text, "</a>"); zephir_concat_self(&code, _2 TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, _inputField) { int ZEPHIR_LAST_CALL_STATUS; zend_bool asValue, _1; zval *type_param = NULL, *parameters, *asValue_param = NULL, *params = NULL, *id, *value, *code = NULL, *name, *_0, *_2 = NULL, *_3, *_4; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &type_param, ¶meters, &asValue_param); zephir_get_strval(type, type_param); if (!asValue_param) { asValue = 0; } else { asValue = zephir_get_boolval(asValue_param); } ZEPHIR_INIT_VAR(params); array_init(params); if (Z_TYPE_P(parameters) != IS_ARRAY) { zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/tag.zep", 435); } else { ZEPHIR_CPY_WRT(params, parameters); } if (asValue == 0) { ZEPHIR_OBS_VAR(id); if (!(zephir_array_isset_long_fetch(&id, params, 0, 0 TSRMLS_CC))) { zephir_array_fetch_string(&_0, params, SL("id"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 443 TSRMLS_CC); zephir_array_update_long(¶ms, 0, &_0, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } ZEPHIR_OBS_VAR(name); if (zephir_array_isset_string_fetch(&name, params, SS("name"), 0 TSRMLS_CC)) { if (ZEPHIR_IS_EMPTY(name)) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(id) == IS_STRING) { _1 = !(zephir_memnstr_str(id, SL("["), "phalcon/tag.zep", 458)); if (_1) { _1 = !(zephir_array_isset_string(params, SS("id"))); } if (_1) { zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_SELF(&_2, "getvalue", NULL, 0, id, params); zephir_check_call_status(); zephir_array_update_string(¶ms, SL("value"), &_2, PH_COPY | PH_SEPARATE); } else { if (!(zephir_array_isset_string(params, SS("value")))) { ZEPHIR_OBS_VAR(value); if (zephir_array_isset_long_fetch(&value, params, 0, 0 TSRMLS_CC)) { zephir_array_update_string(¶ms, SL("value"), &value, PH_COPY | PH_SEPARATE); } } } zephir_array_update_string(¶ms, SL("type"), &type, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "<input", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _3, params); zephir_check_temp_parameter(_3); zephir_check_call_status(); _4 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); if (ZEPHIR_GT_LONG(_4, 5)) { zephir_concat_self_str(&code, SL(" />") TSRMLS_CC); } else { zephir_concat_self_str(&code, SL(">") TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, _inputFieldChecked) { zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *parameters, *params = NULL, *value = NULL, *id, *code = NULL, *name, *currentValue, *_0, _1, *_2, *_4 = NULL, *_5; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, ¶meters); zephir_get_strval(type, type_param); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); } else { ZEPHIR_CPY_WRT(params, parameters); } if (!(zephir_array_isset_long(params, 0))) { zephir_array_fetch_string(&_0, params, SL("id"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 509 TSRMLS_CC); zephir_array_update_long(¶ms, 0, &_0, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } ZEPHIR_OBS_VAR(id); zephir_array_fetch_long(&id, params, 0, PH_NOISY, "phalcon/tag.zep", 512 TSRMLS_CC); if (!(zephir_array_isset_string(params, SS("name")))) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } else { ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, params, SL("name"), PH_NOISY, "phalcon/tag.zep", 516 TSRMLS_CC); if (ZEPHIR_IS_EMPTY(name)) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } } ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "[", 0); ZEPHIR_INIT_VAR(_2); zephir_fast_strpos(_2, id, &_1, 0 ); if (!(zephir_is_true(_2))) { if (!(zephir_array_isset_string(params, SS("id")))) { zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); } } ZEPHIR_OBS_VAR(currentValue); if (zephir_array_isset_string_fetch(¤tValue, params, SS("value"), 0 TSRMLS_CC)) { zephir_array_unset_string(¶ms, SS("value"), PH_SEPARATE); ZEPHIR_CALL_SELF(&value, "getvalue", NULL, 0, id, params); zephir_check_call_status(); _3 = zephir_is_true(value); if (_3) { _3 = ZEPHIR_IS_EQUAL(currentValue, value); } if (_3) { ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "checked", 1); zephir_array_update_string(¶ms, SL("checked"), &_4, PH_COPY | PH_SEPARATE); } zephir_array_update_string(¶ms, SL("value"), ¤tValue, PH_COPY | PH_SEPARATE); } else { ZEPHIR_CALL_SELF(&value, "getvalue", NULL, 0, id, params); zephir_check_call_status(); if (zephir_is_true(value)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "checked", 1); zephir_array_update_string(¶ms, SL("checked"), &_4, PH_COPY | PH_SEPARATE); } zephir_array_update_string(¶ms, SL("value"), &value, PH_COPY | PH_SEPARATE); } zephir_array_update_string(¶ms, SL("type"), &type, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "<input", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _4, params); zephir_check_temp_parameter(_4); zephir_check_call_status(); _5 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); if (ZEPHIR_GT_LONG(_5, 5)) { zephir_concat_self_str(&code, SL(" />") TSRMLS_CC); } else { zephir_concat_self_str(&code, SL(">") TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, colorField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "color", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, textField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "text", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, numericField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "number", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, rangeField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "range", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, emailField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, dateField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "date", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, dateTimeField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "datetime", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, dateTimeLocalField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "datetime-local", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, monthField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "month", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, timeField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "time", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, weekField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "week", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, passwordField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "password", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, hiddenField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "hidden", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, fileField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "file", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, searchField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "search", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, telField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "tel", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, urlField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, checkField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "checkbox", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfieldchecked", &_0, 414, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, radioField) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "radio", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_inputfieldchecked", &_0, 414, _1, parameters); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, imageInput) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "image", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, submitButton) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "submit", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_RETURN_CALL_SELF("_inputfield", &_0, 413, _1, parameters, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, selectStatic) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, ¶meters, &data); if (!data) { data = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_select_ce, "selectfield", &_0, 207, parameters, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, select) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters, *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, ¶meters, &data); if (!data) { data = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_select_ce, "selectfield", &_0, 207, parameters, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Tag, textArea) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters, *params = NULL, *id, *name, *content = NULL, *code = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); } else { ZEPHIR_CPY_WRT(params, parameters); } if (!(zephir_array_isset_long(params, 0))) { if (zephir_array_isset_string(params, SS("id"))) { zephir_array_fetch_string(&_0, params, SL("id"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 933 TSRMLS_CC); zephir_array_update_long(¶ms, 0, &_0, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } } ZEPHIR_OBS_VAR(id); zephir_array_fetch_long(&id, params, 0, PH_NOISY, "phalcon/tag.zep", 937 TSRMLS_CC); if (!(zephir_array_isset_string(params, SS("name")))) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } else { ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, params, SL("name"), PH_NOISY, "phalcon/tag.zep", 941 TSRMLS_CC); if (ZEPHIR_IS_EMPTY(name)) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } } if (!(zephir_array_isset_string(params, SS("id")))) { zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(params, SS("value"))) { ZEPHIR_OBS_VAR(content); zephir_array_fetch_string(&content, params, SL("value"), PH_NOISY, "phalcon/tag.zep", 952 TSRMLS_CC); zephir_array_unset_string(¶ms, SS("value"), PH_SEPARATE); } else { ZEPHIR_CALL_SELF(&content, "getvalue", NULL, 0, id, params); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "<textarea", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _1, params); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, ">", content, "</textarea>"); zephir_concat_self(&code, _2 TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, form) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *params = NULL, *paramsAction = NULL, *action = NULL, *code = NULL, *_0 = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ¶meters); ZEPHIR_SEPARATE_PARAM(parameters); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_OBS_VAR(paramsAction); if (!(zephir_array_isset_long_fetch(¶msAction, params, 0, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(paramsAction); zephir_array_isset_string_fetch(¶msAction, params, SS("action"), 0 TSRMLS_CC); } if (!(zephir_array_isset_string(params, SS("method")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "post", 1); zephir_array_update_string(¶ms, SL("method"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(action); ZVAL_NULL(action); if (!(ZEPHIR_IS_EMPTY(paramsAction))) { ZEPHIR_CALL_SELF(&_1, "geturlservice", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&action, _1, "get", NULL, 0, paramsAction); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(parameters); if (zephir_array_isset_string_fetch(¶meters, params, SS("parameters"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "?", parameters); zephir_concat_self(&action, _2 TSRMLS_CC); } if (!(ZEPHIR_IS_EMPTY(action))) { zephir_array_update_string(¶ms, SL("action"), &action, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "<form", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _0, params); zephir_check_temp_parameter(_0); zephir_check_call_status(); zephir_concat_self_str(&code, SL(">") TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, endForm) { RETURN_STRING("</form>", 1); } static PHP_METHOD(Phalcon_Tag, setTitle) { zval *title_param = NULL; zval *title = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &title_param); zephir_get_strval(title, title_param); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentTitle"), &title TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, setTitleSeparator) { zval *titleSeparator_param = NULL; zval *titleSeparator = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &titleSeparator_param); zephir_get_strval(titleSeparator, titleSeparator_param); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentTitleSeparator"), &titleSeparator TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, appendTitle) { zval *title_param = NULL, *_0, *_1, *_2; zval *title = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &title_param); zephir_get_strval(title, title_param); ZEPHIR_OBS_VAR(_0); zephir_read_static_property_ce(&_0, phalcon_tag_ce, SL("_documentTitle") TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_read_static_property_ce(&_1, phalcon_tag_ce, SL("_documentTitleSeparator") TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VVV(_2, _0, _1, title); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentTitle"), &_2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, prependTitle) { zval *title_param = NULL, *_0, *_1, *_2; zval *title = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &title_param); zephir_get_strval(title, title_param); ZEPHIR_OBS_VAR(_0); zephir_read_static_property_ce(&_0, phalcon_tag_ce, SL("_documentTitleSeparator") TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_read_static_property_ce(&_1, phalcon_tag_ce, SL("_documentTitle") TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VVV(_2, title, _0, _1); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentTitle"), &_2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Tag, getTitle) { zval *tags_param = NULL, *documentTitle, *_0; zend_bool tags; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &tags_param); if (!tags_param) { tags = 1; } else { tags = zephir_get_boolval(tags_param); } ZEPHIR_OBS_VAR(documentTitle); zephir_read_static_property_ce(&documentTitle, phalcon_tag_ce, SL("_documentTitle") TSRMLS_CC); if (tags) { ZEPHIR_INIT_VAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<title>", documentTitle, "</title>", _0); RETURN_MM(); } RETURN_CCTOR(documentTitle); } static PHP_METHOD(Phalcon_Tag, getTitleSeparator) { zval *_0; _0 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentTitleSeparator") TSRMLS_CC); RETURN_CTORW(_0); } static PHP_METHOD(Phalcon_Tag, stylesheetLink) { int ZEPHIR_LAST_CALL_STATUS; zend_bool local; zval *parameters = NULL, *local_param = NULL, *params = NULL, *code = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &local_param); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!local_param) { local = 1; } else { local = zephir_get_boolval(local_param); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 2, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, local); zephir_array_fast_append(params, _0); } else { ZEPHIR_CPY_WRT(params, parameters); } if (zephir_array_isset_long(params, 1)) { ZEPHIR_OBS_VAR(_1); zephir_array_fetch_long(&_1, params, 1, PH_NOISY, "phalcon/tag.zep", 1139 TSRMLS_CC); local = zephir_get_boolval(_1); } else { if (zephir_array_isset_string(params, SS("local"))) { ZEPHIR_OBS_NVAR(_1); zephir_array_fetch_string(&_1, params, SL("local"), PH_NOISY, "phalcon/tag.zep", 1142 TSRMLS_CC); local = zephir_get_boolval(_1); zephir_array_unset_string(¶ms, SS("local"), PH_SEPARATE); } } if (!(zephir_array_isset_string(params, SS("type")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "text/css", 1); zephir_array_update_string(¶ms, SL("type"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(params, SS("href")))) { if (zephir_array_isset_long(params, 0)) { zephir_array_fetch_long(&_2, params, 0, PH_NOISY | PH_READONLY, "phalcon/tag.zep", 1153 TSRMLS_CC); zephir_array_update_string(¶ms, SL("href"), &_2, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "", 1); zephir_array_update_string(¶ms, SL("href"), &_0, PH_COPY | PH_SEPARATE); } } if (local == 1) { ZEPHIR_CALL_SELF(&_3, "geturlservice", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_2, params, SL("href"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 1163 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, _3, "getstatic", NULL, 0, _2); zephir_check_call_status(); zephir_array_update_string(¶ms, SL("href"), &_4, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(params, SS("rel")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "stylesheet", 1); zephir_array_update_string(¶ms, SL("rel"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "<link", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _0, params); zephir_check_temp_parameter(_0); zephir_check_call_status(); _5 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); if (ZEPHIR_GT_LONG(_5, 5)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_EOL"); ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SV(_6, " />", _0); zephir_concat_self(&code, _6 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_EOL"); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, ">", _0); zephir_concat_self(&code, _6 TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, javascriptInclude) { int ZEPHIR_LAST_CALL_STATUS; zend_bool local; zval *parameters = NULL, *local_param = NULL, *params = NULL, *code = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &local_param); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!local_param) { local = 1; } else { local = zephir_get_boolval(local_param); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 2, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, local); zephir_array_fast_append(params, _0); } else { ZEPHIR_CPY_WRT(params, parameters); } if (zephir_array_isset_long(params, 1)) { ZEPHIR_OBS_VAR(_1); zephir_array_fetch_long(&_1, params, 1, PH_NOISY, "phalcon/tag.zep", 1213 TSRMLS_CC); local = zephir_get_boolval(_1); } else { if (zephir_array_isset_string(params, SS("local"))) { ZEPHIR_OBS_NVAR(_1); zephir_array_fetch_string(&_1, params, SL("local"), PH_NOISY, "phalcon/tag.zep", 1216 TSRMLS_CC); local = zephir_get_boolval(_1); zephir_array_unset_string(¶ms, SS("local"), PH_SEPARATE); } } if (!(zephir_array_isset_string(params, SS("type")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "text/javascript", 1); zephir_array_update_string(¶ms, SL("type"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(params, SS("src")))) { if (zephir_array_isset_long(params, 0)) { zephir_array_fetch_long(&_2, params, 0, PH_NOISY | PH_READONLY, "phalcon/tag.zep", 1227 TSRMLS_CC); zephir_array_update_string(¶ms, SL("src"), &_2, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "", 1); zephir_array_update_string(¶ms, SL("src"), &_0, PH_COPY | PH_SEPARATE); } } if (local == 1) { ZEPHIR_CALL_SELF(&_3, "geturlservice", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_2, params, SL("src"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 1237 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, _3, "getstatic", NULL, 0, _2); zephir_check_call_status(); zephir_array_update_string(¶ms, SL("src"), &_4, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "<script", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _0, params); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_EOL"); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SV(_5, "></script>", _0); zephir_concat_self(&code, _5 TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, image) { int ZEPHIR_LAST_CALL_STATUS; zend_bool local; zval *parameters = NULL, *local_param = NULL, *params = NULL, *code = NULL, *src, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &local_param); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!local_param) { local = 1; } else { local = zephir_get_boolval(local_param); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); } else { ZEPHIR_CPY_WRT(params, parameters); if (zephir_array_isset_long(params, 1)) { ZEPHIR_OBS_VAR(_0); zephir_array_fetch_long(&_0, params, 1, PH_NOISY, "phalcon/tag.zep", 1274 TSRMLS_CC); local = zephir_get_boolval(_0); } } if (!(zephir_array_isset_string(params, SS("src")))) { ZEPHIR_OBS_VAR(src); if (zephir_array_isset_long_fetch(&src, params, 0, 0 TSRMLS_CC)) { zephir_array_update_string(¶ms, SL("src"), &src, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "", 1); zephir_array_update_string(¶ms, SL("src"), &_1, PH_COPY | PH_SEPARATE); } } if (local) { ZEPHIR_CALL_SELF(&_2, "geturlservice", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_4, params, SL("src"), PH_NOISY | PH_READONLY, "phalcon/tag.zep", 1290 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, _2, "getstatic", NULL, 0, _4); zephir_check_call_status(); zephir_array_update_string(¶ms, SL("src"), &_3, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "<img", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&code, "renderattributes", NULL, 0, _1, params); zephir_check_temp_parameter(_1); zephir_check_call_status(); _5 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); if (ZEPHIR_GT_LONG(_5, 5)) { zephir_concat_self_str(&code, SL(" />") TSRMLS_CC); } else { zephir_concat_self_str(&code, SL(">") TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag, friendlyTitle) { HashTable *_8; HashPosition _7; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL, *_13 = NULL; zend_bool lowercase, _6; zval *text_param = NULL, *separator_param = NULL, *lowercase_param = NULL, *replace = NULL, *friendly = NULL, *locale = NULL, *search = NULL, _0 = zval_used_for_init, *_1 = NULL, _3 = zval_used_for_init, *_5 = NULL, **_9, *_10 = NULL, *_11 = NULL, *_12; zval *text = NULL, *separator = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &text_param, &separator_param, &lowercase_param, &replace); zephir_get_strval(text, text_param); if (!separator_param) { ZEPHIR_INIT_VAR(separator); ZVAL_STRING(separator, "-", 1); } else { zephir_get_strval(separator, separator_param); } if (!lowercase_param) { lowercase = 1; } else { lowercase = zephir_get_boolval(lowercase_param); } if (!replace) { replace = ZEPHIR_GLOBAL(global_null); } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "iconv", 0); ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", &_2, 129, &_0); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "en_US.UTF-8", 0); ZEPHIR_CALL_FUNCTION(&locale, "setlocale", &_4, 415, &_0, &_3); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "UTF-8", 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "ASCII//TRANSLIT", 0); ZEPHIR_CALL_FUNCTION(&_5, "iconv", NULL, 372, &_0, &_3, text); zephir_check_call_status(); zephir_get_strval(text, _5); } if (zephir_is_true(replace)) { _6 = Z_TYPE_P(replace) != IS_ARRAY; if (_6) { _6 = Z_TYPE_P(replace) != IS_STRING; } if (_6) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "Parameter replace must be an array or a string", "phalcon/tag.zep", 1335); return; } if (Z_TYPE_P(replace) == IS_ARRAY) { zephir_is_iterable(replace, &_8, &_7, 0, 0, "phalcon/tag.zep", 1341); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(search, _9); ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, " ", 0); zephir_fast_str_replace(&_10, search, &_0, text TSRMLS_CC); zephir_get_strval(text, _10); } } else { ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, " ", 0); zephir_fast_str_replace(&_10, replace, &_3, text TSRMLS_CC); zephir_get_strval(text, _10); } } ZEPHIR_INIT_VAR(_11); ZVAL_STRING(_11, "/[^a-zA-Z0-9\\/_|+ -]/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_12); ZVAL_STRING(_12, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&friendly, "preg_replace", &_13, 29, _11, _12, text); zephir_check_temp_parameter(_11); zephir_check_temp_parameter(_12); zephir_check_call_status(); if (lowercase) { ZEPHIR_INIT_NVAR(_11); zephir_fast_strtolower(_11, friendly); ZEPHIR_CPY_WRT(friendly, _11); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "/[\\/_|+ -]+/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", &_13, 29, _11, separator, friendly); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_CPY_WRT(friendly, _5); ZEPHIR_INIT_NVAR(_11); zephir_fast_trim(_11, friendly, separator, ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_CPY_WRT(friendly, _11); ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "iconv", 0); ZEPHIR_CALL_FUNCTION(&_5, "extension_loaded", &_2, 129, &_3); zephir_check_call_status(); if (zephir_is_true(_5)) { ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_CALL_FUNCTION(NULL, "setlocale", &_4, 415, &_3, locale); zephir_check_call_status(); } RETURN_CCTOR(friendly); } static PHP_METHOD(Phalcon_Tag, setDocType) { zend_bool _0; zval *doctype_param = NULL, *_1; int doctype; zephir_fetch_params(0, 1, 0, &doctype_param); doctype = zephir_get_intval(doctype_param); _0 = doctype < 1; if (!(_0)) { _0 = doctype > 11; } if (_0) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 5); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentType"), &_1 TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, doctype); zephir_update_static_property_ce(phalcon_tag_ce, SL("_documentType"), &_1 TSRMLS_CC); } } static PHP_METHOD(Phalcon_Tag, getDocType) { zval *_0, *_1 = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_0, 1)) { ZEPHIR_INIT_VAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_CONCAT_SV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">", _1); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 2)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_VAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"", _1, "\t\"http://www.w3.org/TR/html4/strict.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 3)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"", _1, "\t\"http://www.w3.org/TR/html4/loose.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 4)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"", _1, "\t\"http://www.w3.org/TR/html4/frameset.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 6)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"", _1, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 7)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"", _1, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 8)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"", _1, "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 9)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"", _1, "\t\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 10)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_INIT_NVAR(_2); ZEPHIR_GET_CONSTANT(_2, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 2.0//EN\"", _1, "\t\"http://www.w3.org/MarkUp/DTD/xhtml2.dtd\">", _2); RETURN_MM(); } if (ZEPHIR_IS_LONG(_0, 5) || ZEPHIR_IS_LONG(_0, 11)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_EOL"); ZEPHIR_CONCAT_SV(return_value, "<!DOCTYPE html>", _1); RETURN_MM(); } } while(0); RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Tag, tagHtml) { int ZEPHIR_LAST_CALL_STATUS; zend_bool selfClose, onlyStart, useEol; zval *tagName_param = NULL, *parameters = NULL, *selfClose_param = NULL, *onlyStart_param = NULL, *useEol_param = NULL, *params = NULL, *localCode = NULL, *_1, *_3; zval *tagName = NULL, *_0, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 4, &tagName_param, ¶meters, &selfClose_param, &onlyStart_param, &useEol_param); zephir_get_strval(tagName, tagName_param); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!selfClose_param) { selfClose = 0; } else { selfClose = zephir_get_boolval(selfClose_param); } if (!onlyStart_param) { onlyStart = 0; } else { onlyStart = zephir_get_boolval(onlyStart_param); } if (!useEol_param) { useEol = 0; } else { useEol = zephir_get_boolval(useEol_param); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "<", tagName); ZEPHIR_CALL_SELF(&localCode, "renderattributes", NULL, 0, _0, params); zephir_check_call_status(); _1 = zephir_fetch_static_property_ce(phalcon_tag_ce, SL("_documentType") TSRMLS_CC); if (ZEPHIR_GT_LONG(_1, 5)) { if (selfClose) { zephir_concat_self_str(&localCode, SL(" />") TSRMLS_CC); } else { zephir_concat_self_str(&localCode, SL(">") TSRMLS_CC); } } else { if (onlyStart) { zephir_concat_self_str(&localCode, SL(">") TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "></", tagName, ">"); zephir_concat_self(&localCode, _2 TSRMLS_CC); } } if (useEol) { ZEPHIR_INIT_VAR(_3); ZEPHIR_GET_CONSTANT(_3, "PHP_EOL"); zephir_concat_self(&localCode, _3 TSRMLS_CC); } RETURN_CCTOR(localCode); } static PHP_METHOD(Phalcon_Tag, tagHtmlClose) { zend_bool useEol; zval *tagName_param = NULL, *useEol_param = NULL, *_0; zval *tagName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tagName_param, &useEol_param); zephir_get_strval(tagName, tagName_param); if (!useEol_param) { useEol = 0; } else { useEol = zephir_get_boolval(useEol_param); } if (useEol) { ZEPHIR_INIT_VAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_EOL"); ZEPHIR_CONCAT_SVSV(return_value, "</", tagName, ">", _0); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "</", tagName, ">"); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Text) { ZEPHIR_REGISTER_CLASS(Phalcon, Text, phalcon, text, phalcon_text_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_class_constant_long(phalcon_text_ce, SL("RANDOM_ALNUM"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_text_ce, SL("RANDOM_ALPHA"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_text_ce, SL("RANDOM_HEXDEC"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_text_ce, SL("RANDOM_NUMERIC"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_text_ce, SL("RANDOM_NOZERO"), 4 TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Text, camelize) { zval *str_param = NULL, *_0; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { ZEPHIR_INIT_VAR(str); ZVAL_EMPTY_STRING(str); } ZEPHIR_INIT_VAR(_0); zephir_camelize(_0, str); RETURN_CCTOR(_0); } static PHP_METHOD(Phalcon_Text, uncamelize) { zval *str_param = NULL, *_0; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { ZEPHIR_INIT_VAR(str); ZVAL_EMPTY_STRING(str); } ZEPHIR_INIT_VAR(_0); zephir_uncamelize(_0, str); RETURN_CCTOR(_0); } static PHP_METHOD(Phalcon_Text, increment) { zval *str_param = NULL, *separator_param = NULL, *parts, *number = NULL, *_0; zval *str = NULL, *separator = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &str_param, &separator_param); zephir_get_strval(str, str_param); if (!separator_param) { ZEPHIR_INIT_VAR(separator); ZVAL_STRING(separator, "_", 1); } else { zephir_get_strval(separator, separator_param); } ZEPHIR_INIT_VAR(parts); zephir_fast_explode(parts, separator, str, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(number); if (zephir_array_isset_long_fetch(&number, parts, 1, 0 TSRMLS_CC)) { ZEPHIR_SEPARATE(number); zephir_increment(number); } else { ZEPHIR_INIT_NVAR(number); ZVAL_LONG(number, 1); } zephir_array_fetch_long(&_0, parts, 0, PH_NOISY | PH_READONLY, "phalcon/text.zep", 84 TSRMLS_CC); ZEPHIR_CONCAT_VVV(return_value, _0, separator, number); RETURN_MM(); } static PHP_METHOD(Phalcon_Text, random) { zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; long length; zval *type_param = NULL, *length_param = NULL, *pool = NULL, *str, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7; int type, end, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &type_param, &length_param); if (!type_param) { type = 0; } else { type = zephir_get_intval(type_param); } if (!length_param) { length = 8; } else { length = zephir_get_intval(length_param); } ZEPHIR_INIT_VAR(str); ZVAL_STRING(str, "", 1); do { if (type == 1) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "a", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "z", 0); ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "A", 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "Z", 0); ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(pool); zephir_fast_array_merge(pool, &(_2), &(_4) TSRMLS_CC); break; } if (type == 2) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 9); ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "a", 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "f", 0); ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(pool); zephir_fast_array_merge(pool, &(_2), &(_4) TSRMLS_CC); break; } if (type == 3) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 9); ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); break; } if (type == 4) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 1); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 9); ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); break; } ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 9); ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "a", 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "z", 0); ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "A", 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "Z", 0); ZEPHIR_CALL_FUNCTION(&_5, "range", &_3, 418, &_0, &_1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&pool, "array_merge", &_6, 419, _2, _4, _5); zephir_check_call_status(); break; } while(0); end = (zephir_fast_count_int(pool TSRMLS_CC) - 1); while (1) { if (!(zephir_fast_strlen_ev(str) < length)) { break; } ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, end); zephir_array_fetch_long(&_7, pool, zephir_mt_rand(zephir_get_intval(&_0), zephir_get_intval(&_1) TSRMLS_CC), PH_NOISY | PH_READONLY, "phalcon/text.zep", 126 TSRMLS_CC); zephir_concat_self(&str, _7 TSRMLS_CC); } RETURN_CCTOR(str); } static PHP_METHOD(Phalcon_Text, startsWith) { zend_bool ignoreCase; zval *str_param = NULL, *start_param = NULL, *ignoreCase_param = NULL, _0; zval *str = NULL, *start = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &str_param, &start_param, &ignoreCase_param); zephir_get_strval(str, str_param); zephir_get_strval(start, start_param); if (!ignoreCase_param) { ignoreCase = 1; } else { ignoreCase = zephir_get_boolval(ignoreCase_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_BOOL(&_0, (ignoreCase ? 1 : 0)); RETURN_MM_BOOL(zephir_start_with(str, start, &_0)); } static PHP_METHOD(Phalcon_Text, endsWith) { zend_bool ignoreCase; zval *str_param = NULL, *end_param = NULL, *ignoreCase_param = NULL, _0; zval *str = NULL, *end = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &str_param, &end_param, &ignoreCase_param); zephir_get_strval(str, str_param); zephir_get_strval(end, end_param); if (!ignoreCase_param) { ignoreCase = 1; } else { ignoreCase = zephir_get_boolval(ignoreCase_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_BOOL(&_0, (ignoreCase ? 1 : 0)); RETURN_MM_BOOL(zephir_end_with(str, end, &_0)); } static PHP_METHOD(Phalcon_Text, lower) { int ZEPHIR_LAST_CALL_STATUS; zval *str_param = NULL, *encoding_param = NULL; zval *str = NULL, *encoding = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &str_param, &encoding_param); if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { ZEPHIR_INIT_VAR(str); ZVAL_EMPTY_STRING(str); } if (!encoding_param) { ZEPHIR_INIT_VAR(encoding); ZVAL_STRING(encoding, "UTF-8", 1); } else { if (unlikely(Z_TYPE_P(encoding_param) != IS_STRING && Z_TYPE_P(encoding_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoding' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(encoding_param) == IS_STRING)) { zephir_get_strval(encoding, encoding_param); } else { ZEPHIR_INIT_VAR(encoding); ZVAL_EMPTY_STRING(encoding); } } if ((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 195, str, encoding); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtolower(return_value, str); RETURN_MM(); } static PHP_METHOD(Phalcon_Text, upper) { int ZEPHIR_LAST_CALL_STATUS; zval *str_param = NULL, *encoding_param = NULL; zval *str = NULL, *encoding = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &str_param, &encoding_param); if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { ZEPHIR_INIT_VAR(str); ZVAL_EMPTY_STRING(str); } if (!encoding_param) { ZEPHIR_INIT_VAR(encoding); ZVAL_STRING(encoding, "UTF-8", 1); } else { if (unlikely(Z_TYPE_P(encoding_param) != IS_STRING && Z_TYPE_P(encoding_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoding' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(encoding_param) == IS_STRING)) { zephir_get_strval(encoding, encoding_param); } else { ZEPHIR_INIT_VAR(encoding); ZVAL_EMPTY_STRING(encoding); } } if ((zephir_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_strtoupper", NULL, 196, str, encoding); zephir_check_call_status(); RETURN_MM(); } zephir_fast_strtoupper(return_value, str); RETURN_MM(); } static PHP_METHOD(Phalcon_Text, reduceSlashes) { int ZEPHIR_LAST_CALL_STATUS; zval *str_param = NULL, *_0, *_1; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); zephir_get_strval(str, str_param); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "#(?<!:)//+#", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 29, _0, _1, str); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Text, concat) { HashTable *_6; HashPosition _5; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *separator = NULL, *a = NULL, *b = NULL, _0 = zval_used_for_init, *c = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, **_7, *_8 = NULL, *_9 = NULL, *_10 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_CALL_FUNCTION(&separator, "func_get_arg", &_1, 420, &_0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 1); ZEPHIR_CALL_FUNCTION(&a, "func_get_arg", &_1, 420, &_0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 2); ZEPHIR_CALL_FUNCTION(&b, "func_get_arg", &_1, 420, &_0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_2, "func_num_args", NULL, 421); zephir_check_call_status(); if (ZEPHIR_GT_LONG(_2, 3)) { ZEPHIR_CALL_FUNCTION(&_3, "func_get_args", NULL, 167); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 3); ZEPHIR_CALL_FUNCTION(&_4, "array_slice", NULL, 373, _3, &_0); zephir_check_call_status(); zephir_is_iterable(_4, &_6, &_5, 0, 0, "phalcon/text.zep", 242); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(c, _7); ZEPHIR_INIT_NVAR(_8); zephir_fast_trim(_8, b, separator, ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); zephir_fast_trim(_9, c, separator, ZEPHIR_TRIM_LEFT TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_VVV(_10, _8, separator, _9); ZEPHIR_CPY_WRT(b, _10); } } ZEPHIR_INIT_NVAR(_8); zephir_fast_trim(_8, a, separator, ZEPHIR_TRIM_RIGHT TSRMLS_CC); ZEPHIR_INIT_NVAR(_9); zephir_fast_trim(_9, b, separator, ZEPHIR_TRIM_LEFT TSRMLS_CC); ZEPHIR_CONCAT_VVV(return_value, _8, separator, _9); RETURN_MM(); } static PHP_METHOD(Phalcon_Text, dynamic) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL, *_7 = NULL; zval *text_param = NULL, *leftDelimiter_param = NULL, *rightDelimiter_param = NULL, *separator_param = NULL, *ldS = NULL, *rdS = NULL, *result = NULL, *pattern, *_0 = NULL, *_2 = NULL, *_3 = NULL, *_6 = NULL; zval *text = NULL, *leftDelimiter = NULL, *rightDelimiter = NULL, *separator = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &text_param, &leftDelimiter_param, &rightDelimiter_param, &separator_param); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!leftDelimiter_param) { ZEPHIR_INIT_VAR(leftDelimiter); ZVAL_STRING(leftDelimiter, "{", 1); } else { if (unlikely(Z_TYPE_P(leftDelimiter_param) != IS_STRING && Z_TYPE_P(leftDelimiter_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'leftDelimiter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(leftDelimiter_param) == IS_STRING)) { zephir_get_strval(leftDelimiter, leftDelimiter_param); } else { ZEPHIR_INIT_VAR(leftDelimiter); ZVAL_EMPTY_STRING(leftDelimiter); } } if (!rightDelimiter_param) { ZEPHIR_INIT_VAR(rightDelimiter); ZVAL_STRING(rightDelimiter, "}", 1); } else { if (unlikely(Z_TYPE_P(rightDelimiter_param) != IS_STRING && Z_TYPE_P(rightDelimiter_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'rightDelimiter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(rightDelimiter_param) == IS_STRING)) { zephir_get_strval(rightDelimiter, rightDelimiter_param); } else { ZEPHIR_INIT_VAR(rightDelimiter); ZVAL_EMPTY_STRING(rightDelimiter); } } if (!separator_param) { ZEPHIR_INIT_VAR(separator); ZVAL_STRING(separator, "|", 1); } else { if (unlikely(Z_TYPE_P(separator_param) != IS_STRING && Z_TYPE_P(separator_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'separator' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(separator_param) == IS_STRING)) { zephir_get_strval(separator, separator_param); } else { ZEPHIR_INIT_VAR(separator); ZVAL_EMPTY_STRING(separator); } } ZEPHIR_CALL_FUNCTION(&_0, "substr_count", &_1, 422, text, leftDelimiter); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_2, "substr_count", &_1, 422, text, rightDelimiter); zephir_check_call_status(); if (!ZEPHIR_IS_IDENTICAL(_0, _2)) { ZEPHIR_INIT_VAR(_3); object_init_ex(_3, spl_ce_RuntimeException); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVS(_4, "Syntax error in string \"", text, "\""); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 423, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/text.zep", 261 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_FUNCTION(&ldS, "preg_quote", &_5, 424, leftDelimiter); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&rdS, "preg_quote", &_5, 424, rightDelimiter); zephir_check_call_status(); ZEPHIR_INIT_VAR(pattern); ZEPHIR_CONCAT_SVSVVSVS(pattern, "/", ldS, "([^", ldS, rdS, "]+)", rdS, "/"); ZEPHIR_CPY_WRT(result, text); while (1) { if (!(zephir_memnstr(result, leftDelimiter, "phalcon/text.zep", 269))) { break; } ZEPHIR_INIT_NVAR(_3); ZEPHIR_INIT_NVAR(_3); zephir_create_closure_ex(_3, NULL, phalcon_0__closure_ce, SS("__invoke") TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_6, "preg_replace_callback", &_7, 425, pattern, _3, result); zephir_check_call_status(); ZEPHIR_CPY_WRT(result, _6); } RETURN_CCTOR(result); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate) { ZEPHIR_REGISTER_CLASS(Phalcon, Translate, phalcon, translate, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation) { ZEPHIR_REGISTER_CLASS_EX(Phalcon, Validation, phalcon, validation, phalcon_di_injectable_ce, phalcon_validation_method_entry, 0); zend_declare_property_null(phalcon_validation_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_entity"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_validators"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_defaultMessages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_labels"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_ce, SL("_values"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Validation, setValidators) { zval *validators; zephir_fetch_params(0, 1, 0, &validators); zephir_update_property_this(this_ptr, SL("_validators"), validators TSRMLS_CC); } static PHP_METHOD(Phalcon_Validation, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *validators_param = NULL; zval *validators = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &validators_param); if (!validators_param) { ZEPHIR_INIT_VAR(validators); array_init(validators); } else { zephir_get_arrval(validators, validators_param); } if (1 == 1) { zephir_update_property_this(this_ptr, SL("_validators"), validators TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultmessages", NULL, 0); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Validation, validate) { HashTable *_2; HashPosition _1; zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *entity = NULL, *validators, *messages = NULL, *scope = NULL, *field = NULL, *validator = NULL, *status = NULL, **_3, *_4 = NULL, *_5 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &entity); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(validators); zephir_read_property_this(&validators, this_ptr, SL("_validators"), PH_NOISY_CC); if (Z_TYPE_P(validators) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There are no validators to validate", "phalcon/validation.zep", 83); return; } zephir_update_property_this(this_ptr, SL("_values"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_VAR(messages); object_init_ex(messages, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, messages, "__construct", NULL, 3); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("beforevalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&status, this_ptr, "beforevalidation", NULL, 0, data, entity, messages); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_CCTOR(status); } } zephir_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC); _0 = Z_TYPE_P(data) == IS_ARRAY; if (!(_0)) { _0 = Z_TYPE_P(data) == IS_OBJECT; } if (_0) { zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); } zephir_is_iterable(validators, &_2, &_1, 0, 0, "phalcon/validation.zep", 138); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The validator scope is not valid", "phalcon/validation.zep", 115); return; } ZEPHIR_OBS_NVAR(field); zephir_array_fetch_long(&field, scope, 0, PH_NOISY, "phalcon/validation.zep", 118 TSRMLS_CC); ZEPHIR_OBS_NVAR(validator); zephir_array_fetch_long(&validator, scope, 1, PH_NOISY, "phalcon/validation.zep", 119 TSRMLS_CC); if (Z_TYPE_P(validator) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "One of the validators is not valid", "phalcon/validation.zep", 122); return; } ZEPHIR_CALL_METHOD(&_4, validator, "validate", NULL, 0, this_ptr, field); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "cancelOnFail", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, validator, "getoption", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (zephir_is_true(_5)) { break; } } } ZEPHIR_OBS_NVAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if ((zephir_method_exists_ex(this_ptr, SS("aftervalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, data, entity, messages); zephir_check_call_status(); } RETURN_CCTOR(messages); } static PHP_METHOD(Phalcon_Validation, add) { zval *_0; zval *field_param = NULL, *validator; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field_param, &validator); zephir_get_strval(field, field_param); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, field); zephir_array_fast_append(_0, validator); zephir_update_property_array_append(this_ptr, SL("_validators"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation, rule) { int ZEPHIR_LAST_CALL_STATUS; zval *field_param = NULL, *validator; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field_param, &validator); zephir_get_strval(field, field_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, field, validator); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Validation, rules) { HashTable *_1; HashPosition _0; zval *validators = NULL, *_3 = NULL; zval *field_param = NULL, *validators_param = NULL, *validator = NULL, **_2; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field_param, &validators_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } validators = validators_param; zephir_is_iterable(validators, &_1, &_0, 0, 0, "phalcon/validation.zep", 175); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(validator, _2); if (zephir_instance_of_ev(validator, phalcon_validation_validatorinterface_ce TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_fast_append(_3, field); zephir_array_fast_append(_3, validator); zephir_update_property_array_append(this_ptr, SL("_validators"), _3 TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation, setFilters) { zval *field_param = NULL, *filters; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &field_param, &filters); zephir_get_strval(field, field_param); zephir_update_property_array(this_ptr, SL("_filters"), field, filters TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation, getFilters) { zval *field_param = NULL, *filters, *fieldFilters; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &field_param); if (!field_param) { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } else { zephir_get_strval(field, field_param); } filters = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); if (1 == 0) { RETURN_CTOR(filters); } if (!(zephir_array_isset_fetch(&fieldFilters, filters, field, 1 TSRMLS_CC))) { RETURN_MM_NULL(); } RETURN_CTOR(fieldFilters); } static PHP_METHOD(Phalcon_Validation, getValidators) { RETURN_MEMBER(this_ptr, "_validators"); } static PHP_METHOD(Phalcon_Validation, getEntity) { RETURN_MEMBER(this_ptr, "_entity"); } static PHP_METHOD(Phalcon_Validation, setDefaultMessages) { zval *messages_param = NULL, *defaultMessages, *_0; zval *messages = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &messages_param); if (!messages_param) { ZEPHIR_INIT_VAR(messages); array_init(messages); } else { zephir_get_arrval(messages, messages_param); } ZEPHIR_INIT_VAR(defaultMessages); zephir_create_array(defaultMessages, 24, 0 TSRMLS_CC); add_assoc_stringl_ex(defaultMessages, SS("Alnum"), SL("Field :field must contain only letters and numbers"), 1); add_assoc_stringl_ex(defaultMessages, SS("Alpha"), SL("Field :field must contain only letters"), 1); add_assoc_stringl_ex(defaultMessages, SS("Between"), SL("Field :field must be within the range of :min to :max"), 1); add_assoc_stringl_ex(defaultMessages, SS("Confirmation"), SL("Field :field must be the same as :with"), 1); add_assoc_stringl_ex(defaultMessages, SS("Digit"), SL("Field :field must be numeric"), 1); add_assoc_stringl_ex(defaultMessages, SS("Email"), SL("Field :field must be an email address"), 1); add_assoc_stringl_ex(defaultMessages, SS("ExclusionIn"), SL("Field :field must not be a part of list: :domain"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileEmpty"), SL("Field :field must not be empty"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileIniSize"), SL("File :field exceeds the maximum file size"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileMaxResolution"), SL("File :field must not exceed :max resolution"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileMinResolution"), SL("File :field must be at least :min resolution"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileSize"), SL("File :field exceeds the size of :max"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileType"), SL("File :field must be of type: :types"), 1); add_assoc_stringl_ex(defaultMessages, SS("FileValid"), SL("Field :field is not valid"), 1); add_assoc_stringl_ex(defaultMessages, SS("Identical"), SL("Field :field does not have the expected value"), 1); add_assoc_stringl_ex(defaultMessages, SS("InclusionIn"), SL("Field :field must be a part of list: :domain"), 1); add_assoc_stringl_ex(defaultMessages, SS("Numericality"), SL("Field :field does not have a valid numeric format"), 1); add_assoc_stringl_ex(defaultMessages, SS("PresenceOf"), SL("Field :field is required"), 1); add_assoc_stringl_ex(defaultMessages, SS("Regex"), SL("Field :field does not match the required format"), 1); add_assoc_stringl_ex(defaultMessages, SS("TooLong"), SL("Field :field must not exceed :max characters long"), 1); add_assoc_stringl_ex(defaultMessages, SS("TooShort"), SL("Field :field must be at least :min characters long"), 1); add_assoc_stringl_ex(defaultMessages, SS("Uniqueness"), SL("Field :field must be unique"), 1); add_assoc_stringl_ex(defaultMessages, SS("Url"), SL("Field :field must be a url"), 1); add_assoc_stringl_ex(defaultMessages, SS("CreditCard"), SL("Field :field is not valid for a credit card number"), 1); ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(defaultMessages), &(messages) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_defaultMessages"), _0 TSRMLS_CC); RETURN_MM_MEMBER(this_ptr, "_defaultMessages"); } static PHP_METHOD(Phalcon_Validation, getDefaultMessage) { zval *type_param = NULL, *_0, *_1, *_2; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultMessages"), PH_NOISY_CC); if (!(zephir_array_isset(_0, type))) { RETURN_MM_STRING("", 1); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultMessages"), PH_NOISY_CC); zephir_array_fetch(&_2, _1, type, PH_NOISY | PH_READONLY, "phalcon/validation.zep", 279 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Validation, getMessages) { RETURN_MEMBER(this_ptr, "_messages"); } static PHP_METHOD(Phalcon_Validation, setLabels) { zval *labels_param = NULL; zval *labels = NULL; zephir_fetch_params(0, 1, 0, &labels_param); labels = labels_param; zephir_update_property_this(this_ptr, SL("_labels"), labels TSRMLS_CC); } static PHP_METHOD(Phalcon_Validation, getLabel) { zval *field_param = NULL, *labels, *value; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } labels = zephir_fetch_nproperty_this(this_ptr, SL("_labels"), PH_NOISY_CC); if (Z_TYPE_P(labels) == IS_ARRAY) { if (zephir_array_isset_fetch(&value, labels, field, 1 TSRMLS_CC)) { RETURN_CTOR(value); } } RETURN_CTOR(field); } static PHP_METHOD(Phalcon_Validation, appendMessage) { int ZEPHIR_LAST_CALL_STATUS; zval *message, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "appendmessage", NULL, 0, message); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation, bind) { zend_bool _0; zval *entity, *data; zephir_fetch_params(0, 2, 0, &entity, &data); if (Z_TYPE_P(entity) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_validation_exception_ce, "Entity must be an object", "phalcon/validation.zep", 336); return; } _0 = Z_TYPE_P(data) != IS_ARRAY; if (_0) { _0 = Z_TYPE_P(data) != IS_OBJECT; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_validation_exception_ce, "Data to validate must be an array or object", "phalcon/validation.zep", 340); return; } zephir_update_property_this(this_ptr, SL("_entity"), entity TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Validation, getValue) { zephir_fcall_cache_entry *_2 = NULL; zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *field_param = NULL, *entity, *method = NULL, *value = NULL, *data, *values, *filters, *fieldFilters, *dependencyInjector = NULL, *filterService = NULL, *_3; zval *field = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); zephir_get_strval(field, field_param); ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "get", field); ZEPHIR_CPY_WRT(method, _0); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&value, entity, method, NULL, 0); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&value, entity, "readattribute", NULL, 0, field); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(value); if (zephir_isset_property_zval(entity, field TSRMLS_CC)) { zephir_read_property_zval(&value, entity, field, PH_NOISY_CC); } else { ZVAL_NULL(value); } } } RETURN_CCTOR(value); } ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); _1 = Z_TYPE_P(data) != IS_ARRAY; if (_1) { _1 = Z_TYPE_P(data) != IS_OBJECT; } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There is no data to validate", "phalcon/validation.zep", 387); return; } ZEPHIR_OBS_VAR(values); zephir_read_property_this(&values, this_ptr, SL("_values"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, values, field, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); if (Z_TYPE_P(data) == IS_ARRAY) { if (zephir_array_isset(data, field)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, data, field, PH_NOISY, "phalcon/validation.zep", 401 TSRMLS_CC); } } else if (Z_TYPE_P(data) == IS_OBJECT) { if (zephir_isset_property_zval(data, field TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_read_property_zval(&value, data, field, PH_NOISY_CC); } } if (Z_TYPE_P(value) == IS_NULL) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(filters); zephir_read_property_this(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); if (Z_TYPE_P(filters) == IS_ARRAY) { ZEPHIR_OBS_VAR(fieldFilters); if (zephir_array_isset_fetch(&fieldFilters, filters, field, 0 TSRMLS_CC)) { if (zephir_is_true(fieldFilters)) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_2, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A dependency injector is required to obtain the 'filter' service", "phalcon/validation.zep", 424); return; } } ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&filterService, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(filterService) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Returned 'filter' service is invalid", "phalcon/validation.zep", 430); return; } ZEPHIR_RETURN_CALL_METHOD(filterService, "sanitize", NULL, 0, value, fieldFilters); zephir_check_call_status(); RETURN_MM(); } } } zephir_update_property_array(this_ptr, SL("_values"), field, value TSRMLS_CC); RETURN_CCTOR(value); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Version) { ZEPHIR_REGISTER_CLASS(Phalcon, Version, phalcon, version, phalcon_version_method_entry, 0); zend_declare_class_constant_long(phalcon_version_ce, SL("VERSION_MAJOR"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_version_ce, SL("VERSION_MEDIUM"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_version_ce, SL("VERSION_MINOR"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_version_ce, SL("VERSION_SPECIAL"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_version_ce, SL("VERSION_SPECIAL_NUMBER"), 4 TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Version, _getVersion) { zval *_0 = NULL; ZEPHIR_MM_GROW(); zephir_create_array(return_value, 5, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 8); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 4); zephir_array_fast_append(return_value, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_fast_append(return_value, _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Version, _getSpecial) { zval *special_param = NULL, *suffix = NULL; int special; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &special_param); special = zephir_get_intval(special_param); ZEPHIR_INIT_VAR(suffix); ZVAL_STRING(suffix, "", 1); do { if (special == 1) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "ALPHA", 1); break; } if (special == 2) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "BETA", 1); break; } if (special == 3) { ZEPHIR_INIT_NVAR(suffix); ZVAL_STRING(suffix, "RC", 1); break; } } while(0); RETURN_CCTOR(suffix); } static PHP_METHOD(Phalcon_Version, get) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *version = NULL, *major, *medium, *minor, *special, *specialNumber, *result, *suffix = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_STATIC(&version, "_getversion", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(major); zephir_array_fetch_long(&major, version, 0, PH_NOISY, "phalcon/version.zep", 124 TSRMLS_CC); ZEPHIR_OBS_VAR(medium); zephir_array_fetch_long(&medium, version, 1, PH_NOISY, "phalcon/version.zep", 125 TSRMLS_CC); ZEPHIR_OBS_VAR(minor); zephir_array_fetch_long(&minor, version, 2, PH_NOISY, "phalcon/version.zep", 126 TSRMLS_CC); ZEPHIR_OBS_VAR(special); zephir_array_fetch_long(&special, version, 3, PH_NOISY, "phalcon/version.zep", 127 TSRMLS_CC); ZEPHIR_OBS_VAR(specialNumber); zephir_array_fetch_long(&specialNumber, version, 4, PH_NOISY, "phalcon/version.zep", 128 TSRMLS_CC); ZEPHIR_INIT_VAR(result); ZEPHIR_CONCAT_VSVSVS(result, major, ".", medium, ".", minor, " "); ZEPHIR_CALL_STATIC(&suffix, "_getspecial", &_0, 444, special); zephir_check_call_status(); if (!ZEPHIR_IS_STRING(suffix, "")) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, suffix, " ", specialNumber); zephir_concat_self(&result, _1 TSRMLS_CC); } zephir_fast_trim(return_value, result, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Version, getId) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *version = NULL, *major, *medium, *minor, *special, *specialNumber, _0 = zval_used_for_init, *_1 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_STATIC(&version, "_getversion", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(major); zephir_array_fetch_long(&major, version, 0, PH_NOISY, "phalcon/version.zep", 154 TSRMLS_CC); ZEPHIR_OBS_VAR(medium); zephir_array_fetch_long(&medium, version, 1, PH_NOISY, "phalcon/version.zep", 155 TSRMLS_CC); ZEPHIR_OBS_VAR(minor); zephir_array_fetch_long(&minor, version, 2, PH_NOISY, "phalcon/version.zep", 156 TSRMLS_CC); ZEPHIR_OBS_VAR(special); zephir_array_fetch_long(&special, version, 3, PH_NOISY, "phalcon/version.zep", 157 TSRMLS_CC); ZEPHIR_OBS_VAR(specialNumber); zephir_array_fetch_long(&specialNumber, version, 4, PH_NOISY, "phalcon/version.zep", 158 TSRMLS_CC); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "%02s", 0); ZEPHIR_CALL_FUNCTION(&_1, "sprintf", &_2, 188, &_0, medium); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "%02s", 0); ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_2, 188, &_0, minor); zephir_check_call_status(); ZEPHIR_CONCAT_VVVVV(return_value, major, _1, _3, special, specialNumber); RETURN_MM(); } static PHP_METHOD(Phalcon_Version, getPart) { zephir_fcall_cache_entry *_0 = NULL; zval *part_param = NULL, *version = NULL, *result = NULL, *_1; int part, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &part_param); part = zephir_get_intval(part_param); ZEPHIR_CALL_STATIC(&version, "_getversion", NULL, 0); zephir_check_call_status(); do { if (part == 0 || part == 1 || part == 2 || part == 4) { ZEPHIR_OBS_VAR(result); zephir_array_fetch_long(&result, version, part, PH_NOISY, "phalcon/version.zep", 183 TSRMLS_CC); break; } if (part == 3) { zephir_array_fetch_long(&_1, version, 3, PH_NOISY | PH_READONLY, "phalcon/version.zep", 187 TSRMLS_CC); ZEPHIR_CALL_STATIC(&result, "_getspecial", &_0, 444, _1); zephir_check_call_status(); break; } ZEPHIR_CALL_STATIC(&result, "get", NULL, 0); zephir_check_call_status(); break; } while(0); RETURN_CCTOR(result); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Acl, Adapter, phalcon, acl_adapter, phalcon_acl_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_acl_adapter_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_acl_adapter_ce, SL("_defaultAccess"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_acl_adapter_ce, SL("_accessGranted"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_ce, SL("_activeRole"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_ce, SL("_activeResource"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_ce, SL("_activeAccess"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_acl_adapter_ce TSRMLS_CC, 1, phalcon_acl_adapterinterface_ce); zend_class_implements(phalcon_acl_adapter_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Acl_Adapter, getActiveRole) { RETURN_MEMBER(this_ptr, "_activeRole"); } static PHP_METHOD(Phalcon_Acl_Adapter, getActiveResource) { RETURN_MEMBER(this_ptr, "_activeResource"); } static PHP_METHOD(Phalcon_Acl_Adapter, getActiveAccess) { RETURN_MEMBER(this_ptr, "_activeAccess"); } static PHP_METHOD(Phalcon_Acl_Adapter, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Acl_Adapter, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Acl_Adapter, setDefaultAction) { zval *defaultAccess_param = NULL, *_0; int defaultAccess; zephir_fetch_params(0, 1, 0, &defaultAccess_param); defaultAccess = zephir_get_intval(defaultAccess_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, defaultAccess); zephir_update_property_this(this_ptr, SL("_defaultAccess"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Acl_Adapter, getDefaultAction) { RETURN_MEMBER(this_ptr, "_defaultAccess"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Acl, AdapterInterface, phalcon, acl_adapterinterface, phalcon_acl_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, setDefaultAction); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getDefaultAction); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, addRole); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, addInherit); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, isRole); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, isResource); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, addResource); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, addResourceAccess); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, dropResourceAccess); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, allow); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, deny); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, isAllowed); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getActiveRole); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getActiveResource); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getActiveAccess); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getRoles); ZEPHIR_DOC_METHOD(Phalcon_Acl_AdapterInterface, getResources); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Acl, Exception, phalcon, acl_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_Resource) { ZEPHIR_REGISTER_CLASS(Phalcon\\Acl, Resource, phalcon, acl_resource, phalcon_acl_resource_method_entry, 0); zend_declare_property_null(phalcon_acl_resource_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_resource_ce, SL("_description"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Acl_Resource, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Acl_Resource, __toString) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Acl_Resource, getDescription) { RETURN_MEMBER(this_ptr, "_description"); } static PHP_METHOD(Phalcon_Acl_Resource, __construct) { zval *name_param = NULL, *description_param = NULL; zval *name = NULL, *description = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &description_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!description_param) { ZEPHIR_INIT_VAR(description); ZVAL_EMPTY_STRING(description); } else { zephir_get_strval(description, description_param); } if (ZEPHIR_IS_STRING(name, "*")) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Resource name cannot be '*'", "phalcon/acl/resource.zep", 50); return; } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); if (!(!description) && Z_STRLEN_P(description)) { zephir_update_property_this(this_ptr, SL("_description"), description TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_ResourceInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Acl, ResourceInterface, phalcon, acl_resourceinterface, phalcon_acl_resourceinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Acl_ResourceInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Acl_ResourceInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Acl_ResourceInterface, getDescription); ZEPHIR_DOC_METHOD(Phalcon_Acl_ResourceInterface, __toString); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_Role) { ZEPHIR_REGISTER_CLASS(Phalcon\\Acl, Role, phalcon, acl_role, phalcon_acl_role_method_entry, 0); zend_declare_property_null(phalcon_acl_role_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_role_ce, SL("_description"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_acl_role_ce TSRMLS_CC, 1, phalcon_acl_roleinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Acl_Role, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Acl_Role, __toString) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Acl_Role, getDescription) { RETURN_MEMBER(this_ptr, "_description"); } static PHP_METHOD(Phalcon_Acl_Role, __construct) { zval *name_param = NULL, *description_param = NULL; zval *name = NULL, *description = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &description_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!description_param) { ZEPHIR_INIT_VAR(description); ZVAL_EMPTY_STRING(description); } else { zephir_get_strval(description, description_param); } if (ZEPHIR_IS_STRING(name, "*")) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Role name cannot be '*'", "phalcon/acl/role.zep", 49); return; } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); if (!(!description) && Z_STRLEN_P(description)) { zephir_update_property_this(this_ptr, SL("_description"), description TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_RoleInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Acl, RoleInterface, phalcon, acl_roleinterface, phalcon_acl_roleinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Acl_RoleInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Acl_RoleInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Acl_RoleInterface, getDescription); ZEPHIR_DOC_METHOD(Phalcon_Acl_RoleInterface, __toString); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Acl_Adapter_Memory) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Acl\\Adapter, Memory, phalcon, acl_adapter_memory, phalcon_acl_adapter_ce, phalcon_acl_adapter_memory_method_entry, 0); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_rolesNames"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_roles"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_resourcesNames"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_resources"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_access"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_roleInherits"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_acl_adapter_memory_ce, SL("_accessList"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, __construct) { zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); zephir_array_update_string(&_0, SL("*"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_resourcesNames"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL("*!*"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_accessList"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole) { int ZEPHIR_LAST_CALL_STATUS; zval *role, *accessInherits = NULL, *roleName = NULL, *roleObject = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &role, &accessInherits); if (!accessInherits) { accessInherits = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(role) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&roleName, role, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(roleObject, role); } else { ZEPHIR_CPY_WRT(roleName, role); ZEPHIR_INIT_NVAR(roleObject); object_init_ex(roleObject, phalcon_acl_role_ce); ZEPHIR_CALL_METHOD(NULL, roleObject, "__construct", NULL, 79, role); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (zephir_array_isset(_0, roleName)) { RETURN_MM_BOOL(0); } zephir_update_property_array_append(this_ptr, SL("_roles"), roleObject TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_rolesNames"), roleName, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VS(_2, roleName, "!*!*"); zephir_update_property_array(this_ptr, SL("_access"), _2, _1 TSRMLS_CC); if (Z_TYPE_P(accessInherits) != IS_NULL) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addinherit", NULL, 0, roleName, accessInherits); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, addInherit) { zephir_fcall_cache_entry *_8 = NULL; HashTable *_6; HashPosition _5; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *roleToInherit, *roleInheritName = NULL, *rolesNames, *deepInheritName = NULL, *_0 = NULL, *_2, *_3, *_4, **_7, *_9; zval *roleName = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &roleName_param, &roleToInherit); zephir_get_strval(roleName, roleName_param); ZEPHIR_OBS_VAR(rolesNames); zephir_read_property_this(&rolesNames, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(rolesNames, roleName))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Role '", roleName, "' does not exist in the role list"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/acl/adapter/memory.zep", 194 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(roleToInherit) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&roleInheritName, roleToInherit, "getname", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(roleInheritName, roleToInherit); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); if (zephir_array_isset(_2, roleInheritName)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); zephir_array_fetch(&_4, _3, roleInheritName, PH_NOISY | PH_READONLY, "phalcon/acl/adapter/memory.zep", 207 TSRMLS_CC); zephir_is_iterable(_4, &_6, &_5, 0, 0, "phalcon/acl/adapter/memory.zep", 210); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(deepInheritName, _7); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinherit", &_8, 80, roleName, deepInheritName); zephir_check_call_status(); } } if (!(zephir_array_isset(rolesNames, roleInheritName))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_9); ZEPHIR_CONCAT_SVS(_9, "Role '", roleInheritName, "' (to inherit) does not exist in the role list"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _9); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/acl/adapter/memory.zep", 216 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (ZEPHIR_IS_EQUAL(roleName, roleInheritName)) { RETURN_MM_BOOL(0); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_roleInherits"), PH_NOISY_CC); if (!(zephir_array_isset(_3, roleName))) { zephir_update_property_array(this_ptr, SL("_roleInherits"), roleName, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } zephir_update_property_array_multi(this_ptr, SL("_roleInherits"), &roleInheritName TSRMLS_CC, SL("za"), 2, roleName); RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, isRole) { zval *roleName_param = NULL, *_0; zval *roleName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &roleName_param); zephir_get_strval(roleName, roleName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, roleName)); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, isResource) { zval *resourceName_param = NULL, *_0; zval *resourceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &resourceName_param); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, resourceName)); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResource) { int ZEPHIR_LAST_CALL_STATUS; zval *resourceValue, *accessList, *resourceName = NULL, *resourceObject = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &resourceValue, &accessList); if (Z_TYPE_P(resourceValue) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&resourceName, resourceValue, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(resourceObject, resourceValue); } else { ZEPHIR_CPY_WRT(resourceName, resourceValue); ZEPHIR_INIT_NVAR(resourceObject); object_init_ex(resourceObject, phalcon_acl_resource_ce); ZEPHIR_CALL_METHOD(NULL, resourceObject, "__construct", NULL, 81, resourceName); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, resourceName))) { zephir_update_property_array_append(this_ptr, SL("_resources"), resourceObject TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_resourcesNames"), resourceName, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addresourceaccess", NULL, 0, resourceName, accessList); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess) { HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zend_bool exists, _3; zval *resourceName_param = NULL, *accessList, *accessName = NULL, *accessKey = NULL, *_0, *_1 = NULL, **_6; zval *resourceName = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &resourceName_param, &accessList); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, resourceName))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 298 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = Z_TYPE_P(accessList) != IS_ARRAY; if (_3) { _3 = Z_TYPE_P(accessList) != IS_STRING; } if (_3) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Invalid value for accessList", "phalcon/acl/adapter/memory.zep", 302); return; } exists = 1; if (Z_TYPE_P(accessList) == IS_ARRAY) { zephir_is_iterable(accessList, &_5, &_4, 0, 0, "phalcon/acl/adapter/memory.zep", 313); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(accessName, _6); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _1 TSRMLS_CC); } } } else { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessList); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, exists); zephir_update_property_array(this_ptr, SL("_accessList"), accessKey, _1 TSRMLS_CC); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, dropResourceAccess) { HashTable *_1; HashPosition _0; zval *resourceName_param = NULL, *accessList, *accessName = NULL, *accessKey = NULL, **_2, *_3; zval *resourceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &resourceName_param, &accessList); zephir_get_strval(resourceName, resourceName_param); if (Z_TYPE_P(accessList) == IS_ARRAY) { zephir_is_iterable(accessList, &_1, &_0, 0, 0, "phalcon/acl/adapter/memory.zep", 339); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(accessName, _2); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (zephir_array_isset(accessList, accessKey)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_accessList"), PH_NOISY_CC); zephir_array_unset(&_3, accessKey, PH_SEPARATE); } } } else { if (Z_TYPE_P(accessList) == IS_STRING) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (zephir_array_isset(accessList, accessKey)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_accessList"), PH_NOISY_CC); zephir_array_unset(&_3, accessKey, PH_SEPARATE); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, _allowOrDeny) { HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access, *action, *defaultAccess, *accessList, *accessName = NULL, *accessKey = NULL, *accessKeyAll = NULL, *internalAccess, *_0, *_1 = NULL, *_3, **_6, *_7 = NULL, **_10, *_11; zval *roleName = NULL, *resourceName = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &roleName_param, &resourceName_param, &access, &action); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_0, roleName))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Role '", roleName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 357 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!(zephir_array_isset(_3, resourceName))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource '", resourceName, "' does not exist in ACL"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 361 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(defaultAccess); zephir_read_property_this(&defaultAccess, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); ZEPHIR_OBS_VAR(accessList); zephir_read_property_this(&accessList, this_ptr, SL("_accessList"), PH_NOISY_CC); ZEPHIR_OBS_VAR(internalAccess); zephir_read_property_this(&internalAccess, this_ptr, SL("_access"), PH_NOISY_CC); if (Z_TYPE_P(access) == IS_ARRAY) { zephir_is_iterable(access, &_5, &_4, 0, 0, "phalcon/acl/adapter/memory.zep", 377); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(accessName, _6); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", accessName); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "Access '", accessName, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 373 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_is_iterable(access, &_9, &_8, 0, 0, "phalcon/acl/adapter/memory.zep", 390); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HVALUE(accessName, _10); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", accessName); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (!ZEPHIR_IS_STRING(accessName, "*")) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VSVS(_2, roleName, "!", resourceName, "!*"); ZEPHIR_CPY_WRT(accessKeyAll, _2); if (zephir_array_isset(internalAccess, accessKeyAll)) { zephir_update_property_array(this_ptr, SL("_access"), accessKeyAll, defaultAccess TSRMLS_CC); } } } } else { if (!ZEPHIR_IS_STRING(access, "*")) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSV(accessKey, resourceName, "!", access); if (!(zephir_array_isset(accessList, accessKey))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_acl_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "Access '", access, "' does not exist in resource '", resourceName, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/acl/adapter/memory.zep", 395 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", access); zephir_update_property_array(this_ptr, SL("_access"), accessKey, action TSRMLS_CC); if (!ZEPHIR_IS_STRING(access, "*")) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VSVS(_2, roleName, "!", resourceName, "!*"); ZEPHIR_CPY_WRT(accessKey, _2); if (!(zephir_array_isset(internalAccess, accessKey))) { _11 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); zephir_update_property_array(this_ptr, SL("_access"), accessKey, _11 TSRMLS_CC); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, allow) { HashTable *_4; HashPosition _3; zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access, *innerRoleName = NULL, *_0 = NULL, *_2, **_5, *_6 = NULL; zval *roleName = NULL, *resourceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &roleName_param, &resourceName_param, &access); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); if (!ZEPHIR_IS_STRING(roleName, "*")) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_allowordeny", &_1, 0, roleName, resourceName, access, _0); zephir_check_call_status(); RETURN_MM(); } else { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_0); zephir_is_iterable(_2, &_4, &_3, 0, 0, "phalcon/acl/adapter/memory.zep", 451); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(innerRoleName, _4, _3); ZEPHIR_GET_HVALUE(_0, _5); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_allowordeny", &_1, 0, innerRoleName, resourceName, access, _6); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, deny) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access, *innerRoleName = NULL, *_0 = NULL, *_1, **_4, *_5 = NULL; zval *roleName = NULL, *resourceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &roleName_param, &resourceName_param, &access); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); if (!ZEPHIR_IS_STRING(roleName, "*")) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_allowordeny", NULL, 0, roleName, resourceName, access, _0); zephir_check_call_status(); RETURN_MM(); } else { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_0); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/acl/adapter/memory.zep", 484); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(innerRoleName, _3, _2); ZEPHIR_GET_HVALUE(_0, _4); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_allowordeny", NULL, 0, innerRoleName, resourceName, access, _5); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, isAllowed) { HashTable *_5, *_8, *_11; HashPosition _4, _7, _10; int ZEPHIR_LAST_CALL_STATUS; zval *roleName_param = NULL, *resourceName_param = NULL, *access_param = NULL, *eventsManager = NULL, *accessList, *accessKey = NULL, *haveAccess = NULL, *roleInherits, *inheritedRole = NULL, *rolesNames, *inheritedRoles, *_0, *_1 = NULL, *_2 = NULL, **_6, **_9, **_12; zval *roleName = NULL, *resourceName = NULL, *access = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &roleName_param, &resourceName_param, &access_param); zephir_get_strval(roleName, roleName_param); zephir_get_strval(resourceName, resourceName_param); zephir_get_strval(access, access_param); ZEPHIR_INIT_VAR(haveAccess); ZVAL_NULL(haveAccess); zephir_update_property_this(this_ptr, SL("_activeRole"), roleName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeResource"), resourceName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeAccess"), access TSRMLS_CC); ZEPHIR_OBS_VAR(accessList); zephir_read_property_this(&accessList, this_ptr, SL("_access"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "acl:beforeCheckAccess", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_VAR(rolesNames); zephir_read_property_this(&rolesNames, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(rolesNames, roleName))) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); RETURN_MM_BOOL((ZEPHIR_IS_LONG(_0, 1))); } ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VSVSV(_3, roleName, "!", resourceName, "!", access); ZEPHIR_CPY_WRT(accessKey, _3); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 530 TSRMLS_CC); } if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_OBS_VAR(roleInherits); zephir_read_property_this(&roleInherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); ZEPHIR_OBS_VAR(inheritedRoles); if (zephir_array_isset_fetch(&inheritedRoles, roleInherits, roleName, 0 TSRMLS_CC)) { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_5, &_4, 0, 0, "phalcon/acl/adapter/memory.zep", 551); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(inheritedRole, _6); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, inheritedRole, "!", resourceName, "!", access); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 548 TSRMLS_CC); } } } } } if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSVS(_3, roleName, "!", resourceName, "!*"); ZEPHIR_CPY_WRT(accessKey, _3); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 566 TSRMLS_CC); } else { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_8, &_7, 0, 0, "phalcon/acl/adapter/memory.zep", 580); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(inheritedRole, _9); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVS(accessKey, inheritedRole, "!", resourceName, "!*"); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 576 TSRMLS_CC); break; } } } } } if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VS(_3, roleName, "!*!*"); ZEPHIR_CPY_WRT(accessKey, _3); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 595 TSRMLS_CC); } else { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_11, &_10, 0, 0, "phalcon/acl/adapter/memory.zep", 609); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HVALUE(inheritedRole, _12); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VS(accessKey, inheritedRole, "!*!*"); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 605 TSRMLS_CC); break; } } } } } zephir_update_property_this(this_ptr, SL("_accessGranted"), haveAccess TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "acl:afterCheckAccess", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } if (Z_TYPE_P(haveAccess) == IS_NULL) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL((ZEPHIR_IS_LONG(haveAccess, 1))); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, getRoles) { RETURN_MEMBER(this_ptr, "_roles"); } static PHP_METHOD(Phalcon_Acl_Adapter_Memory, getResources) { RETURN_MEMBER(this_ptr, "_resources"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Adapter, phalcon, annotations_adapter, phalcon_annotations_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_annotations_adapter_ce, SL("_reader"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_adapter_ce, SL("_annotations"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Adapter, setReader) { zval *reader; zephir_fetch_params(0, 1, 0, &reader); zephir_update_property_this(this_ptr, SL("_reader"), reader TSRMLS_CC); } static PHP_METHOD(Phalcon_Annotations_Adapter, getReader) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_reader"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_annotations_reader_ce); if (zephir_has_constructor(_1 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_reader"), _1 TSRMLS_CC); } RETURN_MM_MEMBER(this_ptr, "_reader"); } static PHP_METHOD(Phalcon_Annotations_Adapter, get) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *className, *annotations, *classAnnotations = NULL, *parsedAnnotations = NULL, *realClassName = NULL, *reader = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className); if (Z_TYPE_P(className) == IS_OBJECT) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class(realClassName, className, 0 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(realClassName, className); } ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_annotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) == IS_ARRAY) { if (zephir_array_isset(annotations, realClassName)) { zephir_array_fetch(&_0, annotations, realClassName, PH_NOISY | PH_READONLY, "phalcon/annotations/adapter.zep", 80 TSRMLS_CC); RETURN_CTOR(_0); } } ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "read", NULL, 0, realClassName); zephir_check_call_status(); _1 = Z_TYPE_P(classAnnotations) == IS_NULL; if (!(_1)) { _1 = ZEPHIR_IS_FALSE_IDENTICAL(classAnnotations); } if (_1) { ZEPHIR_CALL_METHOD(&reader, this_ptr, "getreader", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&parsedAnnotations, reader, "parse", NULL, 0, realClassName); zephir_check_call_status(); if (Z_TYPE_P(parsedAnnotations) == IS_ARRAY) { ZEPHIR_INIT_NVAR(classAnnotations); object_init_ex(classAnnotations, phalcon_annotations_reflection_ce); ZEPHIR_CALL_METHOD(NULL, classAnnotations, "__construct", NULL, 18, parsedAnnotations); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_annotations"), realClassName, classAnnotations TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, realClassName, classAnnotations); zephir_check_call_status(); } } RETURN_CCTOR(classAnnotations); } static PHP_METHOD(Phalcon_Annotations_Adapter, getMethods) { int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *classAnnotations = NULL; zval *className = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className_param); zephir_get_strval(className, className_param); ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_RETURN_CALL_METHOD(classAnnotations, "getmethodsannotations", NULL, 0); zephir_check_call_status(); RETURN_MM(); } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Annotations_Adapter, getMethod) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *methodName_param = NULL, *classAnnotations = NULL, *methods = NULL, *method = NULL, *methodKey = NULL, **_2, *_3 = NULL; zval *className = NULL, *methodName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &className_param, &methodName_param); zephir_get_strval(className, className_param); zephir_get_strval(methodName, methodName_param); ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&methods, classAnnotations, "getmethodsannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_ARRAY) { zephir_is_iterable(methods, &_1, &_0, 0, 0, "phalcon/annotations/adapter.zep", 154); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(methodKey, _1, _0); ZEPHIR_GET_HVALUE(method, _2); ZEPHIR_CALL_FUNCTION(&_3, "strcasecmp", &_4, 19, methodKey, methodName); zephir_check_call_status(); if (!(zephir_is_true(_3))) { RETURN_CCTOR(method); } } } } object_init_ex(return_value, phalcon_annotations_collection_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 20); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Annotations_Adapter, getProperties) { int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *classAnnotations = NULL; zval *className = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className_param); zephir_get_strval(className, className_param); ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_RETURN_CALL_METHOD(classAnnotations, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); RETURN_MM(); } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Annotations_Adapter, getProperty) { int ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *propertyName_param = NULL, *classAnnotations = NULL, *properties = NULL, *property; zval *className = NULL, *propertyName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &className_param, &propertyName_param); zephir_get_strval(className, className_param); zephir_get_strval(propertyName, propertyName_param); ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&properties, classAnnotations, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(properties) == IS_ARRAY) { if (zephir_array_isset_fetch(&property, properties, propertyName, 1 TSRMLS_CC)) { RETURN_CTOR(property); } } } object_init_ex(return_value, phalcon_annotations_collection_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 20); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations, AdapterInterface, phalcon, annotations_adapterinterface, phalcon_annotations_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, setReader); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, getReader); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, getMethods); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, getMethod); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, getProperties); ZEPHIR_DOC_METHOD(Phalcon_Annotations_AdapterInterface, getProperty); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Annotation) { ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Annotation, phalcon, annotations_annotation, phalcon_annotations_annotation_method_entry, 0); zend_declare_property_null(phalcon_annotations_annotation_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_annotation_ce, SL("_arguments"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_annotation_ce, SL("_exprArguments"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Annotation, __construct) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *reflectionData_param = NULL, *name, *exprArguments, *argument = NULL, *resolvedArgument = NULL, *arguments, *_0, **_3, *_4; zval *reflectionData = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &reflectionData_param); reflectionData = reflectionData_param; zephir_array_fetch_string(&_0, reflectionData, SL("name"), PH_NOISY | PH_READONLY, "phalcon/annotations/annotation.zep", 58 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_name"), _0 TSRMLS_CC); ZEPHIR_OBS_VAR(exprArguments); if (zephir_array_isset_string_fetch(&exprArguments, reflectionData, SS("arguments"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); zephir_is_iterable(exprArguments, &_2, &_1, 0, 0, "phalcon/annotations/annotation.zep", 73); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(argument, _3); zephir_array_fetch_string(&_4, argument, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/annotations/annotation.zep", 66 TSRMLS_CC); ZEPHIR_CALL_METHOD(&resolvedArgument, this_ptr, "getexpression", &_5, 0, _4); zephir_check_call_status(); if (zephir_array_isset_string_fetch(&name, argument, SS("name"), 1 TSRMLS_CC)) { zephir_array_update_zval(&arguments, name, &resolvedArgument, PH_COPY | PH_SEPARATE); } else { zephir_array_append(&arguments, resolvedArgument, PH_SEPARATE, "phalcon/annotations/annotation.zep", 70); } } zephir_update_property_this(this_ptr, SL("_arguments"), arguments TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_exprArguments"), exprArguments TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Annotations_Annotation, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Annotations_Annotation, getExpression) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *expr_param = NULL, *value = NULL, *item = NULL, *resolvedItem = NULL, *arrayValue, *name = NULL, *type, *_0, **_3, *_4, *_6, *_7; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_OBS_VAR(type); zephir_array_fetch_string(&type, expr, SL("type"), PH_NOISY, "phalcon/annotations/annotation.zep", 96 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(type, 301) || ZEPHIR_IS_LONG(type, 302) || ZEPHIR_IS_LONG(type, 303) || ZEPHIR_IS_LONG(type, 307)) { ZEPHIR_OBS_VAR(value); zephir_array_fetch_string(&value, expr, SL("value"), PH_NOISY, "phalcon/annotations/annotation.zep", 103 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 304)) { ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); break; } if (ZEPHIR_IS_LONG(type, 305)) { ZEPHIR_INIT_NVAR(value); ZVAL_BOOL(value, 0); break; } if (ZEPHIR_IS_LONG(type, 306)) { ZEPHIR_INIT_NVAR(value); ZVAL_BOOL(value, 1); break; } if (ZEPHIR_IS_LONG(type, 308)) { ZEPHIR_INIT_VAR(arrayValue); array_init(arrayValue); zephir_array_fetch_string(&_0, expr, SL("items"), PH_NOISY | PH_READONLY, "phalcon/annotations/annotation.zep", 120 TSRMLS_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/annotations/annotation.zep", 128); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(item, _3); zephir_array_fetch_string(&_4, item, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/annotations/annotation.zep", 121 TSRMLS_CC); ZEPHIR_CALL_METHOD(&resolvedItem, this_ptr, "getexpression", &_5, 86, _4); zephir_check_call_status(); ZEPHIR_OBS_NVAR(name); if (zephir_array_isset_string_fetch(&name, item, SS("name"), 0 TSRMLS_CC)) { zephir_array_update_zval(&arrayValue, name, &resolvedItem, PH_COPY | PH_SEPARATE); } else { zephir_array_append(&arrayValue, resolvedItem, PH_SEPARATE, "phalcon/annotations/annotation.zep", 125); } } RETURN_CCTOR(arrayValue); } if (ZEPHIR_IS_LONG(type, 300)) { object_init_ex(return_value, phalcon_annotations_annotation_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 87, expr); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(_6); object_init_ex(_6, phalcon_annotations_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "The expression ", type, " is unknown"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/annotations/annotation.zep", 134 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); RETURN_CCTOR(value); } static PHP_METHOD(Phalcon_Annotations_Annotation, getExprArguments) { RETURN_MEMBER(this_ptr, "_exprArguments"); } static PHP_METHOD(Phalcon_Annotations_Annotation, getArguments) { RETURN_MEMBER(this_ptr, "_arguments"); } static PHP_METHOD(Phalcon_Annotations_Annotation, numberArguments) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Annotations_Annotation, getArgument) { zval *position, *argument, *_0; zephir_fetch_params(0, 1, 0, &position); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); if (zephir_array_isset_fetch(&argument, _0, position, 1 TSRMLS_CC)) { RETURN_CTORW(argument); } } static PHP_METHOD(Phalcon_Annotations_Annotation, hasArgument) { zval *position, *_0; zephir_fetch_params(0, 1, 0, &position); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, position)); } static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedArgument) { zval *name_param = NULL, *argument, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); if (zephir_array_isset_fetch(&argument, _0, name, 1 TSRMLS_CC)) { RETURN_CTOR(argument); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedParameter) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getnamedargument", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Collection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Collection, phalcon, annotations_collection, phalcon_annotations_collection_method_entry, 0); zend_declare_property_long(phalcon_annotations_collection_ce, SL("_position"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_collection_ce, SL("_annotations"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_annotations_collection_ce TSRMLS_CC, 1, zend_ce_iterator); zend_class_implements(phalcon_annotations_collection_ce TSRMLS_CC, 1, spl_ce_Countable); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Collection, __construct) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool _0; zval *reflectionData = NULL, *annotations, *annotationData = NULL, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &reflectionData); if (!reflectionData) { reflectionData = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(reflectionData) != IS_NULL; if (_0) { _0 = Z_TYPE_P(reflectionData) != IS_ARRAY; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_annotations_exception_ce, "Reflection data must be an array", "phalcon/annotations/collection.zep", 60); return; } ZEPHIR_INIT_VAR(annotations); array_init(annotations); if (Z_TYPE_P(reflectionData) == IS_ARRAY) { zephir_is_iterable(reflectionData, &_2, &_1, 0, 0, "phalcon/annotations/collection.zep", 68); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(annotationData, _3); ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_annotations_annotation_ce); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_5, 87, annotationData); zephir_check_call_status(); zephir_array_append(&annotations, _4, PH_SEPARATE, "phalcon/annotations/collection.zep", 66); } } zephir_update_property_this(this_ptr, SL("_annotations"), annotations TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Annotations_Collection, count) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotations"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Annotations_Collection, rewind) { zval *_0; ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_position"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Annotations_Collection, current) { zval *annotation, *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotations"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); if (zephir_array_isset_fetch(&annotation, _0, _1, 1 TSRMLS_CC)) { RETURN_CTORW(annotation); } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Annotations_Collection, key) { RETURN_MEMBER(this_ptr, "_position"); } static PHP_METHOD(Phalcon_Annotations_Collection, next) { RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_position") TSRMLS_CC)); } static PHP_METHOD(Phalcon_Annotations_Collection, valid) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotations"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, _1)); } static PHP_METHOD(Phalcon_Annotations_Collection, getAnnotations) { RETURN_MEMBER(this_ptr, "_annotations"); } static PHP_METHOD(Phalcon_Annotations_Collection, get) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *name_param = NULL, *annotation = NULL, *annotations, **_2, *_3 = NULL, *_4; zval *name = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_annotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_1, &_0, 0, 0, "phalcon/annotations/collection.zep", 147); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(annotation, _2); ZEPHIR_CALL_METHOD(&_3, annotation, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(name, _3)) { RETURN_CCTOR(annotation); } } } ZEPHIR_INIT_VAR(_4); object_init_ex(_4, phalcon_annotations_exception_ce); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Collection doesn't have an annotation called '", name, "'"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/annotations/collection.zep", 149 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Annotations_Collection, getAll) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *name_param = NULL, *annotations, *found, *annotation = NULL, **_2, *_3 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_INIT_VAR(found); array_init(found); ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_annotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_1, &_0, 0, 0, "phalcon/annotations/collection.zep", 167); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(annotation, _2); ZEPHIR_CALL_METHOD(&_3, annotation, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(name, _3)) { zephir_array_append(&found, annotation, PH_SEPARATE, "phalcon/annotations/collection.zep", 164); } } } RETURN_CCTOR(found); } static PHP_METHOD(Phalcon_Annotations_Collection, has) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *name_param = NULL, *annotations, *annotation = NULL, **_2, *_3 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_annotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_1, &_0, 0, 0, "phalcon/annotations/collection.zep", 186); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(annotation, _2); ZEPHIR_CALL_METHOD(&_3, annotation, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(name, _3)) { RETURN_MM_BOOL(1); } } } RETURN_MM_BOOL(0); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations, Exception, phalcon, annotations_exception, zend_exception_get_default(TSRMLS_C), NULL, 0); return SUCCESS; } /* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> // 28 "parser.lemon" #include <ext/standard/php_smart_str.h> #include <main/spprintf.h> static zval *phannot_ret_literal_zval(int type, phannot_parser_token *T) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_long(ret, "type", type); if (T) { add_assoc_stringl(ret, "value", T->token, T->token_len, 0); efree(T); } return ret; } static zval *phannot_ret_array(zval *items) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_long(ret, "type", PHANNOT_T_ARRAY); if (items) { add_assoc_zval(ret, "items", items); } return ret; } static zval *phannot_ret_zval_list(zval *list_left, zval *right_list) { zval *ret; HashPosition pos; HashTable *list; MAKE_STD_ZVAL(ret); array_init(ret); if (list_left) { list = Z_ARRVAL_P(list_left); if (zend_hash_index_exists(list, 0)) { zend_hash_internal_pointer_reset_ex(list, &pos); for (;; zend_hash_move_forward_ex(list, &pos)) { zval ** item; if (zend_hash_get_current_data_ex(list, (void**) &item, &pos) == FAILURE) { break; } Z_ADDREF_PP(item); add_next_index_zval(ret, *item); } zval_ptr_dtor(&list_left); } else { add_next_index_zval(ret, list_left); } } add_next_index_zval(ret, right_list); return ret; } static zval *phannot_ret_named_item(phannot_parser_token *name, zval *expr) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_zval(ret, "expr", expr); if (name != NULL) { add_assoc_stringl(ret, "name", name->token, name->token_len, 0); efree(name); } return ret; } static zval *phannot_ret_annotation(phannot_parser_token *name, zval *arguments, phannot_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHANNOT_T_ANNOTATION); if (name) { add_assoc_stringl(ret, "name", name->token, name->token_len, 0); efree(name); } if (arguments) { add_assoc_zval(ret, "arguments", arguments); } add_assoc_string(ret, "file", (char*)state->active_file, !IS_INTERNED(state->active_file)); add_assoc_long(ret, "line", state->active_line); return ret; } // 131 "parser.c" /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ /* Make sure the INTERFACE macro is defined. */ #ifndef INTERFACE # define INTERFACE 1 #endif /* The next thing included is series of defines which control ** various aspects of the generated parser. ** AACODETYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 terminals ** and nonterminals. "int" is used otherwise. ** AANOCODE is a number of type AACODETYPE which corresponds ** to no legal terminal or nonterminal number. This ** number is used to fill in empty slots of the hash ** table. ** AAFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the ** original value of the token will not parse. ** AAACTIONTYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. ** phannot_TOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** AAMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of ** which is phannot_TOKENTYPE. The entry in the union ** for base tokens is called "aa0". ** AASTACKDEPTH is the maximum depth of the parser's stack. ** phannot_ARG_SDECL A static variable declaration for the %extra_argument ** phannot_ARG_PDECL A parameter declaration for the %extra_argument ** phannot_ARG_STORE Code to store %extra_argument into aapParser ** phannot_ARG_FETCH Code to extract %extra_argument from aapParser ** AANSTATE the combined number of states. ** AANRULE the number of rules in the grammar ** AAERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define AACODETYPE unsigned char #define AANOCODE 28 #define AAACTIONTYPE unsigned char #define phannot_TOKENTYPE phannot_parser_token* typedef union { phannot_TOKENTYPE aa0; zval* aa36; int aa55; } AAMINORTYPE; #define AASTACKDEPTH 100 #define phannot_ARG_SDECL phannot_parser_status *status; #define phannot_ARG_PDECL ,phannot_parser_status *status #define phannot_ARG_FETCH phannot_parser_status *status = aapParser->status #define phannot_ARG_STORE aapParser->status = status #define AANSTATE 40 #define AANRULE 25 #define AAERRORSYMBOL 18 #define AAERRSYMDT aa55 #define AA_NO_ACTION (AANSTATE+AANRULE+2) #define AA_ACCEPT_ACTION (AANSTATE+AANRULE+1) #define AA_ERROR_ACTION (AANSTATE+AANRULE) /* Next are that tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N < AANSTATE Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** AANSTATE <= N < AANSTATE+AANRULE Reduce by rule N-AANSTATE. ** ** N == AANSTATE+AANRULE A syntax error has occurred. ** ** N == AANSTATE+AANRULE+1 The parser accepts its input. ** ** N == AANSTATE+AANRULE+2 No such action. Denotes unused ** slots in the aa_action[] table. ** ** The action table is constructed as a single large table named aa_action[]. ** Given state S and lookahead X, the action is computed as ** ** aa_action[ aa_shift_ofst[S] + X ] ** ** If the index value aa_shift_ofst[S]+X is out of range or if the value ** aa_lookahead[aa_shift_ofst[S]+X] is not equal to X or if aa_shift_ofst[S] ** is equal to AA_SHIFT_USE_DFLT, it means that the action is not in the table ** and that aa_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the aa_reduce_ofst[] array is used in place of ** the aa_shift_ofst[] array and AA_REDUCE_USE_DFLT is used in place of ** AA_SHIFT_USE_DFLT. ** ** The following are the tables generated in this section: ** ** aa_action[] A single table containing all actions. ** aa_lookahead[] A table containing the lookahead for each entry in ** aa_action. Used to detect hash collisions. ** aa_shift_ofst[] For each state, the offset into aa_action for ** shifting terminals. ** aa_reduce_ofst[] For each state, the offset into aa_action for ** shifting non-terminals after a reduce. ** aa_default[] Default action for each state. */ static AAACTIONTYPE aa_action[] = { /* 0 */ 4, 28, 15, 38, 12, 14, 16, 18, 20, 21, /* 10 */ 22, 23, 24, 4, 31, 4, 28, 15, 40, 12, /* 20 */ 30, 16, 18, 20, 21, 22, 23, 24, 3, 31, /* 30 */ 4, 17, 15, 6, 19, 35, 16, 18, 20, 21, /* 40 */ 22, 23, 24, 5, 31, 15, 7, 27, 11, 16, /* 50 */ 54, 54, 15, 25, 27, 11, 16, 15, 32, 27, /* 60 */ 11, 16, 66, 1, 2, 39, 41, 15, 4, 10, /* 70 */ 11, 16, 15, 9, 9, 37, 16, 8, 13, 36, /* 80 */ 9, 29, 34, 54, 54, 54, 54, 54, 26, 54, /* 90 */ 54, 54, 54, 54, 54, 54, 33, }; static AACODETYPE aa_lookahead[] = { /* 0 */ 2, 3, 22, 5, 6, 25, 26, 9, 10, 11, /* 10 */ 12, 13, 14, 2, 16, 2, 3, 22, 0, 6, /* 20 */ 25, 26, 9, 10, 11, 12, 13, 14, 22, 16, /* 30 */ 2, 3, 22, 4, 6, 25, 26, 9, 10, 11, /* 40 */ 12, 13, 14, 3, 16, 22, 23, 24, 25, 26, /* 50 */ 27, 27, 22, 23, 24, 25, 26, 22, 23, 24, /* 60 */ 25, 26, 19, 20, 21, 22, 0, 22, 2, 24, /* 70 */ 25, 26, 22, 1, 1, 25, 26, 5, 7, 8, /* 80 */ 1, 7, 8, 27, 27, 27, 27, 27, 15, 27, /* 90 */ 27, 27, 27, 27, 27, 27, 17, }; #define AA_SHIFT_USE_DFLT (-3) static signed char aa_shift_ofst[] = { /* 0 */ 11, 18, 66, -3, 40, 29, -2, 72, -3, 13, /* 10 */ -3, -3, 71, 28, -3, -3, -3, -3, -3, -3, /* 20 */ -3, -3, -3, -3, 13, 73, -3, -3, 74, 28, /* 30 */ -3, 13, 79, -3, 28, -3, 28, -3, -3, -3, }; #define AA_REDUCE_USE_DFLT (-21) static signed char aa_reduce_ofst[] = { /* 0 */ 43, -21, 6, -21, -21, -21, 23, -21, -21, 45, /* 10 */ -21, -21, -21, -20, -21, -21, -21, -21, -21, -21, /* 20 */ -21, -21, -21, -21, 30, -21, -21, -21, -21, -5, /* 30 */ -21, 35, -21, -21, 10, -21, 50, -21, -21, -21, }; static AAACTIONTYPE aa_default[] = { /* 0 */ 65, 65, 65, 42, 65, 46, 65, 65, 44, 65, /* 10 */ 47, 49, 58, 65, 50, 54, 55, 56, 57, 58, /* 20 */ 59, 60, 61, 62, 65, 65, 63, 48, 56, 65, /* 30 */ 52, 65, 65, 64, 65, 53, 65, 51, 45, 43, }; #define AA_SZ_ACTTAB (sizeof(aa_action)/sizeof(aa_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammer, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. */ #ifdef AAFALLBACK static const AACODETYPE aaFallback[] = { }; #endif /* AAFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct aaStackEntry { int stateno; /* The state-number */ int major; /* The major token value. This is the code ** number for the token at this stack level */ AAMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct aaStackEntry aaStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct aaParser { int aaidx; /* Index of top element in stack */ int aaerrcnt; /* Shifts left before out of the error */ phannot_ARG_SDECL /* A place to hold %extra_argument */ aaStackEntry aastack[AASTACKDEPTH]; /* The parser's stack */ }; typedef struct aaParser aaParser; #ifndef NDEBUG #include <stdio.h> static FILE *aaTraceFILE = 0; static char *aaTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG static void phannot_Trace(FILE *TraceFILE, char *zTracePrompt){ aaTraceFILE = TraceFILE; aaTracePrompt = zTracePrompt; if( aaTraceFILE==0 ) aaTracePrompt = 0; else if( aaTracePrompt==0 ) aaTraceFILE = 0; } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *aaTokenName[] = { "$", "COMMA", "AT", "IDENTIFIER", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "STRING", "EQUALS", "COLON", "INTEGER", "DOUBLE", "NULL", "FALSE", "TRUE", "BRACKET_OPEN", "BRACKET_CLOSE", "SBRACKET_OPEN", "SBRACKET_CLOSE", "error", "program", "annotation_language", "annotation_list", "annotation", "argument_list", "argument_item", "expr", "array", }; #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *aaRuleName[] = { /* 0 */ "program ::= annotation_language", /* 1 */ "annotation_language ::= annotation_list", /* 2 */ "annotation_list ::= annotation_list annotation", /* 3 */ "annotation_list ::= annotation", /* 4 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", /* 5 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN PARENTHESES_CLOSE", /* 6 */ "annotation ::= AT IDENTIFIER", /* 7 */ "argument_list ::= argument_list COMMA argument_item", /* 8 */ "argument_list ::= argument_item", /* 9 */ "argument_item ::= expr", /* 10 */ "argument_item ::= STRING EQUALS expr", /* 11 */ "argument_item ::= STRING COLON expr", /* 12 */ "argument_item ::= IDENTIFIER EQUALS expr", /* 13 */ "argument_item ::= IDENTIFIER COLON expr", /* 14 */ "expr ::= annotation", /* 15 */ "expr ::= array", /* 16 */ "expr ::= IDENTIFIER", /* 17 */ "expr ::= INTEGER", /* 18 */ "expr ::= STRING", /* 19 */ "expr ::= DOUBLE", /* 20 */ "expr ::= NULL", /* 21 */ "expr ::= FALSE", /* 22 */ "expr ::= TRUE", /* 23 */ "array ::= BRACKET_OPEN argument_list BRACKET_CLOSE", /* 24 */ "array ::= SBRACKET_OPEN argument_list SBRACKET_CLOSE", }; #endif /* NDEBUG */ const char *phannot_TokenName(int tokenType){ #ifndef NDEBUG if( tokenType>0 && tokenType<(sizeof(aaTokenName)/sizeof(aaTokenName[0])) ){ return aaTokenName[tokenType]; }else{ return "Unknown"; } #else return ""; #endif } void *phannot_Alloc(void *(*mallocProc)(size_t)){ aaParser *pParser; pParser = (aaParser*)(*mallocProc)( (size_t)sizeof(aaParser) ); if( pParser ){ pParser->aaidx = -1; } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "aamajor" is the symbol code, and "aapminor" is a pointer to ** the value. */ static void aa_destructor(AACODETYPE aamajor, AAMINORTYPE *aapminor){ switch( aamajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: // 196 "parser.lemon" { if ((aapminor->aa0)) { if ((aapminor->aa0)->free_flag) { efree((aapminor->aa0)->token); } efree((aapminor->aa0)); } } // 499 "parser.c" break; case 20: case 21: case 22: case 23: case 24: case 25: // 209 "parser.lemon" { zval_ptr_dtor(&(aapminor->aa36)); } // 509 "parser.c" break; default: break; /* If no destructor action specified: do nothing */ } } static int aa_pop_parser_stack(aaParser *pParser){ AACODETYPE aamajor; aaStackEntry *aatos = &pParser->aastack[pParser->aaidx]; if( pParser->aaidx<0 ) return 0; #ifndef NDEBUG if( aaTraceFILE && pParser->aaidx>=0 ){ fprintf(aaTraceFILE,"%sPopping %s\n", aaTracePrompt, aaTokenName[aatos->major]); } #endif aamajor = aatos->major; aa_destructor( aamajor, &aatos->minor); pParser->aaidx--; return aamajor; } static void phannot_Free( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ aaParser *pParser = (aaParser*)p; if( pParser==0 ) return; while( pParser->aaidx>=0 ) aa_pop_parser_stack(pParser); (*freeProc)((void*)pParser); } static int aa_find_shift_action( aaParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->aastack[pParser->aaidx].stateno; /* if( pParser->aaidx<0 ) return AA_NO_ACTION; */ i = aa_shift_ofst[stateno]; if( i==AA_SHIFT_USE_DFLT ){ return aa_default[stateno]; } if( iLookAhead==AANOCODE ){ return AA_NO_ACTION; } i += iLookAhead; if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ #ifdef AAFALLBACK int iFallback; /* Fallback token */ if( iLookAhead<sizeof(aaFallback)/sizeof(aaFallback[0]) && (iFallback = aaFallback[iLookAhead])!=0 ){ #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE, "%sFALLBACK %s => %s\n", aaTracePrompt, aaTokenName[iLookAhead], aaTokenName[iFallback]); } #endif return aa_find_shift_action(pParser, iFallback); } #endif return aa_default[stateno]; }else{ return aa_action[i]; } } static int aa_find_reduce_action( aaParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->aastack[pParser->aaidx].stateno; i = aa_reduce_ofst[stateno]; if( i==AA_REDUCE_USE_DFLT ){ return aa_default[stateno]; } if( iLookAhead==AANOCODE ){ return AA_NO_ACTION; } i += iLookAhead; if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ return aa_default[stateno]; }else{ return aa_action[i]; } } static void aa_shift( aaParser *aapParser, /* The parser to be shifted */ int aaNewState, /* The new state to shift in */ int aaMajor, /* The major token to shift in */ AAMINORTYPE *aapMinor /* Pointer ot the minor token to shift in */ ){ aaStackEntry *aatos; aapParser->aaidx++; if( aapParser->aaidx>=AASTACKDEPTH ){ phannot_ARG_FETCH; aapParser->aaidx--; #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sStack Overflow!\n",aaTracePrompt); } #endif while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ phannot_ARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } aatos = &aapParser->aastack[aapParser->aaidx]; aatos->stateno = aaNewState; aatos->major = aaMajor; aatos->minor = *aapMinor; #ifndef NDEBUG if( aaTraceFILE && aapParser->aaidx>0 ){ int i; fprintf(aaTraceFILE,"%sShift %d\n",aaTracePrompt,aaNewState); fprintf(aaTraceFILE,"%sStack:",aaTracePrompt); for(i=1; i<=aapParser->aaidx; i++) fprintf(aaTraceFILE," %s",aaTokenName[aapParser->aastack[i].major]); fprintf(aaTraceFILE,"\n"); } #endif } /* The following table contains information about every rule that ** is used during the reduce. */ static struct { AACODETYPE lhs; /* Symbol on the left-hand side of the rule */ unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } aaRuleInfo[] = { { 19, 1 }, { 20, 1 }, { 21, 2 }, { 21, 1 }, { 22, 5 }, { 22, 4 }, { 22, 2 }, { 23, 3 }, { 23, 1 }, { 24, 1 }, { 24, 3 }, { 24, 3 }, { 24, 3 }, { 24, 3 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 25, 1 }, { 26, 3 }, { 26, 3 }, }; static void aa_accept(aaParser*); /* Forward Declaration */ static void aa_reduce( aaParser *aapParser, /* The parser */ int aaruleno /* Number of the rule by which to reduce */ ){ int aagoto; /* The next state */ int aaact; /* The next action */ AAMINORTYPE aagotominor; /* The LHS of the rule reduced */ aaStackEntry *aamsp; /* The top of the parser's stack */ int aasize; /* Amount to pop the stack */ phannot_ARG_FETCH; aamsp = &aapParser->aastack[aapParser->aaidx]; #ifndef NDEBUG if( aaTraceFILE && aaruleno>=0 && aaruleno<sizeof(aaRuleName)/sizeof(aaRuleName[0]) ){ fprintf(aaTraceFILE, "%sReduce [%s].\n", aaTracePrompt, aaRuleName[aaruleno]); } #endif /* NDEBUG */ switch( aaruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** // <lineno> <grammarfile> ** { ... } // User supplied code ** // <lineno> <thisfile> ** break; */ case 0: // 205 "parser.lemon" { status->ret = aamsp[0].minor.aa36; } // 751 "parser.c" break; case 1: case 14: case 15: // 211 "parser.lemon" { aagotominor.aa36 = aamsp[0].minor.aa36; } // 760 "parser.c" break; case 2: // 217 "parser.lemon" { aagotominor.aa36 = phannot_ret_zval_list(aamsp[-1].minor.aa36, aamsp[0].minor.aa36); } // 767 "parser.c" break; case 3: case 8: // 221 "parser.lemon" { aagotominor.aa36 = phannot_ret_zval_list(NULL, aamsp[0].minor.aa36); } // 775 "parser.c" break; case 4: // 228 "parser.lemon" { aagotominor.aa36 = phannot_ret_annotation(aamsp[-3].minor.aa0, aamsp[-1].minor.aa36, status->scanner_state); aa_destructor(2,&aamsp[-4].minor); aa_destructor(4,&aamsp[-2].minor); aa_destructor(5,&aamsp[0].minor); } // 785 "parser.c" break; case 5: // 232 "parser.lemon" { aagotominor.aa36 = phannot_ret_annotation(aamsp[-2].minor.aa0, NULL, status->scanner_state); aa_destructor(2,&aamsp[-3].minor); aa_destructor(4,&aamsp[-1].minor); aa_destructor(5,&aamsp[0].minor); } // 795 "parser.c" break; case 6: // 236 "parser.lemon" { aagotominor.aa36 = phannot_ret_annotation(aamsp[0].minor.aa0, NULL, status->scanner_state); aa_destructor(2,&aamsp[-1].minor); } // 803 "parser.c" break; case 7: // 242 "parser.lemon" { aagotominor.aa36 = phannot_ret_zval_list(aamsp[-2].minor.aa36, aamsp[0].minor.aa36); aa_destructor(1,&aamsp[-1].minor); } // 811 "parser.c" break; case 9: // 252 "parser.lemon" { aagotominor.aa36 = phannot_ret_named_item(NULL, aamsp[0].minor.aa36); } // 818 "parser.c" break; case 10: case 12: // 256 "parser.lemon" { aagotominor.aa36 = phannot_ret_named_item(aamsp[-2].minor.aa0, aamsp[0].minor.aa36); aa_destructor(7,&aamsp[-1].minor); } // 827 "parser.c" break; case 11: case 13: // 260 "parser.lemon" { aagotominor.aa36 = phannot_ret_named_item(aamsp[-2].minor.aa0, aamsp[0].minor.aa36); aa_destructor(8,&aamsp[-1].minor); } // 836 "parser.c" break; case 16: // 282 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_IDENTIFIER, aamsp[0].minor.aa0); } // 843 "parser.c" break; case 17: // 286 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_INTEGER, aamsp[0].minor.aa0); } // 850 "parser.c" break; case 18: // 290 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_STRING, aamsp[0].minor.aa0); } // 857 "parser.c" break; case 19: // 294 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_DOUBLE, aamsp[0].minor.aa0); } // 864 "parser.c" break; case 20: // 298 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_NULL, NULL); aa_destructor(11,&aamsp[0].minor); } // 872 "parser.c" break; case 21: // 302 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_FALSE, NULL); aa_destructor(12,&aamsp[0].minor); } // 880 "parser.c" break; case 22: // 306 "parser.lemon" { aagotominor.aa36 = phannot_ret_literal_zval(PHANNOT_T_TRUE, NULL); aa_destructor(13,&aamsp[0].minor); } // 888 "parser.c" break; case 23: // 310 "parser.lemon" { aagotominor.aa36 = phannot_ret_array(aamsp[-1].minor.aa36); aa_destructor(14,&aamsp[-2].minor); aa_destructor(15,&aamsp[0].minor); } // 897 "parser.c" break; case 24: // 314 "parser.lemon" { aagotominor.aa36 = phannot_ret_array(aamsp[-1].minor.aa36); aa_destructor(16,&aamsp[-2].minor); aa_destructor(17,&aamsp[0].minor); } // 906 "parser.c" break; }; aagoto = aaRuleInfo[aaruleno].lhs; aasize = aaRuleInfo[aaruleno].nrhs; aapParser->aaidx -= aasize; aaact = aa_find_reduce_action(aapParser,aagoto); if( aaact < AANSTATE ){ aa_shift(aapParser,aaact,aagoto,&aagotominor); }else if( aaact == AANSTATE + AANRULE + 1 ){ aa_accept(aapParser); } } static void aa_parse_failed( aaParser *aapParser /* The parser */ ){ phannot_ARG_FETCH; #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sFail!\n",aaTracePrompt); } #endif while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); /* Here code is inserted which will be executed whenever the ** parser fails */ phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void aa_syntax_error( aaParser *aapParser, /* The parser */ int aamajor, /* The major type of the error token */ AAMINORTYPE aaminor /* The minor type of the error token */ ){ phannot_ARG_FETCH; #define ATOKEN (aaminor.aa0) // 151 "parser.lemon" if (status->scanner_state->start_length) { char *token_name = NULL; const phannot_token_names *tokens = phannot_tokens; uint active_token = status->scanner_state->active_token; uint near_length = status->scanner_state->start_length; if (active_token) { do { if (tokens->code == active_token) { token_name = tokens->name; break; } ++tokens; } while (tokens[0].code != 0); } if (!token_name) { token_name = "UNKNOWN"; } if (near_length > 0) { if (status->token->value) { spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), near to '%s' in %s on line %d", token_name, status->token->value, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); } else { spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, near to '%s' in %s on line %d", token_name, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); } } else { if (active_token != PHANNOT_T_IGNORE) { if (status->token->value) { spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), at the end of docblock in %s on line %d", token_name, status->token->value, status->scanner_state->active_file, status->scanner_state->active_line); } else { spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, at the end of docblock in %s on line %d", token_name, status->scanner_state->active_file, status->scanner_state->active_line); } } else { spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF, at the end of docblock in %s on line %d", status->scanner_state->active_file, status->scanner_state->active_line); } } } else { spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF in %s", status->scanner_state->active_file); } status->status = PHANNOT_PARSING_FAILED; // 993 "parser.c" phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void aa_accept( aaParser *aapParser /* The parser */ ){ phannot_ARG_FETCH; #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sAccept!\n",aaTracePrompt); } #endif while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); /* Here code is inserted which will be executed whenever the ** parser accepts */ phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "phannot_Alloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: ** <ul> ** <li> A pointer to the parser (an opaque structure.) ** <li> The major token number. ** <li> The minor token number. ** <li> An option argument of a grammar-specified type. ** </ul> ** ** Outputs: ** None. */ static void phannot_( void *aap, /* The parser */ int aamajor, /* The major token code number */ phannot_TOKENTYPE aaminor /* The value for the token */ phannot_ARG_PDECL /* Optional %extra_argument parameter */ ){ AAMINORTYPE aaminorunion; int aaact; /* The parser action. */ int aaendofinput; /* True if we are at the end of input */ int aaerrorhit = 0; /* True if aamajor has invoked an error */ aaParser *aapParser; /* The parser */ /* (re)initialize the parser, if necessary */ aapParser = (aaParser*)aap; if( aapParser->aaidx<0 ){ if( aamajor==0 ) return; aapParser->aaidx = 0; aapParser->aaerrcnt = -1; aapParser->aastack[0].stateno = 0; aapParser->aastack[0].major = 0; } aaminorunion.aa0 = aaminor; aaendofinput = (aamajor==0); phannot_ARG_STORE; #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sInput %s\n",aaTracePrompt,aaTokenName[aamajor]); } #endif do{ aaact = aa_find_shift_action(aapParser,aamajor); if( aaact<AANSTATE ){ aa_shift(aapParser,aaact,aamajor,&aaminorunion); aapParser->aaerrcnt--; if( aaendofinput && aapParser->aaidx>=0 ){ aamajor = 0; }else{ aamajor = AANOCODE; } }else if( aaact < AANSTATE + AANRULE ){ aa_reduce(aapParser,aaact-AANSTATE); }else if( aaact == AA_ERROR_ACTION ){ int aamx; #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sSyntax Error!\n",aaTracePrompt); } #endif #ifdef AAERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( aapParser->aaerrcnt<0 ){ aa_syntax_error(aapParser,aamajor,aaminorunion); } aamx = aapParser->aastack[aapParser->aaidx].major; if( aamx==AAERRORSYMBOL || aaerrorhit ){ #ifndef NDEBUG if( aaTraceFILE ){ fprintf(aaTraceFILE,"%sDiscard input token %s\n", aaTracePrompt,aaTokenName[aamajor]); } #endif aa_destructor(aamajor,&aaminorunion); aamajor = AANOCODE; }else{ while( aapParser->aaidx >= 0 && aamx != AAERRORSYMBOL && (aaact = aa_find_shift_action(aapParser,AAERRORSYMBOL)) >= AANSTATE ){ aa_pop_parser_stack(aapParser); } if( aapParser->aaidx < 0 || aamajor==0 ){ aa_destructor(aamajor,&aaminorunion); aa_parse_failed(aapParser); aamajor = AANOCODE; }else if( aamx!=AAERRORSYMBOL ){ AAMINORTYPE u2; u2.AAERRSYMDT = 0; aa_shift(aapParser,aaact,AAERRORSYMBOL,&u2); } } aapParser->aaerrcnt = 3; aaerrorhit = 1; #else /* AAERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( aapParser->aaerrcnt<=0 ){ aa_syntax_error(aapParser,aamajor,aaminorunion); } aapParser->aaerrcnt = 3; aa_destructor(aamajor,&aaminorunion); if( aaendofinput ){ aa_parse_failed(aapParser); } aamajor = AANOCODE; #endif }else{ aa_accept(aapParser); aamajor = AANOCODE; } }while( aamajor!=AANOCODE && aapParser->aaidx>=0 ); return; } const phannot_token_names phannot_tokens[] = { { "INTEGER", PHANNOT_T_INTEGER }, { "DOUBLE", PHANNOT_T_DOUBLE }, { "STRING", PHANNOT_T_STRING }, { "IDENTIFIER", PHANNOT_T_IDENTIFIER }, { "@", PHANNOT_T_AT }, { ",", PHANNOT_T_COMMA }, { "=", PHANNOT_T_EQUALS }, { ":", PHANNOT_T_COLON }, { "(", PHANNOT_T_PARENTHESES_OPEN }, { ")", PHANNOT_T_PARENTHESES_CLOSE }, { "{", PHANNOT_T_BRACKET_OPEN }, { "}", PHANNOT_T_BRACKET_CLOSE }, { "[", PHANNOT_T_SBRACKET_OPEN }, { "]", PHANNOT_T_SBRACKET_CLOSE }, { "ARBITRARY TEXT", PHANNOT_T_ARBITRARY_TEXT }, { NULL, 0 } }; static void *phannot_wrapper_alloc(size_t bytes){ return emalloc(bytes); } static void phannot_wrapper_free(void *pointer){ efree(pointer); } static void phannot_parse_with_token(void* phannot_parser, int opcode, int parsercode, phannot_scanner_token *token, phannot_parser_status *parser_status){ phannot_parser_token *pToken; pToken = emalloc(sizeof(phannot_parser_token)); pToken->opcode = opcode; pToken->token = token->value; pToken->token_len = token->len; pToken->free_flag = 1; phannot_(phannot_parser, parsercode, pToken, parser_status); token->value = NULL; token->len = 0; } static void phannot_scanner_error_msg(phannot_parser_status *parser_status, char **error_msg TSRMLS_DC){ phannot_scanner_state *state = parser_status->scanner_state; if (state->start) { if (state->start_length > 16) { spprintf(error_msg, 0, "Scanning error before '%.16s...' in %s on line %d", state->start, state->active_file, state->active_line); } else { spprintf(error_msg, 0, "Scanning error before '%s' in %s on line %d", state->start, state->active_file, state->active_line); } } else { spprintf(error_msg, 0, "Scanning error near to EOF in %s", state->active_file); } } static int phannot_parse_annotations(zval *result, zval *comment, zval *file_path, zval *line TSRMLS_DC) { char *comment_str; zend_uint comment_len; char *file_path_str; zend_uint line_num; char *error_msg = NULL; ZVAL_NULL(result); if (Z_TYPE_P(comment) == IS_STRING) { comment_str = Z_STRVAL_P(comment); comment_len = Z_STRLEN_P(comment); } else { comment_str = ""; comment_len = 0; } if (Z_TYPE_P(file_path) == IS_STRING) { file_path_str = Z_STRVAL_P(file_path); } else { file_path_str = "eval"; } if (Z_TYPE_P(line) == IS_LONG) { line_num = Z_LVAL_P(line); } else { line_num = 0; } if (phannot_internal_parse_annotations(&result, comment_str, comment_len, file_path_str, line_num, &error_msg TSRMLS_CC) == FAILURE) { if (likely(error_msg != NULL)) { zephir_throw_exception_string(phalcon_annotations_exception_ce, error_msg, strlen(error_msg) TSRMLS_CC); efree(error_msg); } else { zephir_throw_exception_string(phalcon_annotations_exception_ce, SL("There was an error parsing annotation") TSRMLS_CC); } return FAILURE; } return SUCCESS; } static void phannot_remove_comment_separators(char **ret, zend_uint *ret_len, const char *comment, zend_uint length, zend_uint *start_lines) { int start_mode = 1, j, i, open_parentheses; smart_str processed_str = {0}; char ch; (*start_lines) = 0; for (i = 0; i < length; i++) { ch = comment[i]; if (start_mode) { if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { continue; } start_mode = 0; } if (ch == '@') { smart_str_appendc(&processed_str, ch); i++; open_parentheses = 0; for (j = i; j < length; j++) { ch = comment[j]; if (start_mode) { if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { continue; } start_mode = 0; } if (open_parentheses == 0) { if (isalnum(ch) || '_' == ch || '\\' == ch) { smart_str_appendc(&processed_str, ch); continue; } if (ch == '(') { smart_str_appendc(&processed_str, ch); open_parentheses++; continue; } } else { smart_str_appendc(&processed_str, ch); if (ch == '(') { open_parentheses++; } else if (ch == ')') { open_parentheses--; } else if (ch == '\n') { (*start_lines)++; start_mode = 1; } if (open_parentheses > 0) { continue; } } i = j; smart_str_appendc(&processed_str, ' '); break; } } if (ch == '\n') { (*start_lines)++; start_mode = 1; } } smart_str_0(&processed_str); if (processed_str.len) { *ret = processed_str.c; *ret_len = processed_str.len; } else { *ret = NULL; *ret_len = 0; } } static int phannot_internal_parse_annotations(zval **result, const char *comment, zend_uint comment_len, const char *file_path, zend_uint line, char **error_msg TSRMLS_DC) { phannot_scanner_state *state; phannot_scanner_token token; zend_uint start_lines; int scanner_status, status = SUCCESS; phannot_parser_status *parser_status = NULL; void* phannot_parser; char *processed_comment; zend_uint processed_comment_len; *error_msg = NULL; if (UNEXPECTED(!comment)) { ZVAL_BOOL(*result, 0); spprintf(error_msg, 0, "Empty annotation"); return FAILURE; } if (comment_len < 2) { ZVAL_BOOL(*result, 0); return SUCCESS; } phannot_remove_comment_separators(&processed_comment, &processed_comment_len, comment, comment_len, &start_lines); if (processed_comment_len < 2) { ZVAL_BOOL(*result, 0); if (processed_comment) { efree(processed_comment); } return SUCCESS; } phannot_parser = phannot_Alloc(phannot_wrapper_alloc); if (unlikely(!phannot_parser)) { ZVAL_BOOL(*result, 0); return FAILURE; } parser_status = emalloc(sizeof(phannot_parser_status) + sizeof(phannot_scanner_state)); state = (phannot_scanner_state*)((char*)parser_status + sizeof(phannot_parser_status)); parser_status->status = PHANNOT_PARSING_OK; parser_status->scanner_state = state; parser_status->ret = NULL; parser_status->token = &token; parser_status->syntax_error = NULL; state->active_token = 0; state->start = processed_comment; state->start_length = 0; state->mode = PHANNOT_MODE_RAW; state->active_file = file_path; token.value = NULL; token.len = 0; if (line) { state->active_line = line - start_lines; } else { state->active_line = 1; } state->end = state->start; while(0 <= (scanner_status = phannot_get_token(state, &token))) { state->active_token = token.opcode; state->start_length = processed_comment + processed_comment_len - state->start; switch (token.opcode) { case PHANNOT_T_IGNORE: break; case PHANNOT_T_AT: phannot_(phannot_parser, PHANNOT_AT, NULL, parser_status); break; case PHANNOT_T_COMMA: phannot_(phannot_parser, PHANNOT_COMMA, NULL, parser_status); break; case PHANNOT_T_EQUALS: phannot_(phannot_parser, PHANNOT_EQUALS, NULL, parser_status); break; case PHANNOT_T_COLON: phannot_(phannot_parser, PHANNOT_COLON, NULL, parser_status); break; case PHANNOT_T_PARENTHESES_OPEN: phannot_(phannot_parser, PHANNOT_PARENTHESES_OPEN, NULL, parser_status); break; case PHANNOT_T_PARENTHESES_CLOSE: phannot_(phannot_parser, PHANNOT_PARENTHESES_CLOSE, NULL, parser_status); break; case PHANNOT_T_BRACKET_OPEN: phannot_(phannot_parser, PHANNOT_BRACKET_OPEN, NULL, parser_status); break; case PHANNOT_T_BRACKET_CLOSE: phannot_(phannot_parser, PHANNOT_BRACKET_CLOSE, NULL, parser_status); break; case PHANNOT_T_SBRACKET_OPEN: phannot_(phannot_parser, PHANNOT_SBRACKET_OPEN, NULL, parser_status); break; case PHANNOT_T_SBRACKET_CLOSE: phannot_(phannot_parser, PHANNOT_SBRACKET_CLOSE, NULL, parser_status); break; case PHANNOT_T_NULL: phannot_(phannot_parser, PHANNOT_NULL, NULL, parser_status); break; case PHANNOT_T_TRUE: phannot_(phannot_parser, PHANNOT_TRUE, NULL, parser_status); break; case PHANNOT_T_FALSE: phannot_(phannot_parser, PHANNOT_FALSE, NULL, parser_status); break; case PHANNOT_T_INTEGER: phannot_parse_with_token(phannot_parser, PHANNOT_T_INTEGER, PHANNOT_INTEGER, &token, parser_status); break; case PHANNOT_T_DOUBLE: phannot_parse_with_token(phannot_parser, PHANNOT_T_DOUBLE, PHANNOT_DOUBLE, &token, parser_status); break; case PHANNOT_T_STRING: phannot_parse_with_token(phannot_parser, PHANNOT_T_STRING, PHANNOT_STRING, &token, parser_status); break; case PHANNOT_T_IDENTIFIER: phannot_parse_with_token(phannot_parser, PHANNOT_T_IDENTIFIER, PHANNOT_IDENTIFIER, &token, parser_status); break; /*case PHANNOT_T_ARBITRARY_TEXT: phannot_parse_with_token(phannot_parser, PHANNOT_T_ARBITRARY_TEXT, PHANNOT_ARBITRARY_TEXT, &token, parser_status); break;*/ default: parser_status->status = PHANNOT_PARSING_FAILED; if (!*error_msg) { spprintf(error_msg, 0, "Scanner: unknown opcode %d on in %s line %d", token.opcode, state->active_file, state->active_line); } break; } if (parser_status->status != PHANNOT_PARSING_OK) { status = FAILURE; break; } state->end = state->start; } if (status != FAILURE) { switch (scanner_status) { case PHANNOT_SCANNER_RETCODE_ERR: case PHANNOT_SCANNER_RETCODE_IMPOSSIBLE: if (!*error_msg) { phannot_scanner_error_msg(parser_status, error_msg TSRMLS_CC); } status = FAILURE; break; default: phannot_(phannot_parser, 0, NULL, parser_status); } } state->active_token = 0; state->start = NULL; if (parser_status->status != PHANNOT_PARSING_OK) { status = FAILURE; if (parser_status->syntax_error) { if (!*error_msg) { *error_msg = parser_status->syntax_error; } else { efree(parser_status->syntax_error); } } } phannot_Free(phannot_parser, phannot_wrapper_free); if (status != FAILURE) { if (parser_status->status == PHANNOT_PARSING_OK) { if (parser_status->ret) { ZVAL_ZVAL(*result, parser_status->ret, 0, 0); ZVAL_NULL(parser_status->ret); zval_ptr_dtor(&parser_status->ret); } else { array_init(*result); } } } efree(processed_comment); efree(parser_status); return status; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reader) { ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reader, phalcon, annotations_reader, phalcon_annotations_reader_method_entry, 0); zend_class_implements(phalcon_annotations_reader_ce TSRMLS_CC, 1, phalcon_annotations_readerinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Reader, parse) { HashTable *_3, *_8; HashPosition _2, _7; int line, ZEPHIR_LAST_CALL_STATUS; zval *className_param = NULL, *annotations, *reflection, *comment = NULL, *properties = NULL, *methods = NULL, *property = NULL, *method = NULL, *classAnnotations, *annotationsProperties, *propertyAnnotations = NULL, *annotationsMethods, *methodAnnotations = NULL, *_0 = NULL, *_1 = NULL, **_4, *_5 = NULL, *_6 = NULL, **_9; zval *className = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &className_param); zephir_get_strval(className, className_param); ZEPHIR_INIT_VAR(annotations); array_init(annotations); ZEPHIR_INIT_VAR(reflection); object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 65, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&comment, reflection, "getdoccomment", NULL, 88); zephir_check_call_status(); if (Z_TYPE_P(comment) == IS_STRING) { ZEPHIR_INIT_VAR(classAnnotations); ZEPHIR_CALL_METHOD(&_0, reflection, "getfilename", NULL, 89); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, reflection, "getstartline", NULL, 90); zephir_check_call_status(); ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(classAnnotations, comment, _0, _1 TSRMLS_CC); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_ARRAY) { zephir_array_update_string(&annotations, SL("class"), &classAnnotations, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_METHOD(&properties, reflection, "getproperties", NULL, 91); zephir_check_call_status(); if (zephir_fast_count_int(properties TSRMLS_CC)) { line = 1; ZEPHIR_INIT_VAR(annotationsProperties); array_init(annotationsProperties); zephir_is_iterable(properties, &_3, &_2, 0, 0, "phalcon/annotations/reader.zep", 96); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(property, _4); ZEPHIR_CALL_METHOD(&comment, property, "getdoccomment", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(comment) == IS_STRING) { ZEPHIR_INIT_NVAR(propertyAnnotations); ZEPHIR_CALL_METHOD(&_0, reflection, "getfilename", NULL, 89); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, line); ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(propertyAnnotations, comment, _0, _5 TSRMLS_CC); zephir_check_call_status(); if (Z_TYPE_P(propertyAnnotations) == IS_ARRAY) { ZEPHIR_OBS_NVAR(_6); zephir_read_property(&_6, property, SL("name"), PH_NOISY_CC); zephir_array_update_zval(&annotationsProperties, _6, &propertyAnnotations, PH_COPY | PH_SEPARATE); } } } if (zephir_fast_count_int(annotationsProperties TSRMLS_CC)) { zephir_array_update_string(&annotations, SL("properties"), &annotationsProperties, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_METHOD(&methods, reflection, "getmethods", NULL, 92); zephir_check_call_status(); if (zephir_fast_count_int(methods TSRMLS_CC)) { ZEPHIR_INIT_VAR(annotationsMethods); array_init(annotationsMethods); zephir_is_iterable(methods, &_8, &_7, 0, 0, "phalcon/annotations/reader.zep", 126); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(method, _9); ZEPHIR_CALL_METHOD(&comment, method, "getdoccomment", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(comment) == IS_STRING) { ZEPHIR_INIT_NVAR(methodAnnotations); ZEPHIR_CALL_METHOD(&_0, method, "getfilename", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, method, "getstartline", NULL, 0); zephir_check_call_status(); ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(methodAnnotations, comment, _0, _1 TSRMLS_CC); zephir_check_call_status(); if (Z_TYPE_P(methodAnnotations) == IS_ARRAY) { ZEPHIR_OBS_NVAR(_6); zephir_read_property(&_6, method, SL("name"), PH_NOISY_CC); zephir_array_update_zval(&annotationsMethods, _6, &methodAnnotations, PH_COPY | PH_SEPARATE); } } } if (zephir_fast_count_int(annotationsMethods TSRMLS_CC)) { zephir_array_update_string(&annotations, SL("methods"), &annotationsMethods, PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(annotations); } static PHP_METHOD(Phalcon_Annotations_Reader, parseDocBlock) { int ZEPHIR_LAST_CALL_STATUS; zval *docBlock_param = NULL, *file = NULL, *line = NULL; zval *docBlock = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &docBlock_param, &file, &line); zephir_get_strval(docBlock, docBlock_param); if (!file) { ZEPHIR_CPY_WRT(file, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(file); } if (!line) { line = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(file) != IS_STRING) { ZEPHIR_INIT_NVAR(file); ZVAL_STRING(file, "eval code", 1); } ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(return_value, docBlock, file, line TSRMLS_CC); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_ReaderInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations, ReaderInterface, phalcon, annotations_readerinterface, phalcon_annotations_readerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parse); ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parseDocBlock); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reflection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reflection, phalcon, annotations_reflection, phalcon_annotations_reflection_method_entry, 0); zend_declare_property_null(phalcon_annotations_reflection_ce, SL("_reflectionData"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_reflection_ce, SL("_classAnnotations"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_reflection_ce, SL("_methodAnnotations"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_annotations_reflection_ce, SL("_propertyAnnotations"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Reflection, __construct) { zval *reflectionData = NULL; zephir_fetch_params(0, 0, 1, &reflectionData); if (!reflectionData) { reflectionData = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(reflectionData) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_reflectionData"), reflectionData TSRMLS_CC); } } static PHP_METHOD(Phalcon_Annotations_Reflection, getClassAnnotations) { int ZEPHIR_LAST_CALL_STATUS; zval *annotations, *reflectionClass, *collection, *_0; ZEPHIR_MM_GROW(); annotations = zephir_fetch_nproperty_this(this_ptr, SL("_classAnnotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) != IS_OBJECT) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_reflectionData"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&reflectionClass, _0, SS("class"), 1 TSRMLS_CC)) { ZEPHIR_INIT_VAR(collection); object_init_ex(collection, phalcon_annotations_collection_ce); ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 20, reflectionClass); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_classAnnotations"), collection TSRMLS_CC); RETURN_CCTOR(collection); } if (0) { zephir_update_property_this(this_ptr, SL("_classAnnotations"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_classAnnotations"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } RETURN_CTOR(annotations); } static PHP_METHOD(Phalcon_Annotations_Reflection, getMethodsAnnotations) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *annotations, *reflectionMethods, *collections, *methodName = NULL, *reflectionMethod = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_methodAnnotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) != IS_OBJECT) { ZEPHIR_OBS_VAR(reflectionMethods); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_reflectionData"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&reflectionMethods, _0, SS("methods"), 0 TSRMLS_CC)) { if (zephir_fast_count_int(reflectionMethods TSRMLS_CC)) { ZEPHIR_INIT_VAR(collections); array_init(collections); zephir_is_iterable(reflectionMethods, &_2, &_1, 0, 0, "phalcon/annotations/reflection.zep", 104); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(methodName, _2, _1); ZEPHIR_GET_HVALUE(reflectionMethod, _3); ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_annotations_collection_ce); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_5, 20, reflectionMethod); zephir_check_call_status(); zephir_array_update_zval(&collections, methodName, &_4, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_methodAnnotations"), collections TSRMLS_CC); RETURN_CCTOR(collections); } } if (0) { zephir_update_property_this(this_ptr, SL("_methodAnnotations"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_methodAnnotations"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } RETURN_CCTOR(annotations); } static PHP_METHOD(Phalcon_Annotations_Reflection, getPropertiesAnnotations) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *annotations, *reflectionProperties, *collections, *property = NULL, *reflectionProperty = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(annotations); zephir_read_property_this(&annotations, this_ptr, SL("_propertyAnnotations"), PH_NOISY_CC); if (Z_TYPE_P(annotations) != IS_OBJECT) { ZEPHIR_OBS_VAR(reflectionProperties); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_reflectionData"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&reflectionProperties, _0, SS("properties"), 0 TSRMLS_CC)) { if (zephir_fast_count_int(reflectionProperties TSRMLS_CC)) { ZEPHIR_INIT_VAR(collections); array_init(collections); zephir_is_iterable(reflectionProperties, &_2, &_1, 0, 0, "phalcon/annotations/reflection.zep", 131); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(property, _2, _1); ZEPHIR_GET_HVALUE(reflectionProperty, _3); ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_annotations_collection_ce); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_5, 20, reflectionProperty); zephir_check_call_status(); zephir_array_update_zval(&collections, property, &_4, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_propertyAnnotations"), collections TSRMLS_CC); RETURN_CCTOR(collections); } } if (0) { zephir_update_property_this(this_ptr, SL("_propertyAnnotations"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_propertyAnnotations"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } RETURN_CCTOR(annotations); } static PHP_METHOD(Phalcon_Annotations_Reflection, getReflectionData) { RETURN_MEMBER(this_ptr, "_reflectionData"); } static PHP_METHOD(Phalcon_Annotations_Reflection, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *data, *reflectionData; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); if (Z_TYPE_P(data) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&reflectionData, data, SS("_reflectionData"), 1 TSRMLS_CC)) { object_init_ex(return_value, phalcon_annotations_reflection_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 18, reflectionData); zephir_check_call_status(); RETURN_MM(); } } object_init_ex(return_value, phalcon_annotations_reflection_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 18); zephir_check_call_status(); RETURN_MM(); } /* Generated by re2c 0.13.5 on Sun May 10 20:45:09 2015 */ // 1 "scanner.re" #define AACTYPE unsigned char #define AACURSOR (s->start) #define AALIMIT (s->end) #define AAMARKER q static int phannot_get_token(phannot_scanner_state *s, phannot_scanner_token *token) { char next, *q = AACURSOR, *start = AACURSOR; int status = PHANNOT_SCANNER_RETCODE_IMPOSSIBLE; while (PHANNOT_SCANNER_RETCODE_IMPOSSIBLE == status) { if (s->mode == PHANNOT_MODE_RAW) { if (*AACURSOR == '\n') { s->active_line++; } next = *(AACURSOR+1); if (*AACURSOR == '\0' || *AACURSOR == '@') { if ((next >= 'A' && next <= 'Z') || (next >= 'a' && next <= 'z')) { s->mode = PHANNOT_MODE_ANNOTATION; continue; } } ++AACURSOR; token->opcode = PHANNOT_T_IGNORE; return 0; } else { // 61 "scanner.c" { AACTYPE aach; unsigned int aaaccept = 0; aach = *AACURSOR; switch (aach) { case 0x00: goto aa38; case '\t': case '\r': case ' ': goto aa34; case '\n': goto aa36; case '"': goto aa10; case '\'': goto aa11; case '(': goto aa14; case ')': goto aa16; case ',': goto aa32; case '-': goto aa2; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto aa4; case ':': goto aa30; case '=': goto aa28; case '@': goto aa26; case 'A': case 'B': case 'C': case 'D': case 'E': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'o': case 'p': case 'q': case 'r': case 's': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa13; case 'F': case 'f': goto aa8; case 'N': case 'n': goto aa6; case 'T': case 't': goto aa9; case '[': goto aa22; case '\\': goto aa12; case ']': goto aa24; case '{': goto aa18; case '}': goto aa20; default: goto aa40; } aa2: ++AACURSOR; switch ((aach = *AACURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto aa71; default: goto aa3; } aa3: // 178 "scanner.re" { status = PHANNOT_SCANNER_RETCODE_ERR; break; } // 173 "scanner.c" aa4: aaaccept = 0; aach = *(AAMARKER = ++AACURSOR); goto aa72; aa5: // 62 "scanner.re" { token->opcode = PHANNOT_T_INTEGER; token->value = estrndup(start, AACURSOR - start); token->len = AACURSOR - start; q = AACURSOR; return 0; } // 187 "scanner.c" aa6: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'U': case 'u': goto aa66; default: goto aa44; } aa7: // 104 "scanner.re" { token->opcode = PHANNOT_T_IDENTIFIER; token->value = estrndup(start, AACURSOR - start); token->len = AACURSOR - start; q = AACURSOR; return 0; } // 205 "scanner.c" aa8: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'A': case 'a': goto aa61; default: goto aa44; } aa9: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'R': case 'r': goto aa57; default: goto aa44; } aa10: aaaccept = 2; aach = *(AAMARKER = ++AACURSOR); if (aach <= 0x00) goto aa3; goto aa55; aa11: aaaccept = 2; aach = *(AAMARKER = ++AACURSOR); if (aach <= 0x00) goto aa3; goto aa50; aa12: aach = *++AACURSOR; switch (aach) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa43; default: goto aa3; } aa13: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); goto aa44; aa14: ++AACURSOR; // 112 "scanner.re" { token->opcode = PHANNOT_T_PARENTHESES_OPEN; return 0; } // 301 "scanner.c" aa16: ++AACURSOR; // 117 "scanner.re" { token->opcode = PHANNOT_T_PARENTHESES_CLOSE; return 0; } // 309 "scanner.c" aa18: ++AACURSOR; // 122 "scanner.re" { token->opcode = PHANNOT_T_BRACKET_OPEN; return 0; } // 317 "scanner.c" aa20: ++AACURSOR; // 127 "scanner.re" { token->opcode = PHANNOT_T_BRACKET_CLOSE; return 0; } // 325 "scanner.c" aa22: ++AACURSOR; // 132 "scanner.re" { token->opcode = PHANNOT_T_SBRACKET_OPEN; return 0; } // 333 "scanner.c" aa24: ++AACURSOR; // 137 "scanner.re" { token->opcode = PHANNOT_T_SBRACKET_CLOSE; return 0; } // 341 "scanner.c" aa26: ++AACURSOR; // 142 "scanner.re" { token->opcode = PHANNOT_T_AT; return 0; } // 349 "scanner.c" aa28: ++AACURSOR; // 147 "scanner.re" { token->opcode = PHANNOT_T_EQUALS; return 0; } // 357 "scanner.c" aa30: ++AACURSOR; // 152 "scanner.re" { token->opcode = PHANNOT_T_COLON; return 0; } // 365 "scanner.c" aa32: ++AACURSOR; // 157 "scanner.re" { token->opcode = PHANNOT_T_COMMA; return 0; } // 373 "scanner.c" aa34: ++AACURSOR; aach = *AACURSOR; goto aa42; aa35: // 162 "scanner.re" { token->opcode = PHANNOT_T_IGNORE; return 0; } // 384 "scanner.c" aa36: ++AACURSOR; // 167 "scanner.re" { s->active_line++; token->opcode = PHANNOT_T_IGNORE; return 0; } // 393 "scanner.c" aa38: ++AACURSOR; // 173 "scanner.re" { status = PHANNOT_SCANNER_RETCODE_EOF; break; } // 401 "scanner.c" aa40: aach = *++AACURSOR; goto aa3; aa41: ++AACURSOR; aach = *AACURSOR; aa42: switch (aach) { case '\t': case '\r': case ' ': goto aa41; default: goto aa35; } aa43: aaaccept = 1; AAMARKER = ++AACURSOR; aach = *AACURSOR; aa44: switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa43; case '\\': goto aa45; default: goto aa7; } aa45: ++AACURSOR; aach = *AACURSOR; switch (aach) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa47; default: goto aa46; } aa46: AACURSOR = AAMARKER; switch (aaaccept) { case 0: goto aa5; case 1: goto aa7; case 2: goto aa3; case 3: goto aa60; case 4: goto aa65; case 5: goto aa69; } aa47: aaaccept = 1; AAMARKER = ++AACURSOR; aach = *AACURSOR; switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa47; case '\\': goto aa45; default: goto aa7; } aa49: ++AACURSOR; aach = *AACURSOR; aa50: switch (aach) { case 0x00: goto aa46; case '\'': goto aa52; case '\\': goto aa51; default: goto aa49; } aa51: ++AACURSOR; aach = *AACURSOR; switch (aach) { case '\n': goto aa46; default: goto aa49; } aa52: ++AACURSOR; // 95 "scanner.re" { token->opcode = PHANNOT_T_STRING; token->value = estrndup(q, AACURSOR - q - 1); token->len = AACURSOR - q - 1; q = AACURSOR; return 0; } // 654 "scanner.c" aa54: ++AACURSOR; aach = *AACURSOR; aa55: switch (aach) { case 0x00: goto aa46; case '"': goto aa52; case '\\': goto aa56; default: goto aa54; } aa56: ++AACURSOR; aach = *AACURSOR; switch (aach) { case '\n': goto aa46; default: goto aa54; } aa57: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'U': case 'u': goto aa58; default: goto aa44; } aa58: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'E': case 'e': goto aa59; default: goto aa44; } aa59: aaaccept = 3; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa43; case '\\': goto aa45; default: goto aa60; } aa60: // 89 "scanner.re" { token->opcode = PHANNOT_T_TRUE; return 0; } // 764 "scanner.c" aa61: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'L': case 'l': goto aa62; default: goto aa44; } aa62: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'S': case 's': goto aa63; default: goto aa44; } aa63: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'E': case 'e': goto aa64; default: goto aa44; } aa64: aaaccept = 4; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa43; case '\\': goto aa45; default: goto aa65; } aa65: // 84 "scanner.re" { token->opcode = PHANNOT_T_FALSE; return 0; } // 865 "scanner.c" aa66: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'L': case 'l': goto aa67; default: goto aa44; } aa67: aaaccept = 1; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case 'L': case 'l': goto aa68; default: goto aa44; } aa68: aaaccept = 5; aach = *(AAMARKER = ++AACURSOR); switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto aa43; case '\\': goto aa45; default: goto aa69; } aa69: // 79 "scanner.re" { token->opcode = PHANNOT_T_NULL; return 0; } // 958 "scanner.c" aa70: aach = *++AACURSOR; switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto aa73; default: goto aa46; } aa71: aaaccept = 0; AAMARKER = ++AACURSOR; aach = *AACURSOR; aa72: switch (aach) { case '.': goto aa70; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto aa71; default: goto aa5; } aa73: ++AACURSOR; aach = *AACURSOR; switch (aach) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto aa73; default: goto aa75; } aa75: // 71 "scanner.re" { token->opcode = PHANNOT_T_DOUBLE; token->value = estrndup(start, AACURSOR - start); token->len = AACURSOR - start; q = AACURSOR; return 0; } // 1018 "scanner.c" } // 183 "scanner.re" } } return status; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Apc) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Apc, phalcon, annotations_adapter_apc, phalcon_annotations_adapter_ce, phalcon_annotations_adapter_apc_method_entry, 0); zend_declare_property_string(phalcon_annotations_adapter_apc_ce, SL("_prefix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_annotations_adapter_apc_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_annotations_adapter_apc_ce TSRMLS_CC, 1, phalcon_annotations_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Adapter_Apc, __construct) { zval *options = NULL, *prefix, *ttl; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } } } static PHP_METHOD(Phalcon_Annotations_Adapter_Apc, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *_0, *_1, *_2; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVV(_2, "_PHAN", _1, key); zephir_fast_strtolower(_0, _2); ZEPHIR_RETURN_CALL_FUNCTION("apc_fetch", NULL, 82, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Annotations_Adapter_Apc, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0, *_1, *_2, *_3; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVV(_2, "_PHAN", _1, key); zephir_fast_strtolower(_0, _2); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_ttl"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_FUNCTION("apc_store", NULL, 83, _0, data, _3); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Files) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Files, phalcon, annotations_adapter_files, phalcon_annotations_adapter_ce, phalcon_annotations_adapter_files_method_entry, 0); zend_declare_property_string(phalcon_annotations_adapter_files_ce, SL("_annotationsDir"), "./", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_annotations_adapter_files_ce TSRMLS_CC, 1, phalcon_annotations_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Adapter_Files, __construct) { zval *options = NULL, *annotationsDir; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&annotationsDir, options, SS("annotationsDir"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_annotationsDir"), annotationsDir TSRMLS_CC); } } } static PHP_METHOD(Phalcon_Annotations_Adapter_Files, read) { zval *key_param = NULL, *path, *_0, *_1, _2, *_3 = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); zephir_get_strval(key, key_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotationsDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "_", 0); zephir_prepare_virtual_path(_1, key, &_2 TSRMLS_CC); ZEPHIR_INIT_VAR(path); ZEPHIR_CONCAT_VVS(path, _0, _1, ".php"); if ((zephir_file_exists(path TSRMLS_CC) == SUCCESS)) { ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_3); if (zephir_require_zval_ret(&_3, path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_CCTOR(_3); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Annotations_Adapter_Files, write) { zval *key_param = NULL, *data, *path, *_0, *_1, _2, *_3, *_4 = NULL, *_5; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotationsDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "_", 0); zephir_prepare_virtual_path(_1, key, &_2 TSRMLS_CC); ZEPHIR_INIT_VAR(path); ZEPHIR_CONCAT_VVS(path, _0, _1, ".php"); ZEPHIR_INIT_VAR(_3); ZEPHIR_INIT_VAR(_4); ZEPHIR_INIT_NVAR(_4); zephir_var_export_ex(_4, &data TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "<?php return ", _4, "; "); zephir_file_put_contents(_3, path, _5 TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_annotations_exception_ce, "Annotations directory cannot be written", "phalcon/annotations/adapter/files.zep", 92); return; } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Memory) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Memory, phalcon, annotations_adapter_memory, phalcon_annotations_adapter_ce, phalcon_annotations_adapter_memory_method_entry, 0); zend_declare_property_null(phalcon_annotations_adapter_memory_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_annotations_adapter_memory_ce TSRMLS_CC, 1, phalcon_annotations_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, read) { zval *key_param = NULL, *data, *_0, *_1; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, key); if (zephir_array_isset_fetch(&data, _0, _1, 1 TSRMLS_CC)) { RETURN_CTOR(data); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, write) { zval *key_param = NULL, *data, *lowercasedKey; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_INIT_VAR(lowercasedKey); zephir_fast_strtolower(lowercasedKey, key); zephir_update_property_array(this_ptr, SL("_data"), lowercasedKey, data TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Xcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Xcache, phalcon, annotations_adapter_xcache, phalcon_annotations_adapter_ce, phalcon_annotations_adapter_xcache_method_entry, 0); zend_class_implements(phalcon_annotations_adapter_xcache_ce TSRMLS_CC, 1, phalcon_annotations_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Annotations_Adapter_Xcache, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *serialized = NULL, *data = NULL, *_0; zval *key = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "_PHAN", key); zephir_fast_strtolower(_0, _1); ZEPHIR_CALL_FUNCTION(&serialized, "xcache_get", NULL, 84, _0); zephir_check_call_status(); if (Z_TYPE_P(serialized) == IS_STRING) { ZEPHIR_CALL_FUNCTION(&data, "unserialize", NULL, 75, serialized); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_OBJECT) { RETURN_CCTOR(data); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Annotations_Adapter_Xcache, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0, *_2 = NULL; zval *key = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "_PHAN", key); zephir_fast_strtolower(_0, _1); ZEPHIR_CALL_FUNCTION(&_2, "serialize", NULL, 74, data); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", NULL, 85, _0, _2); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Collection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Collection, phalcon, assets_collection, phalcon_assets_collection_method_entry, 0); zend_declare_property_null(phalcon_assets_collection_ce, SL("_prefix"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_assets_collection_ce, SL("_local"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_resources"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_codes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_position"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_attributes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_assets_collection_ce, SL("_join"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_targetUri"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_targetPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_assets_collection_ce, SL("_targetLocal"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_collection_ce, SL("_sourcePath"), ZEND_ACC_PROTECTED TSRMLS_CC); phalcon_assets_collection_ce->create_object = zephir_init_properties_Phalcon_Assets_Collection; zend_class_implements(phalcon_assets_collection_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_assets_collection_ce TSRMLS_CC, 1, zend_ce_iterator); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Collection, getPrefix) { RETURN_MEMBER(this_ptr, "_prefix"); } static PHP_METHOD(Phalcon_Assets_Collection, getLocal) { RETURN_MEMBER(this_ptr, "_local"); } static PHP_METHOD(Phalcon_Assets_Collection, getResources) { RETURN_MEMBER(this_ptr, "_resources"); } static PHP_METHOD(Phalcon_Assets_Collection, getCodes) { RETURN_MEMBER(this_ptr, "_codes"); } static PHP_METHOD(Phalcon_Assets_Collection, getPosition) { RETURN_MEMBER(this_ptr, "_position"); } static PHP_METHOD(Phalcon_Assets_Collection, getFilters) { RETURN_MEMBER(this_ptr, "_filters"); } static PHP_METHOD(Phalcon_Assets_Collection, getAttributes) { RETURN_MEMBER(this_ptr, "_attributes"); } static PHP_METHOD(Phalcon_Assets_Collection, getJoin) { RETURN_MEMBER(this_ptr, "_join"); } static PHP_METHOD(Phalcon_Assets_Collection, getTargetUri) { RETURN_MEMBER(this_ptr, "_targetUri"); } static PHP_METHOD(Phalcon_Assets_Collection, getTargetPath) { RETURN_MEMBER(this_ptr, "_targetPath"); } static PHP_METHOD(Phalcon_Assets_Collection, getTargetLocal) { RETURN_MEMBER(this_ptr, "_targetLocal"); } static PHP_METHOD(Phalcon_Assets_Collection, getSourcePath) { RETURN_MEMBER(this_ptr, "_sourcePath"); } static PHP_METHOD(Phalcon_Assets_Collection, add) { zval *resource; zephir_fetch_params(0, 1, 0, &resource); zephir_update_property_array_append(this_ptr, SL("_resources"), resource TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, addInline) { zval *code; zephir_fetch_params(0, 1, 0, &code); zephir_update_property_array_append(this_ptr, SL("_codes"), code TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, addCss) { int ZEPHIR_LAST_CALL_STATUS; zend_bool filter; zval *path_param = NULL, *local = NULL, *filter_param = NULL, *attributes = NULL, *collectionLocal = NULL, *collectionAttributes = NULL, *_0, *_1; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path_param, &local, &filter_param, &attributes); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!local) { local = ZEPHIR_GLOBAL(global_null); } if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(local) == IS_BOOL) { ZEPHIR_CPY_WRT(collectionLocal, local); } else { ZEPHIR_OBS_NVAR(collectionLocal); zephir_read_property_this(&collectionLocal, this_ptr, SL("_local"), PH_NOISY_CC); } if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CPY_WRT(collectionAttributes, attributes); } else { ZEPHIR_OBS_NVAR(collectionAttributes); zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_resource_css_ce); ZEPHIR_INIT_VAR(_1); if (filter) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 93, path, collectionLocal, _1, collectionAttributes); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_resources"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, addInlineCss) { int ZEPHIR_LAST_CALL_STATUS; zend_bool filter; zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *collectionAttributes = NULL, *_0, *_1; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes); zephir_get_strval(content, content_param); if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CPY_WRT(collectionAttributes, attributes); } else { ZEPHIR_OBS_NVAR(collectionAttributes); zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_inline_css_ce); ZEPHIR_INIT_VAR(_1); if (filter) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 94, content, _1, collectionAttributes); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_codes"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, addJs) { int ZEPHIR_LAST_CALL_STATUS; zend_bool filter; zval *path_param = NULL, *local = NULL, *filter_param = NULL, *attributes = NULL, *collectionLocal = NULL, *collectionAttributes = NULL, *_0, *_1; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path_param, &local, &filter_param, &attributes); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!local) { local = ZEPHIR_GLOBAL(global_null); } if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(local) == IS_BOOL) { ZEPHIR_CPY_WRT(collectionLocal, local); } else { ZEPHIR_OBS_NVAR(collectionLocal); zephir_read_property_this(&collectionLocal, this_ptr, SL("_local"), PH_NOISY_CC); } if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CPY_WRT(collectionAttributes, attributes); } else { ZEPHIR_OBS_NVAR(collectionAttributes); zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_resource_js_ce); ZEPHIR_INIT_VAR(_1); if (filter) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 95, path, collectionLocal, _1, collectionAttributes); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_resources"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, addInlineJs) { int ZEPHIR_LAST_CALL_STATUS; zend_bool filter; zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *collectionAttributes = NULL, *_0, *_1; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes); zephir_get_strval(content, content_param); if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CPY_WRT(collectionAttributes, attributes); } else { ZEPHIR_OBS_NVAR(collectionAttributes); zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_inline_js_ce); ZEPHIR_INIT_VAR(_1); if (filter) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 96, content, _1, collectionAttributes); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_codes"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, count) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resources"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Assets_Collection, rewind) { zval *_0; ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_position"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Assets_Collection, current) { zval *resource, *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resources"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); zephir_array_isset_fetch(&resource, _0, _1, 1 TSRMLS_CC); RETURN_CTORW(resource); } static PHP_METHOD(Phalcon_Assets_Collection, key) { RETURN_MEMBER(this_ptr, "_position"); } static PHP_METHOD(Phalcon_Assets_Collection, next) { RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_position") TSRMLS_CC)); } static PHP_METHOD(Phalcon_Assets_Collection, valid) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_resources"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, _1)); } static PHP_METHOD(Phalcon_Assets_Collection, setTargetPath) { zval *targetPath_param = NULL; zval *targetPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &targetPath_param); if (unlikely(Z_TYPE_P(targetPath_param) != IS_STRING && Z_TYPE_P(targetPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'targetPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(targetPath_param) == IS_STRING)) { zephir_get_strval(targetPath, targetPath_param); } else { ZEPHIR_INIT_VAR(targetPath); ZVAL_EMPTY_STRING(targetPath); } zephir_update_property_this(this_ptr, SL("_targetPath"), targetPath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, setSourcePath) { zval *sourcePath_param = NULL; zval *sourcePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sourcePath_param); if (unlikely(Z_TYPE_P(sourcePath_param) != IS_STRING && Z_TYPE_P(sourcePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sourcePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sourcePath_param) == IS_STRING)) { zephir_get_strval(sourcePath, sourcePath_param); } else { ZEPHIR_INIT_VAR(sourcePath); ZVAL_EMPTY_STRING(sourcePath); } zephir_update_property_this(this_ptr, SL("_sourcePath"), sourcePath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, setTargetUri) { zval *targetUri_param = NULL; zval *targetUri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &targetUri_param); if (unlikely(Z_TYPE_P(targetUri_param) != IS_STRING && Z_TYPE_P(targetUri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'targetUri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(targetUri_param) == IS_STRING)) { zephir_get_strval(targetUri, targetUri_param); } else { ZEPHIR_INIT_VAR(targetUri); ZVAL_EMPTY_STRING(targetUri); } zephir_update_property_this(this_ptr, SL("_targetUri"), targetUri TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, setPrefix) { zval *prefix_param = NULL; zval *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &prefix_param); if (unlikely(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Collection, setLocal) { zval *local_param = NULL; zend_bool local; zephir_fetch_params(0, 1, 0, &local_param); if (unlikely(Z_TYPE_P(local_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'local' must be a bool") TSRMLS_CC); RETURN_NULL(); } local = Z_BVAL_P(local_param); if (local) { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, setAttributes) { zval *attributes_param = NULL; zval *attributes = NULL; zephir_fetch_params(0, 1, 0, &attributes_param); attributes = attributes_param; zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, setFilters) { zval *filters_param = NULL; zval *filters = NULL; zephir_fetch_params(0, 1, 0, &filters_param); filters = filters_param; zephir_update_property_this(this_ptr, SL("_filters"), filters TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, setTargetLocal) { zval *targetLocal_param = NULL; zend_bool targetLocal; zephir_fetch_params(0, 1, 0, &targetLocal_param); if (unlikely(Z_TYPE_P(targetLocal_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'targetLocal' must be a bool") TSRMLS_CC); RETURN_NULL(); } targetLocal = Z_BVAL_P(targetLocal_param); if (targetLocal) { zephir_update_property_this(this_ptr, SL("_targetLocal"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_targetLocal"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, join) { zval *join_param = NULL; zend_bool join; zephir_fetch_params(0, 1, 0, &join_param); join = zephir_get_boolval(join_param); if (join) { zephir_update_property_this(this_ptr, SL("_join"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_join"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Collection, getRealTargetPath) { int ZEPHIR_LAST_CALL_STATUS; zval *basePath_param = NULL, *targetPath, *completePath; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &basePath_param); if (unlikely(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(basePath_param) == IS_STRING)) { zephir_get_strval(basePath, basePath_param); } else { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } ZEPHIR_OBS_VAR(targetPath); zephir_read_property_this(&targetPath, this_ptr, SL("_targetPath"), PH_NOISY_CC); ZEPHIR_INIT_VAR(completePath); ZEPHIR_CONCAT_VV(completePath, basePath, targetPath); if ((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 63, completePath); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(completePath); } static PHP_METHOD(Phalcon_Assets_Collection, addFilter) { zval *filter; zephir_fetch_params(0, 1, 0, &filter); zephir_update_property_array_append(this_ptr, SL("_filters"), filter TSRMLS_CC); RETURN_THISW(); } static zend_object_value zephir_init_properties_Phalcon_Assets_Collection(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1 = NULL, *_2, *_3, *_4; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_attributes"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_attributes"), _1 TSRMLS_CC); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); if (Z_TYPE_P(_2) == IS_NULL) { ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_filters"), _1 TSRMLS_CC); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_codes"), PH_NOISY_CC); if (Z_TYPE_P(_3) == IS_NULL) { ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_codes"), _1 TSRMLS_CC); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_resources"), PH_NOISY_CC); if (Z_TYPE_P(_4) == IS_NULL) { ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_resources"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets, Exception, phalcon, assets_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_FilterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Assets, FilterInterface, phalcon, assets_filterinterface, phalcon_assets_filterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Assets_FilterInterface, filter); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Inline, phalcon, assets_inline, phalcon_assets_inline_method_entry, 0); zend_declare_property_null(phalcon_assets_inline_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_inline_ce, SL("_content"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_inline_ce, SL("_filter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_inline_ce, SL("_attributes"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Inline, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Assets_Inline, getContent) { RETURN_MEMBER(this_ptr, "_content"); } static PHP_METHOD(Phalcon_Assets_Inline, getFilter) { RETURN_MEMBER(this_ptr, "_filter"); } static PHP_METHOD(Phalcon_Assets_Inline, getAttributes) { RETURN_MEMBER(this_ptr, "_attributes"); } static PHP_METHOD(Phalcon_Assets_Inline, __construct) { zend_bool filter; zval *type_param = NULL, *content_param = NULL, *filter_param = NULL, *attributes = NULL; zval *type = NULL, *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &type_param, &content_param, &filter_param, &attributes); zephir_get_strval(type, type_param); zephir_get_strval(content, content_param); if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); if (filter) { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Assets_Inline, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); zephir_get_strval(type, type_param); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Inline, setFilter) { zval *filter_param = NULL; zend_bool filter; zephir_fetch_params(0, 1, 0, &filter_param); filter = zephir_get_boolval(filter_param); if (filter) { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Inline, setAttributes) { zval *attributes_param = NULL; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); zephir_get_arrval(attributes, attributes_param); zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Manager, phalcon, assets_manager, phalcon_assets_manager_method_entry, 0); zend_declare_property_null(phalcon_assets_manager_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_manager_ce, SL("_collections"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_assets_manager_ce, SL("_implicitOutput"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Manager, __construct) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } } static PHP_METHOD(Phalcon_Assets_Manager, setOptions) { zval *options_param = NULL; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Manager, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Assets_Manager, useImplicitOutput) { zval *implicitOutput_param = NULL; zend_bool implicitOutput; zephir_fetch_params(0, 1, 0, &implicitOutput_param); implicitOutput = zephir_get_boolval(implicitOutput_param); if (implicitOutput) { zephir_update_property_this(this_ptr, SL("_implicitOutput"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_implicitOutput"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Manager, addCss) { int ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *local = NULL, *filter = NULL, *attributes = NULL, *_0, *_1; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path_param, &local, &filter, &attributes); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!local) { local = ZEPHIR_GLOBAL(global_true); } if (!filter) { filter = ZEPHIR_GLOBAL(global_true); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_resource_css_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 93, path, local, filter, attributes); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addresourcebytype", NULL, 0, _1, _0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addInlineCss) { int ZEPHIR_LAST_CALL_STATUS; zval *content_param = NULL, *filter = NULL, *attributes = NULL, *_0, *_1; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter, &attributes); zephir_get_strval(content, content_param); if (!filter) { filter = ZEPHIR_GLOBAL(global_true); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_inline_css_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 94, content, filter, attributes); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, _1, _0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addJs) { int ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *local = NULL, *filter = NULL, *attributes = NULL, *_0, *_1; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path_param, &local, &filter, &attributes); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!local) { local = ZEPHIR_GLOBAL(global_true); } if (!filter) { filter = ZEPHIR_GLOBAL(global_true); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_resource_js_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 95, path, local, filter, attributes); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addresourcebytype", NULL, 0, _1, _0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addInlineJs) { int ZEPHIR_LAST_CALL_STATUS; zval *content_param = NULL, *filter = NULL, *attributes = NULL, *_0, *_1; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter, &attributes); zephir_get_strval(content, content_param); if (!filter) { filter = ZEPHIR_GLOBAL(global_true); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_inline_js_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 96, content, filter, attributes); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, _1, _0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addResourceByType) { int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *resource, *collection = NULL, *_0; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &resource); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } ZEPHIR_OBS_VAR(collection); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&collection, _0, type, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(collection); object_init_ex(collection, phalcon_assets_collection_ce); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_collections"), type, collection TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, collection, "add", NULL, 98, resource); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addInlineCodeByType) { int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *code, *collection = NULL, *_0; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &code); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } ZEPHIR_OBS_VAR(collection); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&collection, _0, type, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(collection); object_init_ex(collection, phalcon_assets_collection_ce); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_collections"), type, collection TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, collection, "addinline", NULL, 99, code); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addResource) { int ZEPHIR_LAST_CALL_STATUS; zval *resource, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &resource); ZEPHIR_CALL_METHOD(&_0, resource, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addresourcebytype", NULL, 0, _0, resource); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, addInlineCode) { int ZEPHIR_LAST_CALL_STATUS; zval *code, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &code); ZEPHIR_CALL_METHOD(&_0, code, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, _0, code); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, set) { zval *id_param = NULL, *collection; zval *id = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &id_param, &collection); if (unlikely(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(id_param) == IS_STRING)) { zephir_get_strval(id, id_param); } else { ZEPHIR_INIT_VAR(id); ZVAL_EMPTY_STRING(id); } zephir_update_property_array(this_ptr, SL("_collections"), id, collection TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Manager, get) { zval *id_param = NULL, *collection, *_0; zval *id = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id_param); if (unlikely(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(id_param) == IS_STRING)) { zephir_get_strval(id, id_param); } else { ZEPHIR_INIT_VAR(id); ZVAL_EMPTY_STRING(id); } ZEPHIR_OBS_VAR(collection); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&collection, _0, id, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The collection does not exist in the manager", "phalcon/assets/manager.zep", 231); return; } RETURN_CCTOR(collection); } static PHP_METHOD(Phalcon_Assets_Manager, getCss) { int ZEPHIR_LAST_CALL_STATUS; zval *collection, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&collection, _0, SS("css"), 1 TSRMLS_CC))) { object_init_ex(return_value, phalcon_assets_collection_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); } RETURN_CTOR(collection); } static PHP_METHOD(Phalcon_Assets_Manager, getJs) { int ZEPHIR_LAST_CALL_STATUS; zval *collection, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&collection, _0, SS("js"), 1 TSRMLS_CC))) { object_init_ex(return_value, phalcon_assets_collection_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); } RETURN_CTOR(collection); } static PHP_METHOD(Phalcon_Assets_Manager, collection) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *collection = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_OBS_VAR(collection); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_collections"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&collection, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(collection); object_init_ex(collection, phalcon_assets_collection_ce); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_collections"), name, collection TSRMLS_CC); } RETURN_CCTOR(collection); } static PHP_METHOD(Phalcon_Assets_Manager, output) { HashTable *_4, *_7; HashPosition _3, _6; int ZEPHIR_LAST_CALL_STATUS; zend_bool filterNeeded; zval *collection, *callback, *type = NULL, *output, *resources = NULL, *filters = NULL, *prefix = NULL, *sourceBasePath = NULL, *targetBasePath = NULL, *options, *collectionSourcePath = NULL, *completeSourcePath = NULL, *collectionTargetPath = NULL, *completeTargetPath = NULL, *filteredJoinedContent, *join = NULL, *resource = NULL, *local = NULL, *sourcePath = NULL, *targetPath = NULL, *path = NULL, *prefixedPath = NULL, *attributes = NULL, *parameters = NULL, *html = NULL, *useImplicitOutput, *content = NULL, *mustFilter = NULL, *filter = NULL, *filteredContent = NULL, *typeCss, *targetUri = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, **_5, **_8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &collection, &callback, &type); ZEPHIR_SEPARATE_PARAM(type); ZEPHIR_INIT_VAR(sourceBasePath); ZVAL_NULL(sourceBasePath); ZEPHIR_INIT_VAR(targetBasePath); ZVAL_NULL(targetBasePath); ZEPHIR_OBS_VAR(useImplicitOutput); zephir_read_property_this(&useImplicitOutput, this_ptr, SL("_implicitOutput"), PH_NOISY_CC); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); ZEPHIR_CALL_METHOD(&resources, collection, "getresources", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&filters, collection, "getfilters", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&prefix, collection, "getprefix", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(typeCss); ZVAL_STRING(typeCss, "css", 1); if (zephir_fast_count_int(filters TSRMLS_CC)) { ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_NVAR(sourceBasePath); zephir_array_isset_string_fetch(&sourceBasePath, options, SS("sourceBasePath"), 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(targetBasePath); zephir_array_isset_string_fetch(&targetBasePath, options, SS("targetBasePath"), 0 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&collectionSourcePath, collection, "getsourcepath", NULL, 0); zephir_check_call_status(); if (zephir_is_true(collectionSourcePath)) { ZEPHIR_INIT_VAR(completeSourcePath); ZEPHIR_CONCAT_VV(completeSourcePath, sourceBasePath, collectionSourcePath); } else { ZEPHIR_CPY_WRT(completeSourcePath, sourceBasePath); } ZEPHIR_CALL_METHOD(&collectionTargetPath, collection, "gettargetpath", NULL, 0); zephir_check_call_status(); if (zephir_is_true(collectionTargetPath)) { ZEPHIR_INIT_VAR(completeTargetPath); ZEPHIR_CONCAT_VV(completeTargetPath, targetBasePath, collectionTargetPath); } else { ZEPHIR_CPY_WRT(completeTargetPath, targetBasePath); } ZEPHIR_INIT_VAR(filteredJoinedContent); ZVAL_STRING(filteredJoinedContent, "", 1); ZEPHIR_CALL_METHOD(&join, collection, "getjoin", NULL, 0); zephir_check_call_status(); if (zephir_is_true(join)) { if (!(zephir_is_true(completeTargetPath))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_assets_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Path '", completeTargetPath, "' is not a valid target path (1)"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/assets/manager.zep", 393 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_FUNCTION(&_2, "is_dir", NULL, 100, completeTargetPath); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_assets_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "Path '", completeTargetPath, "' is not a valid target path (2), is dir."); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/assets/manager.zep", 397 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } zephir_is_iterable(resources, &_4, &_3, 0, 0, "phalcon/assets/manager.zep", 635); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(resource, _5); filterNeeded = 0; ZEPHIR_CALL_METHOD(&type, resource, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&local, resource, "getlocal", NULL, 0); zephir_check_call_status(); if (zephir_fast_count_int(filters TSRMLS_CC)) { if (zephir_is_true(local)) { ZEPHIR_CALL_METHOD(&sourcePath, resource, "getrealsourcepath", NULL, 0, completeSourcePath); zephir_check_call_status(); if (!(zephir_is_true(sourcePath))) { ZEPHIR_CALL_METHOD(&sourcePath, resource, "getpath", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_assets_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "Resource '", sourcePath, "' does not have a valid source path"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/assets/manager.zep", 431 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CALL_METHOD(&sourcePath, resource, "getpath", NULL, 0); zephir_check_call_status(); filterNeeded = 1; } ZEPHIR_CALL_METHOD(&targetPath, resource, "getrealtargetpath", NULL, 0, completeTargetPath); zephir_check_call_status(); if (!(zephir_is_true(targetPath))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_assets_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "Resource '", sourcePath, "' does not have a valid target path"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/assets/manager.zep", 455 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(local)) { if (ZEPHIR_IS_EQUAL(targetPath, sourcePath)) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_assets_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "Resource '", targetPath, "' have the same source and target paths"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/assets/manager.zep", 464 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if ((zephir_file_exists(targetPath TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_NVAR(_0); if (zephir_compare_mtime(targetPath, sourcePath TSRMLS_CC)) { filterNeeded = 1; } } else { filterNeeded = 1; } } } else { ZEPHIR_CALL_METHOD(&path, resource, "getrealtargeturi", NULL, 0); zephir_check_call_status(); if (zephir_is_true(prefix)) { ZEPHIR_INIT_NVAR(prefixedPath); ZEPHIR_CONCAT_VV(prefixedPath, prefix, path); } else { ZEPHIR_CPY_WRT(prefixedPath, path); } ZEPHIR_CALL_METHOD(&attributes, resource, "getattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(parameters); array_init(parameters); if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_array_update_long(&attributes, 0, &prefixedPath, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_append(¶meters, attributes, PH_SEPARATE, "phalcon/assets/manager.zep", 499); } else { zephir_array_append(¶meters, prefixedPath, PH_SEPARATE, "phalcon/assets/manager.zep", 501); } zephir_array_append(¶meters, local, PH_SEPARATE, "phalcon/assets/manager.zep", 503); ZEPHIR_INIT_NVAR(html); ZEPHIR_CALL_USER_FUNC_ARRAY(html, callback, parameters); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(useImplicitOutput)) { zend_print_zval(html, 0); } else { zephir_concat_self(&output, html TSRMLS_CC); } continue; } if (filterNeeded == 1) { ZEPHIR_CALL_METHOD(&content, resource, "getcontent", NULL, 0, completeSourcePath); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&mustFilter, resource, "getfilter", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(mustFilter)) { zephir_is_iterable(filters, &_7, &_6, 0, 0, "phalcon/assets/manager.zep", 556); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(filter, _8); if (Z_TYPE_P(filter) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/assets/manager.zep", 544); return; } ZEPHIR_CALL_METHOD(&filteredContent, filter, "filter", NULL, 0, content); zephir_check_call_status(); ZEPHIR_CPY_WRT(content, filteredContent); } if (ZEPHIR_IS_TRUE(join)) { if (ZEPHIR_IS_EQUAL(type, typeCss)) { zephir_concat_self(&filteredJoinedContent, filteredContent TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_VS(_1, filteredContent, ";"); zephir_concat_self(&filteredJoinedContent, _1 TSRMLS_CC); } } } else { if (ZEPHIR_IS_TRUE(join)) { zephir_concat_self(&filteredJoinedContent, content TSRMLS_CC); } else { ZEPHIR_CPY_WRT(filteredContent, content); } } if (!(zephir_is_true(join))) { zephir_file_put_contents(NULL, targetPath, filteredContent TSRMLS_CC); } } if (!(zephir_is_true(join))) { ZEPHIR_CALL_METHOD(&path, resource, "getrealtargeturi", NULL, 0); zephir_check_call_status(); if (zephir_is_true(prefix)) { ZEPHIR_INIT_NVAR(prefixedPath); ZEPHIR_CONCAT_VV(prefixedPath, prefix, path); } else { ZEPHIR_CPY_WRT(prefixedPath, path); } ZEPHIR_CALL_METHOD(&attributes, resource, "getattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(local); ZVAL_BOOL(local, 1); ZEPHIR_INIT_NVAR(parameters); array_init(parameters); if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_array_update_long(&attributes, 0, &prefixedPath, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_append(¶meters, attributes, PH_SEPARATE, "phalcon/assets/manager.zep", 613); } else { zephir_array_append(¶meters, prefixedPath, PH_SEPARATE, "phalcon/assets/manager.zep", 615); } zephir_array_append(¶meters, local, PH_SEPARATE, "phalcon/assets/manager.zep", 617); ZEPHIR_INIT_NVAR(html); ZEPHIR_CALL_USER_FUNC_ARRAY(html, callback, parameters); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(useImplicitOutput)) { zend_print_zval(html, 0); } else { zephir_concat_self(&output, html TSRMLS_CC); } } } if (zephir_fast_count_int(filters TSRMLS_CC)) { if (ZEPHIR_IS_TRUE(join)) { zephir_file_put_contents(NULL, completeTargetPath, filteredJoinedContent TSRMLS_CC); ZEPHIR_CALL_METHOD(&targetUri, collection, "gettargeturi", NULL, 0); zephir_check_call_status(); if (zephir_is_true(prefix)) { ZEPHIR_INIT_NVAR(prefixedPath); ZEPHIR_CONCAT_VV(prefixedPath, prefix, targetUri); } else { ZEPHIR_CPY_WRT(prefixedPath, targetUri); } ZEPHIR_CALL_METHOD(&attributes, collection, "getattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&local, collection, "gettargetlocal", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(parameters); array_init(parameters); if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_array_update_long(&attributes, 0, &prefixedPath, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_append(¶meters, attributes, PH_SEPARATE, "phalcon/assets/manager.zep", 672); } else { zephir_array_append(¶meters, prefixedPath, PH_SEPARATE, "phalcon/assets/manager.zep", 674); } zephir_array_append(¶meters, local, PH_SEPARATE, "phalcon/assets/manager.zep", 676); ZEPHIR_INIT_NVAR(html); ZEPHIR_CALL_USER_FUNC_ARRAY(html, callback, parameters); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(useImplicitOutput)) { zend_print_zval(html, 0); } else { zephir_concat_self(&output, html TSRMLS_CC); } } } RETURN_CCTOR(output); } static PHP_METHOD(Phalcon_Assets_Manager, outputInline) { zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; HashTable *_1, *_4; HashPosition _0, _3; int ZEPHIR_LAST_CALL_STATUS; zval *collection, *type, *output, *html, *codes = NULL, *filters = NULL, *filter = NULL, *code = NULL, *attributes = NULL, *content = NULL, *join = NULL, *joinedContent, **_2, **_5, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_12 = NULL, *_13 = NULL, *_14; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &collection, &type); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); ZEPHIR_INIT_VAR(html); ZVAL_STRING(html, "", 1); ZEPHIR_INIT_VAR(joinedContent); ZVAL_STRING(joinedContent, "", 1); ZEPHIR_CALL_METHOD(&codes, collection, "getcodes", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&filters, collection, "getfilters", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&join, collection, "getjoin", NULL, 0); zephir_check_call_status(); if (zephir_fast_count_int(codes TSRMLS_CC)) { zephir_is_iterable(codes, &_1, &_0, 0, 0, "phalcon/assets/manager.zep", 743); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(code, _2); ZEPHIR_CALL_METHOD(&attributes, code, "getattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&content, code, "getcontent", NULL, 0); zephir_check_call_status(); if (zephir_fast_count_int(filters TSRMLS_CC)) { zephir_is_iterable(filters, &_4, &_3, 0, 0, "phalcon/assets/manager.zep", 734); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(filter, _5); if (Z_TYPE_P(filter) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/assets/manager.zep", 726); return; } ZEPHIR_CALL_METHOD(&_6, filter, "filter", NULL, 0, content); zephir_check_call_status(); ZEPHIR_CPY_WRT(content, _6); } } if (zephir_is_true(join)) { zephir_concat_self(&joinedContent, content TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_8); ZVAL_BOOL(_8, 0); ZEPHIR_INIT_NVAR(_9); ZVAL_BOOL(_9, 1); ZEPHIR_CALL_CE_STATIC(&_6, phalcon_tag_ce, "taghtml", &_7, 0, type, attributes, _8, _9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8); ZVAL_BOOL(_8, 1); ZEPHIR_CALL_CE_STATIC(&_10, phalcon_tag_ce, "taghtmlclose", &_11, 0, type, _8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_VVV(_12, _6, content, _10); zephir_concat_self(&html, _12 TSRMLS_CC); } } if (zephir_is_true(join)) { ZEPHIR_INIT_NVAR(_8); ZVAL_BOOL(_8, 0); ZEPHIR_INIT_NVAR(_9); ZVAL_BOOL(_9, 1); ZEPHIR_CALL_CE_STATIC(&_10, phalcon_tag_ce, "taghtml", &_7, 0, type, attributes, _8, _9); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8); ZVAL_BOOL(_8, 1); ZEPHIR_CALL_CE_STATIC(&_13, phalcon_tag_ce, "taghtmlclose", &_11, 0, type, _8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_VVV(_12, _10, joinedContent, _13); zephir_concat_self(&html, _12 TSRMLS_CC); } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_implicitOutput"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE(_14)) { zend_print_zval(html, 0); } else { zephir_concat_self(&output, html TSRMLS_CC); } } RETURN_CCTOR(output); } static PHP_METHOD(Phalcon_Assets_Manager, outputCss) { zval *_0; int ZEPHIR_LAST_CALL_STATUS; zval *collectionName = NULL, *collection = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &collectionName); if (!collectionName) { collectionName = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(collectionName))) { ZEPHIR_CALL_METHOD(&collection, this_ptr, "getcss", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, collectionName); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "Phalcon\\Tag", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "stylesheetLink", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "output", NULL, 0, collection, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Assets_Manager, outputInlineCss) { int ZEPHIR_LAST_CALL_STATUS; zval *collectionName = NULL, *collection = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &collectionName); if (!collectionName) { collectionName = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(collectionName))) { ZEPHIR_CALL_METHOD(&collection, this_ptr, "getcss", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, collectionName); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "style", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputinline", NULL, 0, collection, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Assets_Manager, outputJs) { zval *_0; int ZEPHIR_LAST_CALL_STATUS; zval *collectionName = NULL, *collection = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &collectionName); if (!collectionName) { collectionName = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(collectionName))) { ZEPHIR_CALL_METHOD(&collection, this_ptr, "getjs", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, collectionName); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "Phalcon\\Tag", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "javascriptInclude", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "output", NULL, 0, collection, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Assets_Manager, outputInlineJs) { int ZEPHIR_LAST_CALL_STATUS; zval *collectionName = NULL, *collection = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &collectionName); if (!collectionName) { collectionName = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(collectionName))) { ZEPHIR_CALL_METHOD(&collection, this_ptr, "getjs", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, collectionName); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "script", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputinline", NULL, 0, collection, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Assets_Manager, getCollections) { RETURN_MEMBER(this_ptr, "_collections"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Resource) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Resource, phalcon, assets_resource, phalcon_assets_resource_method_entry, 0); zend_declare_property_null(phalcon_assets_resource_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_path"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_local"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_filter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_attributes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_sourcePath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_targetPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_assets_resource_ce, SL("_targetUri"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Resource, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Assets_Resource, getPath) { RETURN_MEMBER(this_ptr, "_path"); } static PHP_METHOD(Phalcon_Assets_Resource, getLocal) { RETURN_MEMBER(this_ptr, "_local"); } static PHP_METHOD(Phalcon_Assets_Resource, getFilter) { RETURN_MEMBER(this_ptr, "_filter"); } static PHP_METHOD(Phalcon_Assets_Resource, getAttributes) { RETURN_MEMBER(this_ptr, "_attributes"); } static PHP_METHOD(Phalcon_Assets_Resource, getSourcePath) { RETURN_MEMBER(this_ptr, "_sourcePath"); } static PHP_METHOD(Phalcon_Assets_Resource, getTargetPath) { RETURN_MEMBER(this_ptr, "_targetPath"); } static PHP_METHOD(Phalcon_Assets_Resource, getTargetUri) { RETURN_MEMBER(this_ptr, "_targetUri"); } static PHP_METHOD(Phalcon_Assets_Resource, __construct) { zend_bool local, filter; zval *type_param = NULL, *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes = NULL; zval *type = NULL, *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 3, &type_param, &path_param, &local_param, &filter_param, &attributes); zephir_get_strval(type, type_param); zephir_get_strval(path, path_param); if (!local_param) { local = 1; } else { local = zephir_get_boolval(local_param); } if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); if (local) { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (filter) { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Assets_Resource, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); zephir_get_strval(type, type_param); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, setPath) { zval *path_param = NULL; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &path_param); zephir_get_strval(path, path_param); zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, setLocal) { zval *local_param = NULL; zend_bool local; zephir_fetch_params(0, 1, 0, &local_param); local = zephir_get_boolval(local_param); if (local) { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_local"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Resource, setFilter) { zval *filter_param = NULL; zend_bool filter; zephir_fetch_params(0, 1, 0, &filter_param); filter = zephir_get_boolval(filter_param); if (filter) { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_filter"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Assets_Resource, setAttributes) { zval *attributes_param = NULL; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); zephir_get_arrval(attributes, attributes_param); zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, setTargetUri) { zval *targetUri_param = NULL; zval *targetUri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &targetUri_param); zephir_get_strval(targetUri, targetUri_param); zephir_update_property_this(this_ptr, SL("_targetUri"), targetUri TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, setSourcePath) { zval *sourcePath_param = NULL; zval *sourcePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sourcePath_param); zephir_get_strval(sourcePath, sourcePath_param); zephir_update_property_this(this_ptr, SL("_sourcePath"), sourcePath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, setTargetPath) { zval *targetPath_param = NULL; zval *targetPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &targetPath_param); zephir_get_strval(targetPath, targetPath_param); zephir_update_property_this(this_ptr, SL("_targetPath"), targetPath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Assets_Resource, getContent) { int ZEPHIR_LAST_CALL_STATUS; zval *basePath_param = NULL, *sourcePath = NULL, *completePath, *content, *_0, *_1 = NULL, *_2 = NULL; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &basePath_param); if (!basePath_param) { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } else { zephir_get_strval(basePath, basePath_param); } ZEPHIR_OBS_VAR(sourcePath); zephir_read_property_this(&sourcePath, this_ptr, SL("_sourcePath"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(sourcePath)) { ZEPHIR_OBS_NVAR(sourcePath); zephir_read_property_this(&sourcePath, this_ptr, SL("_path"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(completePath); ZEPHIR_CONCAT_VV(completePath, basePath, sourcePath); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_local"), PH_NOISY_CC); if (zephir_is_true(_0)) { if (!((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_assets_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource's content for '", completePath, "' cannot be read"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/assets/resource.zep", 169 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_INIT_VAR(content); zephir_file_get_contents(content, completePath TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(content)) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_assets_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "Resource's content for '", completePath, "' cannot be read"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/assets/resource.zep", 178 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(content); } static PHP_METHOD(Phalcon_Assets_Resource, getRealTargetUri) { zval *targetUri = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(targetUri); zephir_read_property_this(&targetUri, this_ptr, SL("_targetUri"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(targetUri)) { ZEPHIR_OBS_NVAR(targetUri); zephir_read_property_this(&targetUri, this_ptr, SL("_path"), PH_NOISY_CC); } RETURN_CCTOR(targetUri); } static PHP_METHOD(Phalcon_Assets_Resource, getRealSourcePath) { int ZEPHIR_LAST_CALL_STATUS; zval *basePath_param = NULL, *sourcePath = NULL, *_0, *_1; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &basePath_param); if (!basePath_param) { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } else { zephir_get_strval(basePath, basePath_param); } ZEPHIR_OBS_VAR(sourcePath); zephir_read_property_this(&sourcePath, this_ptr, SL("_sourcePath"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(sourcePath)) { ZEPHIR_OBS_NVAR(sourcePath); zephir_read_property_this(&sourcePath, this_ptr, SL("_path"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_local"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VV(_1, basePath, sourcePath); ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 63, _1); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(sourcePath); } static PHP_METHOD(Phalcon_Assets_Resource, getRealTargetPath) { int ZEPHIR_LAST_CALL_STATUS; zval *basePath_param = NULL, *targetPath = NULL, *completePath, *_0; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &basePath_param); if (!basePath_param) { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } else { zephir_get_strval(basePath, basePath_param); } ZEPHIR_OBS_VAR(targetPath); zephir_read_property_this(&targetPath, this_ptr, SL("_targetPath"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(targetPath)) { ZEPHIR_OBS_NVAR(targetPath); zephir_read_property_this(&targetPath, this_ptr, SL("_path"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_local"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(completePath); ZEPHIR_CONCAT_VV(completePath, basePath, targetPath); if ((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 63, completePath); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(completePath); } RETURN_CCTOR(targetPath); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_Cssmin) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, Cssmin, phalcon, assets_filters_cssmin, phalcon_assets_filters_cssmin_method_entry, 0); zend_class_implements(phalcon_assets_filters_cssmin_ce TSRMLS_CC, 1, phalcon_assets_filterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Filters_Cssmin, filter) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } phalcon_cssmin(return_value, content TSRMLS_CC); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_Jsmin) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, Jsmin, phalcon, assets_filters_jsmin, phalcon_assets_filters_jsmin_method_entry, 0); zend_class_implements(phalcon_assets_filters_jsmin_ce TSRMLS_CC, 1, phalcon_assets_filterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Filters_Jsmin, filter) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } phalcon_jsmin(return_value, content TSRMLS_CC); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_None) { ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, None, phalcon, assets_filters_none, phalcon_assets_filters_none_method_entry, 0); zend_class_implements(phalcon_assets_filters_none_ce TSRMLS_CC, 1, phalcon_assets_filterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Filters_None, filter) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } RETURN_CTOR(content); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline_Css) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Inline, Css, phalcon, assets_inline_css, phalcon_assets_inline_ce, phalcon_assets_inline_css_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Inline_Css, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zend_bool filter; zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *_1, *_2; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes); zephir_get_strval(content, content_param); if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { ZEPHIR_CPY_WRT(attributes, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(attributes); } if (Z_TYPE_P(attributes) == IS_NULL) { ZEPHIR_INIT_NVAR(attributes); zephir_create_array(attributes, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(attributes, SS("type"), SL("text/css"), 1); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); if (filter) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_CALL_PARENT(NULL, phalcon_assets_inline_css_ce, this_ptr, "__construct", &_0, 97, _1, content, _2, attributes); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline_Js) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Inline, Js, phalcon, assets_inline_js, phalcon_assets_inline_ce, phalcon_assets_inline_js_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Inline_Js, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zend_bool filter; zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *_1, *_2; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes); zephir_get_strval(content, content_param); if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { ZEPHIR_CPY_WRT(attributes, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(attributes); } if (Z_TYPE_P(attributes) == IS_NULL) { ZEPHIR_INIT_NVAR(attributes); zephir_create_array(attributes, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(attributes, SS("type"), SL("text/javascript"), 1); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); if (filter) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_CALL_PARENT(NULL, phalcon_assets_inline_js_ce, this_ptr, "__construct", &_0, 97, _1, content, _2, attributes); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Resource_Css) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Resource, Css, phalcon, assets_resource_css, phalcon_assets_resource_ce, phalcon_assets_resource_css_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Resource_Css, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zend_bool local, filter; zval *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes = NULL, *_1, *_2, *_3; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path_param, &local_param, &filter_param, &attributes); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!local_param) { local = 1; } else { local = zephir_get_boolval(local_param); } if (!filter_param) { filter = 1; } else { filter = zephir_get_boolval(filter_param); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); if (local) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_INIT_VAR(_3); if (filter) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_CALL_PARENT(NULL, phalcon_assets_resource_css_ce, this_ptr, "__construct", &_0, 101, _1, path, _2, _3, attributes); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Assets_Resource_Js) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Resource, Js, phalcon, assets_resource_js, phalcon_assets_resource_ce, phalcon_assets_resource_js_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Assets_Resource_Js, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *path, *local = NULL, *filter = NULL, *attributes = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &path, &local, &filter, &attributes); if (!local) { local = ZEPHIR_GLOBAL(global_true); } if (!filter) { filter = ZEPHIR_GLOBAL(global_true); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_PARENT(NULL, phalcon_assets_resource_js_ce, this_ptr, "__construct", &_0, 101, _1, path, local, filter, attributes); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache, Backend, phalcon, cache_backend, phalcon_cache_backend_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_cache_backend_ce, SL("_frontend"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cache_backend_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_cache_backend_ce, SL("_prefix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_cache_backend_ce, SL("_lastKey"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cache_backend_ce, SL("_lastLifetime"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_cache_backend_ce, SL("_fresh"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_cache_backend_ce, SL("_started"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend, getFrontend) { RETURN_MEMBER(this_ptr, "_frontend"); } static PHP_METHOD(Phalcon_Cache_Backend, setFrontend) { zval *frontend; zephir_fetch_params(0, 1, 0, &frontend); zephir_update_property_this(this_ptr, SL("_frontend"), frontend TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Backend, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Cache_Backend, setOptions) { zval *options; zephir_fetch_params(0, 1, 0, &options); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Backend, getLastKey) { RETURN_MEMBER(this_ptr, "_lastKey"); } static PHP_METHOD(Phalcon_Cache_Backend, setLastKey) { zval *lastKey; zephir_fetch_params(0, 1, 0, &lastKey); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Backend, __construct) { zval *frontend, *options = NULL, *prefix; zephir_fetch_params(0, 1, 1, &frontend, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_frontend"), frontend TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Backend, start) { int ZEPHIR_LAST_CALL_STATUS; zend_bool fresh; zval *keyName, *lifetime = NULL, *existingCache = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&existingCache, this_ptr, "get", NULL, 0, keyName, lifetime); zephir_check_call_status(); if (Z_TYPE_P(existingCache) == IS_NULL) { fresh = 1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "start", NULL, 0); zephir_check_call_status(); } else { fresh = 0; } if (fresh) { zephir_update_property_this(this_ptr, SL("_fresh"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_fresh"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (Z_TYPE_P(lifetime) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_lastLifetime"), lifetime TSRMLS_CC); } RETURN_CCTOR(existingCache); } static PHP_METHOD(Phalcon_Cache_Backend, stop) { int ZEPHIR_LAST_CALL_STATUS; zval *stopBuffer_param = NULL, *_0; zend_bool stopBuffer; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &stopBuffer_param); if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (stopBuffer == 1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "stop", NULL, 0); zephir_check_call_status(); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend, isFresh) { RETURN_MEMBER(this_ptr, "_fresh"); } static PHP_METHOD(Phalcon_Cache_Backend, isStarted) { RETURN_MEMBER(this_ptr, "_started"); } static PHP_METHOD(Phalcon_Cache_Backend, getLifetime) { RETURN_MEMBER(this_ptr, "_lastLifetime"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_BackendInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache, BackendInterface, phalcon, cache_backendinterface, phalcon_cache_backendinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, start); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, stop); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, getFrontend); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, getOptions); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, isFresh); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, isStarted); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, setLastKey); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, getLastKey); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, save); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, queryKeys); ZEPHIR_DOC_METHOD(Phalcon_Cache_BackendInterface, exists); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, Exception, phalcon, cache_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_FrontendInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache, FrontendInterface, phalcon, cache_frontendinterface, phalcon_cache_frontendinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, getLifetime); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, isBuffering); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, start); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, getContent); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, stop); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, beforeStore); ZEPHIR_DOC_METHOD(Phalcon_Cache_FrontendInterface, afterRetrieve); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Multiple) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache, Multiple, phalcon, cache_multiple, phalcon_cache_multiple_method_entry, 0); zend_declare_property_null(phalcon_cache_multiple_ce, SL("_backends"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Multiple, __construct) { zval *backends = NULL; zephir_fetch_params(0, 0, 1, &backends); if (!backends) { backends = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(backends) != IS_NULL) { if (Z_TYPE_P(backends) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_cache_exception_ce, "The backends must be an array", "phalcon/cache/multiple.zep", 83); return; } zephir_update_property_this(this_ptr, SL("_backends"), backends TSRMLS_CC); } } static PHP_METHOD(Phalcon_Cache_Multiple, push) { zval *backend; zephir_fetch_params(0, 1, 0, &backend); zephir_update_property_array_append(this_ptr, SL("_backends"), backend TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Cache_Multiple, get) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *keyName, *lifetime = NULL, *backend = NULL, *content = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 116); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(&content, backend, "get", NULL, 0, keyName, lifetime); zephir_check_call_status(); if (Z_TYPE_P(content) != IS_NULL) { RETURN_CCTOR(content); } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Cache_Multiple, start) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *keyName, *lifetime = NULL, *backend = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 132); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(NULL, backend, "start", NULL, 0, keyName, lifetime); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Multiple, save) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer = NULL, *backend = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer) { stopBuffer = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 149); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(NULL, backend, "save", NULL, 0, keyName, content, lifetime, stopBuffer); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Multiple, delete) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *keyName, *backend = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 165); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(NULL, backend, "delete", NULL, 0, keyName); zephir_check_call_status(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Cache_Multiple, exists) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *keyName = NULL, *lifetime = NULL, *backend = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 185); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(&_4, backend, "exists", NULL, 0, keyName, lifetime); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(_4)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Multiple, flush) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *backend = NULL, *_0, **_3; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_backends"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/multiple.zep", 199); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(backend, _3); ZEPHIR_CALL_METHOD(NULL, backend, "flush", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Apc) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Apc, phalcon, cache_backend_apc, phalcon_cache_backend_ce, phalcon_cache_backend_apc_method_entry, 0); zend_class_implements(phalcon_cache_backend_apc_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Apc, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName_param = NULL, *lifetime = NULL, *prefixedKey, *cachedContent = NULL, *_0, *_1; zval *keyName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName_param, &lifetime); if (unlikely(Z_TYPE_P(keyName_param) != IS_STRING && Z_TYPE_P(keyName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'keyName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(keyName_param) == IS_STRING)) { zephir_get_strval(keyName, keyName_param); } else { ZEPHIR_INIT_VAR(keyName); ZVAL_EMPTY_STRING(keyName); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_SVV(prefixedKey, "_PHCA", _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&cachedContent, "apc_fetch", NULL, 82, prefixedKey); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { RETURN_MM_NULL(); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_1, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cachedContent = NULL, *preparedContent = NULL, *ttl = NULL, *isBuffering = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { ZEPHIR_CPY_WRT(lifetime, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(lifetime); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCA", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/apc.zep", 93); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (Z_TYPE_P(content) == IS_NULL) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); if (Z_TYPE_P(lifetime) == IS_NULL) { ZEPHIR_OBS_NVAR(lifetime); zephir_read_property_this(&lifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (Z_TYPE_P(lifetime) == IS_NULL) { ZEPHIR_CALL_METHOD(&ttl, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, lifetime); } } else { ZEPHIR_CPY_WRT(ttl, lifetime); } ZEPHIR_CALL_FUNCTION(NULL, "apc_store", NULL, 83, lastKey, preparedContent, ttl); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, increment) { int value, ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value_param = NULL, *prefixedKey, *cachedContent = NULL, *result = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_SVV(prefixedKey, "_PHCA", _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); if ((zephir_function_exists_ex(SS("apc_inc") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, value); ZEPHIR_CALL_FUNCTION(&result, "apc_inc", NULL, 102, prefixedKey, _1); zephir_check_call_status(); RETURN_CCTOR(result); } else { ZEPHIR_CALL_FUNCTION(&cachedContent, "apc_fetch", NULL, 82, prefixedKey); zephir_check_call_status(); if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_NVAR(result); ZVAL_LONG(result, (zephir_get_numberval(cachedContent) + value)); ZEPHIR_CALL_METHOD(NULL, this_ptr, "save", NULL, 0, keyName, result); zephir_check_call_status(); RETURN_CCTOR(result); } else { RETURN_MM_BOOL(0); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, decrement) { int value, ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value_param = NULL, *lastKey, *cachedContent = NULL, *result, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCA", _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); if ((zephir_function_exists_ex(SS("apc_dec") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, value); ZEPHIR_RETURN_CALL_FUNCTION("apc_dec", NULL, 103, lastKey, _1); zephir_check_call_status(); RETURN_MM(); } else { ZEPHIR_CALL_FUNCTION(&cachedContent, "apc_fetch", NULL, 82, lastKey); zephir_check_call_status(); if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(result); ZVAL_LONG(result, (zephir_get_numberval(cachedContent) - value)); ZEPHIR_CALL_METHOD(NULL, this_ptr, "save", NULL, 0, keyName, result); zephir_check_call_status(); RETURN_CCTOR(result); } else { RETURN_MM_BOOL(0); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName_param = NULL, *_0, *_1; zval *keyName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName_param); if (unlikely(Z_TYPE_P(keyName_param) != IS_STRING && Z_TYPE_P(keyName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'keyName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(keyName_param) == IS_STRING)) { zephir_get_strval(keyName, keyName_param); } else { ZEPHIR_INIT_VAR(keyName); ZVAL_EMPTY_STRING(keyName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVV(_1, "_PHCA", _0, keyName); ZEPHIR_RETURN_CALL_FUNCTION("apc_delete", NULL, 104, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, queryKeys) { zend_object_iterator *_3; int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zend_class_entry *_1 = NULL; zval *prefix_param = NULL, *prefixPattern = NULL, *apc, *keys, *key = NULL, *_2 = NULL, _4 = zval_used_for_init, *_5 = NULL; zval *prefix = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix_param); if (!prefix_param) { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } else { zephir_get_strval(prefix, prefix_param); } ZEPHIR_INIT_VAR(prefixPattern); if (!(!(!prefix) && Z_STRLEN_P(prefix))) { ZVAL_STRING(prefixPattern, "/^_PHCA/", 1); } else { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVS(_0, "/^_PHCA", prefix, "/"); ZEPHIR_CPY_WRT(prefixPattern, _0); } ZEPHIR_INIT_VAR(keys); array_init(keys); ZEPHIR_INIT_VAR(apc); if (!_1) { _1 = zend_fetch_class(SL("APCIterator"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); } object_init_ex(apc, _1); if (zephir_has_constructor(apc TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "user", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, apc, "__construct", NULL, 0, _2, prefixPattern); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_2); _3 = zephir_get_iterator(apc TSRMLS_CC); _3->funcs->rewind(_3 TSRMLS_CC); for (;_3->funcs->valid(_3 TSRMLS_CC) == SUCCESS && !EG(exception); _3->funcs->move_forward(_3 TSRMLS_CC)) { ZEPHIR_GET_IMKEY(key, _3); { zval **ZEPHIR_TMP_ITERATOR_PTR; _3->funcs->get_current_data(_3, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(_2, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 5); ZEPHIR_INIT_NVAR(_5); zephir_substr(_5, key, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_array_append(&keys, _5, PH_SEPARATE, "phalcon/cache/backend/apc.zep", 224); } _3->funcs->dtor(_3 TSRMLS_CC); RETURN_CCTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCA", _0, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_CALL_FUNCTION(&_1, "apc_exists", NULL, 105, lastKey); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Apc, flush) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zend_class_entry *_2 = NULL; zend_object_iterator *_0; zval *item = NULL, *_1, *_3, *_4; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_1); if (!_2) { _2 = zend_fetch_class(SL("APCIterator"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); } object_init_ex(_1, _2); if (zephir_has_constructor(_1 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "user", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); } _0 = zephir_get_iterator(_1 TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(item, (*ZEPHIR_TMP_ITERATOR_PTR)); } zephir_array_fetch_string(&_4, item, SL("key"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/apc.zep", 264 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(NULL, "apc_delete", &_5, 104, _4); zephir_check_call_status(); } _0->funcs->dtor(_0 TSRMLS_CC); RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_File) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, File, phalcon, cache_backend_file, phalcon_cache_backend_ce, phalcon_cache_backend_file_method_entry, 0); zend_declare_property_bool(phalcon_cache_backend_file_ce, SL("_useSafeKey"), 0, ZEND_ACC_PRIVATE TSRMLS_CC); zend_class_implements(phalcon_cache_backend_file_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_File, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_5 = NULL; zend_bool _1; zval *frontend, *options = NULL, *prefix, *safekey, *_0, *_2, *_3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (!(zephir_array_isset_string(options, SS("cacheDir")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache directory must be specified with the option cacheDir", "phalcon/cache/backend/file.zep", 78); return; } ZEPHIR_OBS_VAR(safekey); if (zephir_array_isset_string_fetch(&safekey, options, SS("safekey"), 0 TSRMLS_CC)) { if (Z_TYPE_P(safekey) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "safekey option should be a boolean.", "phalcon/cache/backend/file.zep", 83); return; } zephir_update_property_this(this_ptr, SL("_useSafeKey"), safekey TSRMLS_CC); } ZEPHIR_OBS_VAR(prefix); if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 0 TSRMLS_CC)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_useSafeKey"), PH_NOISY_CC); _1 = zephir_is_true(_0); if (_1) { ZEPHIR_INIT_VAR(_2); ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "/[^a-zA-Z0-9_.-]+/", 0); zephir_preg_match(_3, &_4, prefix, _2, 0, 0 , 0 TSRMLS_CC); _1 = zephir_is_true(_3); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "FileCache prefix should only use alphanumeric characters.", "phalcon/cache/backend/file.zep", 92); return; } } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_file_ce, this_ptr, "__construct", &_5, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_File, get) { int ttl, modifiedTime, ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *prefixedKey, *cacheDir, *cacheFile, *frontend, *lastLifetime, *cachedContent, *ret = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5, *_6, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, _1); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_OBS_VAR(cacheDir); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _2, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 115); return; } ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, cacheDir, prefixedKey); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS) == 1) { ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(lastLifetime); zephir_read_property_this(&lastLifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(lastLifetime))) { ZEPHIR_CALL_METHOD(&_3, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); ttl = zephir_get_intval(_3); } else { ttl = zephir_get_intval(lastLifetime); } } else { ttl = zephir_get_intval(lifetime); } ZEPHIR_INIT_VAR(_4); zephir_filemtime(_4, cacheFile TSRMLS_CC); modifiedTime = zephir_get_intval(_4); ZEPHIR_INIT_VAR(_5); zephir_time(_5); if (!((zephir_get_numberval(_5) - ttl) > modifiedTime)) { ZEPHIR_INIT_VAR(cachedContent); zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { ZEPHIR_INIT_VAR(_6); object_init_ex(_6, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cache file ", cacheFile, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/cache/backend/file.zep", 151 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } else { ZEPHIR_CALL_METHOD(&ret, frontend, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_CCTOR(ret); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_File, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cacheDir, *isBuffering = NULL, *cacheFile, *cachedContent = NULL, *preparedContent = NULL, *status = NULL, *_0, *_1 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, _1); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/file.zep", 186); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cacheDir); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _0, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 192); return; } ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, cacheDir, lastKey); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_INIT_VAR(status); zephir_file_put_contents(status, cacheFile, preparedContent TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(status); zephir_file_put_contents(status, cacheFile, cachedContent TSRMLS_CC); } if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVS(_3, "Cache file ", cacheFile, " could not be written"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/cache/backend/file.zep", 215 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_File, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *cacheFile, *cacheDir, *_0, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); ZEPHIR_OBS_VAR(cacheDir); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _0, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 242); return; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VVV(cacheFile, cacheDir, _1, _2); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("unlink", NULL, 107, cacheFile); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_File, queryKeys) { int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_1; zval *keys = NULL; zval *prefix = NULL, *item = NULL, *key = NULL, *cacheDir, *_0, *_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(keys); array_init(keys); ZEPHIR_INIT_NVAR(keys); array_init(keys); ZEPHIR_OBS_VAR(cacheDir); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _0, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 265); return; } ZEPHIR_INIT_VAR(_2); object_init_ex(_2, spl_ce_DirectoryIterator); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 108, cacheDir); zephir_check_call_status(); _1 = zephir_get_iterator(_2 TSRMLS_CC); _1->funcs->rewind(_1 TSRMLS_CC); for (;_1->funcs->valid(_1 TSRMLS_CC) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _1->funcs->get_current_data(_1, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(item, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(&_3, item, "isdir", NULL, 0); zephir_check_call_status(); if (likely(ZEPHIR_IS_FALSE_IDENTICAL(_3))) { ZEPHIR_CALL_METHOD(&key, item, "getfilename", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(prefix) != IS_NULL) { if (zephir_start_with(key, prefix, NULL)) { zephir_array_append(&keys, key, PH_SEPARATE, "phalcon/cache/backend/file.zep", 277); } } else { zephir_array_append(&keys, key, PH_SEPARATE, "phalcon/cache/backend/file.zep", 280); } } } _1->funcs->dtor(_1 TSRMLS_CC); RETURN_CTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_File, exists) { int lifetime, ttl, ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime_param = NULL, *lastKey = NULL, *prefix, *cacheFile, *_0 = NULL, *_1, *_2, *_3, *_4, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime_param) { lifetime = 0; } else { lifetime = zephir_get_intval(lifetime_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, _0); } if (zephir_is_true(lastKey)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); zephir_array_fetch_string(&_2, _1, SL("cacheDir"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/file.zep", 309 TSRMLS_CC); ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, _2, lastKey); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS)) { if (!(lifetime)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, _3, "getlifetime", NULL, 0); zephir_check_call_status(); ttl = zephir_get_intval(_0); } else { ttl = lifetime; } ZEPHIR_INIT_VAR(_4); zephir_filemtime(_4, cacheFile TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_time(_5); if (ZEPHIR_LT_LONG(_5, (zephir_get_numberval(_4) + ttl))) { RETURN_MM_BOOL(1); } } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_File, increment) { int value, ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value_param = NULL, *prefixedKey, *cacheFile, *frontend, *timestamp, *lifetime, *ttl = NULL, *cachedContent, *result, *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, _1); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); zephir_array_fetch_string(&_3, _2, SL("cacheDir"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/file.zep", 345 TSRMLS_CC); ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, _3, prefixedKey); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS)) { ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_INIT_VAR(timestamp); zephir_time(timestamp); ZEPHIR_OBS_VAR(lifetime); zephir_read_property_this(&lifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(lifetime))) { ZEPHIR_CALL_METHOD(&ttl, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, lifetime); } ZEPHIR_INIT_VAR(_4); zephir_sub_function(_4, timestamp, ttl); ZEPHIR_INIT_VAR(_5); zephir_filemtime(_5, cacheFile TSRMLS_CC); if (ZEPHIR_LT(_4, _5)) { ZEPHIR_INIT_VAR(cachedContent); zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { ZEPHIR_INIT_VAR(_6); object_init_ex(_6, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cache file ", cacheFile, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/cache/backend/file.zep", 377 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(result); ZVAL_LONG(result, (zephir_get_numberval(cachedContent) + value)); ZEPHIR_INIT_NVAR(_6); zephir_file_put_contents(_6, cacheFile, result TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache directory could not be written", "phalcon/cache/backend/file.zep", 384); return; } RETURN_CCTOR(result); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_File, decrement) { int value, ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value_param = NULL, *prefixedKey, *cacheFile, *timestamp, *lifetime, *ttl = NULL, *cachedContent, *result, *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6, *_7 = NULL, *_8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, _1); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); zephir_array_fetch_string(&_3, _2, SL("cacheDir"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/file.zep", 406 TSRMLS_CC); ZEPHIR_INIT_VAR(cacheFile); ZEPHIR_CONCAT_VV(cacheFile, _3, prefixedKey); if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(timestamp); zephir_time(timestamp); ZEPHIR_OBS_VAR(lifetime); zephir_read_property_this(&lifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(lifetime))) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&ttl, _4, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, lifetime); } ZEPHIR_INIT_VAR(_5); zephir_sub_function(_5, timestamp, ttl); ZEPHIR_INIT_VAR(_6); zephir_filemtime(_6, cacheFile TSRMLS_CC); if (ZEPHIR_LT(_5, _6)) { ZEPHIR_INIT_VAR(cachedContent); zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { ZEPHIR_INIT_VAR(_7); object_init_ex(_7, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVS(_8, "Cache file ", cacheFile, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/cache/backend/file.zep", 436 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(result); ZVAL_LONG(result, (zephir_get_numberval(cachedContent) - value)); ZEPHIR_INIT_NVAR(_7); zephir_file_put_contents(_7, cacheFile, result TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_7)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache directory can't be written", "phalcon/cache/backend/file.zep", 443); return; } RETURN_CCTOR(result); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_File, flush) { zephir_fcall_cache_entry *_6 = NULL; zend_bool _4; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_1; zval *prefix, *cacheDir, *item = NULL, *key = NULL, *cacheFile = NULL, *_0, *_2, *_3 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cacheDir); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&cacheDir, _0, SS("cacheDir"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 462); return; } ZEPHIR_INIT_VAR(_2); object_init_ex(_2, spl_ce_DirectoryIterator); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 108, cacheDir); zephir_check_call_status(); _1 = zephir_get_iterator(_2 TSRMLS_CC); _1->funcs->rewind(_1 TSRMLS_CC); for (;_1->funcs->valid(_1 TSRMLS_CC) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _1->funcs->get_current_data(_1, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(item, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(&_3, item, "isfile", NULL, 0); zephir_check_call_status(); if (likely(ZEPHIR_IS_TRUE(_3))) { ZEPHIR_CALL_METHOD(&key, item, "getfilename", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&cacheFile, item, "getpathname", NULL, 0); zephir_check_call_status(); _4 = ZEPHIR_IS_EMPTY(prefix); if (!(_4)) { _4 = zephir_start_with(key, prefix, NULL); } if (_4) { ZEPHIR_CALL_FUNCTION(&_5, "unlink", &_6, 107, cacheFile); zephir_check_call_status(); if (!(zephir_is_true(_5))) { RETURN_MM_BOOL(0); } } } } _1->funcs->dtor(_1 TSRMLS_CC); RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Cache_Backend_File, getKey) { zval *key, *_0; zephir_fetch_params(0, 1, 0, &key); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_useSafeKey"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_0)) { zephir_md5(return_value, key); return; } RETVAL_ZVAL(key, 1, 0); return; } static PHP_METHOD(Phalcon_Cache_Backend_File, useSafeKey) { zval *useSafeKey_param = NULL; zend_bool useSafeKey; zephir_fetch_params(0, 1, 0, &useSafeKey_param); useSafeKey = zephir_get_boolval(useSafeKey_param); if (useSafeKey) { zephir_update_property_this(this_ptr, SL("_useSafeKey"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_useSafeKey"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Libmemcached) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Libmemcached, phalcon, cache_backend_libmemcached, phalcon_cache_backend_ce, phalcon_cache_backend_libmemcached_method_entry, 0); zend_declare_property_null(phalcon_cache_backend_libmemcached_ce, SL("_memcache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_backend_libmemcached_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_2 = NULL; zval *_0; zval *frontend, *options = NULL, *servers, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("servers")))) { ZEPHIR_INIT_VAR(servers); zephir_create_array(servers, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_0, SS("host"), SL("127.0.0.1"), 1); add_assoc_long_ex(_0, SS("port"), 11211); add_assoc_long_ex(_0, SS("weight"), 1); zephir_array_update_long(&servers, 0, &_0, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_string(&options, SL("servers"), &servers, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "_PHCM", 1); zephir_array_update_string(&options, SL("statsKey"), &_1, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_libmemcached_ce, this_ptr, "__construct", &_2, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, _connect) { int ZEPHIR_LAST_CALL_STATUS; zval *options, *memcache, *client, *servers, *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_INIT_VAR(memcache); object_init_ex(memcache, zephir_get_internal_ce(SS("memcached") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, memcache, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(servers); if (!(zephir_array_isset_string_fetch(&servers, options, SS("servers"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Servers must be an array", "phalcon/cache/backend/libmemcached.zep", 104); return; } if (Z_TYPE_P(servers) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Servers must be an array", "phalcon/cache/backend/libmemcached.zep", 108); return; } ZEPHIR_CALL_METHOD(&_0, memcache, "addservers", NULL, 0, servers); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cannot connect to Memcached server", "phalcon/cache/backend/libmemcached.zep", 112); return; } ZEPHIR_OBS_VAR(client); if (zephir_array_isset_string_fetch(&client, options, SS("client"), 0 TSRMLS_CC)) { if (Z_TYPE_P(client) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Client options must be instance of array", "phalcon/cache/backend/libmemcached.zep", 117); return; } ZEPHIR_CALL_METHOD(NULL, memcache, "setoptions", NULL, 0, client); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_memcache"), memcache TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *memcache = NULL, *prefixedKey, *cachedContent = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_METHOD(&cachedContent, memcache, "get", NULL, 0, prefixedKey); zephir_check_call_status(); if (!(zephir_is_true(cachedContent))) { RETURN_MM_NULL(); } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } else { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_1, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *memcache = NULL, *cachedContent = NULL, *preparedContent = NULL, *tmp, *tt1 = NULL, *success = NULL, *options, *specialKey, *keys = NULL, *isBuffering = NULL, *_0, *_1, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/libmemcached.zep", 177); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&tt1, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(tt1, tmp); } } else { ZEPHIR_CPY_WRT(tt1, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, cachedContent, tt1); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, preparedContent, tt1); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_exception_ce); ZEPHIR_CALL_METHOD(&_2, memcache, "getresultcode", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "Failed storing data in memcached, error code: ", _2); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/cache/backend/libmemcached.zep", 223 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/libmemcached.zep", 229); return; } if (!ZEPHIR_IS_STRING(specialKey, "")) { ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } if (!(zephir_array_isset(keys, lastKey))) { zephir_array_update_zval(&keys, lastKey, &tt1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *memcache = NULL, *prefixedKey, *options, *keys = NULL, *specialKey, *ret = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/libmemcached.zep", 280); return; } if (!ZEPHIR_IS_STRING(specialKey, "")) { ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { zephir_array_unset(&keys, prefixedKey, PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(&ret, memcache, "delete", NULL, 0, prefixedKey); zephir_check_call_status(); RETURN_CCTOR(ret); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, queryKeys) { zend_bool _4; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *prefix = NULL, *memcache = NULL, *options, *keys = NULL, *specialKey, *key = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/libmemcached.zep", 318); return; } if (ZEPHIR_IS_STRING(specialKey, "")) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cached keys were disabled (options['statsKey'] == ''), you shouldn't use this function", "phalcon/cache/backend/libmemcached.zep", 322); return; } ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_array_keys(_0, keys TSRMLS_CC); ZEPHIR_CPY_WRT(keys, _0); zephir_is_iterable(keys, &_2, &_1, 1, 0, "phalcon/cache/backend/libmemcached.zep", 336); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(key, _3); _4 = zephir_is_true(prefix); if (_4) { _4 = !(zephir_start_with(key, prefix, NULL)); } if (_4) { zephir_array_unset(&keys, key, PH_SEPARATE); } } } RETURN_CCTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *memcache = NULL, *value = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_CALL_METHOD(&value, memcache, "get", NULL, 0, lastKey); zephir_check_call_status(); if (!(zephir_is_true(value))) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, increment) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *memcache = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(memcache, "increment", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, decrement) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *memcache = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(memcache, "decrement", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, flush) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *memcache = NULL, *options, *keys = NULL, *specialKey, *key = NULL, *_0, **_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/libmemcached.zep", 457); return; } if (ZEPHIR_IS_STRING(specialKey, "")) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cached keys were disabled (options['statsKey'] == ''), flush of memcached phalcon-related keys isn't implemented for now", "phalcon/cache/backend/libmemcached.zep", 461); return; } ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_array_keys(_0, keys TSRMLS_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cache/backend/libmemcached.zep", 472); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(key, _3); ZEPHIR_CALL_METHOD(NULL, memcache, "delete", &_4, 0, key); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Memcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Memcache, phalcon, cache_backend_memcache, phalcon_cache_backend_ce, phalcon_cache_backend_memcache_method_entry, 0); zend_declare_property_null(phalcon_cache_backend_memcache_ce, SL("_memcache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_backend_memcache_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *frontend, *options = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 11211); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { zephir_array_update_string(&options, SL("persistent"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "_PHCM", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_memcache_ce, this_ptr, "__construct", &_1, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, _connect) { zend_bool _0, _1; int ZEPHIR_LAST_CALL_STATUS; zval *options, *memcache, *persistent, *success = NULL, *host, *port; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_INIT_VAR(memcache); object_init_ex(memcache, zephir_get_internal_ce(SS("memcache") TSRMLS_CC)); if (zephir_has_constructor(memcache TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, memcache, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(host); _0 = !(zephir_array_isset_string_fetch(&host, options, SS("host"), 0 TSRMLS_CC)); if (!(_0)) { ZEPHIR_OBS_VAR(port); _0 = !(zephir_array_isset_string_fetch(&port, options, SS("port"), 0 TSRMLS_CC)); } _1 = _0; if (!(_1)) { ZEPHIR_OBS_VAR(persistent); _1 = !(zephir_array_isset_string_fetch(&persistent, options, SS("persistent"), 0 TSRMLS_CC)); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 103); return; } if (zephir_is_true(persistent)) { ZEPHIR_CALL_METHOD(&success, memcache, "pconnect", NULL, 0, host, port); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, memcache, "connect", NULL, 0, host, port); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cannot connect to Memcached server", "phalcon/cache/backend/memcache.zep", 113); return; } zephir_update_property_this(this_ptr, SL("_memcache"), memcache TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *memcache = NULL, *prefixedKey, *cachedContent = NULL, *retrieve = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_METHOD(&cachedContent, memcache, "get", NULL, 0, prefixedKey); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) { RETURN_MM_NULL(); } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&retrieve, _1, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_CCTOR(retrieve); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *memcache = NULL, *cachedContent = NULL, *preparedContent = NULL, *tmp, *ttl = NULL, *success = NULL, *options, *specialKey, *keys = NULL, *isBuffering = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/memcache.zep", 172); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (Z_TYPE_P(content) == IS_NULL) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); if (Z_TYPE_P(lifetime) == IS_NULL) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&ttl, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, tmp); } } else { ZEPHIR_CPY_WRT(ttl, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, cachedContent, _1, ttl); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(&success, memcache, "set", NULL, 0, lastKey, preparedContent, _1, ttl); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Failed storing data in memcached", "phalcon/cache/backend/memcache.zep", 219); return; } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 225); return; } if (Z_TYPE_P(specialKey) != IS_NULL) { ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } if (!(zephir_array_isset(keys, lastKey))) { zephir_array_update_zval(&keys, lastKey, &ttl, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *memcache = NULL, *prefixedKey, *options, *keys = NULL, *specialKey, *ret = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 276); return; } ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { zephir_array_unset(&keys, prefixedKey, PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&ret, memcache, "delete", NULL, 0, prefixedKey); zephir_check_call_status(); RETURN_CCTOR(ret); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, queryKeys) { zend_bool _4; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *prefix = NULL, *memcache = NULL, *options, *keys = NULL, *specialKey, *key = NULL, *realKey, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 313); return; } ZEPHIR_INIT_VAR(realKey); array_init(realKey); ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(keys, &_2, &_1, 0, 0, "phalcon/cache/backend/memcache.zep", 327); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); _4 = !zephir_is_true(prefix); if (!(_4)) { _4 = zephir_start_with(key, prefix, NULL); } if (_4) { zephir_array_append(&realKey, key, PH_SEPARATE, "phalcon/cache/backend/memcache.zep", 324); } } } RETURN_CCTOR(realKey); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *memcache = NULL, *prefix, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_CALL_METHOD(&_0, memcache, "get", NULL, 0, lastKey); zephir_check_call_status(); if (!(zephir_is_true(_0))) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, increment) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *memcache = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(memcache, "increment", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, decrement) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *memcache = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(memcache, "decrement", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Memcache, flush) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *memcache = NULL, *options, *keys = NULL, *specialKey, *key = NULL, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); if (Z_TYPE_P(memcache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(memcache); zephir_read_property_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); if (!(zephir_array_isset_string_fetch(&specialKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/memcache.zep", 450); return; } ZEPHIR_CALL_METHOD(&keys, memcache, "get", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(keys, &_2, &_1, 0, 0, "phalcon/cache/backend/memcache.zep", 461); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_CALL_METHOD(NULL, memcache, "delete", &_4, 0, key); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, memcache, "set", NULL, 0, specialKey, keys); zephir_check_call_status(); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Memory) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Memory, phalcon, cache_backend_memory, phalcon_cache_backend_ce, phalcon_cache_backend_memory_method_entry, 0); zend_declare_property_null(phalcon_cache_backend_memory_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_backend_memory_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); zend_class_implements(phalcon_cache_backend_memory_ce TSRMLS_CC, 1, zend_ce_serializable); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Memory, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *lastKey = NULL, *cachedContent, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } ZEPHIR_OBS_VAR(cachedContent); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cachedContent, _0, lastKey, 0 TSRMLS_CC))) { RETURN_MM_NULL(); } if (Z_TYPE_P(cachedContent) == IS_NULL) { RETURN_MM_NULL(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cachedContent = NULL, *preparedContent = NULL, *isBuffering = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/memory.zep", 97); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (Z_TYPE_P(content) == IS_NULL) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_data"), lastKey, preparedContent TSRMLS_CC); ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, delete) { zval *keyName, *key, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(key); ZEPHIR_CONCAT_VV(key, _0, keyName); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (zephir_array_isset(_1, key)) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); zephir_array_unset(&_2, key, PH_SEPARATE); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, queryKeys) { HashTable *_3; HashPosition _2; zval *_1 = NULL; zval *prefix = NULL, *data, *index = NULL, *keys = NULL, *_0 = NULL, **_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if (Z_TYPE_P(data) == IS_ARRAY) { ZEPHIR_INIT_VAR(keys); if (!(zephir_is_true(prefix))) { ZEPHIR_INIT_VAR(_0); zephir_array_keys(_0, data TSRMLS_CC); zephir_get_arrval(_1, _0); ZEPHIR_CPY_WRT(keys, _1); } else { array_init(keys); ZEPHIR_INIT_NVAR(_0); zephir_is_iterable(data, &_3, &_2, 0, 0, "phalcon/cache/backend/memory.zep", 162); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(index, _3, _2); ZEPHIR_GET_HVALUE(_0, _4); zephir_array_append(&keys, index, PH_SEPARATE, "phalcon/cache/backend/memory.zep", 160); } } } RETURN_CCTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, exists) { zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (zephir_is_true(lastKey)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (zephir_array_isset(_0, lastKey)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, increment) { zval *keyName = NULL, *value = NULL, *lastKey = NULL, *prefix, *cachedContent, *result, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { prefix = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cachedContent, _0, lastKey, 1 TSRMLS_CC))) { RETURN_MM_NULL(); } if (!(zephir_is_true(cachedContent))) { RETURN_MM_NULL(); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_INIT_VAR(result); zephir_add_function(result, cachedContent, value); zephir_update_property_array(this_ptr, SL("_data"), lastKey, result TSRMLS_CC); RETURN_CCTOR(result); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, decrement) { zval *keyName = NULL, *value = NULL, *lastKey = NULL, *prefix, *cachedContent, *result, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { prefix = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cachedContent, _0, lastKey, 1 TSRMLS_CC))) { RETURN_MM_NULL(); } if (!(zephir_is_true(cachedContent))) { RETURN_MM_NULL(); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_INIT_VAR(result); zephir_sub_function(result, cachedContent, value); zephir_update_property_array(this_ptr, SL("_data"), lastKey, result TSRMLS_CC); RETURN_CCTOR(result); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, flush) { zephir_update_property_this(this_ptr, SL("_data"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, serialize) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_frontend"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("frontend"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 74, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Memory, unserialize) { int ZEPHIR_LAST_CALL_STATUS; zval *data, *unserialized = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_CALL_FUNCTION(&unserialized, "unserialize", NULL, 75, data); zephir_check_call_status(); if (Z_TYPE_P(unserialized) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "Unserialized data must be an array", "phalcon/cache/backend/memory.zep", 295); return; } zephir_array_fetch_string(&_0, unserialized, SL("frontend"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/memory.zep", 298 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_frontend"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Mongo) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Mongo, phalcon, cache_backend_mongo, phalcon_cache_backend_ce, phalcon_cache_backend_mongo_method_entry, 0); zend_declare_property_null(phalcon_cache_backend_mongo_ce, SL("_collection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_backend_mongo_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *frontend, *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (!(zephir_array_isset_string(options, SS("mongo")))) { if (!(zephir_array_isset_string(options, SS("server")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The parameter 'server' is required", "phalcon/cache/backend/mongo.zep", 70); return; } } if (!(zephir_array_isset_string(options, SS("db")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The parameter 'db' is required", "phalcon/cache/backend/mongo.zep", 75); return; } if (!(zephir_array_isset_string(options, SS("collection")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The parameter 'collection' is required", "phalcon/cache/backend/mongo.zep", 79); return; } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_mongo_ce, this_ptr, "__construct", &_0, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, _getCollection) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0; zval *options, *mongo = NULL, *server, *database, *collection, *mongoCollection = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(mongoCollection); zephir_read_property_this(&mongoCollection, this_ptr, SL("_collection"), PH_NOISY_CC); if (Z_TYPE_P(mongoCollection) != IS_OBJECT) { ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(mongo); if (zephir_array_isset_string_fetch(&mongo, options, SS("mongo"), 0 TSRMLS_CC)) { if (Z_TYPE_P(mongo) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The 'mongo' parameter must be a valid Mongo instance", "phalcon/cache/backend/mongo.zep", 104); return; } } else { ZEPHIR_OBS_VAR(server); zephir_array_fetch_string(&server, options, SL("server"), PH_NOISY, "phalcon/cache/backend/mongo.zep", 112 TSRMLS_CC); _0 = !zephir_is_true(server); if (!(_0)) { _0 = Z_TYPE_P(server) != IS_STRING; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB connection string", "phalcon/cache/backend/mongo.zep", 114); return; } ZEPHIR_INIT_NVAR(mongo); object_init_ex(mongo, zephir_get_internal_ce(SS("mongoclient") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mongo, "__construct", NULL, 0, server); zephir_check_call_status(); } ZEPHIR_OBS_VAR(database); zephir_array_fetch_string(&database, options, SL("db"), PH_NOISY, "phalcon/cache/backend/mongo.zep", 123 TSRMLS_CC); _0 = !zephir_is_true(database); if (!(_0)) { _0 = Z_TYPE_P(database) != IS_STRING; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB db", "phalcon/cache/backend/mongo.zep", 125); return; } ZEPHIR_OBS_VAR(collection); zephir_array_fetch_string(&collection, options, SL("collection"), PH_NOISY, "phalcon/cache/backend/mongo.zep", 131 TSRMLS_CC); _0 = !zephir_is_true(collection); if (!(_0)) { _0 = Z_TYPE_P(collection) != IS_STRING; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The backend requires a valid MongoDB collection", "phalcon/cache/backend/mongo.zep", 133); return; } ZEPHIR_CALL_METHOD(&_1, mongo, "selectdb", NULL, 0, database); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&mongoCollection, _1, "selectcollection", NULL, 0, collection); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_collection"), mongoCollection TSRMLS_CC); } RETURN_CCTOR(mongoCollection); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, get) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *keyName, *lifetime = NULL, *frontend, *prefixedKey, *conditions, *document = NULL, *cachedContent, *_0, *_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); zephir_array_update_string(&conditions, SL("key"), &prefixedKey, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); zephir_time(_2); zephir_array_update_string(&_1, SL("$gt"), &_2, PH_COPY | PH_SEPARATE); zephir_array_update_string(&conditions, SL("time"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&document, _3, "findone", NULL, 0, conditions); zephir_check_call_status(); if (Z_TYPE_P(document) == IS_ARRAY) { ZEPHIR_OBS_VAR(cachedContent); if (zephir_array_isset_string_fetch(&cachedContent, document, SS("data"), 0 TSRMLS_CC)) { if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } ZEPHIR_RETURN_CALL_METHOD(frontend, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache is corrupt", "phalcon/cache/backend/mongo.zep", 173); return; } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, save) { zval *_1; int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastkey = NULL, *prefix, *frontend, *cachedContent = NULL, *tmp, *ttl = NULL, *collection = NULL, *timestamp, *conditions, *document = NULL, *preparedContent = NULL, *isBuffering = NULL, *data, *_0, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_INIT_VAR(data); array_init(data); if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastkey); zephir_read_property_this(&lastkey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastkey); ZEPHIR_CONCAT_VV(lastkey, prefix, keyName); } if (!(zephir_is_true(lastkey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/mongo.zep", 205); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&ttl, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(ttl, tmp); } } else { ZEPHIR_CPY_WRT(ttl, lifetime); } ZEPHIR_CALL_METHOD(&collection, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); zephir_time(_0); ZEPHIR_INIT_VAR(timestamp); ZVAL_LONG(timestamp, (zephir_get_numberval(_0) + zephir_get_intval(ttl))); zephir_array_update_string(&conditions, SL("key"), &lastkey, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&document, collection, "findone", NULL, 0, conditions); zephir_check_call_status(); if (Z_TYPE_P(document) == IS_ARRAY) { zephir_array_update_string(&document, SL("time"), ×tamp, PH_COPY | PH_SEPARATE); if (!(zephir_is_numeric(cachedContent))) { zephir_array_update_string(&document, SL("data"), &preparedContent, PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&document, SL("data"), &cachedContent, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_2); zephir_array_fetch_string(&_2, document, SL("_id"), PH_NOISY, "phalcon/cache/backend/mongo.zep", 245 TSRMLS_CC); zephir_array_update_string(&_1, SL("_id"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, collection, "update", NULL, 0, _1, document); zephir_check_call_status(); } else { zephir_array_update_string(&data, SL("key"), &lastkey, PH_COPY | PH_SEPARATE); zephir_array_update_string(&data, SL("time"), ×tamp, PH_COPY | PH_SEPARATE); if (!(zephir_is_numeric(cachedContent))) { zephir_array_update_string(&data, SL("data"), &preparedContent, PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&data, SL("data"), &cachedContent, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(NULL, collection, "insert", NULL, 0, data); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, delete) { zval *_1; int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *_0 = NULL, *_2, *_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VV(_3, _2, keyName); zephir_array_update_string(&_1, SL("key"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_4, "rand", NULL, 110); zephir_check_call_status(); if (zephir_safe_mod_long_long(zephir_get_intval(_4), 100 TSRMLS_CC) == 0) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "gc", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, queryKeys) { HashTable *_6; HashPosition _5; zend_object_iterator *_4; int ZEPHIR_LAST_CALL_STATUS; zval *keys = NULL, *conditions = NULL, *_2, *_3; zval *prefix = NULL, *collection = NULL, *key = NULL, *item = NULL, *items = NULL, *value = NULL, *_0 = NULL, *_1, **_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(keys); array_init(keys); ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_INIT_NVAR(keys); array_init(keys); ZEPHIR_INIT_NVAR(conditions); array_init(conditions); if (zephir_is_true(prefix)) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, zephir_get_internal_ce(SS("mongoregex") TSRMLS_CC)); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "/^", prefix, "/"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 0, _1); zephir_check_call_status(); zephir_array_update_string(&conditions, SL("key"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); zephir_time(_0); zephir_array_update_string(&_2, SL("$gt"), &_0, PH_COPY | PH_SEPARATE); zephir_array_update_string(&conditions, SL("time"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&collection, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); add_assoc_long_ex(_3, SS("key"), 1); ZEPHIR_CALL_METHOD(&items, collection, "find", NULL, 0, conditions, _3); zephir_check_call_status(); _4 = zephir_get_iterator(items TSRMLS_CC); _4->funcs->rewind(_4 TSRMLS_CC); for (;_4->funcs->valid(_4 TSRMLS_CC) == SUCCESS && !EG(exception); _4->funcs->move_forward(_4 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _4->funcs->get_current_data(_4, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(item, (*ZEPHIR_TMP_ITERATOR_PTR)); } zephir_is_iterable(item, &_6, &_5, 0, 0, "phalcon/cache/backend/mongo.zep", 317); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HMKEY(key, _6, _5); ZEPHIR_GET_HVALUE(value, _7); if (ZEPHIR_IS_STRING(key, "key")) { zephir_array_append(&keys, value, PH_SEPARATE, "phalcon/cache/backend/mongo.zep", 314); } } } _4->funcs->dtor(_4 TSRMLS_CC); RETURN_CTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, exists) { zval *_3, *_4; int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *_0, *_1 = NULL, *_2 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(keyName) == IS_NULL) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_VV(lastKey, _0, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("key"), &lastKey, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_time(_5); zephir_array_update_string(&_4, SL("$gt"), &_5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_3, SL("time"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_2, _1, "count", NULL, 0, _3); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_GT_LONG(_2, 0)); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, gc) { zval *_1, *_2; int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); zephir_time(_3); zephir_array_update_string(&_2, SL("$lt"), &_3, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("time"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_RETURN_CALL_METHOD(_0, "remove", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, increment) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *value = NULL, *prefixedKey, *document = NULL, *modifiedTime, *cachedContent, *incremented, *_0, *_1 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &value); if (!value) { ZEPHIR_INIT_VAR(value); ZVAL_LONG(value, 1); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_update_string(&_2, SL("key"), &prefixedKey, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&document, _1, "findone", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_OBS_VAR(modifiedTime); if (!(zephir_array_isset_string_fetch(&modifiedTime, document, SS("time"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache is currupted", "phalcon/cache/backend/mongo.zep", 373); return; } ZEPHIR_INIT_VAR(_3); zephir_time(_3); if (ZEPHIR_LT(_3, modifiedTime)) { ZEPHIR_OBS_VAR(cachedContent); if (!(zephir_array_isset_string_fetch(&cachedContent, document, SS("data"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache is currupted", "phalcon/cache/backend/mongo.zep", 382); return; } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(incremented); zephir_add_function(incremented, cachedContent, value); ZEPHIR_CALL_METHOD(NULL, this_ptr, "save", NULL, 0, prefixedKey, incremented); zephir_check_call_status(); RETURN_CCTOR(incremented); } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, decrement) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *value = NULL, *prefixedKey, *document = NULL, *modifiedTime, *cachedContent, *decremented, *_0, *_1 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &value); if (!value) { ZEPHIR_INIT_VAR(value); ZVAL_LONG(value, 1); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_update_string(&_2, SL("key"), &prefixedKey, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&document, _1, "findone", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_OBS_VAR(modifiedTime); if (!(zephir_array_isset_string_fetch(&modifiedTime, document, SS("time"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache is currupted", "phalcon/cache/backend/mongo.zep", 412); return; } ZEPHIR_INIT_VAR(_3); zephir_time(_3); if (ZEPHIR_LT(_3, modifiedTime)) { ZEPHIR_OBS_VAR(cachedContent); if (!(zephir_array_isset_string_fetch(&cachedContent, document, SS("data"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache is currupted", "phalcon/cache/backend/mongo.zep", 421); return; } if (zephir_is_numeric(cachedContent)) { ZEPHIR_INIT_VAR(decremented); zephir_sub_function(decremented, cachedContent, value); ZEPHIR_CALL_METHOD(NULL, this_ptr, "save", NULL, 0, prefixedKey, decremented); zephir_check_call_status(); RETURN_CCTOR(decremented); } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Cache_Backend_Mongo, flush) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getcollection", NULL, 109); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_1, "rand", NULL, 110); zephir_check_call_status(); if (zephir_safe_mod_long_long(zephir_get_intval(_1), 100 TSRMLS_CC) == 0) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "gc", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Redis) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Redis, phalcon, cache_backend_redis, phalcon_cache_backend_ce, phalcon_cache_backend_redis_method_entry, 0); zend_declare_property_null(phalcon_cache_backend_redis_ce, SL("_redis"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_backend_redis_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Redis, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL; zend_bool _1; zval *frontend, *options = NULL, *_0 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 6379); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("index")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_string(&options, SL("index"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { zephir_array_update_string(&options, SL("persistent"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); } _1 = !(zephir_array_isset_string(options, SS("statsKey"))); if (!(_1)) { zephir_array_fetch_string(&_2, options, SL("statsKey"), PH_NOISY | PH_READONLY, "phalcon/cache/backend/redis.zep", 90 TSRMLS_CC); _1 = ZEPHIR_IS_EMPTY(_2); } if (_1) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "_PHCR", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_redis_ce, this_ptr, "__construct", &_3, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, _connect) { zend_bool _0, _1; int ZEPHIR_LAST_CALL_STATUS; zval *options, *redis, *persistent, *success = NULL, *host, *port, *auth, *index, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_INIT_VAR(redis); object_init_ex(redis, zephir_get_internal_ce(SS("redis") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, redis, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(host); _0 = !(zephir_array_isset_string_fetch(&host, options, SS("host"), 0 TSRMLS_CC)); if (!(_0)) { ZEPHIR_OBS_VAR(port); _0 = !(zephir_array_isset_string_fetch(&port, options, SS("port"), 0 TSRMLS_CC)); } _1 = _0; if (!(_1)) { ZEPHIR_OBS_VAR(persistent); _1 = !(zephir_array_isset_string_fetch(&persistent, options, SS("persistent"), 0 TSRMLS_CC)); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/redis.zep", 108); return; } if (zephir_is_true(persistent)) { ZEPHIR_CALL_METHOD(&success, redis, "pconnect", NULL, 0, host, port); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, redis, "connect", NULL, 0, host, port); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_cache_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "Could not connect to the Redisd server ", host, ":", port); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/cache/backend/redis.zep", 118 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(auth); if (zephir_array_isset_string_fetch(&auth, options, SS("auth"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&success, redis, "auth", NULL, 0, auth); zephir_check_call_status(); if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Failed to authenticate with the Redisd server", "phalcon/cache/backend/redis.zep", 125); return; } } ZEPHIR_OBS_VAR(index); if (zephir_array_isset_string_fetch(&index, options, SS("index"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&success, redis, "select", NULL, 0, index); zephir_check_call_status(); if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Redisd server selected database failed", "phalcon/cache/backend/redis.zep", 133); return; } } zephir_update_property_this(this_ptr, SL("_redis"), redis TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *redis = NULL, *frontend, *prefix, *lastKey, *cachedContent = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCR", prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); ZEPHIR_CALL_METHOD(&cachedContent, redis, "get", NULL, 0, lastKey); zephir_check_call_status(); if (!(zephir_is_true(cachedContent))) { RETURN_MM_NULL(); } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } ZEPHIR_RETURN_CALL_METHOD(frontend, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, save) { int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *prefixedKey = NULL, *lastKey = NULL, *prefix, *frontend, *redis = NULL, *cachedContent = NULL, *preparedContent = NULL, *tmp, *tt1 = NULL, *success = NULL, *options, *specialKey, *isBuffering = NULL, _0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 5); ZEPHIR_INIT_VAR(prefixedKey); zephir_substr(prefixedKey, lastKey, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, prefix, keyName); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SV(lastKey, "_PHCR", prefixedKey); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "The cache must be started first", "phalcon/cache/backend/redis.zep", 197); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&tt1, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(tt1, tmp); } } else { ZEPHIR_CPY_WRT(tt1, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_CALL_METHOD(&success, redis, "set", NULL, 0, lastKey, cachedContent); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, redis, "set", NULL, 0, lastKey, preparedContent); zephir_check_call_status(); } if (!(zephir_is_true(success))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Failed storing the data in redis", "phalcon/cache/backend/redis.zep", 243); return; } ZEPHIR_CALL_METHOD(NULL, redis, "settimeout", NULL, 0, lastKey, tt1); zephir_check_call_status(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/redis.zep", 251); return; } ZEPHIR_OBS_VAR(specialKey); zephir_array_fetch_string(&specialKey, options, SL("statsKey"), PH_NOISY, "phalcon/cache/backend/redis.zep", 254 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, redis, "sadd", NULL, 0, specialKey, prefixedKey); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *redis = NULL, *prefix, *prefixedKey, *lastKey, *options, *specialKey; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_VV(prefixedKey, prefix, keyName); ZEPHIR_INIT_VAR(lastKey); ZEPHIR_CONCAT_SV(lastKey, "_PHCR", prefixedKey); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/redis.zep", 293); return; } ZEPHIR_OBS_VAR(specialKey); zephir_array_fetch_string(&specialKey, options, SL("statsKey"), PH_NOISY, "phalcon/cache/backend/redis.zep", 296 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, redis, "srem", NULL, 0, specialKey, prefixedKey); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(redis, "delete", NULL, 0, lastKey); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, queryKeys) { zend_bool _3; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *prefix = NULL, *redis = NULL, *options, *keys = NULL, *specialKey, *key = NULL, *value = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/redis.zep", 326); return; } ZEPHIR_OBS_VAR(specialKey); zephir_array_fetch_string(&specialKey, options, SL("statsKey"), PH_NOISY, "phalcon/cache/backend/redis.zep", 329 TSRMLS_CC); ZEPHIR_CALL_METHOD(&keys, redis, "smembers", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { zephir_is_iterable(keys, &_1, &_0, 1, 0, "phalcon/cache/backend/redis.zep", 341); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); _3 = zephir_is_true(prefix); if (_3) { _3 = !(zephir_start_with(value, prefix, NULL)); } if (_3) { zephir_array_unset(&keys, key, PH_SEPARATE); } } } RETURN_CCTOR(keys); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *redis = NULL, *prefix, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCR", prefix, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } ZEPHIR_CALL_METHOD(&_0, redis, "get", NULL, 0, lastKey); zephir_check_call_status(); if (!(zephir_is_true(_0))) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, increment) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *redis = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCR", prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(redis, "incrby", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, decrement) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *value = NULL, *redis = NULL, *prefix, *lastKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &value); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!value) { ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(value); } ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCR", prefix, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), lastKey TSRMLS_CC); } if (!(zephir_is_true(value))) { ZEPHIR_INIT_NVAR(value); ZVAL_LONG(value, 1); } ZEPHIR_RETURN_CALL_METHOD(redis, "decrby", NULL, 0, lastKey, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Backend_Redis, flush) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *options, *specialKey, *redis = NULL, *keys = NULL, *key = NULL, *lastKey = NULL, **_2; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/redis.zep", 456); return; } ZEPHIR_OBS_VAR(specialKey); zephir_array_fetch_string(&specialKey, options, SL("statsKey"), PH_NOISY, "phalcon/cache/backend/redis.zep", 459 TSRMLS_CC); ZEPHIR_OBS_VAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); if (Z_TYPE_P(redis) != IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(redis); zephir_read_property_this(&redis, this_ptr, SL("_redis"), PH_NOISY_CC); } ZEPHIR_CALL_METHOD(&keys, redis, "smembers", NULL, 0, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { zephir_is_iterable(keys, &_1, &_0, 0, 0, "phalcon/cache/backend/redis.zep", 475); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(key, _2); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SV(lastKey, "_PHCR", key); ZEPHIR_CALL_METHOD(NULL, redis, "srem", &_3, 0, specialKey, key); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, redis, "delete", &_4, 0, lastKey); zephir_check_call_status(); } } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Backend_Xcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Backend, Xcache, phalcon, cache_backend_xcache, phalcon_cache_backend_ce, phalcon_cache_backend_xcache_method_entry, 0); zend_class_implements(phalcon_cache_backend_xcache_ce TSRMLS_CC, 1, phalcon_cache_backendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *frontend, *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &frontend, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "_PHCX", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_PARENT(NULL, phalcon_cache_backend_xcache_ce, this_ptr, "__construct", &_1, 106, frontend, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, get) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *lifetime = NULL, *frontend, *prefixedKey, *cachedContent = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &lifetime); if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_SVV(prefixedKey, "_PHCX", _0, keyName); zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&cachedContent, "xcache_get", NULL, 84, prefixedKey); zephir_check_call_status(); if (!(zephir_is_true(cachedContent))) { RETURN_MM_NULL(); } if (zephir_is_numeric(cachedContent)) { RETURN_CCTOR(cachedContent); } else { ZEPHIR_RETURN_CALL_METHOD(frontend, "afterretrieve", NULL, 0, cachedContent); zephir_check_call_status(); RETURN_MM(); } } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, save) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool stopBuffer; zval *keyName = NULL, *content = NULL, *lifetime = NULL, *stopBuffer_param = NULL, *lastKey = NULL, *frontend, *cachedContent = NULL, *preparedContent = NULL, *tmp, *tt1 = NULL, *success = NULL, *isBuffering = NULL, *options, *keys = NULL, *specialKey, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &keyName, &content, &lifetime, &stopBuffer_param); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!stopBuffer_param) { stopBuffer = 1; } else { stopBuffer = zephir_get_boolval(stopBuffer_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/xcache.zep", 119); return; } ZEPHIR_OBS_VAR(frontend); zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC); if (!(zephir_is_true(content))) { ZEPHIR_CALL_METHOD(&cachedContent, frontend, "getcontent", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(cachedContent, content); } if (!(zephir_is_numeric(cachedContent))) { ZEPHIR_CALL_METHOD(&preparedContent, frontend, "beforestore", NULL, 0, cachedContent); zephir_check_call_status(); } if (!(zephir_is_true(lifetime))) { ZEPHIR_OBS_VAR(tmp); zephir_read_property_this(&tmp, this_ptr, SL("_lastLifetime"), PH_NOISY_CC); if (!(zephir_is_true(tmp))) { ZEPHIR_CALL_METHOD(&tt1, frontend, "getlifetime", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(tt1, tmp); } } else { ZEPHIR_CPY_WRT(tt1, lifetime); } if (zephir_is_numeric(cachedContent)) { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 85, lastKey, cachedContent, tt1); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&success, "xcache_set", &_1, 85, lastKey, preparedContent, tt1); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&isBuffering, frontend, "isbuffering", NULL, 0); zephir_check_call_status(); if (stopBuffer == 1) { ZEPHIR_CALL_METHOD(NULL, frontend, "stop", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_TRUE_IDENTICAL(isBuffering)) { zend_print_zval(cachedContent, 0); } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (zephir_is_true(success)) { ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _0, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 169); return; } ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 84, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } zephir_array_update_zval(&keys, lastKey, &tt1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", &_1, 85, specialKey, keys); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName, *prefixedKey, *specialKey, *keys = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keyName); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixedKey); ZEPHIR_CONCAT_SVV(prefixedKey, "_PHCX", _0, keyName); ZEPHIR_OBS_VAR(specialKey); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _1, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 199); return; } ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 84, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) != IS_ARRAY) { ZEPHIR_INIT_NVAR(keys); array_init(keys); } zephir_array_unset(&keys, prefixedKey, PH_SEPARATE); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", NULL, 85, specialKey, keys); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, queryKeys) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *prefix = NULL, *options, *prefixed, *specialKey, *keys = NULL, *retval, *key = NULL, *realKey = NULL, *_0, *_1 = NULL, **_4, _5 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &prefix); if (!prefix) { prefix = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(prefixed); if (!(zephir_is_true(prefix))) { ZVAL_STRING(prefixed, "_PHCX", 1); } else { ZEPHIR_CONCAT_SV(prefixed, "_PHCX", prefix); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _0, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 231); return; } ZEPHIR_INIT_VAR(retval); array_init(retval); ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 84, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_is_iterable(keys, &_3, &_2, 0, 0, "phalcon/cache/backend/xcache.zep", 248); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(key, _3, _2); ZEPHIR_GET_HVALUE(_1, _4); if (zephir_start_with(key, prefixed, NULL)) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 5); ZEPHIR_INIT_NVAR(realKey); zephir_substr(realKey, key, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_array_append(&retval, realKey, PH_SEPARATE, "phalcon/cache/backend/xcache.zep", 245); } } } RETURN_CCTOR(retval); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *keyName = NULL, *lifetime = NULL, *lastKey = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &keyName, &lifetime); if (!keyName) { keyName = ZEPHIR_GLOBAL(global_null); } if (!lifetime) { lifetime = ZEPHIR_GLOBAL(global_null); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (zephir_is_true(lastKey)) { ZEPHIR_RETURN_CALL_FUNCTION("xcache_isset", NULL, 111, lastKey); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, increment) { int ZEPHIR_LAST_CALL_STATUS; long value; zval *keyName, *value_param = NULL, *lastKey = NULL, *newVal = NULL, *origVal = NULL, *_0, _1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &value_param); if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/xcache.zep", 294); return; } if ((zephir_function_exists_ex(SS("xcache_inc") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, value); ZEPHIR_CALL_FUNCTION(&newVal, "xcache_inc", NULL, 112, lastKey, &_1); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&origVal, "xcache_get", NULL, 84, lastKey); zephir_check_call_status(); ZEPHIR_INIT_NVAR(newVal); ZVAL_LONG(newVal, (zephir_get_numberval(origVal) - value)); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", NULL, 85, lastKey, newVal); zephir_check_call_status(); } RETURN_CCTOR(newVal); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, decrement) { int ZEPHIR_LAST_CALL_STATUS; long value; zval *keyName, *value_param = NULL, *lastKey = NULL, *newVal = NULL, *origVal = NULL, *success = NULL, *_0, _1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &keyName, &value_param); if (!value_param) { value = 1; } else { value = zephir_get_intval(value_param); } if (!(zephir_is_true(keyName))) { ZEPHIR_OBS_VAR(lastKey); zephir_read_property_this(&lastKey, this_ptr, SL("_lastKey"), PH_NOISY_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(lastKey); ZEPHIR_CONCAT_SVV(lastKey, "_PHCX", _0, keyName); } if (!(zephir_is_true(lastKey))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Cache must be started first", "phalcon/cache/backend/xcache.zep", 326); return; } if ((zephir_function_exists_ex(SS("xcache_dec") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, value); ZEPHIR_CALL_FUNCTION(&newVal, "xcache_dec", NULL, 113, lastKey, &_1); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&origVal, "xcache_get", NULL, 84, lastKey); zephir_check_call_status(); ZEPHIR_INIT_NVAR(newVal); ZVAL_LONG(newVal, (zephir_get_numberval(origVal) - value)); ZEPHIR_CALL_FUNCTION(&success, "xcache_set", NULL, 85, lastKey, newVal); zephir_check_call_status(); } RETURN_CCTOR(newVal); } static PHP_METHOD(Phalcon_Cache_Backend_Xcache, flush) { zephir_fcall_cache_entry *_5 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *options, *specialKey, *keys = NULL, *key = NULL, *_0, *_1 = NULL, **_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(specialKey); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&specialKey, _0, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/xcache.zep", 350); return; } ZEPHIR_CALL_FUNCTION(&keys, "xcache_get", NULL, 84, specialKey); zephir_check_call_status(); if (Z_TYPE_P(keys) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_is_iterable(keys, &_3, &_2, 1, 0, "phalcon/cache/backend/xcache.zep", 360); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(key, _3, _2); ZEPHIR_GET_HVALUE(_1, _4); zephir_array_unset(&keys, key, PH_SEPARATE); ZEPHIR_CALL_FUNCTION(NULL, "xcache_unset", &_5, 114, key); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", NULL, 85, specialKey, keys); zephir_check_call_status(); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_Base64) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache\\Frontend, Base64, phalcon, cache_frontend_base64, phalcon_cache_frontend_base64_method_entry, 0); zend_declare_property_null(phalcon_cache_frontend_base64_ce, SL("_frontendOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_frontend_base64_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, __construct) { zval *frontendOptions = NULL; zephir_fetch_params(0, 0, 1, &frontendOptions); if (!frontendOptions) { frontendOptions = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_frontendOptions"), frontendOptions TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, getLifetime) { zval *options, *lifetime; options = zephir_fetch_nproperty_this(this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 1 TSRMLS_CC)) { RETURN_CTORW(lifetime); } } RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, isBuffering) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, start) { } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, getContent) { RETURN_NULL(); } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, stop) { } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, beforeStore) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 115, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Frontend_Base64, afterRetrieve) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("base64_decode", NULL, 116, data); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_Data) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache\\Frontend, Data, phalcon, cache_frontend_data, phalcon_cache_frontend_data_method_entry, 0); zend_declare_property_null(phalcon_cache_frontend_data_ce, SL("_frontendOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_frontend_data_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_Data, __construct) { zval *frontendOptions = NULL; zephir_fetch_params(0, 0, 1, &frontendOptions); if (!frontendOptions) { frontendOptions = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_frontendOptions"), frontendOptions TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Frontend_Data, getLifetime) { zval *options, *lifetime; options = zephir_fetch_nproperty_this(this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 1 TSRMLS_CC)) { RETURN_CTORW(lifetime); } } RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_Data, isBuffering) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Frontend_Data, start) { } static PHP_METHOD(Phalcon_Cache_Frontend_Data, getContent) { RETURN_NULL(); } static PHP_METHOD(Phalcon_Cache_Frontend_Data, stop) { } static PHP_METHOD(Phalcon_Cache_Frontend_Data, beforeStore) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 74, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Frontend_Data, afterRetrieve) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("unserialize", NULL, 75, data); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_Igbinary) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Frontend, Igbinary, phalcon, cache_frontend_igbinary, phalcon_cache_frontend_data_ce, phalcon_cache_frontend_igbinary_method_entry, 0); zend_class_implements(phalcon_cache_frontend_igbinary_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, __construct) { zval *frontendOptions = NULL; zephir_fetch_params(0, 0, 1, &frontendOptions); if (!frontendOptions) { frontendOptions = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_frontendOptions"), frontendOptions TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, getLifetime) { zval *options, *lifetime; options = zephir_fetch_nproperty_this(this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 1 TSRMLS_CC)) { RETURN_CTORW(lifetime); } } RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, isBuffering) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, start) { } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, getContent) { RETURN_NULL(); } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, stop) { } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, beforeStore) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("igbinary_serialize", NULL, 117, data); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, afterRetrieve) { int ZEPHIR_LAST_CALL_STATUS; zval *data; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data); ZEPHIR_RETURN_CALL_FUNCTION("igbinary_unserialize", NULL, 118, data); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_Json) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache\\Frontend, Json, phalcon, cache_frontend_json, phalcon_cache_frontend_json_method_entry, 0); zend_declare_property_null(phalcon_cache_frontend_json_ce, SL("_frontendOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_frontend_json_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_Json, __construct) { zval *frontendOptions = NULL; zephir_fetch_params(0, 0, 1, &frontendOptions); if (!frontendOptions) { frontendOptions = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_frontendOptions"), frontendOptions TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Frontend_Json, getLifetime) { zval *options, *lifetime; options = zephir_fetch_nproperty_this(this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 1 TSRMLS_CC)) { RETURN_CTORW(lifetime); } } RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_Json, isBuffering) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Frontend_Json, start) { } static PHP_METHOD(Phalcon_Cache_Frontend_Json, getContent) { RETURN_NULL(); } static PHP_METHOD(Phalcon_Cache_Frontend_Json, stop) { } static PHP_METHOD(Phalcon_Cache_Frontend_Json, beforeStore) { zval *data; zephir_fetch_params(0, 1, 0, &data); zephir_json_encode(return_value, &(return_value), data, 0 TSRMLS_CC); return; } static PHP_METHOD(Phalcon_Cache_Frontend_Json, afterRetrieve) { zval *data; zephir_fetch_params(0, 1, 0, &data); zephir_json_decode(return_value, &(return_value), data, 0 TSRMLS_CC); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_None) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache\\Frontend, None, phalcon, cache_frontend_none, phalcon_cache_frontend_none_method_entry, 0); zend_class_implements(phalcon_cache_frontend_none_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_None, getLifetime) { RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_None, isBuffering) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Cache_Frontend_None, start) { } static PHP_METHOD(Phalcon_Cache_Frontend_None, getContent) { } static PHP_METHOD(Phalcon_Cache_Frontend_None, stop) { } static PHP_METHOD(Phalcon_Cache_Frontend_None, beforeStore) { zval *data; zephir_fetch_params(0, 1, 0, &data); RETVAL_ZVAL(data, 1, 0); return; } static PHP_METHOD(Phalcon_Cache_Frontend_None, afterRetrieve) { zval *data; zephir_fetch_params(0, 1, 0, &data); RETVAL_ZVAL(data, 1, 0); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cache_Frontend_Output) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cache\\Frontend, Output, phalcon, cache_frontend_output, phalcon_cache_frontend_output_method_entry, 0); zend_declare_property_bool(phalcon_cache_frontend_output_ce, SL("_buffering"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cache_frontend_output_ce, SL("_frontendOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cache_frontend_output_ce TSRMLS_CC, 1, phalcon_cache_frontendinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cache_Frontend_Output, __construct) { zval *frontendOptions = NULL; zephir_fetch_params(0, 0, 1, &frontendOptions); if (!frontendOptions) { frontendOptions = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_frontendOptions"), frontendOptions TSRMLS_CC); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, getLifetime) { zval *options, *lifetime; options = zephir_fetch_nproperty_this(this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 1 TSRMLS_CC)) { RETURN_CTORW(lifetime); } } RETURN_LONG(1); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, isBuffering) { RETURN_MEMBER(this_ptr, "_buffering"); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, start) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); if (1) { zephir_update_property_this(this_ptr, SL("_buffering"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_buffering"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, getContent) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_buffering"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_RETURN_CALL_FUNCTION("ob_get_contents", NULL, 120); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, stop) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_buffering"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); } if (0) { zephir_update_property_this(this_ptr, SL("_buffering"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_buffering"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cache_Frontend_Output, beforeStore) { zval *data; zephir_fetch_params(0, 1, 0, &data); RETVAL_ZVAL(data, 1, 0); return; } static PHP_METHOD(Phalcon_Cache_Frontend_Output, afterRetrieve) { zval *data; zephir_fetch_params(0, 1, 0, &data); RETVAL_ZVAL(data, 1, 0); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Console) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cli, Console, phalcon, cli_console, phalcon_cli_console_method_entry, 0); zend_declare_property_null(phalcon_cli_console_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_console_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_console_ce, SL("_modules"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_console_ce, SL("_moduleObject"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_console_ce, SL("_arguments"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_console_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cli_console_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_cli_console_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cli_Console, __construct) { zval *dependencyInjector = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &dependencyInjector); if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_arguments"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_options"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Console, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Cli_Console, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Cli_Console, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Cli_Console, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Cli_Console, registerModules) { zval *modules_param = NULL; zval *modules = NULL; zephir_fetch_params(0, 1, 0, &modules_param); modules = modules_param; zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); } static PHP_METHOD(Phalcon_Cli_Console, addModules) { zval *modules_param = NULL, *_0, *_1; zval *modules = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &modules_param); modules = modules_param; ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_modules"), PH_NOISY_CC); zephir_fast_array_merge(_0, &(modules), &(_1) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modules"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Console, getModules) { RETURN_MEMBER(this_ptr, "_modules"); } static PHP_METHOD(Phalcon_Cli_Console, handle) { zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *arguments_param = NULL, *dependencyInjector, *router = NULL, *eventsManager = NULL, *moduleName = NULL, *modules, *module, *path, *className = NULL, *moduleObject = NULL, *dispatcher = NULL, *task = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL; zval *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments_param); if (!arguments_param) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); } else { zephir_get_arrval(arguments, arguments_param); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 152); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _1); _3 = !(zephir_fast_count_int(arguments TSRMLS_CC)); if (_3) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); _3 = zephir_is_true(_0); } if (_3) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, _4); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, arguments); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&moduleName, router, "getmodulename", NULL, 0); zephir_check_call_status(); if (zephir_is_true(moduleName)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "console:beforeStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, moduleName); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_VAR(modules); zephir_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC); if (!(zephir_array_isset(modules, moduleName))) { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_cli_console_exception_ce); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Module '", moduleName, "' isn't registered in the console container"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/cli/console.zep", 176 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(module); zephir_array_fetch(&module, modules, moduleName, PH_NOISY, "phalcon/cli/console.zep", 179 TSRMLS_CC); if (Z_TYPE_P(module) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 181); return; } ZEPHIR_OBS_VAR(path); if (zephir_array_isset_string_fetch(&path, module, SS("path"), 0 TSRMLS_CC)) { if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_cli_console_exception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "Module definition path '", path, "' doesn't exist"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/cli/console.zep", 186 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_require_zval(path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } } ZEPHIR_OBS_VAR(className); if (!(zephir_array_isset_string_fetch(&className, module, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(className); ZVAL_STRING(className, "Module", 1); } ZEPHIR_CALL_METHOD(&moduleObject, dependencyInjector, "get", NULL, 0, className); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerautoloaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerservices", NULL, 0, dependencyInjector); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_moduleObject"), moduleObject TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "console:afterStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_6, eventsManager, "fire", NULL, 0, _2, this_ptr, moduleObject); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { RETURN_MM_BOOL(0); } } } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_6, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(dispatcher, _6); ZEPHIR_CALL_METHOD(&_6, router, "gettaskname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "settaskname", NULL, 0, _6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, router, "getactionname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setactionname", NULL, 0, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, router, "getparams", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _8); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setoptions", NULL, 0, _4); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "console:beforeHandleTask", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, eventsManager, "fire", NULL, 0, _2, this_ptr, dispatcher); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_9)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_METHOD(&task, dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "console:afterHandleTask", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, task); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_CCTOR(task); } static PHP_METHOD(Phalcon_Cli_Console, setArgument) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL, *_8 = NULL, *_16 = NULL; zend_bool str, shift, _0; zval *arguments_param = NULL, *str_param = NULL, *shift_param = NULL, *arg = NULL, *pos = NULL, *args, *opts, *handleArgs = NULL, **_4, _5 = zval_used_for_init, _6 = zval_used_for_init, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, _12 = zval_used_for_init, _13 = zval_used_for_init, *_14 = NULL, *_15 = NULL; zval *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &arguments_param, &str_param, &shift_param); if (!arguments_param) { ZEPHIR_INIT_VAR(arguments); array_init(arguments); } else { arguments = arguments_param; } if (!str_param) { str = 1; } else { if (unlikely(Z_TYPE_P(str_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } str = Z_BVAL_P(str_param); } if (!shift_param) { shift = 1; } else { if (unlikely(Z_TYPE_P(shift_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'shift' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } shift = Z_BVAL_P(shift_param); } ZEPHIR_INIT_VAR(args); array_init(args); ZEPHIR_INIT_VAR(opts); array_init(opts); ZEPHIR_INIT_VAR(handleArgs); array_init(handleArgs); _0 = shift; if (_0) { _0 = (zephir_fast_count_int(arguments TSRMLS_CC)) ? 1 : 0; } if (_0) { ZEPHIR_MAKE_REF(arguments); ZEPHIR_CALL_FUNCTION(NULL, "array_shift", &_1, 122, arguments); ZEPHIR_UNREF(arguments); zephir_check_call_status(); } zephir_is_iterable(arguments, &_3, &_2, 0, 0, "phalcon/cli/console.zep", 267); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(arg, _4); if (Z_TYPE_P(arg) == IS_STRING) { ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "--", 0); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 2); ZEPHIR_CALL_FUNCTION(&_7, "strncmp", &_8, 123, arg, &_5, &_6); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_7, 0)) { ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "=", 0); ZEPHIR_INIT_NVAR(pos); zephir_fast_strpos(pos, arg, &_5, 0 ); if (zephir_is_true(pos)) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, (zephir_get_numberval(pos) + 1)); ZEPHIR_INIT_NVAR(_10); zephir_substr(_10, arg, zephir_get_intval(&_6), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_fast_trim(_9, _10, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 2); ZEPHIR_SINIT_NVAR(_13); ZVAL_LONG(&_13, (zephir_get_numberval(pos) - 2)); ZEPHIR_INIT_NVAR(_14); zephir_substr(_14, arg, 2 , zephir_get_intval(&_13), 0); zephir_fast_trim(_11, _14, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_array_update_zval(&opts, _11, &_9, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_9); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 2); ZEPHIR_INIT_NVAR(_10); zephir_substr(_10, arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_fast_trim(_9, _10, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_array_update_zval(&opts, _9, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } } else { ZEPHIR_SINIT_NVAR(_12); ZVAL_STRING(&_12, "-", 0); ZEPHIR_SINIT_NVAR(_13); ZVAL_LONG(&_13, 1); ZEPHIR_CALL_FUNCTION(&_15, "strncmp", &_8, 123, arg, &_12, &_13); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_15, 0)) { ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 1); ZEPHIR_INIT_NVAR(_9); zephir_substr(_9, arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_array_update_zval(&opts, _9, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_append(&args, arg, PH_SEPARATE, "phalcon/cli/console.zep", 259); } } } else { zephir_array_append(&args, arg, PH_SEPARATE, "phalcon/cli/console.zep", 263); } } if (str) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_CALL_CE_STATIC(&_7, phalcon_cli_router_route_ce, "getdelimiter", &_16, 124); zephir_check_call_status(); zephir_fast_join(_9, _7, args TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_arguments"), _9 TSRMLS_CC); } else { if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_MAKE_REF(args); ZEPHIR_CALL_FUNCTION(&_15, "array_shift", &_1, 122, args); ZEPHIR_UNREF(args); zephir_check_call_status(); zephir_array_update_string(&handleArgs, SL("task"), &_15, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_MAKE_REF(args); ZEPHIR_CALL_FUNCTION(&_7, "array_shift", &_1, 122, args); ZEPHIR_UNREF(args); zephir_check_call_status(); zephir_array_update_string(&handleArgs, SL("action"), &_7, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(args TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_10); zephir_fast_array_merge(_10, &(handleArgs), &(args) TSRMLS_CC); ZEPHIR_CPY_WRT(handleArgs, _10); } zephir_update_property_this(this_ptr, SL("_arguments"), handleArgs TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_options"), opts TSRMLS_CC); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Dispatcher, phalcon, cli_dispatcher, phalcon_dispatcher_ce, phalcon_cli_dispatcher_method_entry, 0); zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("_handlerSuffix"), "Task", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("_defaultHandler"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("_defaultAction"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_dispatcher_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Cli_Dispatcher, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_options"), _0 TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_cli_dispatcher_ce, this_ptr, "__construct", &_1, 125); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskSuffix) { zval *taskSuffix_param = NULL; zval *taskSuffix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &taskSuffix_param); zephir_get_strval(taskSuffix, taskSuffix_param); zephir_update_property_this(this_ptr, SL("_handlerSuffix"), taskSuffix TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, setDefaultTask) { zval *taskName_param = NULL; zval *taskName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &taskName_param); zephir_get_strval(taskName, taskName_param); zephir_update_property_this(this_ptr, SL("_defaultHandler"), taskName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskName) { zval *taskName_param = NULL; zval *taskName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &taskName_param); zephir_get_strval(taskName, taskName_param); zephir_update_property_this(this_ptr, SL("_handlerName"), taskName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, getTaskName) { RETURN_MEMBER(this_ptr, "_handlerName"); } static PHP_METHOD(Phalcon_Cli_Dispatcher, _throwDispatchException) { int exceptionCode, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *exceptionCode_param = NULL, *exception, *_0, *_1 = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); zephir_get_strval(message, message_param); if (!exceptionCode_param) { exceptionCode = 0; } else { exceptionCode = zephir_get_intval(exceptionCode_param); } ZEPHIR_INIT_VAR(exception); object_init_ex(exception, phalcon_cli_dispatcher_exception_ce); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, exceptionCode); ZEPHIR_CALL_METHOD(NULL, exception, "__construct", NULL, 9, message, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_handleexception", NULL, 0, exception); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } zephir_throw_exception_debug(exception, "phalcon/cli/dispatcher.zep", 116 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Cli_Dispatcher, _handleException) { int ZEPHIR_LAST_CALL_STATUS; zval *exception, *eventsManager = NULL, *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &exception); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "dispatch:beforeException", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, exception); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, getLastTask) { RETURN_MEMBER(this_ptr, "_lastHandler"); } static PHP_METHOD(Phalcon_Cli_Dispatcher, getActiveTask) { RETURN_MEMBER(this_ptr, "_activeHandler"); } static PHP_METHOD(Phalcon_Cli_Dispatcher, setOptions) { zval *options_param = NULL; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); zephir_get_arrval(options, options_param); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Dispatcher, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Router) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cli, Router, phalcon, cli_router, phalcon_cli_router_method_entry, 0); zend_declare_property_null(phalcon_cli_router_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_module"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_task"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_defaultModule"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_defaultTask"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_defaultAction"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_defaultParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_routes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_matchedRoute"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_ce, SL("_matches"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_cli_router_ce, SL("_wasMatched"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_cli_router_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Cli_Router, __construct) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_1, *_4; zval *defaultRoutes_param = NULL, *routes, *_0 = NULL, *_2 = NULL, *_5; zend_bool defaultRoutes; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &defaultRoutes_param); if (!defaultRoutes_param) { defaultRoutes = 1; } else { defaultRoutes = zephir_get_boolval(defaultRoutes_param); } ZEPHIR_INIT_VAR(routes); array_init(routes); if (defaultRoutes == 1) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_cli_router_route_ce); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); add_assoc_long_ex(_1, SS("task"), 1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+)[:delimiter]{0,1}$#", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_3, 126, _2, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_append(&routes, _0, PH_SEPARATE, "phalcon/cli/router.zep", 90); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_cli_router_route_ce); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); add_assoc_long_ex(_4, SS("task"), 1); add_assoc_long_ex(_4, SS("action"), 2); add_assoc_long_ex(_4, SS("params"), 3); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+):delimiter([a-zA-Z0-9\\.\\_]+)(:delimiter.*)*$#", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_3, 126, _5, _4); zephir_check_temp_parameter(_5); zephir_check_call_status(); zephir_array_append(&routes, _2, PH_SEPARATE, "phalcon/cli/router.zep", 96); } ZEPHIR_INIT_NVAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); array_init(_2); zephir_update_property_this(this_ptr, SL("_defaultParams"), _2 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Cli_Router, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Cli_Router, setDefaultModule) { zval *moduleName_param = NULL; zval *moduleName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &moduleName_param); zephir_get_strval(moduleName, moduleName_param); zephir_update_property_this(this_ptr, SL("_defaultModule"), moduleName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router, setDefaultTask) { zval *taskName_param = NULL; zval *taskName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &taskName_param); zephir_get_strval(taskName, taskName_param); zephir_update_property_this(this_ptr, SL("_defaultTask"), taskName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router, setDefaultAction) { zval *actionName_param = NULL; zval *actionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionName_param); zephir_get_strval(actionName, actionName_param); zephir_update_property_this(this_ptr, SL("_defaultAction"), actionName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router, setDefaults) { zval *defaults_param = NULL, *module, *task, *action, *params; zval *defaults = NULL; zephir_fetch_params(0, 1, 0, &defaults_param); defaults = defaults_param; if (zephir_array_isset_string_fetch(&module, defaults, SS("module"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultModule"), module TSRMLS_CC); } if (zephir_array_isset_string_fetch(&task, defaults, SS("task"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultTask"), task TSRMLS_CC); } if (zephir_array_isset_string_fetch(&action, defaults, SS("action"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultAction"), action TSRMLS_CC); } if (zephir_array_isset_string_fetch(¶ms, defaults, SS("params"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultParams"), params TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Cli_Router, handle) { zephir_fcall_cache_entry *_18 = NULL; zval *_15 = NULL; zval *_5 = NULL, *_10 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_3, *_7; HashPosition _2, _6; zend_bool _0; zval *arguments = NULL, *moduleName = NULL, *taskName = NULL, *actionName = NULL, *params = NULL, *route = NULL, *parts = NULL, *pattern = NULL, *routeFound = NULL, *matches, *paths = NULL, *beforeMatch = NULL, *converters = NULL, *converter = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *strParams, *_1, **_4, **_8, *_9 = NULL, *_11, *_12, *_13, *_14, _16, *_17 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); if (Z_TYPE_P(arguments) != IS_ARRAY) { _0 = Z_TYPE_P(arguments) != IS_STRING; if (_0) { _0 = Z_TYPE_P(arguments) != IS_NULL; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Arguments must be an array or string", "phalcon/cli/router.zep", 204); return; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 1, "phalcon/cli/router.zep", 304); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_backwards_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(route, _4); ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL, 0); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/cli/router.zep", 214)) { ZEPHIR_INIT_NVAR(routeFound); zephir_preg_match(routeFound, pattern, arguments, matches, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, arguments)); } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/cli/router.zep", 232); return; } ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 3, 0 TSRMLS_CC); zephir_array_fast_append(_5, arguments); zephir_array_fast_append(_5, route); zephir_array_fast_append(_5, this_ptr); ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _5); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL, 0); zephir_check_call_status(); zephir_is_iterable(paths, &_7, &_6, 0, 0, "phalcon/cli/router.zep", 293); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(part, _7, _6); ZEPHIR_GET_HVALUE(position, _8); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_fast_append(_5, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_9, converter, _5); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_9, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); zephir_array_fast_append(_10, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_9, converter, _10); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_9, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { if (1) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } _11 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _11 TSRMLS_CC); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultTask"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_task"), _12 TSRMLS_CC); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _13 TSRMLS_CC); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _14 TSRMLS_CC); RETURN_THIS(); } } else { ZEPHIR_CPY_WRT(parts, arguments); } ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(taskName); ZVAL_NULL(taskName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_OBS_NVAR(moduleName); if (zephir_array_isset_string_fetch(&moduleName, parts, SS("module"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(moduleName); zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(taskName); if (zephir_array_isset_string_fetch(&taskName, parts, SS("task"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("task"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(taskName); zephir_read_property_this(&taskName, this_ptr, SL("_defaultTask"), PH_NOISY_CC); } ZEPHIR_OBS_NVAR(actionName); if (zephir_array_isset_string_fetch(&actionName, parts, SS("action"), 0 TSRMLS_CC)) { zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_defaultAction"), PH_NOISY_CC); } if (zephir_is_true(routeFound)) { ZEPHIR_OBS_NVAR(params); if (zephir_array_isset_string_fetch(¶ms, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(params) != IS_ARRAY) { zephir_get_strval(_15, params); ZEPHIR_SINIT_VAR(_16); ZVAL_LONG(&_16, 1); ZEPHIR_INIT_VAR(strParams); zephir_substr(strParams, _15, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); if (zephir_is_true(strParams)) { ZEPHIR_CALL_CE_STATIC(&_17, phalcon_cli_router_route_ce, "getdelimiter", &_18, 124); zephir_check_call_status(); ZEPHIR_INIT_NVAR(params); zephir_fast_explode(params, _17, strParams, LONG_MAX TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(params); array_init(params); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); zephir_fast_array_merge(_9, &(params), &(parts) TSRMLS_CC); ZEPHIR_CPY_WRT(params, _9); } else { ZEPHIR_CPY_WRT(params, parts); } } else { ZEPHIR_CPY_WRT(params, parts); } zephir_update_property_this(this_ptr, SL("_module"), moduleName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_task"), taskName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_action"), actionName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router, add) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *route; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(route); object_init_ex(route, phalcon_cli_router_route_ce); ZEPHIR_CALL_METHOD(NULL, route, "__construct", NULL, 126, pattern, paths); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_routes"), route TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Cli_Router, getModuleName) { RETURN_MEMBER(this_ptr, "_module"); } static PHP_METHOD(Phalcon_Cli_Router, getTaskName) { RETURN_MEMBER(this_ptr, "_task"); } static PHP_METHOD(Phalcon_Cli_Router, getActionName) { RETURN_MEMBER(this_ptr, "_action"); } static PHP_METHOD(Phalcon_Cli_Router, getParams) { RETURN_MEMBER(this_ptr, "_params"); } static PHP_METHOD(Phalcon_Cli_Router, getMatchedRoute) { RETURN_MEMBER(this_ptr, "_matchedRoute"); } static PHP_METHOD(Phalcon_Cli_Router, getMatches) { RETURN_MEMBER(this_ptr, "_matches"); } static PHP_METHOD(Phalcon_Cli_Router, wasMatched) { RETURN_MEMBER(this_ptr, "_wasMatched"); } static PHP_METHOD(Phalcon_Cli_Router, getRoutes) { RETURN_MEMBER(this_ptr, "_routes"); } static PHP_METHOD(Phalcon_Cli_Router, getRouteById) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *id, *route = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cli/router.zep", 486); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_CALL_METHOD(&_4, route, "getrouteid", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_4, id)) { RETURN_CCTOR(route); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Cli_Router, getRouteByName) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *name_param = NULL, *route = NULL, *_0, **_3, *_4 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cli/router.zep", 501); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_CALL_METHOD(&_4, route, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_4, name)) { RETURN_CCTOR(route); } } RETURN_MM_BOOL(0); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Task) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Task, phalcon, cli_task, phalcon_di_injectable_ce, phalcon_cli_task_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Cli_Task, __construct) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Console_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Console, Exception, phalcon, cli_console_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Dispatcher, Exception, phalcon, cli_dispatcher_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Router, Exception, phalcon, cli_router_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Route) { ZEPHIR_REGISTER_CLASS(Phalcon\\Cli\\Router, Route, phalcon, cli_router_route, phalcon_cli_router_route_method_entry, 0); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_pattern"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_compiledPattern"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_paths"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_converters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_id"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_beforeMatch"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_delimiter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_uniqueId"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_cli_router_route_ce, SL("_delimiterPath"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_class_constant_string(phalcon_cli_router_route_ce, SL("DEFAULT_DELIMITER"), " " TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Cli_Router_Route, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *routeId = NULL, *uniqueId = NULL, *delimiter = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(delimiter); zephir_read_static_property_ce(&delimiter, phalcon_cli_router_route_ce, SL("_delimiterPath") TSRMLS_CC); if (!(zephir_is_true(delimiter))) { ZEPHIR_INIT_NVAR(delimiter); ZVAL_STRING(delimiter, " ", 1); } zephir_update_property_this(this_ptr, SL("_delimiter"), delimiter TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, pattern, paths); zephir_check_call_status(); ZEPHIR_OBS_VAR(uniqueId); zephir_read_static_property_ce(&uniqueId, phalcon_cli_router_route_ce, SL("_uniqueId") TSRMLS_CC); if (Z_TYPE_P(uniqueId) == IS_NULL) { ZEPHIR_INIT_NVAR(uniqueId); ZVAL_LONG(uniqueId, 0); } ZEPHIR_CPY_WRT(routeId, uniqueId); zephir_update_property_this(this_ptr, SL("_id"), routeId TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, (zephir_get_numberval(uniqueId) + 1)); zephir_update_static_property_ce(phalcon_cli_router_route_ce, SL("_uniqueId"), &_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router_Route, compilePattern) { zval *pattern_param = NULL, *idPattern, *part = NULL, *_0, *_1 = NULL, *_2, _3, *_4, *_5 = NULL; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (zephir_memnstr_str(pattern, SL(":"), "phalcon/cli/router/route.zep", 94)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_VAR(idPattern); ZEPHIR_CONCAT_VS(idPattern, _0, "([a-zA-Z0-9\\_\\-]+)"); if (zephir_memnstr_str(pattern, SL(":delimiter"), "phalcon/cli/router/route.zep", 100)) { ZEPHIR_INIT_VAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, ":delimiter", 0); zephir_fast_str_replace(&_1, &_3, _2, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_VAR(part); ZEPHIR_CONCAT_VS(part, _2, ":module"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 106)) { ZEPHIR_INIT_NVAR(_1); zephir_fast_str_replace(&_1, part, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(part); ZEPHIR_CONCAT_VS(part, _2, ":task"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 112)) { ZEPHIR_INIT_NVAR(_1); zephir_fast_str_replace(&_1, part, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(part); ZEPHIR_CONCAT_VS(part, _2, ":namespace"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 118)) { ZEPHIR_INIT_NVAR(_1); zephir_fast_str_replace(&_1, part, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(part); ZEPHIR_CONCAT_VS(part, _2, ":action"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 124)) { ZEPHIR_INIT_NVAR(_1); zephir_fast_str_replace(&_1, part, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(part); ZEPHIR_CONCAT_VS(part, _2, ":params"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 130)) { ZEPHIR_INIT_NVAR(_1); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "(", _4, ".*)*"); zephir_fast_str_replace(&_1, part, _5, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(part); ZEPHIR_CONCAT_VS(part, _2, ":int"); if (zephir_memnstr(pattern, part, "phalcon/cli/router/route.zep", 136)) { ZEPHIR_INIT_NVAR(_1); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VS(_5, _4, "([0-9]+)"); zephir_fast_str_replace(&_1, part, _5, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } } if (zephir_memnstr_str(pattern, SL("("), "phalcon/cli/router/route.zep", 142)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } if (zephir_memnstr_str(pattern, SL("["), "phalcon/cli/router/route.zep", 147)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } RETURN_CTOR(pattern); } static PHP_METHOD(Phalcon_Cli_Router_Route, extractNamedParams) { long _0, _5, _25; zend_bool notValid, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0; char ch; zval *pattern_param = NULL, *matches, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, _18 = zval_used_for_init, _19 = zval_used_for_init, *_20 = NULL, _22 = zval_used_for_init, *_23 = NULL, *_26, *_27 = NULL; zval *pattern = NULL, *route, *item = NULL, *variable = NULL, *regexp = NULL, *_4 = NULL, *_21 = NULL, *_24 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (zephir_fast_strlen_ev(pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, marker); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (cursor - marker)); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, pattern, zephir_get_intval(&_1), zephir_get_intval(&_2), 0); zephir_get_strval(_4, _3); ZEPHIR_CPY_WRT(item, _4); for (_5 = 0; _5 < Z_STRLEN_P(item); _5++) { cursorVar = _5; ch = ZEPHIR_STRING_OFFSET(item, _5); if (ch == '\0') { break; } _6 = cursorVar == 0; if (_6) { _7 = ch >= 'a'; if (_7) { _7 = ch <= 'z'; } _8 = _7; if (!(_8)) { _9 = ch >= 'A'; if (_9) { _9 = ch <= 'Z'; } _8 = _9; } _6 = !(_8); } if (_6) { notValid = 1; break; } _10 = ch >= 'a'; if (_10) { _10 = ch <= 'z'; } _11 = _10; if (!(_11)) { _12 = ch >= 'A'; if (_12) { _12 = ch <= 'Z'; } _11 = _12; } _13 = _11; if (!(_13)) { _14 = ch >= '0'; if (_14) { _14 = ch <= '9'; } _13 = _14; } _15 = _13; if (!(_15)) { _15 = ch == '-'; } _16 = _15; if (!(_16)) { _16 = ch == '_'; } _17 = _16; if (!(_17)) { _17 = ch == ':'; } if (_17) { if (ch == ':') { ZEPHIR_SINIT_NVAR(_18); ZVAL_LONG(&_18, 0); ZEPHIR_SINIT_NVAR(_19); ZVAL_LONG(&_19, cursorVar); ZEPHIR_INIT_NVAR(_20); zephir_substr(_20, item, 0 , zephir_get_intval(&_19), 0); zephir_get_strval(_21, _20); ZEPHIR_CPY_WRT(variable, _21); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_23); zephir_substr(_23, item, zephir_get_intval(&_22), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(_24, _23); ZEPHIR_CPY_WRT(regexp, _24); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _6 = zephir_is_true(variable); if (_6) { _6 = zephir_is_true(regexp); } if (_6) { foundPattern = 0; for (_25 = 0; _25 < Z_STRLEN_P(regexp); _25++) { ch = ZEPHIR_STRING_OFFSET(regexp, _25); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { zephir_concat_self_str(&route, "(", sizeof("(")-1 TSRMLS_CC); zephir_concat_self(&route, regexp TSRMLS_CC); zephir_concat_self_str(&route, ")", sizeof(")")-1 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_20); ZVAL_LONG(_20, tmp); zephir_array_update_zval(&matches, variable, &_20, PH_COPY | PH_SEPARATE); } else { _26 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_27); ZEPHIR_CONCAT_SVS(_27, "([^", _26, "]*)"); zephir_concat_self(&route, _27 TSRMLS_CC); ZEPHIR_INIT_NVAR(_23); ZVAL_LONG(_23, tmp); zephir_array_update_zval(&matches, item, &_23, PH_COPY | PH_SEPARATE); } } else { zephir_concat_self_str(&route, "{", sizeof("{")-1 TSRMLS_CC); zephir_concat_self(&route, item TSRMLS_CC); zephir_concat_self_str(&route, "}", sizeof("}")-1 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); } static PHP_METHOD(Phalcon_Cli_Router_Route, reConfigure) { int _0, ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *moduleName = NULL, *taskName = NULL, *actionName = NULL, *parts, *routePaths = NULL, *realClassName = NULL, *namespaceName, *pcrePattern = NULL, *compiledPattern = NULL, *extracted = NULL, *_1 = NULL, *_2, *_3, _4; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(taskName); ZVAL_NULL(taskName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0 = zephir_fast_count_int(parts TSRMLS_CC); if (_0 == 3) { ZEPHIR_OBS_NVAR(moduleName); zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 318 TSRMLS_CC); ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 1, PH_NOISY, "phalcon/cli/router/route.zep", 319 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY, "phalcon/cli/router/route.zep", 320 TSRMLS_CC); break; } if (_0 == 2) { ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 324 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY, "phalcon/cli/router/route.zep", 325 TSRMLS_CC); break; } if (_0 == 1) { ZEPHIR_OBS_NVAR(taskName); zephir_array_fetch_long(&taskName, parts, 0, PH_NOISY, "phalcon/cli/router/route.zep", 329 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(routePaths); array_init(routePaths); if (Z_TYPE_P(moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(taskName) != IS_NULL) { if (zephir_memnstr_str(taskName, SL("\\"), "phalcon/cli/router/route.zep", 344)) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class_ns(realClassName, taskName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(namespaceName); zephir_get_ns_class(namespaceName, taskName, 0 TSRMLS_CC); if (zephir_is_true(namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(realClassName, taskName); } ZEPHIR_INIT_VAR(_1); zephir_uncamelize(_1, realClassName); zephir_array_update_string(&routePaths, SL("task"), &_1, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(routePaths, paths); } } else { ZEPHIR_INIT_NVAR(routePaths); array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/cli/router/route.zep", 376); return; } if (!(zephir_start_with_str(pattern, SL("#")))) { if (zephir_memnstr_str(pattern, SL("{"), "phalcon/cli/router/route.zep", 384)) { ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, pattern); zephir_check_call_status(); ZEPHIR_OBS_VAR(pcrePattern); zephir_array_fetch_long(&pcrePattern, extracted, 0, PH_NOISY, "phalcon/cli/router/route.zep", 389 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); zephir_array_fetch_long(&_2, extracted, 1, PH_NOISY | PH_READONLY, "phalcon/cli/router/route.zep", 390 TSRMLS_CC); zephir_fast_array_merge(_1, &(routePaths), &(_2) TSRMLS_CC); ZEPHIR_CPY_WRT(routePaths, _1); } else { ZEPHIR_CPY_WRT(pcrePattern, pattern); } ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, pcrePattern); zephir_check_call_status(); } else { if (zephir_memnstr_str(pattern, SL(":delimiter"), "phalcon/cli/router/route.zep", 401)) { ZEPHIR_INIT_NVAR(_1); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_delimiter"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, ":delimiter", 0); zephir_fast_str_replace(&_1, &_4, _3, pattern TSRMLS_CC); zephir_get_strval(pattern, _1); } ZEPHIR_CPY_WRT(compiledPattern, pattern); } zephir_update_property_this(this_ptr, SL("_pattern"), pattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_compiledPattern"), compiledPattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_paths"), routePaths TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router_Route, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Cli_Router_Route, setName) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Cli_Router_Route, beforeMatch) { zval *callback; zephir_fetch_params(0, 1, 0, &callback); zephir_update_property_this(this_ptr, SL("_beforeMatch"), callback TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Cli_Router_Route, getBeforeMatch) { RETURN_MEMBER(this_ptr, "_beforeMatch"); } static PHP_METHOD(Phalcon_Cli_Router_Route, getRouteId) { RETURN_MEMBER(this_ptr, "_id"); } static PHP_METHOD(Phalcon_Cli_Router_Route, getPattern) { RETURN_MEMBER(this_ptr, "_pattern"); } static PHP_METHOD(Phalcon_Cli_Router_Route, getCompiledPattern) { RETURN_MEMBER(this_ptr, "_compiledPattern"); } static PHP_METHOD(Phalcon_Cli_Router_Route, getPaths) { RETURN_MEMBER(this_ptr, "_paths"); } static PHP_METHOD(Phalcon_Cli_Router_Route, getReversedPaths) { HashTable *_2; HashPosition _1; zval *reversed, *path = NULL, *position = NULL, *_0, **_3; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(reversed); array_init(reversed); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_paths"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/cli/router/route.zep", 513); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(path, _2, _1); ZEPHIR_GET_HVALUE(position, _3); zephir_array_update_zval(&reversed, position, &path, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(reversed); } static PHP_METHOD(Phalcon_Cli_Router_Route, convert) { zval *name_param = NULL, *converter; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &converter); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_converters"), name, converter TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Cli_Router_Route, getConverters) { RETURN_MEMBER(this_ptr, "_converters"); } static PHP_METHOD(Phalcon_Cli_Router_Route, reset) { zephir_update_static_property_ce(phalcon_cli_router_route_ce, SL("_uniqueId"), &ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } static PHP_METHOD(Phalcon_Cli_Router_Route, delimiter) { zval *delimiter_param = NULL; zval *delimiter = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &delimiter_param); if (!delimiter_param) { ZEPHIR_INIT_VAR(delimiter); ZVAL_EMPTY_STRING(delimiter); } else { if (unlikely(Z_TYPE_P(delimiter_param) != IS_STRING && Z_TYPE_P(delimiter_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'delimiter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(delimiter_param) == IS_STRING)) { zephir_get_strval(delimiter, delimiter_param); } else { ZEPHIR_INIT_VAR(delimiter); ZVAL_EMPTY_STRING(delimiter); } } zephir_update_static_property_ce(phalcon_cli_router_route_ce, SL("_delimiterPath"), &delimiter TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Cli_Router_Route, getDelimiter) { zval *delimiter = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(delimiter); zephir_read_static_property_ce(&delimiter, phalcon_cli_router_route_ce, SL("_delimiterPath") TSRMLS_CC); if (!(zephir_is_true(delimiter))) { ZEPHIR_INIT_NVAR(delimiter); ZVAL_STRING(delimiter, " ", 1); } RETURN_CCTOR(delimiter); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Config, Exception, phalcon, config_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config_Adapter_Ini) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Config\\Adapter, Ini, phalcon, config_adapter_ini, phalcon_config_ce, phalcon_config_adapter_ini_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Config_Adapter_Ini, __construct) { zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL; HashTable *_4, *_7; HashPosition _3, _6; int ZEPHIR_LAST_CALL_STATUS; zval *filePath_param = NULL, *iniConfig = NULL, *_0 = NULL, *_1, *_2, *config, *section = NULL, *sections = NULL, *directives = NULL, *path = NULL, *lastValue = NULL, **_5, **_8, *_9 = NULL, _11 = zval_used_for_init; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &filePath_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } ZEPHIR_CALL_FUNCTION(&iniConfig, "parse_ini_file", NULL, 127, filePath, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(iniConfig)) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_config_exception_ce); ZEPHIR_INIT_VAR(_1); zephir_basename(_1, filePath TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Configuration file ", _1, " can't be loaded"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/config/adapter/ini.zep", 67 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(config); array_init(config); zephir_is_iterable(iniConfig, &_4, &_3, 0, 0, "phalcon/config/adapter/ini.zep", 88); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(section, _4, _3); ZEPHIR_GET_HVALUE(directives, _5); if (Z_TYPE_P(directives) == IS_ARRAY) { ZEPHIR_INIT_NVAR(sections); array_init(sections); zephir_is_iterable(directives, &_7, &_6, 0, 0, "phalcon/config/adapter/ini.zep", 80); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(path, _7, _6); ZEPHIR_GET_HVALUE(lastValue, _8); ZEPHIR_CALL_METHOD(&_9, this_ptr, "_parseinistring", &_10, 0, path, lastValue); zephir_check_call_status(); zephir_array_append(§ions, _9, PH_SEPARATE, "phalcon/config/adapter/ini.zep", 78); } if (zephir_fast_count_int(sections TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_11); ZVAL_STRING(&_11, "array_merge_recursive", 0); ZEPHIR_CALL_USER_FUNC_ARRAY(_0, &_11, sections); zephir_check_call_status(); zephir_array_update_zval(&config, section, &_0, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&config, section, &directives, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_ini_ce, this_ptr, "__construct", &_12, 22, config); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Config_Adapter_Ini, _parseIniString) { int ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *value, *pos, *key, _0, _1, _2, *_3, *_4 = NULL; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &path_param, &value); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, ".", 0); ZEPHIR_INIT_VAR(pos); zephir_fast_strpos(pos, path, &_0, 0 ); if (ZEPHIR_IS_FALSE_IDENTICAL(pos)) { zephir_create_array(return_value, 1, 0 TSRMLS_CC); zephir_array_update_string(&return_value, Z_STRVAL_P(path), Z_STRLEN_P(path), &value, PH_COPY); RETURN_MM(); } ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_INIT_VAR(key); zephir_substr(key, path, 0 , zephir_get_intval(pos), 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, (zephir_get_numberval(pos) + 1)); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, path, zephir_get_intval(&_2), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(path, _3); zephir_create_array(return_value, 1, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, this_ptr, "_parseinistring", NULL, 128, path, value); zephir_check_call_status(); zephir_array_update_zval(&return_value, key, &_4, PH_COPY); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config_Adapter_Json) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Config\\Adapter, Json, phalcon, config_adapter_json, phalcon_config_ce, phalcon_config_adapter_json_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Config_Adapter_Json, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *filePath_param = NULL, *_1, *_2; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &filePath_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } ZEPHIR_INIT_VAR(_1); ZEPHIR_INIT_VAR(_2); zephir_file_get_contents(_2, filePath TSRMLS_CC); zephir_json_decode(_1, &(_1), _2, zephir_get_intval(ZEPHIR_GLOBAL(global_true)) TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_json_ce, this_ptr, "__construct", &_0, 22, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config_Adapter_Php) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Config\\Adapter, Php, phalcon, config_adapter_php, phalcon_config_ce, phalcon_config_adapter_php_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Config_Adapter_Php, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *filePath_param = NULL, *_1 = NULL; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &filePath_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_1); if (zephir_require_zval_ret(&_1, filePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_php_ce, this_ptr, "__construct", &_0, 22, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Config_Adapter_Yaml) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Config\\Adapter, Yaml, phalcon, config_adapter_yaml, phalcon_config_ce, phalcon_config_adapter_yaml_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Config_Adapter_Yaml, __construct) { zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; int ndocs = 0, ZEPHIR_LAST_CALL_STATUS; zval *callbacks = NULL; zval *filePath_param = NULL, *callbacks_param = NULL, *yamlConfig = NULL, _0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_5; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &filePath_param, &callbacks_param); if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) { zephir_get_strval(filePath, filePath_param); } else { ZEPHIR_INIT_VAR(filePath); ZVAL_EMPTY_STRING(filePath); } if (!callbacks_param) { ZEPHIR_INIT_VAR(callbacks); array_init(callbacks); } else { callbacks = callbacks_param; } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "yaml", 0); ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", NULL, 129, &_0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_config_exception_ce, "Yaml extension not loaded", "phalcon/config/adapter/yaml.zep", 71); return; } if (!ZEPHIR_IS_STRING_IDENTICAL(callbacks, "")) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, ndocs); ZEPHIR_MAKE_REF(_3); ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_4, 130, filePath, _2, _3, callbacks); ZEPHIR_UNREF(_3); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&yamlConfig, "yaml_parse_file", &_4, 130, filePath); zephir_check_call_status(); } if (ZEPHIR_IS_FALSE_IDENTICAL(yamlConfig)) { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_config_exception_ce); ZEPHIR_INIT_NVAR(_3); zephir_basename(_3, filePath TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "Configuration file ", _3, " can't be loaded"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/config/adapter/yaml.zep", 81 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_yaml_ce, this_ptr, "__construct", &_6, 22, yamlConfig); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Crypt_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Crypt, Exception, phalcon, crypt_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Adapter, phalcon, db_adapter, phalcon_db_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_db_adapter_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_descriptor"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_dialectType"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_dialect"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_connectionId"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_sqlStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_sqlVariables"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_ce, SL("_sqlBindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_adapter_ce, SL("_transactionLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_adapter_ce, SL("_transactionsWithSavepoints"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_adapter_ce, SL("_connectionConsecutive"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_db_adapter_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter, getDialectType) { RETURN_MEMBER(this_ptr, "_dialectType"); } static PHP_METHOD(Phalcon_Db_Adapter, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Db_Adapter, getSqlVariables) { RETURN_MEMBER(this_ptr, "_sqlVariables"); } static PHP_METHOD(Phalcon_Db_Adapter, __construct) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_3; zval *descriptor_param = NULL, *dialectClass = NULL, *connectionId, *_0, *_1, *_2 = NULL; zval *descriptor = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &descriptor_param); descriptor = descriptor_param; ZEPHIR_OBS_VAR(connectionId); zephir_read_static_property_ce(&connectionId, phalcon_db_adapter_ce, SL("_connectionConsecutive") TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_connectionId"), connectionId TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, (zephir_get_numberval(connectionId) + 1)); zephir_update_static_property_ce(phalcon_db_adapter_ce, SL("_connectionConsecutive"), &_0 TSRMLS_CC); ZEPHIR_OBS_VAR(dialectClass); if (!(zephir_array_isset_string_fetch(&dialectClass, descriptor, SS("dialectClass"), 0 TSRMLS_CC))) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialectType"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(dialectClass); ZEPHIR_CONCAT_SV(dialectClass, "phalcon\\db\\dialect\\", _0); } if (Z_TYPE_P(dialectClass) == IS_STRING) { ZEPHIR_INIT_VAR(_1); zephir_fetch_safe_class(_2, dialectClass); _3 = zend_fetch_class(Z_STRVAL_P(_2), Z_STRLEN_P(_2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(_1, _3); if (zephir_has_constructor(_1 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_dialect"), _1 TSRMLS_CC); } else { if (Z_TYPE_P(dialectClass) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_dialect"), dialectClass TSRMLS_CC); } } zephir_update_property_this(this_ptr, SL("_descriptor"), descriptor TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Adapter, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Db_Adapter, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Db_Adapter, setDialect) { zval *dialect; zephir_fetch_params(0, 1, 0, &dialect); zephir_update_property_this(this_ptr, SL("_dialect"), dialect TSRMLS_CC); } static PHP_METHOD(Phalcon_Db_Adapter, getDialect) { RETURN_MEMBER(this_ptr, "_dialect"); } static PHP_METHOD(Phalcon_Db_Adapter, fetchOne) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery_param = NULL, *fetchMode = NULL, *bindParams = NULL, *bindTypes = NULL, *result = NULL; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &sqlQuery_param, &fetchMode, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } if (!fetchMode) { ZEPHIR_INIT_VAR(fetchMode); ZVAL_LONG(fetchMode, 2); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&result, this_ptr, "query", NULL, 0, sqlQuery, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(result) == IS_OBJECT) { if (Z_TYPE_P(fetchMode) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, fetchMode); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(result, "fetch", NULL, 0); zephir_check_call_status(); RETURN_MM(); } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, fetchAll) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery_param = NULL, *fetchMode = NULL, *bindParams = NULL, *bindTypes = NULL, *results, *result = NULL, *row = NULL; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &sqlQuery_param, &fetchMode, &bindParams, &bindTypes); zephir_get_strval(sqlQuery, sqlQuery_param); if (!fetchMode) { ZEPHIR_INIT_VAR(fetchMode); ZVAL_LONG(fetchMode, 2); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(results); array_init(results); ZEPHIR_CALL_METHOD(&result, this_ptr, "query", NULL, 0, sqlQuery, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(result) == IS_OBJECT) { if (Z_TYPE_P(fetchMode) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, fetchMode); zephir_check_call_status(); } while (1) { ZEPHIR_CALL_METHOD(&row, result, "fetch", &_0, 0); zephir_check_call_status(); if (!(zephir_is_true(row))) { break; } zephir_array_append(&results, row, PH_SEPARATE, "phalcon/db/adapter.zep", 243); } } RETURN_CCTOR(results); } static PHP_METHOD(Phalcon_Db_Adapter, fetchColumn) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery, *placeholders = NULL, *column = NULL, *row = NULL, *columnValue, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlQuery, &placeholders, &column); if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } if (!column) { ZEPHIR_INIT_VAR(column); ZVAL_LONG(column, 0); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 4); ZEPHIR_CALL_METHOD(&row, this_ptr, "fetchone", NULL, 0, sqlQuery, _0, placeholders); zephir_check_call_status(); _1 = !(ZEPHIR_IS_EMPTY(row)); if (_1) { _1 = zephir_array_isset_fetch(&columnValue, row, column, 1 TSRMLS_CC); } if (_1) { RETURN_CTOR(columnValue); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter, insert) { zephir_fcall_cache_entry *_10 = NULL; zval *_5 = NULL; HashTable *_3, *_7; HashPosition _2, _6; int ZEPHIR_LAST_CALL_STATUS; zval *values = NULL; zval *table, *values_param = NULL, *fields = NULL, *dataTypes = NULL, *placeholders, *insertValues, *bindDataTypes, *bindType = NULL, *position = NULL, *value = NULL, *escapedTable = NULL, *joinedValues, *escapedFields = NULL, *field = NULL, *insertSql, *_0 = NULL, *_1, **_4, **_8, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &table, &values_param, &fields, &dataTypes); values = values_param; if (!fields) { fields = ZEPHIR_GLOBAL(global_null); } if (!dataTypes) { dataTypes = ZEPHIR_GLOBAL(global_null); } if (!(zephir_fast_count_int(values TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_db_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Unable to insert into ", table, " without data"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/db/adapter.zep", 312 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(placeholders); array_init(placeholders); ZEPHIR_INIT_VAR(insertValues); array_init(insertValues); ZEPHIR_INIT_VAR(bindDataTypes); array_init(bindDataTypes); zephir_is_iterable(values, &_3, &_2, 0, 0, "phalcon/db/adapter.zep", 342); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(position, _3, _2); ZEPHIR_GET_HVALUE(value, _4); if (Z_TYPE_P(value) == IS_OBJECT) { zephir_get_strval(_5, value); zephir_array_append(&placeholders, _5, PH_SEPARATE, "phalcon/db/adapter.zep", 325); } else { if (Z_TYPE_P(value) == IS_NULL) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "null", 1); zephir_array_append(&placeholders, _0, PH_SEPARATE, "phalcon/db/adapter.zep", 328); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "?", 1); zephir_array_append(&placeholders, _0, PH_SEPARATE, "phalcon/db/adapter.zep", 330); zephir_array_append(&insertValues, value, PH_SEPARATE, "phalcon/db/adapter.zep", 331); if (Z_TYPE_P(dataTypes) == IS_ARRAY) { ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, dataTypes, position, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/db/adapter.zep", 334); return; } zephir_array_append(&bindDataTypes, bindType, PH_SEPARATE, "phalcon/db/adapter.zep", 336); } } } } if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", NULL, 0, table); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(escapedTable, table); } ZEPHIR_INIT_VAR(joinedValues); zephir_fast_join_str(joinedValues, SL(", "), placeholders TSRMLS_CC); ZEPHIR_INIT_VAR(insertSql); if (Z_TYPE_P(fields) == IS_ARRAY) { if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_INIT_VAR(escapedFields); array_init(escapedFields); zephir_is_iterable(fields, &_7, &_6, 0, 0, "phalcon/db/adapter.zep", 359); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(field, _8); ZEPHIR_CALL_METHOD(&_9, this_ptr, "escapeidentifier", &_10, 0, field); zephir_check_call_status(); zephir_array_append(&escapedFields, _9, PH_SEPARATE, "phalcon/db/adapter.zep", 357); } } else { ZEPHIR_CPY_WRT(escapedFields, fields); } ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(", "), escapedFields TSRMLS_CC); ZEPHIR_CONCAT_SVSVSVS(insertSql, "INSERT INTO ", escapedTable, " (", _0, ") VALUES (", joinedValues, ")"); } else { ZEPHIR_CONCAT_SVSVS(insertSql, "INSERT INTO ", escapedTable, " VALUES (", joinedValues, ")"); } if (!(zephir_fast_count_int(bindDataTypes TSRMLS_CC))) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, insertSql, insertValues); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, insertSql, insertValues, bindDataTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, insertAsDict) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool _0; zval *table, *data, *dataTypes = NULL, *values, *fields, *field = NULL, *value = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &table, &data, &dataTypes); if (!dataTypes) { dataTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_VAR(fields); array_init(fields); _0 = Z_TYPE_P(data) != IS_ARRAY; if (!(_0)) { _0 = ZEPHIR_IS_EMPTY(data); } if (_0) { RETURN_MM_BOOL(0); } zephir_is_iterable(data, &_2, &_1, 0, 0, "phalcon/db/adapter.zep", 414); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(field, _2, _1); ZEPHIR_GET_HVALUE(value, _3); zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/db/adapter.zep", 410); zephir_array_append(&values, value, PH_SEPARATE, "phalcon/db/adapter.zep", 411); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "insert", NULL, 0, table, values, fields, dataTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, update) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *table, *fields, *values, *whereCondition = NULL, *dataTypes = NULL, *placeholders, *updateValues, *position = NULL, *value = NULL, *field = NULL, *bindDataTypes, *escapedField = NULL, *bindType = NULL, *escapedTable = NULL, *setClause, *updateSql, *conditions, *whereBind, *whereTypes, **_2, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 2, &table, &fields, &values, &whereCondition, &dataTypes); if (!whereCondition) { whereCondition = ZEPHIR_GLOBAL(global_null); } if (!dataTypes) { dataTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(placeholders); array_init(placeholders); ZEPHIR_INIT_VAR(updateValues); array_init(updateValues); ZEPHIR_INIT_VAR(bindDataTypes); array_init(bindDataTypes); zephir_is_iterable(values, &_1, &_0, 0, 0, "phalcon/db/adapter.zep", 500); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(position, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_OBS_NVAR(field); if (!(zephir_array_isset_fetch(&field, fields, position, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The number of values in the update is not the same as fields", "phalcon/db/adapter.zep", 473); return; } if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CALL_METHOD(&escapedField, this_ptr, "escapeidentifier", &_3, 0, field); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(escapedField, field); } if (Z_TYPE_P(value) == IS_OBJECT) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VSV(_4, escapedField, " = ", value); zephir_array_append(&placeholders, _4, PH_SEPARATE, "phalcon/db/adapter.zep", 483); } else { if (Z_TYPE_P(value) == IS_NULL) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, escapedField, " = null"); zephir_array_append(&placeholders, _4, PH_SEPARATE, "phalcon/db/adapter.zep", 486); } else { zephir_array_append(&updateValues, value, PH_SEPARATE, "phalcon/db/adapter.zep", 488); if (Z_TYPE_P(dataTypes) == IS_ARRAY) { ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, dataTypes, position, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Incomplete number of bind types", "phalcon/db/adapter.zep", 491); return; } zephir_array_append(&bindDataTypes, bindType, PH_SEPARATE, "phalcon/db/adapter.zep", 493); } ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VS(_5, escapedField, " = ?"); zephir_array_append(&placeholders, _5, PH_SEPARATE, "phalcon/db/adapter.zep", 495); } } } if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", NULL, 0, table); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(escapedTable, table); } ZEPHIR_INIT_VAR(setClause); zephir_fast_join_str(setClause, SL(", "), placeholders TSRMLS_CC); ZEPHIR_INIT_VAR(updateSql); if (Z_TYPE_P(whereCondition) != IS_NULL) { ZEPHIR_CONCAT_SVSVS(updateSql, "UPDATE ", escapedTable, " SET ", setClause, " WHERE "); if (Z_TYPE_P(whereCondition) == IS_STRING) { zephir_concat_self(&updateSql, whereCondition TSRMLS_CC); } else { if (Z_TYPE_P(whereCondition) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid WHERE clause conditions", "phalcon/db/adapter.zep", 523); return; } ZEPHIR_OBS_VAR(conditions); if (zephir_array_isset_string_fetch(&conditions, whereCondition, SS("conditions"), 0 TSRMLS_CC)) { zephir_concat_self(&updateSql, conditions TSRMLS_CC); } ZEPHIR_OBS_VAR(whereBind); if (zephir_array_isset_string_fetch(&whereBind, whereCondition, SS("bind"), 0 TSRMLS_CC)) { zephir_merge_append(updateValues, whereBind); } ZEPHIR_OBS_VAR(whereTypes); if (zephir_array_isset_string_fetch(&whereTypes, whereCondition, SS("bindTypes"), 0 TSRMLS_CC)) { zephir_merge_append(bindDataTypes, whereTypes); } } } else { ZEPHIR_CONCAT_SVSV(updateSql, "UPDATE ", escapedTable, " SET ", setClause); } if (!(zephir_fast_count_int(bindDataTypes TSRMLS_CC))) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, updateSql, updateValues); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, updateSql, updateValues, bindDataTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, updateAsDict) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool _0; zval *table, *data, *whereCondition = NULL, *dataTypes = NULL, *values, *fields, *field = NULL, *value = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &table, &data, &whereCondition, &dataTypes); if (!whereCondition) { whereCondition = ZEPHIR_GLOBAL(global_null); } if (!dataTypes) { dataTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_VAR(fields); array_init(fields); _0 = Z_TYPE_P(data) != IS_ARRAY; if (!(_0)) { _0 = ZEPHIR_IS_EMPTY(data); } if (_0) { RETURN_MM_BOOL(0); } zephir_is_iterable(data, &_2, &_1, 0, 0, "phalcon/db/adapter.zep", 599); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(field, _2, _1); ZEPHIR_GET_HVALUE(value, _3); zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/db/adapter.zep", 595); zephir_array_append(&values, value, PH_SEPARATE, "phalcon/db/adapter.zep", 596); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "update", NULL, 0, table, fields, values, whereCondition, dataTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *table, *whereCondition = NULL, *placeholders = NULL, *dataTypes = NULL, *sql, *escapedTable = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &table, &whereCondition, &placeholders, &dataTypes); if (!whereCondition) { whereCondition = ZEPHIR_GLOBAL(global_null); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } if (!dataTypes) { dataTypes = ZEPHIR_GLOBAL(global_null); } if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CALL_METHOD(&escapedTable, this_ptr, "escapeidentifier", NULL, 0, table); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(escapedTable, table); } ZEPHIR_INIT_VAR(sql); if (!(ZEPHIR_IS_EMPTY(whereCondition))) { ZEPHIR_CONCAT_SVSV(sql, "DELETE FROM ", escapedTable, " WHERE ", whereCondition); } else { ZEPHIR_CONCAT_SV(sql, "DELETE FROM ", escapedTable); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, sql, placeholders, dataTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, getColumnList) { int ZEPHIR_LAST_CALL_STATUS; zval *columnList, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &columnList); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getcolumnlist", NULL, 0, columnList); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, limit) { int number, ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery_param = NULL, *number_param = NULL, *_0, *_1; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number_param); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } number = zephir_get_intval(number_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, number); ZEPHIR_RETURN_CALL_METHOD(_0, "limit", NULL, 0, sqlQuery, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, tableExists) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, *_4; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "tableexists", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchone", NULL, 0, _2, _3); zephir_check_call_status(); zephir_array_fetch_long(&_4, _0, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 676 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_GT_LONG(_4, 0)); } static PHP_METHOD(Phalcon_Db_Adapter, viewExists) { int ZEPHIR_LAST_CALL_STATUS; zval *viewName_param = NULL, *schemaName_param = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, *_4; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "viewexists", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchone", NULL, 0, _2, _3); zephir_check_call_status(); zephir_array_fetch_long(&_4, _0, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 688 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_GT_LONG(_4, 0)); } static PHP_METHOD(Phalcon_Db_Adapter, forUpdate) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery_param = NULL, *_0; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlQuery_param); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "forupdate", NULL, 0, sqlQuery); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, sharedLock) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlQuery_param = NULL, *_0; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlQuery_param); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "sharedlock", NULL, 0, sqlQuery); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, createTable) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *columns, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter.zep", 715); return; } if (!(zephir_fast_count_int(columns TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter.zep", 719); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "createtable", NULL, 0, tableName, schemaName, definition); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropTable) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *_0, *_1 = NULL, *_2; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } if (!ifExists_param) { ifExists = 1; } else { ifExists = zephir_get_boolval(ifExists_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); if (ifExists) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_CALL_METHOD(&_1, _0, "droptable", NULL, 0, tableName, schemaName, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, createView) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *viewName_param = NULL, *definition_param = NULL, *schemaName = NULL, *_0, *_1 = NULL; zval *viewName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } definition = definition_param; if (!schemaName) { schemaName = ZEPHIR_GLOBAL(global_null); } if (!(zephir_array_isset_string(definition, SS("sql")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter.zep", 739); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "createview", NULL, 0, viewName, definition, schemaName); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropView) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *_0, *_1 = NULL, *_2; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } if (!ifExists_param) { ifExists = 1; } else { ifExists = zephir_get_boolval(ifExists_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); if (ifExists) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_CALL_METHOD(&_1, _0, "dropview", NULL, 0, viewName, schemaName, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, addColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "addcolumn", NULL, 0, tableName, schemaName, column); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, modifyColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "modifycolumn", NULL, 0, tableName, schemaName, column, currentColumn); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL, *columnName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } zephir_get_strval(columnName, columnName_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "dropcolumn", NULL, 0, tableName, schemaName, columnName); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, addIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "addindex", NULL, 0, tableName, schemaName, index); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *indexName, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "dropindex", NULL, 0, tableName, schemaName, indexName); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, addPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "addprimarykey", NULL, 0, tableName, schemaName, index); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "dropprimarykey", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, addForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *reference, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "addforeignkey", NULL, 0, tableName, schemaName, reference); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, dropForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, *_0, *_1 = NULL; zval *tableName = NULL, *schemaName = NULL, *referenceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceName_param) == IS_STRING)) { zephir_get_strval(referenceName, referenceName_param); } else { ZEPHIR_INIT_VAR(referenceName); ZVAL_EMPTY_STRING(referenceName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "dropforeignkey", NULL, 0, tableName, schemaName, referenceName); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, getColumnDefinition) { int ZEPHIR_LAST_CALL_STATUS; zval *column, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, listTables) { HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *schemaName_param = NULL, *table = NULL, *allTables, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } ZEPHIR_INIT_VAR(allTables); array_init(allTables); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "listtables", NULL, 0, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter.zep", 848); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(table, _6); zephir_array_fetch_long(&_7, table, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 846 TSRMLS_CC); zephir_array_append(&allTables, _7, PH_SEPARATE, "phalcon/db/adapter.zep", 846); } RETURN_CCTOR(allTables); } static PHP_METHOD(Phalcon_Db_Adapter, listViews) { HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *schemaName_param = NULL, *table = NULL, *allTables, *_0 = NULL, *_1, *_2 = NULL, *_3, **_6, *_7; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } ZEPHIR_INIT_VAR(allTables); array_init(allTables); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "listviews", NULL, 0, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter.zep", 866); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(table, _6); zephir_array_fetch_long(&_7, table, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 864 TSRMLS_CC); zephir_array_append(&allTables, _7, PH_SEPARATE, "phalcon/db/adapter.zep", 864); } RETURN_CCTOR(allTables); } static PHP_METHOD(Phalcon_Db_Adapter, describeIndexes) { zephir_fcall_cache_entry *_11 = NULL; HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema = NULL, *indexes, *index = NULL, *keyName, *indexObjects, *name = NULL, *indexColumns = NULL, *columns = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7, **_10; zval *table = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema) { schema = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(indexes); array_init(indexes); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describeindexes", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter.zep", 898); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(index, _6); zephir_array_fetch_long(&keyName, index, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 887 TSRMLS_CC); if (!(zephir_array_isset(indexes, keyName))) { ZEPHIR_INIT_NVAR(columns); array_init(columns); } else { ZEPHIR_OBS_NVAR(columns); zephir_array_fetch(&columns, indexes, keyName, PH_NOISY, "phalcon/db/adapter.zep", 891 TSRMLS_CC); } zephir_array_fetch_long(&_7, index, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 894 TSRMLS_CC); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter.zep", 894); zephir_array_update_zval(&indexes, keyName, &columns, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(indexObjects); array_init(indexObjects); zephir_is_iterable(indexes, &_9, &_8, 0, 0, "phalcon/db/adapter.zep", 907); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(name, _9, _8); ZEPHIR_GET_HVALUE(indexColumns, _10); ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_db_index_ce); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_11, 15, name, indexColumns); zephir_check_call_status(); zephir_array_update_zval(&indexObjects, name, &_3, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(indexObjects); } static PHP_METHOD(Phalcon_Db_Adapter, describeReferences) { zephir_fcall_cache_entry *_16 = NULL; zval *_11 = NULL; HashTable *_5, *_13; HashPosition _4, _12; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *references, *reference = NULL, *arrayReference = NULL, *constraintName, *referenceObjects, *name = NULL, *referencedSchema = NULL, *referencedTable = NULL, *columns = NULL, *referencedColumns = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7, *_8, *_9, *_10, **_14, *_15 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { if (unlikely(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schema_param) == IS_STRING)) { zephir_get_strval(schema, schema_param); } else { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } } ZEPHIR_INIT_VAR(references); array_init(references); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describereferences", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter.zep", 951); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(reference, _6); zephir_array_fetch_long(&constraintName, reference, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 927 TSRMLS_CC); if (!(zephir_array_isset(references, constraintName))) { ZEPHIR_OBS_NVAR(referencedSchema); zephir_array_fetch_long(&referencedSchema, reference, 3, PH_NOISY, "phalcon/db/adapter.zep", 929 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedTable); zephir_array_fetch_long(&referencedTable, reference, 4, PH_NOISY, "phalcon/db/adapter.zep", 930 TSRMLS_CC); ZEPHIR_INIT_NVAR(columns); array_init(columns); ZEPHIR_INIT_NVAR(referencedColumns); array_init(referencedColumns); } else { zephir_array_fetch(&_7, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 934 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedSchema); zephir_array_fetch_string(&referencedSchema, _7, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter.zep", 934 TSRMLS_CC); zephir_array_fetch(&_8, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 935 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedTable); zephir_array_fetch_string(&referencedTable, _8, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter.zep", 935 TSRMLS_CC); zephir_array_fetch(&_9, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 936 TSRMLS_CC); ZEPHIR_OBS_NVAR(columns); zephir_array_fetch_string(&columns, _9, SL("columns"), PH_NOISY, "phalcon/db/adapter.zep", 936 TSRMLS_CC); zephir_array_fetch(&_10, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 937 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedColumns); zephir_array_fetch_string(&referencedColumns, _10, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter.zep", 937 TSRMLS_CC); } zephir_array_fetch_long(&_7, reference, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 940 TSRMLS_CC); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter.zep", 940); zephir_array_fetch_long(&_8, reference, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 941 TSRMLS_CC); zephir_array_append(&referencedColumns, _8, PH_SEPARATE, "phalcon/db/adapter.zep", 941); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("columns"), &columns, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&references, constraintName, &_11, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(referenceObjects); array_init(referenceObjects); zephir_is_iterable(references, &_13, &_12, 0, 0, "phalcon/db/adapter.zep", 961); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HMKEY(name, _13, _12); ZEPHIR_GET_HVALUE(arrayReference, _14); ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_db_reference_ce); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter.zep", 954 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedSchema"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter.zep", 955 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedTable"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("columns"), PH_NOISY, "phalcon/db/adapter.zep", 956 TSRMLS_CC); zephir_array_update_string(&_11, SL("columns"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter.zep", 958 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedColumns"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_16, 16, name, _11); zephir_check_call_status(); zephir_array_update_zval(&referenceObjects, name, &_3, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(referenceObjects); } static PHP_METHOD(Phalcon_Db_Adapter, tableOptions) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *sql = NULL, *_0, *_1 = NULL, *_2, *_3; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&sql, _0, "tableoptions", NULL, 0, tableName, schemaName); zephir_check_call_status(); if (zephir_is_true(sql)) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 2); ZEPHIR_CALL_METHOD(&_1, this_ptr, "fetchall", NULL, 0, sql, _2); zephir_check_call_status(); zephir_array_fetch_long(&_3, _1, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter.zep", 977 TSRMLS_CC); RETURN_CTOR(_3); } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, createSavepoint) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *dialect, *_0 = NULL, *_1 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(dialect); zephir_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, dialect, "supportssavepoints", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter.", "phalcon/db/adapter.zep", 992); return; } ZEPHIR_CALL_METHOD(&_1, dialect, "createsavepoint", NULL, 0, name); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, releaseSavepoint) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *dialect, *_0 = NULL, *_1 = NULL, *_2 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(dialect); zephir_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, dialect, "supportssavepoints", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/db/adapter.zep", 1008); return; } ZEPHIR_CALL_METHOD(&_1, dialect, "supportsreleasesavepoints", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(&_2, dialect, "releasesavepoint", NULL, 0, name); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _2); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, rollbackSavepoint) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *dialect, *_0 = NULL, *_1 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(dialect); zephir_read_property_this(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, dialect, "supportssavepoints", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/db/adapter.zep", 1028); return; } ZEPHIR_CALL_METHOD(&_1, dialect, "rollbacksavepoint", NULL, 0, name); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, setNestedTransactionsWithSavepoints) { int ZEPHIR_LAST_CALL_STATUS; zval *nestedTransactionsWithSavepoints_param = NULL, *_0, *_1, *_2 = NULL; zend_bool nestedTransactionsWithSavepoints; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &nestedTransactionsWithSavepoints_param); nestedTransactionsWithSavepoints = zephir_get_boolval(nestedTransactionsWithSavepoints_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_transactionLevel"), PH_NOISY_CC); if (ZEPHIR_GT_LONG(_0, 0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Nested transaction with savepoints behavior cannot be changed while a transaction is open", "phalcon/db/adapter.zep", 1041); return; } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "supportssavepoints", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Savepoints are not supported by this database adapter", "phalcon/db/adapter.zep", 1045); return; } if (nestedTransactionsWithSavepoints) { zephir_update_property_this(this_ptr, SL("_transactionsWithSavepoints"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_transactionsWithSavepoints"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Db_Adapter, isNestedTransactionsWithSavepoints) { RETURN_MEMBER(this_ptr, "_transactionsWithSavepoints"); } static PHP_METHOD(Phalcon_Db_Adapter, getNestedTransactionSavepointName) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_transactionLevel"), PH_NOISY_CC); ZEPHIR_CONCAT_SV(return_value, "PHALCON_SAVEPOINT_", _0); return; } static PHP_METHOD(Phalcon_Db_Adapter, getDefaultIdValue) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); object_init_ex(return_value, phalcon_db_rawvalue_ce); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "null", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 17, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, getDefaultValue) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); object_init_ex(return_value, phalcon_db_rawvalue_ce); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "DEFAULT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 17, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter, supportSequences) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter, useExplicitIdValue) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter, getDescriptor) { RETURN_MEMBER(this_ptr, "_descriptor"); } static PHP_METHOD(Phalcon_Db_Adapter, getConnectionId) { RETURN_MEMBER(this_ptr, "_connectionId"); } static PHP_METHOD(Phalcon_Db_Adapter, getSQLStatement) { RETURN_MEMBER(this_ptr, "_sqlStatement"); } static PHP_METHOD(Phalcon_Db_Adapter, getRealSQLStatement) { RETURN_MEMBER(this_ptr, "_sqlStatement"); } static PHP_METHOD(Phalcon_Db_Adapter, getSQLBindTypes) { RETURN_MEMBER(this_ptr, "_sqlBindTypes"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, AdapterInterface, phalcon, db_adapterinterface, phalcon_db_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, fetchOne); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, fetchAll); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, insert); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, update); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getColumnList); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, limit); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, tableExists); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, viewExists); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, forUpdate); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, sharedLock); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, createTable); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropTable); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, createView); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropView); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, addColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, modifyColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, addIndex); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropIndex); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, addPrimaryKey); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropPrimaryKey); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, addForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, dropForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getColumnDefinition); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, listTables); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, listViews); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getDescriptor); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getConnectionId); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getSQLStatement); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getRealSQLStatement); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getSQLVariables); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getSQLBindTypes); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getDialectType); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getDialect); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, connect); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, query); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, execute); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, affectedRows); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, close); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, escapeIdentifier); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, escapeString); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, lastInsertId); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, begin); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, rollback); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, commit); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, isUnderTransaction); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getInternalHandler); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, describeIndexes); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, describeReferences); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, tableOptions); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, useExplicitIdValue); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getDefaultIdValue); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, supportSequences); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, createSavepoint); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, releaseSavepoint); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, rollbackSavepoint); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, setNestedTransactionsWithSavepoints); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, isNestedTransactionsWithSavepoints); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, getNestedTransactionSavepointName); ZEPHIR_DOC_METHOD(Phalcon_Db_AdapterInterface, describeColumns); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Column) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Column, phalcon, db_column, phalcon_db_column_method_entry, 0); zend_declare_property_null(phalcon_db_column_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_schemaName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_typeReference"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_typeValues"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_isNumeric"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_column_ce, SL("_size"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_column_ce, SL("_scale"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_default"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_unsigned"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_notNull"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_primary"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_autoIncrement"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_column_ce, SL("_first"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_column_ce, SL("_after"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_column_ce, SL("_bindType"), 2, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_INTEGER"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_VARCHAR"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DECIMAL"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATETIME"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_CHAR"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TEXT"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_FLOAT"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BOOLEAN"), 8 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DOUBLE"), 9 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYBLOB"), 10 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BLOB"), 11 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMBLOB"), 12 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_LONGBLOB"), 13 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BIGINTEGER"), 14 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSON"), 15 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSONB"), 16 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TIMESTAMP"), 17 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_NULL"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_INT"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_STR"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BLOB"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BOOL"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_DECIMAL"), 32 TSRMLS_CC); zend_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_SKIP"), 1024 TSRMLS_CC); zend_class_implements(phalcon_db_column_ce TSRMLS_CC, 1, phalcon_db_columninterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Column, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Db_Column, getSchemaName) { RETURN_MEMBER(this_ptr, "_schemaName"); } static PHP_METHOD(Phalcon_Db_Column, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Db_Column, getTypeReference) { RETURN_MEMBER(this_ptr, "_typeReference"); } static PHP_METHOD(Phalcon_Db_Column, getTypeValues) { RETURN_MEMBER(this_ptr, "_typeValues"); } static PHP_METHOD(Phalcon_Db_Column, getSize) { RETURN_MEMBER(this_ptr, "_size"); } static PHP_METHOD(Phalcon_Db_Column, getScale) { RETURN_MEMBER(this_ptr, "_scale"); } static PHP_METHOD(Phalcon_Db_Column, getDefault) { RETURN_MEMBER(this_ptr, "_default"); } static PHP_METHOD(Phalcon_Db_Column, __construct) { zval *definition = NULL; zval *name_param = NULL, *definition_param = NULL, *type, *notNull, *primary, *size, *scale, *dunsigned, *first, *after, *bindType, *isNumeric, *autoIncrement, *defaultValue, *typeReference, *typeValues, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } definition = definition_param; zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); ZEPHIR_OBS_VAR(type); if (zephir_array_isset_string_fetch(&type, definition, SS("type"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type is required", "phalcon/db/column.zep", 297); return; } ZEPHIR_OBS_VAR(typeReference); if (zephir_array_isset_string_fetch(&typeReference, definition, SS("typeReference"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_typeReference"), typeReference TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, -1); zephir_update_property_this(this_ptr, SL("_typeReference"), _0 TSRMLS_CC); } ZEPHIR_OBS_VAR(typeValues); if (zephir_array_isset_string_fetch(&typeValues, definition, SS("typeValues"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_typeValues"), typeValues TSRMLS_CC); } ZEPHIR_OBS_VAR(notNull); if (zephir_array_isset_string_fetch(¬Null, definition, SS("notNull"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_notNull"), notNull TSRMLS_CC); } ZEPHIR_OBS_VAR(primary); if (zephir_array_isset_string_fetch(&primary, definition, SS("primary"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_primary"), primary TSRMLS_CC); } ZEPHIR_OBS_VAR(size); if (zephir_array_isset_string_fetch(&size, definition, SS("size"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_size"), size TSRMLS_CC); } ZEPHIR_OBS_VAR(scale); if (zephir_array_isset_string_fetch(&scale, definition, SS("scale"), 0 TSRMLS_CC)) { do { if (ZEPHIR_IS_LONG(type, 0) || ZEPHIR_IS_LONG(type, 7) || ZEPHIR_IS_LONG(type, 3) || ZEPHIR_IS_LONG(type, 9) || ZEPHIR_IS_LONG(type, 14)) { zephir_update_property_this(this_ptr, SL("_scale"), scale TSRMLS_CC); break; } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type does not support scale parameter", "phalcon/db/column.zep", 343); return; } while(0); } ZEPHIR_OBS_VAR(defaultValue); if (zephir_array_isset_string_fetch(&defaultValue, definition, SS("default"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_default"), defaultValue TSRMLS_CC); } ZEPHIR_OBS_VAR(dunsigned); if (zephir_array_isset_string_fetch(&dunsigned, definition, SS("unsigned"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_unsigned"), dunsigned TSRMLS_CC); } ZEPHIR_OBS_VAR(isNumeric); if (zephir_array_isset_string_fetch(&isNumeric, definition, SS("isNumeric"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_isNumeric"), isNumeric TSRMLS_CC); } ZEPHIR_OBS_VAR(autoIncrement); if (zephir_array_isset_string_fetch(&autoIncrement, definition, SS("autoIncrement"), 0 TSRMLS_CC)) { if (!(zephir_is_true(autoIncrement))) { if (0) { zephir_update_property_this(this_ptr, SL("_autoIncrement"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_autoIncrement"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { do { if (ZEPHIR_IS_LONG(type, 0) || ZEPHIR_IS_LONG(type, 14)) { if (1) { zephir_update_property_this(this_ptr, SL("_autoIncrement"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_autoIncrement"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } break; } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type cannot be auto-increment", "phalcon/db/column.zep", 383); return; } while(0); } } if (zephir_array_isset_string_fetch(&first, definition, SS("first"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_first"), first TSRMLS_CC); } if (zephir_array_isset_string_fetch(&after, definition, SS("after"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_after"), after TSRMLS_CC); } if (zephir_array_isset_string_fetch(&bindType, definition, SS("bindType"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_bindType"), bindType TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Column, isUnsigned) { RETURN_MEMBER(this_ptr, "_unsigned"); } static PHP_METHOD(Phalcon_Db_Column, isNotNull) { RETURN_MEMBER(this_ptr, "_notNull"); } static PHP_METHOD(Phalcon_Db_Column, isPrimary) { RETURN_MEMBER(this_ptr, "_primary"); } static PHP_METHOD(Phalcon_Db_Column, isAutoIncrement) { RETURN_MEMBER(this_ptr, "_autoIncrement"); } static PHP_METHOD(Phalcon_Db_Column, isNumeric) { RETURN_MEMBER(this_ptr, "_isNumeric"); } static PHP_METHOD(Phalcon_Db_Column, isFirst) { RETURN_MEMBER(this_ptr, "_first"); } static PHP_METHOD(Phalcon_Db_Column, getAfterPosition) { RETURN_MEMBER(this_ptr, "_after"); } static PHP_METHOD(Phalcon_Db_Column, getBindType) { RETURN_MEMBER(this_ptr, "_bindType"); } static PHP_METHOD(Phalcon_Db_Column, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *definition, *columnType, *notNull, *size, *dunsigned, *after, *isNumeric, *first, *bindType, *primary, *columnName = NULL, *scale, *defaultValue, *autoIncrement, *columnTypeReference, *columnTypeValues, *_0, *_1; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); data = data_param; ZEPHIR_OBS_VAR(columnName); if (!(zephir_array_isset_string_fetch(&columnName, data, SS("_columnName"), 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(columnName); if (!(zephir_array_isset_string_fetch(&columnName, data, SS("_name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column name is required", "phalcon/db/column.zep", 489); return; } } ZEPHIR_INIT_VAR(definition); array_init(definition); if (zephir_array_isset_string_fetch(&columnType, data, SS("_type"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("type"), &columnType, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&columnTypeReference, data, SS("_typeReference"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("typeReference"), &columnTypeReference, PH_COPY | PH_SEPARATE); } else { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, -1); zephir_array_update_string(&definition, SL("typeReference"), &_0, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&columnTypeValues, data, SS("_typeValues"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("typeValues"), &columnTypeValues, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(¬Null, data, SS("_notNull"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("notNull"), ¬Null, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&primary, data, SS("_primary"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("primary"), &primary, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&size, data, SS("_size"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("size"), &size, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&scale, data, SS("_scale"), 1 TSRMLS_CC)) { zephir_array_fetch_string(&_1, definition, SL("type"), PH_NOISY | PH_READONLY, "phalcon/db/column.zep", 523 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_1, 0) || ZEPHIR_IS_LONG(_1, 7) || ZEPHIR_IS_LONG(_1, 3) || ZEPHIR_IS_LONG(_1, 9) || ZEPHIR_IS_LONG(_1, 14)) { zephir_array_update_string(&definition, SL("scale"), &scale, PH_COPY | PH_SEPARATE); break; } } while(0); } if (zephir_array_isset_string_fetch(&defaultValue, data, SS("_default"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("default"), &defaultValue, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&dunsigned, data, SS("_unsigned"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("unsigned"), &dunsigned, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&autoIncrement, data, SS("_autoIncrement"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("autoIncrement"), &autoIncrement, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&isNumeric, data, SS("_isNumeric"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("isNumeric"), &isNumeric, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&first, data, SS("_first"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("first"), &first, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&after, data, SS("_after"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("after"), &after, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&bindType, data, SS("_bindType"), 1 TSRMLS_CC)) { zephir_array_update_string(&definition, SL("bindType"), &bindType, PH_COPY | PH_SEPARATE); } object_init_ex(return_value, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 141, columnName, definition); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Column, hasDefault) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_default"), PH_NOISY_CC); RETURN_BOOL(Z_TYPE_P(_0) != IS_NULL); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_ColumnInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ColumnInterface, phalcon, db_columninterface, phalcon_db_columninterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getSchemaName); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeReference); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeValues); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getSize); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getScale); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isUnsigned); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNotNull); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isPrimary); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isAutoIncrement); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNumeric); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isFirst); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getAfterPosition); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getBindType); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getDefault); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, hasDefault); ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Dialect, phalcon, db_dialect, phalcon_db_dialect_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_db_dialect_ce, SL("_escapeChar"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_dialect_ce, SL("_customFunctions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_dialect_ce TSRMLS_CC, 1, phalcon_db_dialectinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Dialect, registerCustomFunction) { zval *name_param = NULL, *customFunction; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &customFunction); zephir_get_strval(name, name_param); zephir_update_property_array(this_ptr, SL("_customFunctions"), name, customFunction TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Db_Dialect, getCustomFunctions) { RETURN_MEMBER(this_ptr, "_customFunctions"); } static PHP_METHOD(Phalcon_Db_Dialect, escape) { HashTable *_7; HashPosition _6; zval *_5 = NULL; zend_bool _2, _9; zval *str_param = NULL, *escapeChar_param = NULL, *parts = NULL, *key = NULL, *part = NULL, *newParts = NULL, *_0, *_3, *_4, **_8, *_10 = NULL; zval *str = NULL, *escapeChar = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &str_param, &escapeChar_param); if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { ZEPHIR_INIT_VAR(str); ZVAL_EMPTY_STRING(str); } if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!(ZEPHIR_GLOBAL(db).escape_identifiers)) { RETURN_CTOR(str); } if (ZEPHIR_IS_STRING(escapeChar, "")) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_escapeChar"), PH_NOISY_CC); zephir_get_strval(_1, _0); ZEPHIR_CPY_WRT(escapeChar, _1); } if (!(zephir_memnstr_str(str, SL("."), "phalcon/db/dialect.zep", 68))) { _2 = !ZEPHIR_IS_STRING(escapeChar, ""); if (_2) { _2 = !ZEPHIR_IS_STRING(str, "*"); } if (_2) { ZEPHIR_CONCAT_VVV(return_value, escapeChar, str, escapeChar); RETURN_MM(); } RETURN_CTOR(str); } ZEPHIR_INIT_VAR(_3); ZEPHIR_INIT_VAR(_4); zephir_fast_trim(_4, str, escapeChar, ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_fast_explode_str(_3, SL("."), _4, LONG_MAX TSRMLS_CC); zephir_get_arrval(_5, _3); ZEPHIR_CPY_WRT(parts, _5); ZEPHIR_CPY_WRT(newParts, parts); zephir_is_iterable(parts, &_7, &_6, 0, 0, "phalcon/db/dialect.zep", 89); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(key, _7, _6); ZEPHIR_GET_HVALUE(part, _8); _2 = ZEPHIR_IS_STRING(escapeChar, ""); if (!(_2)) { _2 = ZEPHIR_IS_STRING(part, ""); } _9 = _2; if (!(_9)) { _9 = ZEPHIR_IS_STRING(part, "*"); } if (_9) { continue; } ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_VVV(_10, escapeChar, part, escapeChar); zephir_array_update_zval(&newParts, key, &_10, PH_COPY | PH_SEPARATE); } zephir_fast_join_str(return_value, SL("."), newParts TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, limit) { zend_bool _2; zval *sqlQuery_param = NULL, *number, *_0, *_1, *_3, *_4, *_5; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } if (Z_TYPE_P(number) == IS_ARRAY) { zephir_array_fetch_long(&_0, number, 0, PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 107 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, " LIMIT ", _0); zephir_concat_self(&sqlQuery, _1 TSRMLS_CC); _2 = zephir_array_isset_long(number, 1); if (_2) { zephir_array_fetch_long(&_3, number, 1, PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 109 TSRMLS_CC); _2 = (zephir_fast_strlen_ev(_3)) ? 1 : 0; } if (_2) { zephir_array_fetch_long(&_4, number, 1, PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 110 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SV(_5, " OFFSET ", _4); zephir_concat_self(&sqlQuery, _5 TSRMLS_CC); } RETURN_CTOR(sqlQuery); } ZEPHIR_CONCAT_VSV(return_value, sqlQuery, " LIMIT ", number); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, forUpdate) { zval *sqlQuery_param = NULL; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlQuery_param); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } ZEPHIR_CONCAT_VS(return_value, sqlQuery, " FOR UPDATE"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, sharedLock) { zval *sqlQuery_param = NULL; zval *sqlQuery = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlQuery_param); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } ZEPHIR_CONCAT_VS(return_value, sqlQuery, " LOCK IN SHARE MODE"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getColumnList) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *escapeChar = NULL; zval *columnList_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *columns, *column = NULL, **_2, *_3 = NULL; zval *columnList = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &columnList_param, &escapeChar_param, &bindCounts); columnList = columnList_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(columns); array_init(columns); zephir_is_iterable(columnList, &_1, &_0, 0, 0, "phalcon/db/dialect.zep", 161); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(column, _2); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getsqlcolumn", &_4, 30, column, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_append(&columns, _3, PH_SEPARATE, "phalcon/db/dialect.zep", 158); } zephir_fast_join_str(return_value, SL(", "), columns TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlColumn) { zephir_fcall_cache_entry *_3 = NULL; zend_bool _1, _2; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *column = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *columnExpression = NULL, *columnAlias = NULL, *columnField, *columnDomain, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &column, &escapeChar_param, &bindCounts); ZEPHIR_SEPARATE_PARAM(column); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(column) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); ZVAL_NULL(_0); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, column, _0, escapeChar); zephir_check_call_status(); RETURN_MM(); } if (!(zephir_array_isset_string(column, SS("type")))) { ZEPHIR_OBS_VAR(columnField); zephir_array_fetch_long(&columnField, column, 0, PH_NOISY, "phalcon/db/dialect.zep", 180 TSRMLS_CC); if (Z_TYPE_P(columnField) == IS_ARRAY) { ZEPHIR_INIT_VAR(columnExpression); zephir_create_array(columnExpression, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(columnExpression, SS("type"), SL("scalar"), 1); zephir_array_update_string(&columnExpression, SL("value"), &columnField, PH_COPY | PH_SEPARATE); } else if (ZEPHIR_IS_STRING(columnField, "*")) { ZEPHIR_INIT_NVAR(columnExpression); zephir_create_array(columnExpression, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(columnExpression, SS("type"), SL("all"), 1); } else { ZEPHIR_INIT_NVAR(columnExpression); zephir_create_array(columnExpression, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(columnExpression, SS("type"), SL("qualified"), 1); zephir_array_update_string(&columnExpression, SL("name"), &columnField, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(columnDomain); _1 = zephir_array_isset_long_fetch(&columnDomain, column, 1, 0 TSRMLS_CC); if (_1) { _1 = !ZEPHIR_IS_STRING(columnDomain, ""); } if (_1) { zephir_array_update_string(&columnExpression, SL("domain"), &columnDomain, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(columnAlias); _2 = zephir_array_isset_long_fetch(&columnAlias, column, 2, 0 TSRMLS_CC); if (_2) { _2 = zephir_is_true(columnAlias); } if (_2) { zephir_array_update_string(&columnExpression, SL("sqlAlias"), &columnAlias, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(columnExpression, column); } ZEPHIR_CALL_METHOD(&column, this_ptr, "getsqlexpression", NULL, 0, columnExpression, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_OBS_NVAR(columnAlias); _1 = zephir_array_isset_string_fetch(&columnAlias, columnExpression, SS("sqlAlias"), 0 TSRMLS_CC); if (!(_1)) { ZEPHIR_OBS_NVAR(columnAlias); _1 = zephir_array_isset_string_fetch(&columnAlias, columnExpression, SS("alias"), 0 TSRMLS_CC); } if (_1) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", &_3, 0, column, columnAlias, escapeChar); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_NVAR(_0); ZVAL_NULL(_0); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", &_3, 0, column, _0, escapeChar); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpression) { zend_bool _1; int i, ZEPHIR_LAST_CALL_STATUS, _2; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *type, *times = NULL, *postTimes, *placeholders, *rawValue, *value, *_0, *_3 = NULL, _4 = zval_used_for_init, *_5 = NULL, *_6 = NULL, *_7; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(type); if (!(zephir_array_isset_string_fetch(&type, expression, SS("type"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/db/dialect.zep", 241); return; } do { if (ZEPHIR_IS_STRING(type, "scalar")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionscalar", NULL, 31, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "object")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionobject", NULL, 32, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "qualified")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionqualified", NULL, 33, expression, escapeChar); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "literal")) { zephir_array_fetch_string(&_0, expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 268 TSRMLS_CC); RETURN_CTOR(_0); } if (ZEPHIR_IS_STRING(type, "placeholder")) { ZEPHIR_OBS_VAR(times); if (zephir_array_isset_string_fetch(×, expression, SS("times"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(placeholders); array_init(placeholders); ZEPHIR_OBS_VAR(rawValue); zephir_array_fetch_string(&rawValue, expression, SL("rawValue"), PH_NOISY, "phalcon/db/dialect.zep", 274 TSRMLS_CC); ZEPHIR_OBS_VAR(value); zephir_array_fetch_string(&value, expression, SL("value"), PH_NOISY, "phalcon/db/dialect.zep", 275 TSRMLS_CC); ZEPHIR_OBS_VAR(postTimes); if (zephir_array_isset_fetch(&postTimes, bindCounts, rawValue, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(times, postTimes); } ZEPHIR_CPY_WRT(_3, times); _2 = 1; _1 = 0; if (ZEPHIR_GE_LONG(_3, _2)) { while (1) { if (_1) { _2++; if (!(ZEPHIR_GE_LONG(_3, _2))) { break; } } else { _1 = 1; } i = _2; ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, ((i - 1))); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VV(_5, value, &_4); zephir_array_append(&placeholders, _5, PH_SEPARATE, "phalcon/db/dialect.zep", 282); } } zephir_fast_join_str(return_value, SL(", "), placeholders TSRMLS_CC); RETURN_MM(); } zephir_array_fetch_string(&_0, expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 287 TSRMLS_CC); RETURN_CTOR(_0); } if (ZEPHIR_IS_STRING(type, "binary-op")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionbinaryoperations", NULL, 34, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "unary-op")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionunaryoperations", NULL, 35, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "parentheses")) { zephir_array_fetch_string(&_0, expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 305 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_6, this_ptr, "getsqlexpression", NULL, 36, _0, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "(", _6, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "functionCall")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionfunctioncall", NULL, 37, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "list")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionlist", NULL, 38, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "all")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionall", NULL, 39, expression, escapeChar); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "select")) { zephir_array_fetch_string(&_0, expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 329 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_6, this_ptr, "select", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "(", _6, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "cast")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncastvalue", NULL, 40, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "convert")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionconvertvalue", NULL, 41, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "case")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncase", NULL, 42, expression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(_7); object_init_ex(_7, phalcon_db_exception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "Invalid SQL expression type '", type, "'"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/db/dialect.zep", 350 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Db_Dialect, getSqlTable) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *table, *escapeChar_param = NULL, *tableName, *schemaName, *aliasName; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table, &escapeChar_param); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (Z_TYPE_P(table) == IS_ARRAY) { ZEPHIR_OBS_VAR(tableName); zephir_array_fetch_long(&tableName, table, 0, PH_NOISY, "phalcon/db/dialect.zep", 365 TSRMLS_CC); ZEPHIR_OBS_VAR(schemaName); zephir_array_isset_long_fetch(&schemaName, table, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(aliasName); zephir_array_isset_long_fetch(&aliasName, table, 2, 0 TSRMLS_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparetable", NULL, 0, tableName, schemaName, aliasName, escapeChar); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 43, table, escapeChar); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, select) { zend_bool _4, _8, _9, _10, _11, _12, _14; int ZEPHIR_LAST_CALL_STATUS; zval *definition_param = NULL, *tables, *columns, *sql = NULL, *distinct, *joins, *where, *escapeChar, *groupBy, *having, *orderBy, *limit, *forUpdate, *bindCounts, *_0 = NULL, *_1, *_2 = NULL, *_3, *_5 = NULL, *_6, *_7 = NULL; zval *definition = NULL, *_13; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &definition_param); definition = definition_param; ZEPHIR_OBS_VAR(tables); if (!(zephir_array_isset_string_fetch(&tables, definition, SS("tables"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'tables' is required in the definition array", "phalcon/db/dialect.zep", 392); return; } ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/db/dialect.zep", 396); return; } ZEPHIR_OBS_VAR(distinct); if (zephir_array_isset_string_fetch(&distinct, definition, SS("distinct"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(sql); if (zephir_is_true(distinct)) { ZVAL_STRING(sql, "SELECT DISTINCT", 1); } else { ZVAL_STRING(sql, "SELECT ALL", 1); } } else { ZEPHIR_INIT_NVAR(sql); ZVAL_STRING(sql, "SELECT", 1); } ZEPHIR_OBS_VAR(bindCounts); zephir_array_isset_string_fetch(&bindCounts, definition, SS("bindCounts"), 0 TSRMLS_CC); ZEPHIR_OBS_VAR(escapeChar); zephir_read_property_this(&escapeChar, this_ptr, SL("_escapeChar"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcolumnlist", NULL, 44, columns, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, " ", _0); zephir_concat_self(&sql, _1 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getsqlexpressionfrom", NULL, 45, tables, escapeChar); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, " ", _2); zephir_concat_self(&sql, _3 TSRMLS_CC); ZEPHIR_OBS_VAR(joins); _4 = zephir_array_isset_string_fetch(&joins, definition, SS("joins"), 0 TSRMLS_CC); if (_4) { _4 = zephir_is_true(joins); } if (_4) { zephir_array_fetch_string(&_6, definition, SL("joins"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 429 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpressionjoins", NULL, 46, _6, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, " ", _5); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_OBS_VAR(where); _8 = zephir_array_isset_string_fetch(&where, definition, SS("where"), 0 TSRMLS_CC); if (_8) { _8 = zephir_is_true(where); } if (_8) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpressionwhere", NULL, 47, where, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " ", _5); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_OBS_VAR(groupBy); _9 = zephir_array_isset_string_fetch(&groupBy, definition, SS("group"), 0 TSRMLS_CC); if (_9) { _9 = zephir_is_true(groupBy); } if (_9) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpressiongroupby", NULL, 48, groupBy, escapeChar); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " ", _5); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_OBS_VAR(having); _10 = zephir_array_isset_string_fetch(&having, definition, SS("having"), 0 TSRMLS_CC); if (_10) { _10 = zephir_is_true(having); } if (_10) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpressionhaving", NULL, 49, having, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " ", _5); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_OBS_VAR(orderBy); _11 = zephir_array_isset_string_fetch(&orderBy, definition, SS("order"), 0 TSRMLS_CC); if (_11) { _11 = zephir_is_true(orderBy); } if (_11) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpressionorderby", NULL, 50, orderBy, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " ", _5); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_OBS_VAR(limit); _12 = zephir_array_isset_string_fetch(&limit, definition, SS("limit"), 0 TSRMLS_CC); if (_12) { _12 = zephir_is_true(limit); } if (_12) { ZEPHIR_INIT_VAR(_13); zephir_create_array(_13, 2, 0 TSRMLS_CC); zephir_array_update_string(&_13, SL("sql"), &sql, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_13, SL("value"), &limit, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&sql, this_ptr, "getsqlexpressionlimit", NULL, 51, _13, escapeChar, bindCounts); zephir_check_call_status(); } _14 = zephir_array_isset_string_fetch(&forUpdate, definition, SS("forUpdate"), 1 TSRMLS_CC); if (_14) { _14 = zephir_is_true(forUpdate); } if (_14) { zephir_concat_self_str(&sql, SL(" FOR UPDATE") TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect, supportsSavepoints) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Db_Dialect, supportsReleaseSavepoints) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "supportssavepoints", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, createSavepoint) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_CONCAT_SV(return_value, "SAVEPOINT ", name); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, releaseSavepoint) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_CONCAT_SV(return_value, "RELEASE SAVEPOINT ", name); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, rollbackSavepoint) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_CONCAT_SV(return_value, "ROLLBACK TO SAVEPOINT ", name); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionScalar) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *value, *_0; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } if (zephir_array_isset_string(expression, SS("column"))) { zephir_array_fetch_string(&_0, expression, SL("column"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 525 TSRMLS_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlcolumn", NULL, 30, _0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, expression, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/db/dialect.zep", 529); return; } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, value, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(value); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionObject) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *domain = NULL, *objectExpression; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(domain); ZVAL_NULL(domain); ZEPHIR_INIT_VAR(objectExpression); zephir_create_array(objectExpression, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(objectExpression, SS("type"), SL("all"), 1); ZEPHIR_OBS_NVAR(domain); _0 = zephir_array_isset_string_fetch(&domain, expression, SS("column"), 0 TSRMLS_CC); if (!(_0)) { ZEPHIR_OBS_NVAR(domain); _0 = zephir_array_isset_string_fetch(&domain, expression, SS("domain"), 0 TSRMLS_CC); } _1 = _0; if (_1) { _1 = !ZEPHIR_IS_STRING(domain, ""); } if (_1) { zephir_array_update_string(&objectExpression, SL("domain"), &domain, PH_COPY | PH_SEPARATE); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, objectExpression, escapeChar, bindCounts); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionQualified) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *column, *domain = NULL; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } ZEPHIR_OBS_VAR(column); zephir_array_fetch_string(&column, expression, SL("name"), PH_NOISY, "phalcon/db/dialect.zep", 563 TSRMLS_CC); ZEPHIR_OBS_VAR(domain); if (!(zephir_array_isset_string_fetch(&domain, expression, SS("domain"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(domain); ZVAL_NULL(domain); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, column, domain, escapeChar); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionBinaryOperations) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *left = NULL, *right = NULL, *_0, *_2, *_3; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } zephir_array_fetch_string(&_0, expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 582 TSRMLS_CC); ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", &_1, 0, _0, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_2, expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 583 TSRMLS_CC); ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", &_1, 36, _2, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_3, expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 585 TSRMLS_CC); ZEPHIR_CONCAT_VSVSV(return_value, left, " ", _3, " ", right); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionUnaryOperations) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *left, *right, *_0 = NULL, *_2; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(left); if (zephir_array_isset_string_fetch(&left, expression, SS("left"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", &_1, 0, left, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_2, expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 599 TSRMLS_CC); ZEPHIR_CONCAT_VSV(return_value, _0, " ", _2); RETURN_MM(); } ZEPHIR_OBS_VAR(right); if (zephir_array_isset_string_fetch(&right, expression, SS("right"), 0 TSRMLS_CC)) { zephir_array_fetch_string(&_2, expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 606 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", &_1, 36, right, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CONCAT_VSV(return_value, _2, " ", _0); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-unary expression", "phalcon/db/dialect.zep", 609); return; } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFunctionCall) { zend_bool _1, _3; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts, *name, *customFunction, *arguments = NULL, *_0, *_4; zval *expression = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, expression, SL("name"), PH_NOISY, "phalcon/db/dialect.zep", 619 TSRMLS_CC); ZEPHIR_OBS_VAR(customFunction); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_customFunctions"), PH_NOISY_CC); if (zephir_array_isset_fetch(&customFunction, _0, name, 0 TSRMLS_CC)) { ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(customFunction, NULL, 0, this_ptr, expression, escapeChar); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_OBS_VAR(arguments); _1 = zephir_array_isset_string_fetch(&arguments, expression, SS("arguments"), 0 TSRMLS_CC); if (_1) { _1 = Z_TYPE_P(arguments) == IS_ARRAY; } if (_1) { ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_2, SS("type"), SL("list"), 1); zephir_array_update_string(&_2, SL("parentheses"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); zephir_array_update_string(&_2, SL("value"), &arguments, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&arguments, this_ptr, "getsqlexpression", NULL, 0, _2, escapeChar, bindCounts); zephir_check_call_status(); _3 = zephir_array_isset_string(expression, SS("distinct")); if (_3) { zephir_array_fetch_string(&_4, expression, SL("distinct"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 633 TSRMLS_CC); _3 = zephir_is_true(_4); } if (_3) { ZEPHIR_CONCAT_VSVS(return_value, name, "(DISTINCT ", arguments, ")"); RETURN_MM(); } ZEPHIR_CONCAT_VSVS(return_value, name, "(", arguments, ")"); RETURN_MM(); } ZEPHIR_CONCAT_VS(return_value, name, "()"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionList) { zephir_fcall_cache_entry *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_3; HashPosition _2; zend_bool _0, _1, _7; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *items, *item = NULL, *values = NULL, *separator = NULL, **_4, *_5 = NULL, *_8, *_9; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(items); array_init(items); ZEPHIR_INIT_VAR(separator); ZVAL_STRING(separator, ", ", 1); if (zephir_array_isset_string(expression, SS("separator"))) { ZEPHIR_OBS_NVAR(separator); zephir_array_fetch_string(&separator, expression, SL("separator"), PH_NOISY, "phalcon/db/dialect.zep", 654 TSRMLS_CC); } ZEPHIR_OBS_VAR(values); _0 = zephir_array_isset_long_fetch(&values, expression, 0, 0 TSRMLS_CC); if (!(_0)) { ZEPHIR_OBS_NVAR(values); _0 = zephir_array_isset_string_fetch(&values, expression, SS("value"), 0 TSRMLS_CC); } _1 = _0; if (_1) { _1 = Z_TYPE_P(values) == IS_ARRAY; } if (_1) { zephir_is_iterable(values, &_3, &_2, 0, 0, "phalcon/db/dialect.zep", 663); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(item, _4); ZEPHIR_CALL_METHOD(&_5, this_ptr, "getsqlexpression", &_6, 0, item, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_append(&items, _5, PH_SEPARATE, "phalcon/db/dialect.zep", 660); } _7 = zephir_array_isset_string(expression, SS("parentheses")); if (_7) { zephir_array_fetch_string(&_8, expression, SL("parentheses"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 663 TSRMLS_CC); _7 = ZEPHIR_IS_FALSE_IDENTICAL(_8); } if (_7) { zephir_fast_join(return_value, separator, items TSRMLS_CC); RETURN_MM(); } ZEPHIR_INIT_VAR(_9); zephir_fast_join(_9, separator, items TSRMLS_CC); ZEPHIR_CONCAT_SVS(return_value, "(", _9, ")"); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-list expression", "phalcon/db/dialect.zep", 670); return; } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionAll) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *domain, *_0; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } ZEPHIR_OBS_VAR(domain); zephir_array_isset_string_fetch(&domain, expression, SS("domain"), 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "*", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, _0, domain, escapeChar); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCastValue) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *left = NULL, *right = NULL, *_0, *_2; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } zephir_array_fetch_string(&_0, expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 692 TSRMLS_CC); ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", &_1, 0, _0, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_2, expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 693 TSRMLS_CC); ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", &_1, 36, _2, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "CAST(", left, " AS ", right, ")"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionConvertValue) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *left = NULL, *right = NULL, *_0, *_2; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } zephir_array_fetch_string(&_0, expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 705 TSRMLS_CC); ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", &_1, 0, _0, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_2, expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 706 TSRMLS_CC); ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", &_1, 36, _2, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "CONVERT(", left, " USING ", right, ")"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCase) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts = NULL, *sql, *whenClause = NULL, *_0 = NULL, *_1, *_3, **_6, *_7, *_8 = NULL, *_9, *_10 = NULL, *_11, *_12 = NULL; zval *expression = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts); expression = expression_param; if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } zephir_array_fetch_string(&_1, expression, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 718 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", &_2, 0, _1, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SV(sql, "CASE ", _0); zephir_array_fetch_string(&_3, expression, SL("when-clauses"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 720 TSRMLS_CC); zephir_is_iterable(_3, &_5, &_4, 0, 0, "phalcon/db/dialect.zep", 731); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(whenClause, _6); zephir_array_fetch_string(&_7, whenClause, SL("type"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 721 TSRMLS_CC); if (ZEPHIR_IS_STRING(_7, "when")) { zephir_array_fetch_string(&_9, whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 723 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_8, this_ptr, "getsqlexpression", &_2, 36, _9, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_fetch_string(&_11, whenClause, SL("then"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 725 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_10, this_ptr, "getsqlexpression", &_2, 36, _11, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SVSV(_12, " WHEN ", _8, " THEN ", _10); zephir_concat_self(&sql, _12 TSRMLS_CC); } else { zephir_array_fetch_string(&_9, whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 727 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_8, this_ptr, "getsqlexpression", &_2, 36, _9, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SV(_12, " ELSE ", _8); zephir_concat_self(&sql, _12 TSRMLS_CC); } } ZEPHIR_CONCAT_VS(return_value, sql, " END"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFrom) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *table = NULL, *tables = NULL, **_2, *_3 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &expression, &escapeChar_param); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (Z_TYPE_P(expression) == IS_ARRAY) { ZEPHIR_INIT_VAR(tables); array_init(tables); zephir_is_iterable(expression, &_1, &_0, 0, 0, "phalcon/db/dialect.zep", 749); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(table, _2); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getsqltable", &_4, 52, table, escapeChar); zephir_check_call_status(); zephir_array_append(&tables, _3, PH_SEPARATE, "phalcon/db/dialect.zep", 746); } ZEPHIR_INIT_VAR(_5); zephir_fast_join_str(_5, SL(", "), tables TSRMLS_CC); ZEPHIR_CPY_WRT(tables, _5); } else { ZEPHIR_CPY_WRT(tables, expression); } ZEPHIR_CONCAT_SV(return_value, "FROM ", tables); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionJoins) { zephir_fcall_cache_entry *_4 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool _3, _10; HashTable *_1, *_6; HashPosition _0, _5; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *condition = NULL, *join = NULL, *sql, *joinCondition = NULL, *joinTable = NULL, *joinType = NULL, *joinConditionsArray = NULL, **_2, **_7, *_8 = NULL, *_9 = NULL, *_11, *_13 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "", 1); ZEPHIR_INIT_VAR(joinType); ZVAL_STRING(joinType, "", 1); zephir_is_iterable(expression, &_1, &_0, 0, 0, "phalcon/db/dialect.zep", 797); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(join, _2); ZEPHIR_OBS_NVAR(joinConditionsArray); _3 = zephir_array_isset_string_fetch(&joinConditionsArray, join, SS("conditions"), 0 TSRMLS_CC); if (_3) { _3 = !(ZEPHIR_IS_EMPTY(joinConditionsArray)); } if (_3) { if (!(zephir_array_isset_long(joinConditionsArray, 0))) { ZEPHIR_CALL_METHOD(&joinCondition, this_ptr, "getsqlexpression", &_4, 0, joinConditionsArray, escapeChar, bindCounts); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(joinCondition); array_init(joinCondition); zephir_is_iterable(joinConditionsArray, &_6, &_5, 0, 0, "phalcon/db/dialect.zep", 782); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(condition, _7); ZEPHIR_CALL_METHOD(&_8, this_ptr, "getsqlexpression", &_4, 36, condition, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_append(&joinCondition, _8, PH_SEPARATE, "phalcon/db/dialect.zep", 779); } ZEPHIR_INIT_NVAR(_9); zephir_fast_join_str(_9, SL(" AND "), joinCondition TSRMLS_CC); ZEPHIR_CPY_WRT(joinCondition, _9); } } else { ZEPHIR_INIT_NVAR(joinCondition); ZVAL_LONG(joinCondition, 1); } ZEPHIR_OBS_NVAR(joinType); _10 = zephir_array_isset_string_fetch(&joinType, join, SS("type"), 0 TSRMLS_CC); if (_10) { _10 = zephir_is_true(joinType); } if (_10) { zephir_concat_self_str(&joinType, SL(" ") TSRMLS_CC); } zephir_array_fetch_string(&_11, join, SL("source"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 792 TSRMLS_CC); ZEPHIR_CALL_METHOD(&joinTable, this_ptr, "getsqltable", &_12, 52, _11, escapeChar); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); ZEPHIR_CONCAT_SVSVSV(_13, " ", joinType, "JOIN ", joinTable, " ON ", joinCondition); zephir_concat_self(&sql, _13 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *whereSql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(expression) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&whereSql, this_ptr, "getsqlexpression", NULL, 0, expression, escapeChar, bindCounts); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(whereSql, expression); } ZEPHIR_CONCAT_SV(return_value, "WHERE ", whereSql); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionGroupBy) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *filed = NULL, *fields = NULL, **_2, *_3 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(expression) == IS_ARRAY) { ZEPHIR_INIT_VAR(fields); array_init(fields); zephir_is_iterable(expression, &_1, &_0, 0, 0, "phalcon/db/dialect.zep", 835); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(filed, _2); if (unlikely(Z_TYPE_P(filed) != IS_ARRAY)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-GROUP-BY expression", "phalcon/db/dialect.zep", 829); return; } ZEPHIR_CALL_METHOD(&_3, this_ptr, "getsqlexpression", &_4, 0, filed, escapeChar, bindCounts); zephir_check_call_status(); zephir_array_append(&fields, _3, PH_SEPARATE, "phalcon/db/dialect.zep", 832); } ZEPHIR_INIT_VAR(_5); zephir_fast_join_str(_5, SL(", "), fields TSRMLS_CC); ZEPHIR_CPY_WRT(fields, _5); } else { ZEPHIR_CPY_WRT(fields, expression); } ZEPHIR_CONCAT_SV(return_value, "GROUP BY ", fields); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionHaving) { int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(expression) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", NULL, 0, expression, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CONCAT_SV(return_value, "HAVING ", _0); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-HAVING expression", "phalcon/db/dialect.zep", 853); return; } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionOrderBy) { zend_bool _5; zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *filed = NULL, *fields = NULL, *type = NULL, *fieldSql = NULL, **_2, *_3, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(fieldSql); ZVAL_NULL(fieldSql); if (Z_TYPE_P(expression) == IS_ARRAY) { ZEPHIR_INIT_VAR(fields); array_init(fields); zephir_is_iterable(expression, &_1, &_0, 0, 0, "phalcon/db/dialect.zep", 885); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(filed, _2); if (unlikely(Z_TYPE_P(filed) != IS_ARRAY)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-ORDER-BY expression", "phalcon/db/dialect.zep", 870); return; } zephir_array_fetch_long(&_3, filed, 0, PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 873 TSRMLS_CC); ZEPHIR_CALL_METHOD(&fieldSql, this_ptr, "getsqlexpression", &_4, 0, _3, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_OBS_NVAR(type); _5 = zephir_array_isset_long_fetch(&type, filed, 1, 0 TSRMLS_CC); if (_5) { _5 = !ZEPHIR_IS_STRING(type, ""); } if (_5) { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, " ", type); zephir_concat_self(&fieldSql, _6 TSRMLS_CC); } zephir_array_append(&fields, fieldSql, PH_SEPARATE, "phalcon/db/dialect.zep", 882); } ZEPHIR_INIT_VAR(_7); zephir_fast_join_str(_7, SL(", "), fields TSRMLS_CC); ZEPHIR_CPY_WRT(fields, _7); } else { ZEPHIR_CPY_WRT(fields, expression); } ZEPHIR_CONCAT_SV(return_value, "ORDER BY ", fields); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionLimit) { zval *_5; zend_bool _3; zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *escapeChar = NULL; zval *expression, *escapeChar_param = NULL, *bindCounts = NULL, *sql = NULL, *value, *limit = NULL, *offset = NULL, *_0, *_1, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts); if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!bindCounts) { bindCounts = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "", 1); ZEPHIR_INIT_VAR(offset); ZVAL_NULL(offset); ZEPHIR_OBS_VAR(value); zephir_array_fetch_string(&value, expression, SL("value"), PH_NOISY, "phalcon/db/dialect.zep", 900 TSRMLS_CC); if (zephir_array_isset_string(expression, SS("sql"))) { ZEPHIR_OBS_NVAR(sql); zephir_array_fetch_string(&sql, expression, SL("sql"), PH_NOISY, "phalcon/db/dialect.zep", 903 TSRMLS_CC); } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_OBS_VAR(_0); zephir_array_fetch_string(&_0, value, SL("number"), PH_NOISY, "phalcon/db/dialect.zep", 908 TSRMLS_CC); if (Z_TYPE_P(_0) == IS_ARRAY) { zephir_array_fetch_string(&_1, value, SL("number"), PH_NOISY | PH_READONLY, "phalcon/db/dialect.zep", 909 TSRMLS_CC); ZEPHIR_CALL_METHOD(&limit, this_ptr, "getsqlexpression", &_2, 0, _1, escapeChar, bindCounts); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(limit); zephir_array_fetch_string(&limit, value, SL("number"), PH_NOISY, "phalcon/db/dialect.zep", 911 TSRMLS_CC); } ZEPHIR_OBS_NVAR(offset); _3 = zephir_array_isset_string_fetch(&offset, value, SS("offset"), 0 TSRMLS_CC); if (_3) { _3 = Z_TYPE_P(offset) == IS_ARRAY; } if (_3) { ZEPHIR_CALL_METHOD(&_4, this_ptr, "getsqlexpression", &_2, 36, offset, escapeChar, bindCounts); zephir_check_call_status(); ZEPHIR_CPY_WRT(offset, _4); } } else { ZEPHIR_CPY_WRT(limit, value); } ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 2, 0 TSRMLS_CC); zephir_array_fast_append(_5, limit); zephir_array_fast_append(_5, offset); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "limit", NULL, 0, sql, _5); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect, prepareColumnAlias) { int ZEPHIR_LAST_CALL_STATUS; zval *qualified_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, *_0 = NULL; zval *qualified = NULL, *alias = NULL, *escapeChar = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &qualified_param, &alias_param, &escapeChar_param); if (unlikely(Z_TYPE_P(qualified_param) != IS_STRING && Z_TYPE_P(qualified_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'qualified' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(qualified_param) == IS_STRING)) { zephir_get_strval(qualified, qualified_param); } else { ZEPHIR_INIT_VAR(qualified); ZVAL_EMPTY_STRING(qualified); } if (!alias_param) { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } else { zephir_get_strval(alias, alias_param); } if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!ZEPHIR_IS_STRING(alias, "")) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "escape", NULL, 43, alias, escapeChar); zephir_check_call_status(); ZEPHIR_CONCAT_VSV(return_value, qualified, " AS ", _0); RETURN_MM(); } RETURN_CTOR(qualified); } static PHP_METHOD(Phalcon_Db_Dialect, prepareTable) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, *_0 = NULL, *_2 = NULL, *_3 = NULL; zval *table = NULL, *schema = NULL, *alias = NULL, *escapeChar = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &table_param, &schema_param, &alias_param, &escapeChar_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } if (!alias_param) { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } else { zephir_get_strval(alias, alias_param); } if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "escape", &_1, 43, table, escapeChar); zephir_check_call_status(); zephir_get_strval(table, _0); if (!ZEPHIR_IS_STRING(schema, "")) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "escape", &_1, 43, schema, escapeChar); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VSV(_3, _2, ".", table); zephir_get_strval(table, _3); } if (!ZEPHIR_IS_STRING(alias, "")) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "escape", &_1, 43, alias, escapeChar); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, table, " AS ", _2); zephir_get_strval(table, _3); } RETURN_CTOR(table); } static PHP_METHOD(Phalcon_Db_Dialect, prepareQualified) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *column_param = NULL, *domain_param = NULL, *escapeChar_param = NULL; zval *column = NULL, *domain = NULL, *escapeChar = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &column_param, &domain_param, &escapeChar_param); if (unlikely(Z_TYPE_P(column_param) != IS_STRING && Z_TYPE_P(column_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'column' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(column_param) == IS_STRING)) { zephir_get_strval(column, column_param); } else { ZEPHIR_INIT_VAR(column); ZVAL_EMPTY_STRING(column); } if (!domain_param) { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } else { zephir_get_strval(domain, domain_param); } if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } if (!ZEPHIR_IS_STRING(domain, "")) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, domain, ".", column); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", &_1, 43, _0, escapeChar); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", &_1, 43, column, escapeChar); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_DialectInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, DialectInterface, phalcon, db_dialectinterface, phalcon_db_dialectinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, limit); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, forUpdate); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, sharedLock); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, select); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnList); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnDefinition); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, modifyColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropColumn); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addIndex); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropIndex); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addPrimaryKey); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropPrimaryKey); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createTable); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createView); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropTable); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropView); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableExists); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, viewExists); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeColumns); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, listTables); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeIndexes); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeReferences); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableOptions); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsSavepoints); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsReleaseSavepoints); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createSavepoint); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, releaseSavepoint); ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, rollbackSavepoint); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db, Exception, phalcon, db_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Index) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Index, phalcon, db_index, phalcon_db_index_method_entry, 0); zend_declare_property_null(phalcon_db_index_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_index_ce, SL("_columns"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_index_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_index_ce TSRMLS_CC, 1, phalcon_db_indexinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Index, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Db_Index, getColumns) { RETURN_MEMBER(this_ptr, "_columns"); } static PHP_METHOD(Phalcon_Db_Index, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Db_Index, __construct) { zval *columns = NULL; zval *name_param = NULL, *columns_param = NULL, *type = NULL; zval *name = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &name_param, &columns_param, &type); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } columns = columns_param; if (!type) { type = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_columns"), columns TSRMLS_CC); zephir_get_strval(_0, type); zephir_update_property_this(this_ptr, SL("_type"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Index, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *indexName, *columns, *type = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); data = data_param; ZEPHIR_OBS_VAR(indexName); if (!(zephir_array_isset_string_fetch(&indexName, data, SS("_name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "_name parameter is required", "phalcon/db/index.zep", 71); return; } ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, data, SS("_columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "_columns parameter is required", "phalcon/db/index.zep", 75); return; } ZEPHIR_OBS_VAR(type); if (!(zephir_array_isset_string_fetch(&type, data, SS("_type"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "", 1); } object_init_ex(return_value, phalcon_db_index_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 15, indexName, columns, type); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_IndexInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, IndexInterface, phalcon, db_indexinterface, phalcon_db_indexinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getColumns); ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Profiler) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Profiler, phalcon, db_profiler, phalcon_db_profiler_method_entry, 0); zend_declare_property_null(phalcon_db_profiler_ce, SL("_allProfiles"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_profiler_ce, SL("_activeProfile"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_profiler_ce, SL("_totalSeconds"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Profiler, startProfile) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement, *sqlVariables = NULL, *sqlBindTypes = NULL, *activeProfile, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement, &sqlVariables, &sqlBindTypes); if (!sqlVariables) { sqlVariables = ZEPHIR_GLOBAL(global_null); } if (!sqlBindTypes) { sqlBindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(activeProfile); object_init_ex(activeProfile, phalcon_db_profiler_item_ce); if (zephir_has_constructor(activeProfile TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlstatement", NULL, 146, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(sqlVariables) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlvariables", NULL, 147, sqlVariables); zephir_check_call_status(); } if (Z_TYPE_P(sqlBindTypes) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, activeProfile, "setsqlbindtypes", NULL, 148, sqlBindTypes); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_0); zephir_microtime(_0, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, activeProfile, "setinitialtime", NULL, 149, _0); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("beforestartprofile") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "beforestartprofile", NULL, 0, activeProfile); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_activeProfile"), activeProfile TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Db_Profiler, stopProfile) { int ZEPHIR_LAST_CALL_STATUS; zval *finalTime, *initialTime = NULL, *activeProfile = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(finalTime); zephir_microtime(finalTime, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_activeProfile"), PH_NOISY_CC); ZEPHIR_CPY_WRT(activeProfile, _0); ZEPHIR_CALL_METHOD(NULL, activeProfile, "setfinaltime", NULL, 0, finalTime); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&initialTime, activeProfile, "getinitialtime", NULL, 0); zephir_check_call_status(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_totalSeconds"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_sub_function(_1, finalTime, initialTime); ZEPHIR_INIT_VAR(_2); zephir_add_function(_2, _0, _1); zephir_update_property_this(this_ptr, SL("_totalSeconds"), _2 TSRMLS_CC); zephir_update_property_array_append(this_ptr, SL("_allProfiles"), activeProfile TSRMLS_CC); if ((zephir_method_exists_ex(this_ptr, SS("afterendprofile") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "afterendprofile", NULL, 0, activeProfile); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Db_Profiler, getNumberTotalStatements) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_allProfiles"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedSeconds) { RETURN_MEMBER(this_ptr, "_totalSeconds"); } static PHP_METHOD(Phalcon_Db_Profiler, getProfiles) { RETURN_MEMBER(this_ptr, "_allProfiles"); } static PHP_METHOD(Phalcon_Db_Profiler, reset) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_allProfiles"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Db_Profiler, getLastProfile) { RETURN_MEMBER(this_ptr, "_activeProfile"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_RawValue) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, RawValue, phalcon, db_rawvalue, phalcon_db_rawvalue_method_entry, 0); zend_declare_property_null(phalcon_db_rawvalue_ce, SL("_value"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_RawValue, getValue) { RETURN_MEMBER(this_ptr, "_value"); } static PHP_METHOD(Phalcon_Db_RawValue, __toString) { RETURN_MEMBER(this_ptr, "_value"); } static PHP_METHOD(Phalcon_Db_RawValue, __construct) { zval *_2 = NULL; zend_bool _0; zval *value, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value); _0 = Z_TYPE_P(value) == IS_STRING; if (_0) { _0 = ZEPHIR_IS_STRING(value, ""); } if (_0) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_STRING(_1, "''", 1); zephir_update_property_this(this_ptr, SL("_value"), _1 TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(value) == IS_NULL) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_STRING(_1, "NULL", 1); zephir_update_property_this(this_ptr, SL("_value"), _1 TSRMLS_CC); RETURN_MM_NULL(); } zephir_get_strval(_2, value); zephir_update_property_this(this_ptr, SL("_value"), _2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Reference) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Reference, phalcon, db_reference, phalcon_db_reference_method_entry, 0); zend_declare_property_null(phalcon_db_reference_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_schemaName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_referencedSchema"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_referencedTable"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_columns"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_referencedColumns"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_onDelete"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_reference_ce, SL("_onUpdate"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_reference_ce TSRMLS_CC, 1, phalcon_db_referenceinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Reference, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Db_Reference, getSchemaName) { RETURN_MEMBER(this_ptr, "_schemaName"); } static PHP_METHOD(Phalcon_Db_Reference, getReferencedSchema) { RETURN_MEMBER(this_ptr, "_referencedSchema"); } static PHP_METHOD(Phalcon_Db_Reference, getReferencedTable) { RETURN_MEMBER(this_ptr, "_referencedTable"); } static PHP_METHOD(Phalcon_Db_Reference, getColumns) { RETURN_MEMBER(this_ptr, "_columns"); } static PHP_METHOD(Phalcon_Db_Reference, getReferencedColumns) { RETURN_MEMBER(this_ptr, "_referencedColumns"); } static PHP_METHOD(Phalcon_Db_Reference, getOnDelete) { RETURN_MEMBER(this_ptr, "_onDelete"); } static PHP_METHOD(Phalcon_Db_Reference, getOnUpdate) { RETURN_MEMBER(this_ptr, "_onUpdate"); } static PHP_METHOD(Phalcon_Db_Reference, __construct) { zval *definition = NULL; zval *name_param = NULL, *definition_param = NULL, *columns, *schema, *referencedTable, *referencedSchema, *referencedColumns, *onDelete, *onUpdate; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } definition = definition_param; zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); ZEPHIR_OBS_VAR(referencedTable); if (zephir_array_isset_string_fetch(&referencedTable, definition, SS("referencedTable"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_referencedTable"), referencedTable TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Referenced table is required", "phalcon/db/reference.zep", 99); return; } ZEPHIR_OBS_VAR(columns); if (zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_columns"), columns TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Foreign key columns are required", "phalcon/db/reference.zep", 105); return; } ZEPHIR_OBS_VAR(referencedColumns); if (zephir_array_isset_string_fetch(&referencedColumns, definition, SS("referencedColumns"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_referencedColumns"), referencedColumns TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Referenced columns of the foreign key are required", "phalcon/db/reference.zep", 111); return; } ZEPHIR_OBS_VAR(schema); if (zephir_array_isset_string_fetch(&schema, definition, SS("schema"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_schemaName"), schema TSRMLS_CC); } ZEPHIR_OBS_VAR(referencedSchema); if (zephir_array_isset_string_fetch(&referencedSchema, definition, SS("referencedSchema"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_referencedSchema"), referencedSchema TSRMLS_CC); } ZEPHIR_OBS_VAR(onDelete); if (zephir_array_isset_string_fetch(&onDelete, definition, SS("onDelete"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_onDelete"), onDelete TSRMLS_CC); } ZEPHIR_OBS_VAR(onUpdate); if (zephir_array_isset_string_fetch(&onUpdate, definition, SS("onUpdate"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_onUpdate"), onUpdate TSRMLS_CC); } if (zephir_fast_count_int(columns TSRMLS_CC) != zephir_fast_count_int(referencedColumns TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Number of columns is not equals than the number of columns referenced", "phalcon/db/reference.zep", 131); return; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Reference, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *referencedSchema, *referencedTable, *columns, *referencedColumns, *constraintName = NULL, *onDelete, *onUpdate; zval *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); data = data_param; ZEPHIR_OBS_VAR(constraintName); if (!(zephir_array_isset_string_fetch(&constraintName, data, SS("_referenceName"), 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(constraintName); if (!(zephir_array_isset_string_fetch(&constraintName, data, SS("_name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "_name parameter is required", "phalcon/db/reference.zep", 146); return; } } zephir_array_isset_string_fetch(&referencedSchema, data, SS("_referencedSchema"), 1 TSRMLS_CC); zephir_array_isset_string_fetch(&referencedTable, data, SS("_referencedTable"), 1 TSRMLS_CC); zephir_array_isset_string_fetch(&columns, data, SS("_columns"), 1 TSRMLS_CC); zephir_array_isset_string_fetch(&referencedColumns, data, SS("_referencedColumns"), 1 TSRMLS_CC); zephir_array_isset_string_fetch(&onDelete, data, SS("_onDelete"), 1 TSRMLS_CC); zephir_array_isset_string_fetch(&onUpdate, data, SS("_onUpdate"), 1 TSRMLS_CC); object_init_ex(return_value, phalcon_db_reference_ce); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 6, 0 TSRMLS_CC); zephir_array_update_string(&_0, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("columns"), &columns, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("onDelete"), &onDelete, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("onUpdate"), &onUpdate, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 16, constraintName, _0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_ReferenceInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ReferenceInterface, phalcon, db_referenceinterface, phalcon_db_referenceinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getSchemaName); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedSchema); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getColumns); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedTable); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getReferencedColumns); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getOnDelete); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, getOnUpdate); ZEPHIR_DOC_METHOD(Phalcon_Db_ReferenceInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Db_ResultInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ResultInterface, phalcon, db_resultinterface, phalcon_db_resultinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, execute); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetch); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetchArray); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, fetchAll); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, numRows); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, dataSeek); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, setFetchMode); ZEPHIR_DOC_METHOD(Phalcon_Db_ResultInterface, getInternalResult); static int phalcon_db_checktype(zval *return_value, zval *placeholder TSRMLS_DC) { if (Z_TYPE_P(placeholder) != IS_STRING) { } return 0; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter, Pdo, phalcon, db_adapter_pdo, phalcon_db_adapter_ce, phalcon_db_adapter_pdo_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_db_adapter_pdo_ce, SL("_pdo"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_adapter_pdo_ce, SL("_affectedRows"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, __construct) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *descriptor_param = NULL; zval *descriptor = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &descriptor_param); descriptor = descriptor_param; ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0, descriptor); zephir_check_call_status(); ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_ce, this_ptr, "__construct", &_0, 25, descriptor); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *descriptor = NULL, *username = NULL, *password = NULL, *dsnParts, *dsnAttributes = NULL, *persistent, *options = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(username); if (zephir_array_isset_string_fetch(&username, descriptor, SS("username"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("username"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(username); ZVAL_NULL(username); } ZEPHIR_OBS_VAR(password); if (zephir_array_isset_string_fetch(&password, descriptor, SS("password"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("password"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(password); ZVAL_NULL(password); } ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, descriptor, SS("options"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("options"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(options); array_init(options); } ZEPHIR_OBS_VAR(persistent); if (zephir_array_isset_string_fetch(&persistent, descriptor, SS("persistent"), 0 TSRMLS_CC)) { if (zephir_is_true(persistent)) { zephir_array_update_long(&options, 12, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } zephir_array_unset_string(&descriptor, SS("persistent"), PH_SEPARATE); } if (zephir_array_isset_string(descriptor, SS("dialectClass"))) { zephir_array_unset_string(&descriptor, SS("dialectClass"), PH_SEPARATE); } ZEPHIR_OBS_VAR(dsnAttributes); if (!(zephir_array_isset_string_fetch(&dsnAttributes, descriptor, SS("dsn"), 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(dsnParts); array_init(dsnParts); zephir_is_iterable(descriptor, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 147); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, key, "=", value); zephir_array_append(&dsnParts, _3, PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 145); } ZEPHIR_INIT_NVAR(dsnAttributes); zephir_fast_join_str(dsnAttributes, SL(";"), dsnParts TSRMLS_CC); } ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 2); zephir_array_update_long(&options, 3, &_4, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_VAR(_5); object_init_ex(_5, php_pdo_get_dbh_ce()); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSV(_3, _6, ":", dsnAttributes); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 0, _3, username, password, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_pdo"), _5 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, prepare) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement_param = NULL, *_0; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlStatement_param); if (unlikely(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { zephir_get_strval(sqlStatement, sqlStatement_param); } else { ZEPHIR_INIT_VAR(sqlStatement); ZVAL_EMPTY_STRING(sqlStatement); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "prepare", NULL, 0, sqlStatement); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared) { zval *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; zend_bool _3; HashTable *_1, *_9, *_13; HashPosition _0, _8, _12; zval *placeholders = NULL; zval *statement, *placeholders_param = NULL, *dataTypes, *wildcard = NULL, *value = NULL, *type = NULL, *castValue = NULL, *parameter = NULL, *position = NULL, *itemValue = NULL, **_2, _4 = zval_used_for_init, **_10, *_11 = NULL, **_14; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &statement, &placeholders_param, &dataTypes); placeholders = placeholders_param; zephir_is_iterable(placeholders, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 271); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(wildcard, _1, _0); ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(wildcard) == IS_LONG) { ZEPHIR_INIT_NVAR(parameter); ZVAL_LONG(parameter, (zephir_get_numberval(wildcard) + 1)); } else { if (Z_TYPE_P(wildcard) == IS_STRING) { ZEPHIR_CPY_WRT(parameter, wildcard); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/db/adapter/pdo.zep", 197); return; } } _3 = Z_TYPE_P(dataTypes) == IS_ARRAY; if (_3) { ZEPHIR_OBS_NVAR(type); _3 = zephir_array_isset_fetch(&type, dataTypes, wildcard, 0 TSRMLS_CC); } if (_3) { if (ZEPHIR_IS_LONG(type, 32)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_DOUBLE(castValue, zephir_get_doubleval(value)); ZEPHIR_INIT_NVAR(type); ZVAL_LONG(type, 1024); } else { if (ZEPHIR_GLOBAL(db).force_casting) { if (Z_TYPE_P(value) != IS_ARRAY) { do { if (ZEPHIR_IS_LONG(type, 1)) { ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 10); ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_5, 26, value, &_4); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 2)) { zephir_get_strval(_6, value); ZEPHIR_CPY_WRT(castValue, _6); break; } if (ZEPHIR_IS_LONG(type, 0)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_NULL(castValue); break; } if (ZEPHIR_IS_LONG(type, 5)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_BOOL(castValue, zephir_get_boolval(value)); break; } ZEPHIR_CPY_WRT(castValue, value); break; } while(0); } else { ZEPHIR_CPY_WRT(castValue, value); } } else { ZEPHIR_CPY_WRT(castValue, value); } } if (Z_TYPE_P(castValue) != IS_ARRAY) { if (ZEPHIR_IS_LONG(type, 1024)) { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, castValue); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, castValue, type); zephir_check_call_status(); } } else { zephir_is_iterable(castValue, &_9, &_8, 0, 0, "phalcon/db/adapter/pdo.zep", 259); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(position, _9, _8); ZEPHIR_GET_HVALUE(itemValue, _10); if (ZEPHIR_IS_LONG(type, 1024)) { ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_VV(_11, parameter, position); ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _11, itemValue); zephir_check_call_status(); } else { ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_VV(_11, parameter, position); ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _11, itemValue, type); zephir_check_call_status(); } } } } else { if (Z_TYPE_P(value) != IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, value); zephir_check_call_status(); } else { zephir_is_iterable(value, &_13, &_12, 0, 0, "phalcon/db/adapter/pdo.zep", 267); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HMKEY(position, _13, _12); ZEPHIR_GET_HVALUE(itemValue, _14); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_VV(_11, parameter, position); ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _11, itemValue); zephir_check_call_status(); } } } } ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL, 0); zephir_check_call_status(); RETVAL_ZVAL(statement, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, query) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement_param = NULL, *bindParams = NULL, *bindTypes = NULL, *eventsManager = NULL, *pdo = NULL, *statement = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { zephir_get_strval(sqlStatement, sqlStatement_param); } else { ZEPHIR_INIT_VAR(sqlStatement); ZVAL_EMPTY_STRING(sqlStatement); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlVariables"), bindParams TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlBindTypes"), bindTypes TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beforeQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_CPY_WRT(pdo, _0); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&statement, pdo, "prepare", NULL, 0, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(statement) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "executeprepared", NULL, 0, statement, bindParams, bindTypes); zephir_check_call_status(); ZEPHIR_CPY_WRT(statement, _1); } } else { ZEPHIR_CALL_METHOD(&statement, pdo, "query", NULL, 0, sqlStatement); zephir_check_call_status(); } if (Z_TYPE_P(statement) == IS_OBJECT) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:afterQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); } object_init_ex(return_value, phalcon_db_result_pdo_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 27, this_ptr, statement, sqlStatement, bindParams, bindTypes); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(statement); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, execute) { int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement_param = NULL, *bindParams = NULL, *bindTypes = NULL, *eventsManager = NULL, *affectedRows = NULL, *pdo = NULL, *newStatement = NULL, *statement = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &sqlStatement_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(sqlStatement_param) != IS_STRING && Z_TYPE_P(sqlStatement_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlStatement' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlStatement_param) == IS_STRING)) { zephir_get_strval(sqlStatement, sqlStatement_param); } else { ZEPHIR_INIT_VAR(sqlStatement); ZVAL_EMPTY_STRING(sqlStatement); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlVariables"), bindParams TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlBindTypes"), bindTypes TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beforeQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(affectedRows); ZVAL_LONG(affectedRows, 0); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_CPY_WRT(pdo, _0); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&statement, pdo, "prepare", NULL, 0, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(statement) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&newStatement, this_ptr, "executeprepared", NULL, 0, statement, bindParams, bindTypes); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&affectedRows, newStatement, "rowcount", NULL, 0); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(&affectedRows, pdo, "exec", NULL, 0, sqlStatement); zephir_check_call_status(); } if (Z_TYPE_P(affectedRows) == IS_LONG) { zephir_update_property_this(this_ptr, SL("_affectedRows"), affectedRows TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:afterQuery", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, bindParams); zephir_check_temp_parameter(_2); zephir_check_call_status(); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, affectedRows) { RETURN_MEMBER(this_ptr, "_affectedRows"); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, close) { zval *pdo; pdo = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_pdo"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, escapeIdentifier) { zval *identifier, *_0, *_1; zephir_fetch_params(0, 1, 0, &identifier); if (Z_TYPE_P(identifier) == IS_ARRAY) { zephir_array_fetch_long(&_0, identifier, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo.zep", 423 TSRMLS_CC); zephir_array_fetch_long(&_1, identifier, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo.zep", 423 TSRMLS_CC); ZEPHIR_CONCAT_SVSVS(return_value, "\"", _0, "\".\"", _1, "\""); return; } ZEPHIR_CONCAT_SVS(return_value, "\"", identifier, "\""); return; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, escapeString) { int ZEPHIR_LAST_CALL_STATUS; zval *str_param = NULL, *_0; zval *str = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &str_param); zephir_get_strval(str, str_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "quote", NULL, 0, str); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, convertBoundParams) { HashTable *_3; HashPosition _2; int setOrder, ZEPHIR_LAST_CALL_STATUS; zval *params = NULL; zval *sql_param = NULL, *params_param = NULL, *boundSql = NULL, *placeHolders, *bindPattern, *matches, *placeMatch = NULL, *value = NULL, *_0 = NULL, *_1 = NULL, **_4, *_5, *_6; zval *sql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &sql_param, ¶ms_param); if (unlikely(Z_TYPE_P(sql_param) != IS_STRING && Z_TYPE_P(sql_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sql' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sql_param) == IS_STRING)) { zephir_get_strval(sql, sql_param); } else { ZEPHIR_INIT_VAR(sql); ZVAL_EMPTY_STRING(sql); } if (!params_param) { ZEPHIR_INIT_VAR(params); array_init(params); } else { zephir_get_arrval(params, params_param); } ZEPHIR_INIT_VAR(placeHolders); array_init(placeHolders); ZEPHIR_INIT_VAR(bindPattern); ZVAL_STRING(bindPattern, "/\\?([0-9]+)|:([a-zA-Z0-9_]+):/", 1); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); setOrder = 2; ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, setOrder); ZEPHIR_MAKE_REF(matches); ZEPHIR_CALL_FUNCTION(&_1, "preg_match_all", NULL, 28, bindPattern, sql, matches, _0); ZEPHIR_UNREF(matches); zephir_check_call_status(); if (zephir_is_true(_1)) { zephir_is_iterable(matches, &_3, &_2, 0, 0, "phalcon/db/adapter/pdo.zep", 472); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(placeMatch, _4); ZEPHIR_OBS_NVAR(value); zephir_array_fetch_long(&_5, placeMatch, 1, PH_READONLY, "phalcon/db/adapter/pdo.zep", 459 TSRMLS_CC); if (!(zephir_array_isset_fetch(&value, params, _5, 0 TSRMLS_CC))) { if (zephir_array_isset_long(placeMatch, 2)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch_long(&_6, placeMatch, 2, PH_READONLY, "phalcon/db/adapter/pdo.zep", 461 TSRMLS_CC); if (!(zephir_array_isset_fetch(&value, params, _6, 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/db/adapter/pdo.zep", 462); return; } } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Matched parameter wasn't found in parameters list", "phalcon/db/adapter/pdo.zep", 465); return; } } zephir_array_append(&placeHolders, value, PH_SEPARATE, "phalcon/db/adapter/pdo.zep", 469); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "?", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&boundSql, "preg_replace", NULL, 29, bindPattern, _0, sql); zephir_check_temp_parameter(_0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(boundSql, sql); } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_update_string(&return_value, SL("sql"), &boundSql, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("params"), &placeHolders, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, lastInsertId) { int ZEPHIR_LAST_CALL_STATUS; zval *sequenceName = NULL, *pdo; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sequenceName); if (!sequenceName) { sequenceName = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) != IS_OBJECT) { RETURN_MM_BOOL(0); } ZEPHIR_RETURN_CALL_METHOD(pdo, "lastinsertid", NULL, 0, sequenceName); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, begin) { int transactionLevel, ZEPHIR_LAST_CALL_STATUS; zval *nesting_param = NULL, *pdo, *eventsManager = NULL, *savepointName = NULL, *_0, *_1, *_2 = NULL, *_5 = NULL; zend_bool nesting, _3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &nesting_param); if (!nesting_param) { nesting = 1; } else { nesting = zephir_get_boolval(nesting_param); } ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) != IS_OBJECT) { RETURN_MM_BOOL(0); } RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_transactionLevel"), PH_NOISY_CC); transactionLevel = zephir_get_intval(_0); if (transactionLevel == 1) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:beginTransaction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(pdo, "begintransaction", NULL, 0); zephir_check_call_status(); RETURN_MM(); } else { _3 = (transactionLevel) ? 1 : 0; if (_3) { _3 = nesting; } _4 = _3; if (_4) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); zephir_check_call_status(); _4 = zephir_is_true(_5); } if (_4) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:createSavepoint", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, savepointName); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "createsavepoint", NULL, 0, savepointName); zephir_check_call_status(); RETURN_MM(); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, rollback) { int transactionLevel, ZEPHIR_LAST_CALL_STATUS; zval *nesting_param = NULL, *pdo, *eventsManager = NULL, *savepointName = NULL, *_0, *_1, *_2 = NULL, *_5 = NULL; zend_bool nesting, _3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &nesting_param); if (!nesting_param) { nesting = 1; } else { nesting = zephir_get_boolval(nesting_param); } ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) != IS_OBJECT) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_transactionLevel"), PH_NOISY_CC); transactionLevel = zephir_get_intval(_0); if (!(transactionLevel)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/db/adapter/pdo.zep", 586); return; } if (transactionLevel == 1) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:rollbackTransaction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_RETURN_CALL_METHOD(pdo, "rollback", NULL, 0); zephir_check_call_status(); RETURN_MM(); } else { _3 = (transactionLevel) ? 1 : 0; if (_3) { _3 = nesting; } _4 = _3; if (_4) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); zephir_check_call_status(); _4 = zephir_is_true(_5); } if (_4) { ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:rollbackSavepoint", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, savepointName); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rollbacksavepoint", NULL, 0, savepointName); zephir_check_call_status(); RETURN_MM(); } } if (transactionLevel > 0) { RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, commit) { int transactionLevel, ZEPHIR_LAST_CALL_STATUS; zval *nesting_param = NULL, *pdo, *eventsManager = NULL, *savepointName = NULL, *_0, *_1, *_2 = NULL, *_5 = NULL; zend_bool nesting, _3, _4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &nesting_param); if (!nesting_param) { nesting = 1; } else { nesting = zephir_get_boolval(nesting_param); } ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) != IS_OBJECT) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_transactionLevel"), PH_NOISY_CC); transactionLevel = zephir_get_intval(_0); if (!(transactionLevel)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "There is no active transaction", "phalcon/db/adapter/pdo.zep", 660); return; } if (transactionLevel == 1) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "db:commitTransaction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_RETURN_CALL_METHOD(pdo, "commit", NULL, 0); zephir_check_call_status(); RETURN_MM(); } else { _3 = (transactionLevel) ? 1 : 0; if (_3) { _3 = nesting; } _4 = _3; if (_4) { ZEPHIR_CALL_METHOD(&_5, this_ptr, "isnestedtransactionswithsavepoints", NULL, 0); zephir_check_call_status(); _4 = zephir_is_true(_5); } if (_4) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "db:releaseSavepoint", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, savepointName); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "releasesavepoint", NULL, 0, savepointName); zephir_check_call_status(); RETURN_MM(); } } if (transactionLevel > 0) { RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_transactionLevel") TSRMLS_CC)); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, getTransactionLevel) { RETURN_MEMBER(this_ptr, "_transactionLevel"); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, isUnderTransaction) { int ZEPHIR_LAST_CALL_STATUS; zval *pdo; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(pdo); zephir_read_property_this(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC); if (Z_TYPE_P(pdo) == IS_OBJECT) { ZEPHIR_RETURN_CALL_METHOD(pdo, "intransaction", NULL, 0); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, getInternalHandler) { RETURN_MEMBER(this_ptr, "_pdo"); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo, getErrorInfo) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdo"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "errorinfo", NULL, 0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Mysql) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Mysql, phalcon, db_adapter_pdo_mysql, phalcon_db_adapter_pdo_ce, phalcon_db_adapter_pdo_mysql_method_entry, 0); zend_declare_property_string(phalcon_db_adapter_pdo_mysql_ce, SL("_type"), "mysql", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_db_adapter_pdo_mysql_ce, SL("_dialectType"), "mysql", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_adapter_pdo_mysql_ce TSRMLS_CC, 1, phalcon_db_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, escapeIdentifier) { zval *identifier, *domain, *name; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &identifier); if (Z_TYPE_P(identifier) == IS_ARRAY) { ZEPHIR_OBS_VAR(domain); zephir_array_fetch_long(&domain, identifier, 0, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 63 TSRMLS_CC); ZEPHIR_OBS_VAR(name); zephir_array_fetch_long(&name, identifier, 1, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 64 TSRMLS_CC); if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CONCAT_SVSVS(return_value, "`", domain, "`.`", name, "`"); RETURN_MM(); } ZEPHIR_CONCAT_VSV(return_value, domain, ".", name); RETURN_MM(); } if (ZEPHIR_GLOBAL(db).escape_identifiers) { ZEPHIR_CONCAT_SVS(return_value, "`", identifier, "`"); RETURN_MM(); } RETVAL_ZVAL(identifier, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, describeColumns) { zephir_fcall_cache_entry *_15 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *sizePattern, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_11, *_12, *_13 = NULL, *_14; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(sizePattern); ZVAL_STRING(sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#", 1); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/mysql.zep", 337); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 111 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/mysql.zep", 118)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 14); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/mysql.zep", 128)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("varchar"), "phalcon/db/adapter/pdo/mysql.zep", 138)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("datetime"), "phalcon/db/adapter/pdo/mysql.zep", 146)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/mysql.zep", 154)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/mysql.zep", 162)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/mysql.zep", 170)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/mysql.zep", 178)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 17); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/mysql.zep", 186)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/mysql.zep", 194)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 3); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("double"), "phalcon/db/adapter/pdo/mysql.zep", 204)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 9); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/mysql.zep", 214)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bit"), "phalcon/db/adapter/pdo/mysql.zep", 224)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 8); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 5); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("tinyblob"), "phalcon/db/adapter/pdo/mysql.zep", 233)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 10); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 5); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("mediumblob"), "phalcon/db/adapter/pdo/mysql.zep", 242)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 12); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("longblob"), "phalcon/db/adapter/pdo/mysql.zep", 250)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 13); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("blob"), "phalcon/db/adapter/pdo/mysql.zep", 258)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 11); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("("), "phalcon/db/adapter/pdo/mysql.zep", 273)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_8); zephir_preg_match(_8, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_8)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_9, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_9, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/mysql.zep", 288)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 304 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_11, field, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 311 TSRMLS_CC); if (ZEPHIR_IS_STRING(_11, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_12, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 318 TSRMLS_CC); if (ZEPHIR_IS_STRING(_12, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_13); zephir_array_fetch_long(&_13, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 325 TSRMLS_CC); if (Z_TYPE_P(_13) != IS_NULL) { zephir_array_fetch_long(&_14, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 326 TSRMLS_CC); zephir_array_update_string(&definition, SL("default"), &_14, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/mysql.zep", 332 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_15, 141, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/mysql.zep", 333); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Oracle) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Oracle, phalcon, db_adapter_pdo_oracle, phalcon_db_adapter_pdo_ce, phalcon_db_adapter_pdo_oracle_method_entry, 0); zend_declare_property_string(phalcon_db_adapter_pdo_oracle_ce, SL("_type"), "oci", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_db_adapter_pdo_oracle_ce, SL("_dialectType"), "oracle", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_adapter_pdo_oracle_ce TSRMLS_CC, 1, phalcon_db_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, connect) { HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_4 = NULL; zval *descriptor = NULL, *startup, *value = NULL, *status = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (!(zephir_is_true(descriptor))) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_CALL_PARENT(&status, phalcon_db_adapter_pdo_oracle_ce, this_ptr, "connect", &_0, 142, descriptor); zephir_check_call_status(); ZEPHIR_OBS_VAR(startup); if (zephir_array_isset_string_fetch(&startup, descriptor, SS("startup"), 0 TSRMLS_CC)) { if (Z_TYPE_P(startup) == IS_ARRAY) { zephir_is_iterable(startup, &_2, &_1, 0, 0, "phalcon/db/adapter/pdo/oracle.zep", 76); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "execute", &_4, 0, value); zephir_check_call_status(); } } } RETURN_CCTOR(status); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, describeColumns) { zephir_fcall_cache_entry *_11 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *oldColumn = NULL, *field = NULL, *definition = NULL, *columnSize = NULL, *columnPrecision = NULL, *columnScale = NULL, *columnType = NULL, *columnName, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9, *_10; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(columns); array_init(columns); ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/oracle.zep", 203); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnSize); zephir_array_fetch_long(&columnSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 102 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnPrecision); zephir_array_fetch_long(&columnPrecision, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 103 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnScale); zephir_array_fetch_long(&columnScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 104 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/oracle.zep", 105 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("NUMBER"), "phalcon/db/adapter/pdo/oracle.zep", 112)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 3); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 32); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("INTEGER"), "phalcon/db/adapter/pdo/oracle.zep", 121)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnPrecision, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("VARCHAR2"), "phalcon/db/adapter/pdo/oracle.zep", 129)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("FLOAT"), "phalcon/db/adapter/pdo/oracle.zep", 135)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &columnScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("TIMESTAMP"), "phalcon/db/adapter/pdo/oracle.zep", 144)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 17); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("RAW"), "phalcon/db/adapter/pdo/oracle.zep", 149)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("BLOB"), "phalcon/db/adapter/pdo/oracle.zep", 154)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CLOB"), "phalcon/db/adapter/pdo/oracle.zep", 159)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("CHAR"), "phalcon/db/adapter/pdo/oracle.zep", 164)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &columnSize, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_9, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 183 TSRMLS_CC); if (ZEPHIR_IS_STRING(_9, "P")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 190 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "N")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 194 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_11, 141, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _8, PH_SEPARATE, "phalcon/db/adapter/pdo/oracle.zep", 199); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, lastInsertId) { int ZEPHIR_LAST_CALL_STATUS; zval *sequenceName_param = NULL, *_0 = NULL, *_2, *_3; zval *sequenceName = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sequenceName_param); if (!sequenceName_param) { ZEPHIR_INIT_VAR(sequenceName); ZVAL_EMPTY_STRING(sequenceName); } else { zephir_get_strval(sequenceName, sequenceName_param); } ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "SELECT ", sequenceName, ".CURRVAL FROM dual"); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _1, _2); zephir_check_call_status(); zephir_array_fetch_long(&_3, _0, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/oracle.zep", 223 TSRMLS_CC); RETURN_CTOR(_3); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, useExplicitIdValue) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, getDefaultIdValue) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); object_init_ex(return_value, phalcon_db_rawvalue_ce); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "default", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 17, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Oracle, supportSequences) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Postgresql) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Postgresql, phalcon, db_adapter_pdo_postgresql, phalcon_db_adapter_pdo_ce, phalcon_db_adapter_pdo_postgresql_method_entry, 0); zend_declare_property_string(phalcon_db_adapter_pdo_postgresql_ce, SL("_type"), "pgsql", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_db_adapter_pdo_postgresql_ce, SL("_dialectType"), "postgresql", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_adapter_pdo_postgresql_ce TSRMLS_CC, 1, phalcon_db_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, connect) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL; zend_bool _1; zval *descriptor = NULL, *schema = NULL, *sql, *_0, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(schema); if (zephir_array_isset_string_fetch(&schema, descriptor, SS("schema"), 0 TSRMLS_CC)) { zephir_array_unset_string(&descriptor, SS("schema"), PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(schema); ZVAL_STRING(schema, "", 1); } if (zephir_array_isset_string(descriptor, SS("password"))) { ZEPHIR_OBS_VAR(_0); zephir_array_fetch_string(&_0, descriptor, SL("password"), PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 75 TSRMLS_CC); _1 = Z_TYPE_P(_0) == IS_STRING; if (_1) { zephir_array_fetch_string(&_2, descriptor, SL("password"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 75 TSRMLS_CC); _1 = zephir_fast_strlen_ev(_2) == 0; } if (_1) { zephir_array_update_string(&descriptor, SL("password"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_postgresql_ce, this_ptr, "connect", &_3, 142, descriptor); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(schema))) { ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVS(sql, "SET search_path TO '", schema, "'"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "execute", NULL, 0, sql); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, describeColumns) { zephir_fcall_cache_entry *_16 = NULL, *_20 = NULL, *_21 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *columnName, *charSize = NULL, *numericSize = NULL, *numericScale = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_11, *_12, *_13 = NULL, *_14, *_15 = NULL, *_17, _18 = zval_used_for_init, *_19 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 326); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 1, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 116 TSRMLS_CC); ZEPHIR_OBS_NVAR(charSize); zephir_array_fetch_long(&charSize, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 117 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericSize); zephir_array_fetch_long(&numericSize, field, 3, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 118 TSRMLS_CC); ZEPHIR_OBS_NVAR(numericScale); zephir_array_fetch_long(&numericScale, field, 4, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 119 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("smallint(1)"), "phalcon/db/adapter/pdo/postgresql.zep", 126)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 8); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/postgresql.zep", 135)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 14); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/postgresql.zep", 145)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("varying"), "phalcon/db/adapter/pdo/postgresql.zep", 156)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/postgresql.zep", 165)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 174)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 17); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("numeric"), "phalcon/db/adapter/pdo/postgresql.zep", 182)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 3); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("scale"), &numericScale, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/postgresql.zep", 194)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/postgresql.zep", 203)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/postgresql.zep", 212)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &charSize, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/postgresql.zep", 221)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("size"), &numericSize, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("bool"), "phalcon/db/adapter/pdo/postgresql.zep", 232)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 8); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_9); ZVAL_LONG(_9, 5); zephir_array_update_string(&definition, SL("bindType"), &_9, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("jsonb"), "phalcon/db/adapter/pdo/postgresql.zep", 242)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 16); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("json"), "phalcon/db/adapter/pdo/postgresql.zep", 250)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 15); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("uuid"), "phalcon/db/adapter/pdo/postgresql.zep", 258)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 36); zephir_array_update_string(&definition, SL("size"), &_8, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/postgresql.zep", 274)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 6, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 290 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "PRI")) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_11, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 297 TSRMLS_CC); if (ZEPHIR_IS_STRING(_11, "NO")) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_12, field, 7, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 304 TSRMLS_CC); if (ZEPHIR_IS_STRING(_12, "auto_increment")) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(_13); zephir_array_fetch_long(&_13, field, 9, PH_NOISY, "phalcon/db/adapter/pdo/postgresql.zep", 311 TSRMLS_CC); if (Z_TYPE_P(_13) != IS_NULL) { zephir_array_fetch_long(&_14, field, 9, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 312 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "/^'|'?::[[:alnum:][:space:]]+$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_9); ZVAL_STRING(_9, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_15, "preg_replace", &_16, 29, _8, _9, _14); zephir_check_temp_parameter(_8); zephir_check_temp_parameter(_9); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_15, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_17, definition, SL("default"), PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 313 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_18); ZVAL_STRING(&_18, "null", 0); ZEPHIR_CALL_FUNCTION(&_19, "strcasecmp", &_20, 19, _17, &_18); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_19, 0)) { zephir_array_update_string(&definition, SL("default"), &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } zephir_array_fetch_long(&columnName, field, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 321 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_21, 141, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/postgresql.zep", 322); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, createTable) { zephir_fcall_cache_entry *_5 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *sql = NULL, *queries, *query = NULL, *exception = NULL, *columns, *_0, **_3, *_4 = NULL, *_6; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 337); return; } if (!(zephir_fast_count_int(columns TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The table must contain at least one column", "phalcon/db/adapter/pdo/postgresql.zep", 341); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&sql, _0, "createtable", NULL, 0, tableName, schemaName, definition); zephir_check_call_status(); ZEPHIR_INIT_VAR(queries); zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC); if (zephir_fast_count_int(queries TSRMLS_CC) > 1) { /* try_start_1: */ ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); zephir_check_call_status_or_jump(try_end_1); zephir_is_iterable(queries, &_2, &_1, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 357); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(query, _3); if (ZEPHIR_IS_EMPTY(query)) { continue; } ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, query, ";"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); zephir_check_call_status_or_jump(try_end_1); RETURN_MM(); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(exception, EG(exception)); if (zephir_instance_of_ev(exception, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 361 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } else { zephir_array_fetch_long(&_6, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 364 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, _6, ";"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, _4); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, modifyColumn) { zephir_fcall_cache_entry *_5 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *sql = NULL, *queries, *query = NULL, *exception = NULL, *_0, **_3, *_4 = NULL, *_6 = NULL, *_7; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&sql, _0, "modifycolumn", NULL, 0, tableName, schemaName, column, currentColumn); zephir_check_call_status(); ZEPHIR_INIT_VAR(queries); zephir_fast_explode_str(queries, SL(";"), sql, LONG_MAX TSRMLS_CC); if (zephir_fast_count_int(queries TSRMLS_CC) > 1) { /* try_start_1: */ ZEPHIR_CALL_METHOD(NULL, this_ptr, "begin", NULL, 0); zephir_check_call_status_or_jump(try_end_1); zephir_is_iterable(queries, &_2, &_1, 0, 0, "phalcon/db/adapter/pdo/postgresql.zep", 389); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(query, _3); if (ZEPHIR_IS_EMPTY(query)) { continue; } ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, query, ";"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "query", &_5, 0, _4); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "commit", NULL, 0); zephir_check_call_status_or_jump(try_end_1); RETURN_MM(); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(exception, EG(exception)); if (zephir_instance_of_ev(exception, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); zephir_throw_exception_debug(exception, "phalcon/db/adapter/pdo/postgresql.zep", 394 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } else { ZEPHIR_INIT_VAR(_6); if (!(ZEPHIR_IS_EMPTY(sql))) { zephir_array_fetch_long(&_7, queries, 0, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/postgresql.zep", 398 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, _7, ";"); ZEPHIR_CALL_METHOD(&_6, this_ptr, "execute", NULL, 0, _4); zephir_check_call_status(); } else { ZVAL_BOOL(_6, 1); } RETURN_CCTOR(_6); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, useExplicitIdValue) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, getDefaultIdValue) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); object_init_ex(return_value, phalcon_db_rawvalue_ce); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "DEFAULT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 17, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Postgresql, supportSequences) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Adapter_Pdo_Sqlite) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Adapter\\Pdo, Sqlite, phalcon, db_adapter_pdo_sqlite, phalcon_db_adapter_pdo_ce, phalcon_db_adapter_pdo_sqlite_method_entry, 0); zend_declare_property_string(phalcon_db_adapter_pdo_sqlite_ce, SL("_type"), "sqlite", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_db_adapter_pdo_sqlite_ce, SL("_dialectType"), "sqlite", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_adapter_pdo_sqlite_ce TSRMLS_CC, 1, phalcon_db_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, connect) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *descriptor = NULL, *dbname; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &descriptor); if (!descriptor) { ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(descriptor); } if (Z_TYPE_P(descriptor) == IS_NULL) { ZEPHIR_OBS_NVAR(descriptor); zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(dbname); if (!(zephir_array_isset_string_fetch(&dbname, descriptor, SS("dbname"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "dbname must be specified", "phalcon/db/adapter/pdo/sqlite.zep", 70); return; } zephir_array_update_string(&descriptor, SL("dsn"), &dbname, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_sqlite_ce, this_ptr, "connect", &_0, 142, descriptor); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns) { zephir_fcall_cache_entry *_16 = NULL, *_20 = NULL, *_21 = NULL; zend_bool _9; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *columns, *columnType = NULL, *field = NULL, *definition = NULL, *oldColumn = NULL, *sizePattern, *matches = NULL, *matchOne = NULL, *matchTwo = NULL, *columnName, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_10, *_11 = NULL, *_12, *_13, _14 = zval_used_for_init, *_15 = NULL, *_17, *_18, *_19 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); zephir_get_strval(table, table_param); if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(oldColumn); ZVAL_NULL(oldColumn); ZEPHIR_INIT_VAR(sizePattern); ZVAL_STRING(sizePattern, "#\\(([0-9]+)(?:,\\s*([0-9]+))*\\)#", 1); ZEPHIR_INIT_VAR(columns); array_init(columns); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 291); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); ZEPHIR_INIT_NVAR(definition); zephir_create_array(definition, 1, 0 TSRMLS_CC); add_assoc_long_ex(definition, SS("bindType"), 2); ZEPHIR_OBS_NVAR(columnType); zephir_array_fetch_long(&columnType, field, 2, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 108 TSRMLS_CC); while (1) { if (zephir_memnstr_str(columnType, SL("tinyint(1)"), "phalcon/db/adapter/pdo/sqlite.zep", 115)) { ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 8); zephir_array_update_string(&definition, SL("type"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("bindType"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(columnType); ZVAL_STRING(columnType, "boolean", 1); break; } if (zephir_memnstr_str(columnType, SL("bigint"), "phalcon/db/adapter/pdo/sqlite.zep", 125)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 14); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } _9 = zephir_memnstr_str(columnType, SL("int"), "phalcon/db/adapter/pdo/sqlite.zep", 135); if (!(_9)) { _9 = zephir_memnstr_str(columnType, SL("INT"), "phalcon/db/adapter/pdo/sqlite.zep", 135); } if (_9) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 1); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); zephir_array_fetch_long(&_10, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 141 TSRMLS_CC); if (zephir_is_true(_10)) { zephir_array_update_string(&definition, SL("autoIncrement"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } break; } if (zephir_memnstr_str(columnType, SL("varchar"), "phalcon/db/adapter/pdo/sqlite.zep", 150)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("date"), "phalcon/db/adapter/pdo/sqlite.zep", 158)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 1); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("timestamp"), "phalcon/db/adapter/pdo/sqlite.zep", 166)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 17); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("decimal"), "phalcon/db/adapter/pdo/sqlite.zep", 174)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 3); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("char"), "phalcon/db/adapter/pdo/sqlite.zep", 184)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("datetime"), "phalcon/db/adapter/pdo/sqlite.zep", 192)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 4); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("text"), "phalcon/db/adapter/pdo/sqlite.zep", 200)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 6); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("float"), "phalcon/db/adapter/pdo/sqlite.zep", 208)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 7); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); zephir_array_update_string(&definition, SL("isNumeric"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 3); zephir_array_update_string(&definition, SL("bindType"), &_8, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("enum"), "phalcon/db/adapter/pdo/sqlite.zep", 218)) { ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_string(&definition, SL("type"), &_7, PH_COPY | PH_SEPARATE); break; } if (zephir_memnstr_str(columnType, SL("("), "phalcon/db/adapter/pdo/sqlite.zep", 233)) { ZEPHIR_INIT_NVAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_8); zephir_preg_match(_8, sizePattern, columnType, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_8)) { ZEPHIR_OBS_NVAR(matchOne); if (zephir_array_isset_long_fetch(&matchOne, matches, 1, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, zephir_get_intval(matchOne)); zephir_array_update_string(&definition, SL("size"), &_11, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(matchTwo); if (zephir_array_isset_long_fetch(&matchTwo, matches, 2, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, zephir_get_intval(matchTwo)); zephir_array_update_string(&definition, SL("scale"), &_11, PH_COPY | PH_SEPARATE); } } } if (zephir_memnstr_str(columnType, SL("unsigned"), "phalcon/db/adapter/pdo/sqlite.zep", 248)) { zephir_array_update_string(&definition, SL("unsigned"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(oldColumn) == IS_NULL) { zephir_array_update_string(&definition, SL("first"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { zephir_array_update_string(&definition, SL("after"), &oldColumn, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_10, field, 5, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 264 TSRMLS_CC); if (zephir_is_true(_10)) { zephir_array_update_string(&definition, SL("primary"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_12, field, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 271 TSRMLS_CC); if (zephir_is_true(_12)) { zephir_array_update_string(&definition, SL("notNull"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&_13, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 279 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "null", 0); ZEPHIR_CALL_FUNCTION(&_15, "strcasecmp", &_16, 19, _13, &_14); zephir_check_call_status(); _9 = !ZEPHIR_IS_LONG(_15, 0); if (_9) { zephir_array_fetch_long(&_17, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 279 TSRMLS_CC); _9 = !ZEPHIR_IS_STRING(_17, ""); } if (_9) { zephir_array_fetch_long(&_18, field, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 280 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "/^'|'$/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_19, "preg_replace", &_20, 29, _7, _8, _18); zephir_check_temp_parameter(_7); zephir_check_temp_parameter(_8); zephir_check_call_status(); zephir_array_update_string(&definition, SL("default"), &_19, PH_COPY | PH_SEPARATE); } zephir_array_fetch_long(&columnName, field, 1, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 286 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_db_column_ce); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_21, 141, columnName, definition); zephir_check_call_status(); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 287); ZEPHIR_CPY_WRT(oldColumn, columnName); } RETURN_CCTOR(columns); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeIndexes) { zephir_fcall_cache_entry *_17 = NULL; HashTable *_5, *_11, *_15; HashPosition _4, _10, _14; int ZEPHIR_LAST_CALL_STATUS; zval *table, *schema = NULL, *indexes, *index = NULL, *keyName = NULL, *indexObjects, *name = NULL, *indexColumns = NULL, *columns = NULL, *describe_index = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8, *_9 = NULL, **_12, *_13, **_16; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table, &schema); if (!schema) { schema = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(indexes); array_init(indexes); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describeindexes", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 323); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(index, _6); ZEPHIR_OBS_NVAR(keyName); zephir_array_fetch_long(&keyName, index, 1, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 309 TSRMLS_CC); if (!(zephir_array_isset(indexes, keyName))) { ZEPHIR_INIT_NVAR(columns); array_init(columns); } else { ZEPHIR_OBS_NVAR(columns); zephir_array_fetch(&columns, indexes, keyName, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 313 TSRMLS_CC); } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_9, _8, "describeindex", NULL, 0, keyName); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_7, this_ptr, "fetchall", NULL, 0, _9, _3); zephir_check_call_status(); zephir_is_iterable(_7, &_11, &_10, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 320); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HVALUE(describe_index, _12); zephir_array_fetch_long(&_13, describe_index, 2, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 317 TSRMLS_CC); zephir_array_append(&columns, _13, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 317); } zephir_array_update_zval(&indexes, keyName, &columns, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(indexObjects); array_init(indexObjects); zephir_is_iterable(indexes, &_15, &_14, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 328); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HMKEY(name, _15, _14); ZEPHIR_GET_HVALUE(indexColumns, _16); ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_db_index_ce); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_17, 15, name, indexColumns); zephir_check_call_status(); zephir_array_update_zval(&indexObjects, name, &_3, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(indexObjects); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeReferences) { zephir_fcall_cache_entry *_16 = NULL; zval *_11 = NULL; HashTable *_5, *_13; HashPosition _4, _12; int ZEPHIR_LAST_CALL_STATUS; zval *table, *schema = NULL, *references, *reference = NULL, *arrayReference = NULL, *constraintName = NULL, *referenceObjects, *name = NULL, *referencedSchema = NULL, *referencedTable = NULL, *columns = NULL, *referencedColumns = NULL, *number = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, **_6, *_7, *_8, *_9, *_10, **_14, *_15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table, &schema); if (!schema) { schema = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(references); array_init(references); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dialect"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "describereferences", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 3); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fetchall", NULL, 0, _2, _3); zephir_check_call_status(); zephir_is_iterable(_0, &_5, &_4, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 373); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(number, _5, _4); ZEPHIR_GET_HVALUE(reference, _6); ZEPHIR_INIT_NVAR(constraintName); ZEPHIR_CONCAT_SV(constraintName, "foreign_key_", number); if (!(zephir_array_isset(references, constraintName))) { ZEPHIR_INIT_NVAR(referencedSchema); ZVAL_NULL(referencedSchema); ZEPHIR_OBS_NVAR(referencedTable); zephir_array_fetch_long(&referencedTable, reference, 2, PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 352 TSRMLS_CC); ZEPHIR_INIT_NVAR(columns); array_init(columns); ZEPHIR_INIT_NVAR(referencedColumns); array_init(referencedColumns); } else { zephir_array_fetch(&_7, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 356 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedSchema); zephir_array_fetch_string(&referencedSchema, _7, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 356 TSRMLS_CC); zephir_array_fetch(&_8, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 357 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedTable); zephir_array_fetch_string(&referencedTable, _8, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 357 TSRMLS_CC); zephir_array_fetch(&_9, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 358 TSRMLS_CC); ZEPHIR_OBS_NVAR(columns); zephir_array_fetch_string(&columns, _9, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 358 TSRMLS_CC); zephir_array_fetch(&_10, references, constraintName, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 359 TSRMLS_CC); ZEPHIR_OBS_NVAR(referencedColumns); zephir_array_fetch_string(&referencedColumns, _10, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 359 TSRMLS_CC); } zephir_array_fetch_long(&_7, reference, 3, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 362 TSRMLS_CC); zephir_array_append(&columns, _7, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 362); zephir_array_fetch_long(&_8, reference, 4, PH_NOISY | PH_READONLY, "phalcon/db/adapter/pdo/sqlite.zep", 363 TSRMLS_CC); zephir_array_append(&referencedColumns, _8, PH_SEPARATE, "phalcon/db/adapter/pdo/sqlite.zep", 363); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedSchema"), &referencedSchema, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("referencedTable"), &referencedTable, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("columns"), &columns, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_11, SL("referencedColumns"), &referencedColumns, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&references, constraintName, &_11, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(referenceObjects); array_init(referenceObjects); zephir_is_iterable(references, &_13, &_12, 0, 0, "phalcon/db/adapter/pdo/sqlite.zep", 383); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HMKEY(name, _13, _12); ZEPHIR_GET_HVALUE(arrayReference, _14); ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_db_reference_ce); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedSchema"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 376 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedSchema"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedTable"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 377 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedTable"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("columns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 378 TSRMLS_CC); zephir_array_update_string(&_11, SL("columns"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, arrayReference, SL("referencedColumns"), PH_NOISY, "phalcon/db/adapter/pdo/sqlite.zep", 380 TSRMLS_CC); zephir_array_update_string(&_11, SL("referencedColumns"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_16, 16, name, _11); zephir_check_call_status(); zephir_array_update_zval(&referenceObjects, name, &_3, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(referenceObjects); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, useExplicitIdValue) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, getDefaultValue) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); object_init_ex(return_value, phalcon_db_rawvalue_ce); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "NULL", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 17, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_MySQL) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, MySQL, phalcon, db_dialect_mysql, phalcon_db_dialect_ce, phalcon_db_dialect_mysql_method_entry, 0); zend_declare_property_string(phalcon_db_dialect_mysql_ce, SL("_escapeChar"), "`", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, getColumnDefinition) { zephir_fcall_cache_entry *_10 = NULL; HashTable *_7; HashPosition _6; int ZEPHIR_LAST_CALL_STATUS; zval *column, *columnSql, *size = NULL, *scale = NULL, *type = NULL, *typeValues = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *value = NULL, *valueSql, **_8, _9 = zval_used_for_init, _11 = zval_used_for_init, *_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column); ZEPHIR_INIT_VAR(columnSql); ZVAL_STRING(columnSql, "", 1); ZEPHIR_CALL_METHOD(&type, column, "gettype", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(type) == IS_STRING) { zephir_concat_self(&columnSql, type TSRMLS_CC); ZEPHIR_CALL_METHOD(&type, column, "gettypereference", NULL, 0); zephir_check_call_status(); } do { if (ZEPHIR_IS_LONG(type, 0)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("INT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, column, "isunsigned", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { zephir_concat_self_str(&columnSql, SL(" UNSIGNED") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 1)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DATE") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 2)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("VARCHAR") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 3)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DECIMAL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "(", _0, ",", _2, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, column, "isunsigned", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { zephir_concat_self_str(&columnSql, SL(" UNSIGNED") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 4)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DATETIME") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 17)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TIMESTAMP") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 5)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("CHAR") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 6)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TEXT") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 8)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TINYINT(1)") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 7)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("FLOAT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&size, column, "getsize", NULL, 0); zephir_check_call_status(); if (zephir_is_true(size)) { ZEPHIR_CALL_METHOD(&scale, column, "getscale", NULL, 0); zephir_check_call_status(); if (zephir_is_true(scale)) { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "(", size, ",", scale, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVS(_4, "(", size, ")"); zephir_concat_self(&columnSql, _4 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_0, column, "isunsigned", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { zephir_concat_self_str(&columnSql, SL(" UNSIGNED") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 9)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DOUBLE") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&size, column, "getsize", NULL, 0); zephir_check_call_status(); if (zephir_is_true(size)) { ZEPHIR_CALL_METHOD(&scale, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "(", size); zephir_concat_self(&columnSql, _1 TSRMLS_CC); if (zephir_is_true(scale)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, ",", scale, ")"); zephir_concat_self(&columnSql, _4 TSRMLS_CC); } else { zephir_concat_self_str(&columnSql, SL(")") TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_0, column, "isunsigned", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { zephir_concat_self_str(&columnSql, SL(" UNSIGNED") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 14)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("BIGINT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&scale, column, "getsize", NULL, 0); zephir_check_call_status(); if (zephir_is_true(scale)) { ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_2, column, "isunsigned", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { zephir_concat_self_str(&columnSql, SL(" UNSIGNED") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 10)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TINYBLOB") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 11)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("BLOB") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 12)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("MEDIUMBLOB") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 13)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("LONGBLOB") TSRMLS_CC); } break; } if (ZEPHIR_IS_EMPTY(columnSql)) { ZEPHIR_INIT_VAR(_5); object_init_ex(_5, phalcon_db_exception_ce); ZEPHIR_CALL_METHOD(&_0, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "Unrecognized MySQL data type at column ", _0); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/db/dialect/mysql.zep", 197 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(typeValues))) { if (Z_TYPE_P(typeValues) == IS_ARRAY) { ZEPHIR_INIT_VAR(valueSql); ZVAL_STRING(valueSql, "", 1); zephir_is_iterable(typeValues, &_7, &_6, 0, 0, "phalcon/db/dialect/mysql.zep", 208); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(value, _8); ZEPHIR_SINIT_NVAR(_9); ZVAL_STRING(&_9, "\"", 0); ZEPHIR_CALL_FUNCTION(&_2, "addcslashes", &_10, 143, value, &_9); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "\"", _2, "\", "); zephir_concat_self(&valueSql, _4 TSRMLS_CC); } ZEPHIR_SINIT_NVAR(_9); ZVAL_LONG(&_9, 0); ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, -2); ZEPHIR_INIT_NVAR(_5); zephir_substr(_5, valueSql, 0 , -2 , 0); ZEPHIR_INIT_VAR(_12); ZEPHIR_CONCAT_SVS(_12, "(", _5, ")"); zephir_concat_self(&columnSql, _12 TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_11); ZVAL_STRING(&_11, "\"", 0); ZEPHIR_CALL_FUNCTION(&_3, "addcslashes", &_10, 143, typeValues, &_11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "(\"", _3, "\")"); zephir_concat_self(&columnSql, _4 TSRMLS_CC); } } } while(0); RETURN_CCTOR(columnSql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, addColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *afterPosition = NULL, *sql, *defaultValue = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, _5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVSVSV(sql, "ALTER TABLE ", _0, " ADD `", _1, "` ", _2); ZEPHIR_CALL_METHOD(&_3, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); zephir_fast_strtoupper(_4, defaultValue); if (zephir_memnstr_str(_4, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/mysql.zep", 229)) { zephir_concat_self_str(&sql, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "\"", 0); ZEPHIR_CALL_FUNCTION(&_6, "addcslashes", NULL, 143, defaultValue, &_5); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, " DEFAULT \"", _6, "\""); zephir_concat_self(&sql, _7 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_6, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_6)) { zephir_concat_self_str(&sql, SL(" NOT NULL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_8, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_8)) { zephir_concat_self_str(&sql, SL(" AUTO_INCREMENT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_9, column, "isfirst", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_9)) { zephir_concat_self_str(&sql, SL(" FIRST") TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(&afterPosition, column, "getafterposition", NULL, 0); zephir_check_call_status(); if (zephir_is_true(afterPosition)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " AFTER ", afterPosition); zephir_concat_self(&sql, _7 TSRMLS_CC); } } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, modifyColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *sql, *defaultValue = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, _5, *_6 = NULL, *_7, *_8 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVSVSV(sql, "ALTER TABLE ", _0, " MODIFY `", _1, "` ", _2); ZEPHIR_CALL_METHOD(&_3, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); zephir_fast_strtoupper(_4, defaultValue); if (zephir_memnstr_str(_4, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/mysql.zep", 266)) { zephir_concat_self_str(&sql, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "\"", 0); ZEPHIR_CALL_FUNCTION(&_6, "addcslashes", NULL, 143, defaultValue, &_5); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, " DEFAULT \"", _6, "\""); zephir_concat_self(&sql, _7 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_6, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_6)) { zephir_concat_self_str(&sql, SL(" NOT NULL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_8, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_8)) { zephir_concat_self_str(&sql, SL(" AUTO_INCREMENT") TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL, *columnName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(columnName_param) == IS_STRING)) { zephir_get_strval(columnName, columnName_param); } else { ZEPHIR_INIT_VAR(columnName); ZVAL_EMPTY_STRING(columnName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " DROP COLUMN `", columnName, "`"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, addIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *sql, *indexType = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SV(sql, "ALTER TABLE ", _0); ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(indexType))) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, " ADD ", indexType, " INDEX "); zephir_concat_self(&sql, _1 TSRMLS_CC); } else { zephir_concat_self_str(&sql, SL(" ADD INDEX ") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_2, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcolumnlist", NULL, 44, _4); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "`", _2, "` (", _3, ")"); zephir_concat_self(&sql, _1 TSRMLS_CC); RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL, *indexName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(indexName_param) == IS_STRING)) { zephir_get_strval(indexName, indexName_param); } else { ZEPHIR_INIT_VAR(indexName); ZVAL_EMPTY_STRING(indexName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " DROP INDEX `", indexName, "`"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, addPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *_0 = NULL, *_1 = NULL, *_2 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 44, _2); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " ADD PRIMARY KEY (", _1, ")"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "ALTER TABLE ", _0, " DROP PRIMARY KEY"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, addForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *reference, *sql, *onDelete = NULL, *onUpdate = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, reference, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, reference, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumnlist", NULL, 44, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, reference, "getreferencedtable", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, reference, "getreferencedschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "preparetable", NULL, 0, _5, _6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, reference, "getreferencedcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, this_ptr, "getcolumnlist", NULL, 44, _8); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVSVSVSVSVS(sql, "ALTER TABLE ", _0, " ADD FOREIGN KEY `", _1, "`(", _2, ") REFERENCES ", _4, "(", _7, ")"); ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onDelete))) { ZEPHIR_INIT_VAR(_9); ZEPHIR_CONCAT_SV(_9, " ON DELETE ", onDelete); zephir_concat_self(&sql, _9 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onUpdate))) { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SV(_9, " ON UPDATE ", onUpdate); zephir_concat_self(&sql, _9 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL, *referenceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceName_param) == IS_STRING)) { zephir_get_strval(referenceName, referenceName_param); } else { ZEPHIR_INIT_VAR(referenceName); ZVAL_EMPTY_STRING(referenceName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " DROP FOREIGN KEY `", referenceName, "`"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, createTable) { zephir_fcall_cache_entry *_5 = NULL, *_10 = NULL, *_17 = NULL; HashTable *_1, *_15, *_19; HashPosition _0, _14, _18; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *temporary = NULL, *options, *table = NULL, *createLines, *columns, *column = NULL, *indexes, *index = NULL, *reference = NULL, *references, *indexName = NULL, *indexSql = NULL, *sql, *columnLine = NULL, *indexType = NULL, *referenceSql = NULL, *onDelete = NULL, *onUpdate = NULL, *defaultValue = NULL, **_2, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, _8 = zval_used_for_init, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, **_16, **_20, *_21; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/db/dialect/mysql.zep", 377); return; } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(temporary); ZVAL_BOOL(temporary, 0); ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, definition, SS("options"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(temporary); zephir_array_isset_string_fetch(&temporary, options, SS("temporary"), 0 TSRMLS_CC); } ZEPHIR_INIT_VAR(sql); if (zephir_is_true(temporary)) { ZEPHIR_CONCAT_SVS(sql, "CREATE TEMPORARY TABLE ", table, " (\n\t"); } else { ZEPHIR_CONCAT_SVS(sql, "CREATE TABLE ", table, " (\n\t"); } ZEPHIR_INIT_VAR(createLines); array_init(createLines); zephir_is_iterable(columns, &_1, &_0, 0, 0, "phalcon/db/dialect/mysql.zep", 440); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(column, _2); ZEPHIR_CALL_METHOD(&_3, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumndefinition", &_5, 0, column); zephir_check_call_status(); ZEPHIR_INIT_NVAR(columnLine); ZEPHIR_CONCAT_SVSV(columnLine, "`", _3, "` ", _4); ZEPHIR_CALL_METHOD(&_6, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_6)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_7); zephir_fast_strtoupper(_7, defaultValue); if (zephir_memnstr_str(_7, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/mysql.zep", 406)) { zephir_concat_self_str(&columnLine, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_8); ZVAL_STRING(&_8, "\"", 0); ZEPHIR_CALL_FUNCTION(&_9, "addcslashes", &_10, 143, defaultValue, &_8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, " DEFAULT \"", _9, "\""); zephir_concat_self(&columnLine, _11 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_9, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_9)) { zephir_concat_self_str(&columnLine, SL(" NOT NULL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_12, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_12)) { zephir_concat_self_str(&columnLine, SL(" AUTO_INCREMENT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_13, column, "isprimary", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_13)) { zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY") TSRMLS_CC); } zephir_array_append(&createLines, columnLine, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 434); } ZEPHIR_OBS_VAR(indexes); if (zephir_array_isset_string_fetch(&indexes, definition, SS("indexes"), 0 TSRMLS_CC)) { zephir_is_iterable(indexes, &_15, &_14, 0, 0, "phalcon/db/dialect/mysql.zep", 462); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(index, _16); ZEPHIR_CALL_METHOD(&indexName, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_STRING(indexName, "PRIMARY")) { ZEPHIR_CALL_METHOD(&_4, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcolumnlist", &_17, 44, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(indexSql); ZEPHIR_CONCAT_SVS(indexSql, "PRIMARY KEY (", _3, ")"); } else { ZEPHIR_INIT_NVAR(indexSql); if (!(ZEPHIR_IS_EMPTY(indexType))) { ZEPHIR_CALL_METHOD(&_9, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, this_ptr, "getcolumnlist", &_17, 44, _9); zephir_check_call_status(); ZEPHIR_CONCAT_VSVSVS(indexSql, indexType, " KEY `", indexName, "` (", _6, ")"); } else { ZEPHIR_CALL_METHOD(&_13, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_12, this_ptr, "getcolumnlist", &_17, 44, _13); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(indexSql, "KEY `", indexName, "` (", _12, ")"); } } zephir_array_append(&createLines, indexSql, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 460); } } ZEPHIR_OBS_VAR(references); if (zephir_array_isset_string_fetch(&references, definition, SS("references"), 0 TSRMLS_CC)) { zephir_is_iterable(references, &_19, &_18, 0, 0, "phalcon/db/dialect/mysql.zep", 484); for ( ; zephir_hash_get_current_data_ex(_19, (void**) &_20, &_18) == SUCCESS ; zephir_hash_move_forward_ex(_19, &_18) ) { ZEPHIR_GET_HVALUE(reference, _20); ZEPHIR_CALL_METHOD(&_3, reference, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, reference, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", &_17, 44, _6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, reference, "getreferencedtable", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_13, reference, "getreferencedcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_12, this_ptr, "getcolumnlist", &_17, 44, _13); zephir_check_call_status(); ZEPHIR_INIT_NVAR(referenceSql); ZEPHIR_CONCAT_SVSVSSVSVS(referenceSql, "CONSTRAINT `", _3, "` FOREIGN KEY (", _4, ")", " REFERENCES `", _9, "`(", _12, ")"); ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onDelete))) { ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SV(_11, " ON DELETE ", onDelete); zephir_concat_self(&referenceSql, _11 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onUpdate))) { ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SV(_11, " ON UPDATE ", onUpdate); zephir_concat_self(&referenceSql, _11 TSRMLS_CC); } zephir_array_append(&createLines, referenceSql, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 482); } } ZEPHIR_INIT_NVAR(_7); zephir_fast_join_str(_7, SL(",\n\t"), createLines TSRMLS_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_VS(_11, _7, "\n)"); zephir_concat_self(&sql, _11 TSRMLS_CC); if (zephir_array_isset_string(definition, SS("options"))) { ZEPHIR_CALL_METHOD(&_3, this_ptr, "_gettableoptions", NULL, 0, definition); zephir_check_call_status(); ZEPHIR_INIT_VAR(_21); ZEPHIR_CONCAT_SV(_21, " ", _3); zephir_concat_self(&sql, _21 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropTable) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *sql, *table = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SV(sql, "DROP TABLE IF EXISTS ", table); } else { ZEPHIR_CONCAT_SV(sql, "DROP TABLE ", table); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, createView) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, *viewSql, *_0 = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } definition = definition_param; if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_OBS_VAR(viewSql); if (!(zephir_array_isset_string_fetch(&viewSql, definition, SS("sql"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/db/dialect/mysql.zep", 520); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", _0, " AS ", viewSql); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, dropView) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *sql, *view = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SV(sql, "DROP VIEW IF EXISTS ", view); } else { ZEPHIR_CONCAT_SV(sql, "DROP VIEW ", view); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, tableExists) { zval *tableName_param = NULL, *schemaName_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVSVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`= '", tableName, "' AND `TABLE_SCHEMA` = '", schemaName, "'"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME` = '", tableName, "' AND `TABLE_SCHEMA` = DATABASE()"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, viewExists) { zval *viewName_param = NULL, *schemaName_param = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVSVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_NAME`= '", viewName, "' AND `TABLE_SCHEMA`='", schemaName, "'"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_NAME`='", viewName, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, describeColumns) { int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *_0 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_CONCAT_SV(return_value, "DESCRIBE ", _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, listTables) { zval *schemaName_param = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVS(return_value, "SHOW TABLES FROM `", schemaName, "`"); RETURN_MM(); } RETURN_MM_STRING("SHOW TABLES", 1); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, listViews) { zval *schemaName_param = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVS(return_value, "SELECT `TABLE_NAME` AS view_name FROM `INFORMATION_SCHEMA`.`VIEWS` WHERE `TABLE_SCHEMA` = '", schemaName, "' ORDER BY view_name"); RETURN_MM(); } RETURN_MM_STRING("SELECT `TABLE_NAME` AS view_name FROM `INFORMATION_SCHEMA`.`VIEWS` ORDER BY view_name", 1); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, describeIndexes) { int ZEPHIR_LAST_CALL_STATUS; zval *table_param = NULL, *schema_param = NULL, *_0 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, table, schema); zephir_check_call_status(); ZEPHIR_CONCAT_SV(return_value, "SHOW INDEXES FROM ", _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, describeReferences) { zval *table_param = NULL, *schema_param = NULL, *sql; zval *table = NULL, *schema = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,REFERENCED_TABLE_SCHEMA,REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL AND ", 1); if (!(!schema) && Z_STRLEN_P(schema)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVS(_0, "CONSTRAINT_SCHEMA = '", schema, "' AND TABLE_NAME = '", table, "'"); zephir_concat_self(&sql, _0 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SVS(_0, "TABLE_NAME = '", table, "'"); zephir_concat_self(&sql, _0 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, tableOptions) { zval *table_param = NULL, *schema_param = NULL, *sql; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "SELECT TABLES.TABLE_TYPE AS table_type,TABLES.AUTO_INCREMENT AS auto_increment,TABLES.ENGINE AS engine,TABLES.TABLE_COLLATION AS table_collation FROM INFORMATION_SCHEMA.TABLES WHERE ", 1); if (!(!schema) && Z_STRLEN_P(schema)) { ZEPHIR_CONCAT_VSVSVS(return_value, sql, "TABLES.TABLE_SCHEMA = '", schema, "' AND TABLES.TABLE_NAME = '", table, "'"); RETURN_MM(); } ZEPHIR_CONCAT_VSVS(return_value, sql, "TABLES.TABLE_NAME = '", table, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_MySQL, _getTableOptions) { zval *definition_param = NULL, *options, *engine, *autoIncrement, *tableCollation, *collationParts, *tableOptions, *_0 = NULL, *_1, *_2; zval *definition = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &definition_param); definition = definition_param; ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, definition, SS("options"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(tableOptions); array_init(tableOptions); ZEPHIR_OBS_VAR(engine); if (zephir_array_isset_string_fetch(&engine, options, SS("ENGINE"), 0 TSRMLS_CC)) { if (zephir_is_true(engine)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "ENGINE=", engine); zephir_array_append(&tableOptions, _0, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 660); } } ZEPHIR_OBS_VAR(autoIncrement); if (zephir_array_isset_string_fetch(&autoIncrement, options, SS("AUTO_INCREMENT"), 0 TSRMLS_CC)) { if (zephir_is_true(autoIncrement)) { ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SV(_0, "AUTO_INCREMENT=", autoIncrement); zephir_array_append(&tableOptions, _0, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 669); } } ZEPHIR_OBS_VAR(tableCollation); if (zephir_array_isset_string_fetch(&tableCollation, options, SS("TABLE_COLLATION"), 0 TSRMLS_CC)) { if (zephir_is_true(tableCollation)) { ZEPHIR_INIT_VAR(collationParts); zephir_fast_explode_str(collationParts, SL("_"), tableCollation, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_1, collationParts, 0, PH_NOISY | PH_READONLY, "phalcon/db/dialect/mysql.zep", 679 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SV(_0, "DEFAULT CHARSET=", _1); zephir_array_append(&tableOptions, _0, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 679); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "COLLATE=", tableCollation); zephir_array_append(&tableOptions, _2, PH_SEPARATE, "phalcon/db/dialect/mysql.zep", 680); } } if (zephir_fast_count_int(tableOptions TSRMLS_CC)) { zephir_fast_join_str(return_value, SL(" "), tableOptions TSRMLS_CC); RETURN_MM(); } } RETURN_MM_STRING("", 1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Oracle) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Oracle, phalcon, db_dialect_oracle, phalcon_db_dialect_ce, phalcon_db_dialect_oracle_method_entry, 0); zend_declare_property_string(phalcon_db_dialect_oracle_ce, SL("_escapeChar"), "", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, limit) { int limit, offset = 0; zval *sqlQuery_param = NULL, *number, *_0 = NULL, *_1, _2 = zval_used_for_init, *_3, _4 = zval_used_for_init, _6; zval *sqlQuery = NULL, *_5, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number); if (unlikely(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { zephir_get_strval(sqlQuery, sqlQuery_param); } else { ZEPHIR_INIT_VAR(sqlQuery); ZVAL_EMPTY_STRING(sqlQuery); } if (Z_TYPE_P(number) == IS_ARRAY) { if (zephir_array_isset_long(number, 1)) { ZEPHIR_INIT_VAR(_0); zephir_array_fetch_long(&_1, number, 1, PH_NOISY | PH_READONLY, "phalcon/db/dialect/oracle.zep", 51 TSRMLS_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "'", 0); zephir_fast_trim(_0, _1, &_2, ZEPHIR_TRIM_BOTH TSRMLS_CC); offset = zephir_get_intval(_0); } ZEPHIR_INIT_NVAR(_0); zephir_array_fetch_long(&_1, number, 0, PH_NOISY | PH_READONLY, "phalcon/db/dialect/oracle.zep", 54 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "'", 0); zephir_fast_trim(_0, _1, &_2, ZEPHIR_TRIM_BOTH TSRMLS_CC); limit = (zephir_get_intval(_0) + offset); } else { ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "'", 0); zephir_fast_trim(_3, number, &_4, ZEPHIR_TRIM_BOTH TSRMLS_CC); limit = zephir_get_intval(_3); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, limit); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVSVS(_5, "SELECT * FROM (SELECT Z1.*, ROWNUM PHALCON_RN FROM (", sqlQuery, ") Z1 WHERE ROWNUM <= ", &_4, ")"); ZEPHIR_CPY_WRT(sqlQuery, _5); if (offset != 0) { ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, offset); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, " WHERE PHALCON_RN >= ", &_6); zephir_concat_self(&sqlQuery, _7 TSRMLS_CC); } RETURN_CTOR(sqlQuery); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, getColumnDefinition) { int ZEPHIR_LAST_CALL_STATUS; zval *column, *columnSql = NULL, *size = NULL, *scale = NULL, *type = NULL, *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column); ZEPHIR_CALL_METHOD(&type, column, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&size, column, "getsize", NULL, 0); zephir_check_call_status(); do { if (ZEPHIR_IS_LONG(type, 0)) { ZEPHIR_INIT_VAR(columnSql); ZVAL_STRING(columnSql, "INTEGER", 1); break; } if (ZEPHIR_IS_LONG(type, 1)) { ZEPHIR_INIT_NVAR(columnSql); ZVAL_STRING(columnSql, "DATE", 1); break; } if (ZEPHIR_IS_LONG(type, 2)) { ZEPHIR_INIT_NVAR(columnSql); ZEPHIR_CONCAT_SVS(columnSql, "VARCHAR2(", size, ")"); break; } if (ZEPHIR_IS_LONG(type, 3)) { ZEPHIR_CALL_METHOD(&scale, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(columnSql); ZEPHIR_CONCAT_SVSVS(columnSql, "NUMBER(", size, ",", scale, ")"); break; } if (ZEPHIR_IS_LONG(type, 4)) { ZEPHIR_INIT_NVAR(columnSql); ZVAL_STRING(columnSql, "TIMESTAMP", 1); break; } if (ZEPHIR_IS_LONG(type, 17)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TIMESTAMP") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 5)) { ZEPHIR_INIT_NVAR(columnSql); ZEPHIR_CONCAT_SVS(columnSql, "CHAR(", size, ")"); break; } if (ZEPHIR_IS_LONG(type, 6)) { ZEPHIR_INIT_NVAR(columnSql); ZVAL_STRING(columnSql, "TEXT", 1); break; } if (ZEPHIR_IS_LONG(type, 7)) { ZEPHIR_CALL_METHOD(&scale, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(columnSql); ZEPHIR_CONCAT_SVSVS(columnSql, "FLOAT(", size, ",", scale, ")"); break; } if (ZEPHIR_IS_LONG(type, 8)) { ZEPHIR_INIT_NVAR(columnSql); ZVAL_STRING(columnSql, "TINYINT(1)", 1); break; } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_db_exception_ce); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "Unrecognized Oracle data type at column ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/db/dialect/oracle.zep", 125 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); RETURN_CCTOR(columnSql); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, addColumn) { zval *tableName_param = NULL, *schemaName_param = NULL, *column; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 136); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, modifyColumn) { zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 144); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropColumn) { zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *columnName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } zephir_get_strval(columnName, columnName_param); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 152); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, addIndex) { zval *tableName_param = NULL, *schemaName_param = NULL, *index; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 160); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropIndex) { zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *indexName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(indexName_param) == IS_STRING)) { zephir_get_strval(indexName, indexName_param); } else { ZEPHIR_INIT_VAR(indexName); ZVAL_EMPTY_STRING(indexName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 169); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, addPrimaryKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *index; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); zephir_get_strval(tableName, tableName_param); zephir_get_strval(schemaName, schemaName_param); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 177); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropPrimaryKey) { zval *tableName_param = NULL, *schemaName_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 185); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, addForeignKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *reference; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 193); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropForeignKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *referenceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceName_param) == IS_STRING)) { zephir_get_strval(referenceName, referenceName_param); } else { ZEPHIR_INIT_VAR(referenceName); ZVAL_EMPTY_STRING(referenceName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 201); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, createTable) { zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Not implemented yet", "phalcon/db/dialect/oracle.zep", 209); return; } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropTable) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *table = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &tableName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); if (ifExists) { ZEPHIR_CONCAT_SV(return_value, "DROP TABLE IF EXISTS ", table); RETURN_MM(); } ZEPHIR_CONCAT_SV(return_value, "DROP TABLE ", table); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, createView) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, *viewSql, *_0 = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } definition = definition_param; if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_OBS_VAR(viewSql); if (!(zephir_array_isset_string_fetch(&viewSql, definition, SS("sql"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/db/dialect/oracle.zep", 236); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", _0, " AS ", viewSql); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, dropView) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *view = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); if (ifExists) { ZEPHIR_CONCAT_SV(return_value, "DROP VIEW IF EXISTS ", view); RETURN_MM(); } ZEPHIR_CONCAT_SV(return_value, "DROP VIEW ", view); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, viewExists) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *viewName_param = NULL, *schemaName_param = NULL, *_0 = NULL, *_2 = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ZEPHIR_IS_STRING(schemaName, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, viewName); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_2, phalcon_text_ce, "upper", &_1, 144, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END RET FROM ALL_VIEWS WHERE VIEW_NAME='", _0, "' AND OWNER='", _2, "'"); RETURN_MM(); } ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, viewName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END RET FROM ALL_VIEWS WHERE VIEW_NAME='", _0, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, listViews) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *schemaName_param = NULL, *_0 = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ZEPHIR_IS_STRING(schemaName, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT VIEW_NAME FROM ALL_VIEWS WHERE OWNER='", _0, "' ORDER BY VIEW_NAME"); RETURN_MM(); } RETURN_MM_STRING("SELECT VIEW_NAME FROM ALL_VIEWS VIEW_NAME", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, tableExists) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *_0 = NULL, *_2 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ZEPHIR_IS_STRING(schemaName, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, tableName); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_2, phalcon_text_ce, "upper", &_1, 144, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END RET FROM ALL_TABLES WHERE TABLE_NAME='", _0, "' AND OWNER = '", _2, "'"); RETURN_MM(); } ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, tableName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END RET FROM ALL_TABLES WHERE TABLE_NAME='", _0, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, describeColumns) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *table_param = NULL, *schema_param = NULL, *_0 = NULL, *_2 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } if (!ZEPHIR_IS_STRING(schema, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_2, phalcon_text_ce, "upper", &_1, 144, schema); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "SELECT TC.COLUMN_NAME, TC.DATA_TYPE, TC.DATA_LENGTH, TC.DATA_PRECISION, TC.DATA_SCALE, TC.NULLABLE, C.CONSTRAINT_TYPE, TC.DATA_DEFAULT, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = '", _0, "' AND TC.OWNER = '", _2, "' ORDER BY TC.COLUMN_ID"); RETURN_MM(); } ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT TC.COLUMN_NAME, TC.DATA_TYPE, TC.DATA_LENGTH, TC.DATA_PRECISION, TC.DATA_SCALE, TC.NULLABLE, C.CONSTRAINT_TYPE, TC.DATA_DEFAULT, CC.POSITION FROM ALL_TAB_COLUMNS TC LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P')) ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME WHERE TC.TABLE_NAME = '", _0, "' ORDER BY TC.COLUMN_ID"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, listTables) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *schemaName_param = NULL, *_0 = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ZEPHIR_IS_STRING(schemaName, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT TABLE_NAME, OWNER FROM ALL_TABLES WHERE OWNER='", _0, "' ORDER BY OWNER, TABLE_NAME"); RETURN_MM(); } RETURN_MM_STRING("SELECT TABLE_NAME, OWNER FROM ALL_TABLES ORDER BY OWNER, TABLE_NAME", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, describeIndexes) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *table_param = NULL, *schema_param = NULL, *_0 = NULL, *_2 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } if (!ZEPHIR_IS_STRING(schema, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_2, phalcon_text_ce, "upper", &_1, 144, schema); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "SELECT I.TABLE_NAME, 0 AS C0, I.INDEX_NAME, IC.COLUMN_POSITION, IC.COLUMN_NAME FROM ALL_INDEXES I JOIN ALL_IND_COLUMNS IC ON I.INDEX_NAME = IC.INDEX_NAME WHERE I.TABLE_NAME = '", _0, "' AND IC.INDEX_OWNER = '", _2, "'"); RETURN_MM(); } ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "SELECT I.TABLE_NAME, 0 AS C0, I.INDEX_NAME, IC.COLUMN_POSITION, IC.COLUMN_NAME FROM ALL_INDEXES I JOIN ALL_IND_COLUMNS IC ON I.INDEX_NAME = IC.INDEX_NAME WHERE I.TABLE_NAME = '", _0, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, describeReferences) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *table_param = NULL, *schema_param = NULL, *sql, *_0 = NULL, *_2 = NULL, *_3 = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "SELECT AC.TABLE_NAME, CC.COLUMN_NAME, AC.CONSTRAINT_NAME, AC.R_OWNER, RCC.TABLE_NAME R_TABLE_NAME, RCC.COLUMN_NAME R_COLUMN_NAME FROM ALL_CONSTRAINTS AC JOIN ALL_CONS_COLUMNS CC ON AC.CONSTRAINT_NAME = CC.CONSTRAINT_NAME JOIN ALL_CONS_COLUMNS RCC ON AC.R_OWNER = RCC.OWNER AND AC.R_CONSTRAINT_NAME = RCC.CONSTRAINT_NAME WHERE AC.CONSTRAINT_TYPE='R' ", 1); if (!ZEPHIR_IS_STRING(schema, "")) { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, schema); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_2, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSVS(_3, "AND AC.OWNER='", _0, "' AND AC.TABLE_NAME = '", _2, "'"); zephir_concat_self(&sql, _3 TSRMLS_CC); } else { ZEPHIR_CALL_CE_STATIC(&_0, phalcon_text_ce, "upper", &_1, 144, table); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVS(_3, "AND AC.TABLE_NAME = '", _0, "'"); zephir_concat_self(&sql, _3 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, tableOptions) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, supportsSavepoints) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, supportsReleaseSavepoints) { RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Db_Dialect_Oracle, prepareTable) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL; zval *table_param = NULL, *schema_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, *_1 = NULL, *_3 = NULL; zval *table = NULL, *schema = NULL, *alias = NULL, *escapeChar = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &table_param, &schema_param, &alias_param, &escapeChar_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } if (!alias_param) { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } else { zephir_get_strval(alias, alias_param); } if (!escapeChar_param) { ZEPHIR_INIT_VAR(escapeChar); ZVAL_EMPTY_STRING(escapeChar); } else { zephir_get_strval(escapeChar, escapeChar_param); } ZEPHIR_CALL_CE_STATIC(&_1, phalcon_text_ce, "upper", &_2, 144, table); zephir_check_call_status(); ZEPHIR_CALL_CE_STATIC(&_3, phalcon_text_ce, "upper", &_2, 144, schema); zephir_check_call_status(); ZEPHIR_RETURN_CALL_PARENT(phalcon_db_dialect_oracle_ce, this_ptr, "preparetable", &_0, 145, _1, _3, alias, escapeChar); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Postgresql) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Postgresql, phalcon, db_dialect_postgresql, phalcon_db_dialect_ce, phalcon_db_dialect_postgresql_method_entry, 0); zend_declare_property_string(phalcon_db_dialect_postgresql_ce, SL("_escapeChar"), "\"", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, getColumnDefinition) { zephir_fcall_cache_entry *_7 = NULL; HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zval *column, *size = NULL, *columnType = NULL, *columnSql, *typeValues = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *value = NULL, *valueSql, **_5, _6 = zval_used_for_init, *_8 = NULL, _9 = zval_used_for_init, *_10 = NULL, *_11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column); ZEPHIR_CALL_METHOD(&size, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&columnType, column, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(columnSql); ZVAL_STRING(columnSql, "", 1); if (Z_TYPE_P(columnType) == IS_STRING) { zephir_concat_self(&columnSql, columnType TSRMLS_CC); ZEPHIR_CALL_METHOD(&columnType, column, "gettypereference", NULL, 0); zephir_check_call_status(); } do { if (ZEPHIR_IS_LONG(columnType, 0)) { if (ZEPHIR_IS_EMPTY(columnSql)) { ZEPHIR_CALL_METHOD(&_0, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { zephir_concat_self_str(&columnSql, SL("SERIAL") TSRMLS_CC); } else { zephir_concat_self_str(&columnSql, SL("INT") TSRMLS_CC); } } break; } if (ZEPHIR_IS_LONG(columnType, 1)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DATE") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 2)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("CHARACTER VARYING") TSRMLS_CC); } ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", size, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(columnType, 3)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("NUMERIC") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "(", size, ",", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(columnType, 4)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TIMESTAMP") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 17)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TIMESTAMP") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 5)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("CHARACTER") TSRMLS_CC); } ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", size, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(columnType, 6)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TEXT") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 7)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("FLOAT") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 14)) { if (ZEPHIR_IS_EMPTY(columnSql)) { ZEPHIR_CALL_METHOD(&_0, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { zephir_concat_self_str(&columnSql, SL("BIGSERIAL") TSRMLS_CC); } else { zephir_concat_self_str(&columnSql, SL("BIGINT") TSRMLS_CC); } } break; } if (ZEPHIR_IS_LONG(columnType, 15)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("JSON") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 16)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("JSONB") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(columnType, 8)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("BOOLEAN") TSRMLS_CC); } break; } if (ZEPHIR_IS_EMPTY(columnSql)) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_db_exception_ce); ZEPHIR_CALL_METHOD(&_0, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "Unrecognized PostgreSQL data type at column ", _0); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/db/dialect/postgresql.zep", 150 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(typeValues))) { if (Z_TYPE_P(typeValues) == IS_ARRAY) { ZEPHIR_INIT_VAR(valueSql); ZVAL_STRING(valueSql, "", 1); zephir_is_iterable(typeValues, &_4, &_3, 0, 0, "phalcon/db/dialect/postgresql.zep", 161); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(value, _5); ZEPHIR_SINIT_NVAR(_6); ZVAL_STRING(&_6, "\"", 0); ZEPHIR_CALL_FUNCTION(&_0, "addcslashes", &_7, 143, value, &_6); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "\"", _0, "\", "); zephir_concat_self(&valueSql, _8 TSRMLS_CC); } ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, -2); ZEPHIR_INIT_NVAR(_2); zephir_substr(_2, valueSql, 0 , -2 , 0); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "(", _2, ")"); zephir_concat_self(&columnSql, _8 TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_9); ZVAL_STRING(&_9, "\"", 0); ZEPHIR_CALL_FUNCTION(&_10, "addcslashes", &_7, 143, typeValues, &_9); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11); ZEPHIR_CONCAT_SVS(_11, "(\"", _10, "\")"); zephir_concat_self(&columnSql, _11 TSRMLS_CC); } } } while(0); RETURN_CCTOR(columnSql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *sql, *defaultValue = NULL, *columnDefinition = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5, *_6 = NULL, *_7, _8, *_9 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVS(sql, "ALTER TABLE ", _0, " ADD COLUMN "); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVSV(_2, "\"", _1, "\" ", columnDefinition); zephir_concat_self(&sql, _2 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); zephir_fast_strtoupper(_4, columnDefinition); ZEPHIR_INIT_VAR(_5); zephir_fast_strtoupper(_5, defaultValue); if (zephir_memnstr_str(_4, SL("BOOLEAN"), "phalcon/db/dialect/postgresql.zep", 185)) { ZEPHIR_INIT_VAR(_6); if (zephir_is_true(defaultValue)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "true", 1); } else { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "false", 1); } ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, " DEFAULT ", _6); zephir_concat_self(&sql, _7 TSRMLS_CC); } else if (zephir_memnstr_str(_5, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/postgresql.zep", 187)) { zephir_concat_self_str(&sql, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_VAR(_8); ZVAL_STRING(&_8, "\"", 0); ZEPHIR_CALL_FUNCTION(&_9, "addcslashes", NULL, 143, defaultValue, &_8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, " DEFAULT \"", _9, "\""); zephir_concat_self(&sql, _6 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_9, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_9)) { zephir_concat_self_str(&sql, SL(" NOT NULL") TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, modifyColumn) { zend_bool _9; int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL, *sql, *sqlAlterTable, *defaultValue = NULL, *columnDefinition = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_10 = NULL, *_11, *_12, *_13 = NULL, *_14 = NULL, _15, *_16 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "", 1); ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sqlAlterTable); ZEPHIR_CONCAT_SV(sqlAlterTable, "ALTER TABLE ", _0); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, currentColumn, "getname", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_1, _2)) { ZEPHIR_CALL_METHOD(&_3, currentColumn, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_VSVSVS(_5, sqlAlterTable, " RENAME COLUMN \"", _3, "\" TO \"", _4, "\";"); zephir_concat_self(&sql, _5 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_3, column, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, currentColumn, "gettype", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_3, _4)) { ZEPHIR_CALL_METHOD(&_6, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VSVSVS(_5, sqlAlterTable, " ALTER COLUMN \"", _6, "\" TYPE ", columnDefinition, ";"); zephir_concat_self(&sql, _5 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_3, column, "isnotnull", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, currentColumn, "isnotnull", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_3, _4)) { ZEPHIR_CALL_METHOD(&_6, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_6)) { ZEPHIR_CALL_METHOD(&_7, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VSVS(_5, sqlAlterTable, " ALTER COLUMN \"", _7, "\" SET NOT NULL;"); zephir_concat_self(&sql, _5 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(&_7, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_VSVS(_8, sqlAlterTable, " ALTER COLUMN \"", _7, "\" DROP NOT NULL;"); zephir_concat_self(&sql, _8 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_3, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, currentColumn, "getdefault", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_3, _4)) { ZEPHIR_CALL_METHOD(&_6, column, "hasdefault", NULL, 0); zephir_check_call_status(); _9 = !zephir_is_true(_6); if (_9) { ZEPHIR_CALL_METHOD(&_7, currentColumn, "getdefault", NULL, 0); zephir_check_call_status(); _9 = !(ZEPHIR_IS_EMPTY(_7)); } if (_9) { ZEPHIR_CALL_METHOD(&_10, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VSVS(_5, sqlAlterTable, " ALTER COLUMN \"", _10, "\" DROP DEFAULT;"); zephir_concat_self(&sql, _5 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_7, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_7)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11); zephir_fast_strtoupper(_11, columnDefinition); ZEPHIR_INIT_VAR(_12); zephir_fast_strtoupper(_12, defaultValue); if (zephir_memnstr_str(_11, SL("BOOLEAN"), "phalcon/db/dialect/postgresql.zep", 238)) { ZEPHIR_CALL_METHOD(&_10, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); if (zephir_is_true(defaultValue)) { ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "true", 1); } else { ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "false", 1); } ZEPHIR_INIT_VAR(_13); ZEPHIR_CONCAT_SVSV(_13, " ALTER COLUMN \"", _10, "\" SET DEFAULT ", _8); zephir_concat_self(&sql, _13 TSRMLS_CC); } else if (zephir_memnstr_str(_12, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/postgresql.zep", 240)) { ZEPHIR_CALL_METHOD(&_14, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); ZEPHIR_CONCAT_VSVS(_13, sqlAlterTable, " ALTER COLUMN \"", _14, "\" SET DEFAULT CURRENT_TIMESTAMP"); zephir_concat_self(&sql, _13 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(&_14, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_15); ZVAL_STRING(&_15, "\"", 0); ZEPHIR_CALL_FUNCTION(&_16, "addcslashes", NULL, 143, defaultValue, &_15); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); ZEPHIR_CONCAT_VSVSVS(_13, sqlAlterTable, " ALTER COLUMN \"", _14, "\" SET DEFAULT \"", _16, "\""); zephir_concat_self(&sql, _13 TSRMLS_CC); } } } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL, *columnName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(columnName_param) == IS_STRING)) { zephir_get_strval(columnName, columnName_param); } else { ZEPHIR_INIT_VAR(columnName); ZVAL_EMPTY_STRING(columnName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " DROP COLUMN \"", columnName, "\""); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *sql, *indexType = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, index, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_STRING_IDENTICAL(_0, "PRIMARY")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addprimarykey", NULL, 0, tableName, schemaName, index); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "CREATE", 1); ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(indexType))) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, " ", indexType); zephir_concat_self(&sql, _1 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_2, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSV(_1, " INDEX \"", _2, "\" ON ", _3); zephir_concat_self(&sql, _1 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", NULL, 44, _5); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SVS(_6, " (", _4, ")"); zephir_concat_self(&sql, _6 TSRMLS_CC); RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropIndex) { zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *indexName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(indexName_param) == IS_STRING)) { zephir_get_strval(indexName, indexName_param); } else { ZEPHIR_INIT_VAR(indexName); ZVAL_EMPTY_STRING(indexName); } ZEPHIR_CONCAT_SVS(return_value, "DROP INDEX \"", indexName, "\""); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *_0 = NULL, *_1 = NULL, *_2 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 44, _2); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " ADD CONSTRAINT \"PRIMARY\" PRIMARY KEY (", _1, ")"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropPrimaryKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "ALTER TABLE ", _0, " DROP CONSTRAINT \"PRIMARY\""); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, addForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *reference, *sql, *onDelete = NULL, *onUpdate = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, reference, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, reference, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumnlist", NULL, 44, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, reference, "getreferencedtable", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, reference, "getreferencedcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 44, _6); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVSVSVSSVSVS(sql, "ALTER TABLE ", _0, " ADD CONSTRAINT \"", _1, "\" FOREIGN KEY (", _2, ")", " REFERENCES \"", _4, "\" (", _5, ")"); ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onDelete))) { ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, " ON DELETE ", onDelete); zephir_concat_self(&sql, _7 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onUpdate))) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, " ON UPDATE ", onUpdate); zephir_concat_self(&sql, _7 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropForeignKey) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL, *_0 = NULL; zval *tableName = NULL, *schemaName = NULL, *referenceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceName_param) == IS_STRING)) { zephir_get_strval(referenceName, referenceName_param); } else { ZEPHIR_INIT_VAR(referenceName); ZVAL_EMPTY_STRING(referenceName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "ALTER TABLE ", _0, " DROP CONSTRAINT \"", referenceName, "\""); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createTable) { zephir_fcall_cache_entry *_3 = NULL, *_12 = NULL; HashTable *_1, *_16, *_22; HashPosition _0, _15, _21; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *temporary = NULL, *options, *table = NULL, *createLines, *columns, *column = NULL, *indexes, *index = NULL, *reference = NULL, *references, *indexName = NULL, *indexSql = NULL, *indexSqlAfterCreate, *sql, *columnLine = NULL, *indexType = NULL, *referenceSql = NULL, *onDelete = NULL, *onUpdate = NULL, *defaultValue = NULL, *primaryColumns, *columnDefinition = NULL, **_2, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, _10 = zval_used_for_init, *_11 = NULL, *_13 = NULL, *_14 = NULL, **_17, *_18 = NULL, *_19 = NULL, *_20 = NULL, **_23, *_24; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/db/dialect/postgresql.zep", 350); return; } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(temporary); ZVAL_BOOL(temporary, 0); ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, definition, SS("options"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(temporary); zephir_array_isset_string_fetch(&temporary, options, SS("temporary"), 0 TSRMLS_CC); } ZEPHIR_INIT_VAR(sql); if (zephir_is_true(temporary)) { ZEPHIR_CONCAT_SVS(sql, "CREATE TEMPORARY TABLE ", table, " (\n\t"); } else { ZEPHIR_CONCAT_SVS(sql, "CREATE TABLE ", table, " (\n\t"); } ZEPHIR_INIT_VAR(createLines); array_init(createLines); ZEPHIR_INIT_VAR(primaryColumns); array_init(primaryColumns); zephir_is_iterable(columns, &_1, &_0, 0, 0, "phalcon/db/dialect/postgresql.zep", 406); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(column, _2); ZEPHIR_CALL_METHOD(&columnDefinition, this_ptr, "getcolumndefinition", &_3, 0, column); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(columnLine); ZEPHIR_CONCAT_SVSV(columnLine, "\"", _4, "\" ", columnDefinition); ZEPHIR_CALL_METHOD(&_5, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_5)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_6); zephir_fast_strtoupper(_6, columnDefinition); ZEPHIR_INIT_NVAR(_7); zephir_fast_strtoupper(_7, defaultValue); if (zephir_memnstr_str(_6, SL("BOOLEAN"), "phalcon/db/dialect/postgresql.zep", 381)) { ZEPHIR_INIT_LNVAR(_8); if (zephir_is_true(defaultValue)) { ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "true", 1); } else { ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "false", 1); } ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SV(_9, " DEFAULT ", _8); zephir_concat_self(&sql, _9 TSRMLS_CC); } else if (zephir_memnstr_str(_7, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/postgresql.zep", 383)) { zephir_concat_self_str(&columnLine, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_10); ZVAL_STRING(&_10, "\"", 0); ZEPHIR_CALL_FUNCTION(&_11, "addcslashes", &_12, 143, defaultValue, &_10); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, " DEFAULT \"", _11, "\""); zephir_concat_self(&columnLine, _8 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_11, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_11)) { zephir_concat_self_str(&columnLine, SL(" NOT NULL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_13, column, "isprimary", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_13)) { ZEPHIR_CALL_METHOD(&_14, column, "getname", NULL, 0); zephir_check_call_status(); zephir_array_append(&primaryColumns, _14, PH_SEPARATE, "phalcon/db/dialect/postgresql.zep", 401); } zephir_array_append(&createLines, columnLine, PH_SEPARATE, "phalcon/db/dialect/postgresql.zep", 404); } if (!(ZEPHIR_IS_EMPTY(primaryColumns))) { ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", NULL, 44, primaryColumns); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "PRIMARY KEY (", _4, ")"); zephir_array_append(&createLines, _8, PH_SEPARATE, "phalcon/db/dialect/postgresql.zep", 407); } ZEPHIR_INIT_VAR(indexSqlAfterCreate); ZVAL_STRING(indexSqlAfterCreate, "", 1); ZEPHIR_OBS_VAR(indexes); if (zephir_array_isset_string_fetch(&indexes, definition, SS("indexes"), 0 TSRMLS_CC)) { zephir_is_iterable(indexes, &_16, &_15, 0, 0, "phalcon/db/dialect/postgresql.zep", 441); for ( ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HVALUE(index, _17); ZEPHIR_CALL_METHOD(&indexName, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(indexSql); ZVAL_STRING(indexSql, "", 1); if (ZEPHIR_IS_STRING(indexName, "PRIMARY")) { ZEPHIR_CALL_METHOD(&_5, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", NULL, 44, _5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(indexSql); ZEPHIR_CONCAT_SVS(indexSql, "CONSTRAINT \"PRIMARY\" PRIMARY KEY (", _4, ")"); } else { if (!(ZEPHIR_IS_EMPTY(indexType))) { ZEPHIR_CALL_METHOD(&_13, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_11, this_ptr, "getcolumnlist", NULL, 44, _13); zephir_check_call_status(); ZEPHIR_INIT_NVAR(indexSql); ZEPHIR_CONCAT_SVSVSVS(indexSql, "CONSTRAINT \"", indexName, "\" ", indexType, " (", _11, ")"); } else { ZEPHIR_CALL_METHOD(&_14, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_18, this_ptr, "preparetable", NULL, 145, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSV(_8, "CREATE INDEX \"", _14, "\" ON ", _18); zephir_concat_self(&indexSqlAfterCreate, _8 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_20, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_19, this_ptr, "getcolumnlist", NULL, 44, _20); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, " (", _19, ");"); zephir_concat_self(&indexSqlAfterCreate, _9 TSRMLS_CC); } } if (!(ZEPHIR_IS_EMPTY(indexSql))) { zephir_array_append(&createLines, indexSql, PH_SEPARATE, "phalcon/db/dialect/postgresql.zep", 438); } } } ZEPHIR_OBS_VAR(references); if (zephir_array_isset_string_fetch(&references, definition, SS("references"), 0 TSRMLS_CC)) { zephir_is_iterable(references, &_22, &_21, 0, 0, "phalcon/db/dialect/postgresql.zep", 466); for ( ; zephir_hash_get_current_data_ex(_22, (void**) &_23, &_21) == SUCCESS ; zephir_hash_move_forward_ex(_22, &_21) ) { ZEPHIR_GET_HVALUE(reference, _23); ZEPHIR_CALL_METHOD(&_4, reference, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_11, reference, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, this_ptr, "getcolumnlist", NULL, 44, _11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(referenceSql); ZEPHIR_CONCAT_SVSVS(referenceSql, "CONSTRAINT \"", _4, "\" FOREIGN KEY (", _5, ") REFERENCES "); ZEPHIR_CALL_METHOD(&_14, reference, "getreferencedtable", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_13, this_ptr, "preparetable", NULL, 145, _14, schemaName); zephir_check_call_status(); zephir_concat_self(&referenceSql, _13 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_19, reference, "getreferencedcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_18, this_ptr, "getcolumnlist", NULL, 44, _19); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, " (", _18, ")"); zephir_concat_self(&referenceSql, _8 TSRMLS_CC); ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onDelete))) { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SV(_9, " ON DELETE ", onDelete); zephir_concat_self(&referenceSql, _9 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onUpdate))) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SV(_8, " ON UPDATE ", onUpdate); zephir_concat_self(&referenceSql, _8 TSRMLS_CC); } zephir_array_append(&createLines, referenceSql, PH_SEPARATE, "phalcon/db/dialect/postgresql.zep", 464); } } ZEPHIR_INIT_NVAR(_6); zephir_fast_join_str(_6, SL(",\n\t"), createLines TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_VS(_8, _6, "\n)"); zephir_concat_self(&sql, _8 TSRMLS_CC); if (zephir_array_isset_string(definition, SS("options"))) { ZEPHIR_CALL_METHOD(&_4, this_ptr, "_gettableoptions", NULL, 0, definition); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SV(_9, " ", _4); zephir_concat_self(&sql, _9 TSRMLS_CC); } ZEPHIR_INIT_VAR(_24); ZEPHIR_CONCAT_SV(_24, ";", indexSqlAfterCreate); zephir_concat_self(&sql, _24 TSRMLS_CC); RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropTable) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *table = NULL, *sql; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SV(sql, "DROP TABLE IF EXISTS ", table); } else { ZEPHIR_CONCAT_SV(sql, "DROP TABLE ", table); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, createView) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, *viewSql, *_0 = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } definition = definition_param; if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_OBS_VAR(viewSql); if (!(zephir_array_isset_string_fetch(&viewSql, definition, SS("sql"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/db/dialect/postgresql.zep", 503); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", _0, " AS ", viewSql); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, dropView) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *view = NULL, *sql; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SV(sql, "DROP VIEW IF EXISTS ", view); } else { ZEPHIR_CONCAT_SV(sql, "DROP VIEW ", view); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, tableExists) { zval *tableName_param = NULL, *schemaName_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM information_schema.tables WHERE table_schema = '", schemaName, "' AND table_name='", tableName, "'"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM information_schema.tables WHERE table_schema = 'public' AND table_name='", tableName, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, viewExists) { zval *viewName_param = NULL, *schemaName_param = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVSVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM pg_views WHERE viewname='", viewName, "' AND schemaname='", schemaName, "'"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM pg_views WHERE viewname='", viewName, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeColumns) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } if (!(!schema) && Z_STRLEN_P(schema)) { ZEPHIR_CONCAT_SVSVS(return_value, "SELECT DISTINCT c.column_name AS Field, c.data_type AS Type, c.character_maximum_length AS Size, c.numeric_precision AS NumericSize, c.numeric_scale AS NumericScale, c.is_nullable AS Null, CASE WHEN pkc.column_name NOTNULL THEN 'PRI' ELSE '' END AS Key, CASE WHEN c.data_type LIKE '%int%' AND c.column_default LIKE '%nextval%' THEN 'auto_increment' ELSE '' END AS Extra, c.ordinal_position AS Position, c.column_default FROM information_schema.columns c LEFT JOIN ( SELECT kcu.column_name, kcu.table_name, kcu.table_schema FROM information_schema.table_constraints tc INNER JOIN information_schema.key_column_usage kcu on (kcu.constraint_name = tc.constraint_name and kcu.table_name=tc.table_name and kcu.table_schema=tc.table_schema) WHERE tc.constraint_type='PRIMARY KEY') pkc ON (c.column_name=pkc.column_name AND c.table_schema = pkc.table_schema AND c.table_name=pkc.table_name) WHERE c.table_schema='", schema, "' AND c.table_name='", table, "' ORDER BY c.ordinal_position"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "SELECT DISTINCT c.column_name AS Field, c.data_type AS Type, c.character_maximum_length AS Size, c.numeric_precision AS NumericSize, c.numeric_scale AS NumericScale, c.is_nullable AS Null, CASE WHEN pkc.column_name NOTNULL THEN 'PRI' ELSE '' END AS Key, CASE WHEN c.data_type LIKE '%int%' AND c.column_default LIKE '%nextval%' THEN 'auto_increment' ELSE '' END AS Extra, c.ordinal_position AS Position, c.column_default FROM information_schema.columns c LEFT JOIN ( SELECT kcu.column_name, kcu.table_name, kcu.table_schema FROM information_schema.table_constraints tc INNER JOIN information_schema.key_column_usage kcu on (kcu.constraint_name = tc.constraint_name and kcu.table_name=tc.table_name and kcu.table_schema=tc.table_schema) WHERE tc.constraint_type='PRIMARY KEY') pkc ON (c.column_name=pkc.column_name AND c.table_schema = pkc.table_schema AND c.table_name=pkc.table_name) WHERE c.table_schema='public' AND c.table_name='", table, "' ORDER BY c.ordinal_position"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, listTables) { zval *schemaName_param = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVS(return_value, "SELECT table_name FROM information_schema.tables WHERE table_schema = '", schemaName, "' ORDER BY table_name"); RETURN_MM(); } RETURN_MM_STRING("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, listViews) { zval *schemaName = NULL; zephir_fetch_params(0, 0, 1, &schemaName); if (!schemaName) { schemaName = ZEPHIR_GLOBAL(global_null); } if (zephir_is_true(schemaName)) { ZEPHIR_CONCAT_SVS(return_value, "SELECT viewname AS view_name FROM pg_views WHERE schemaname = '", schemaName, "' ORDER BY view_name"); return; } RETURN_STRING("SELECT viewname AS view_name FROM pg_views WHERE schemaname = 'public' ORDER BY view_name", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeIndexes) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CONCAT_SVS(return_value, "SELECT 0 as c0, t.relname as table_name, i.relname as key_name, 3 as c3, a.attname as column_name FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND a.attnum = ANY(ix.indkey) AND t.relkind = 'r' AND t.relname = '", table, "' ORDER BY t.relname, i.relname;"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, describeReferences) { zval *table_param = NULL, *schema_param = NULL, *sql; zval *table = NULL, *schema = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_INIT_VAR(sql); ZVAL_STRING(sql, "SELECT tc.table_name as TABLE_NAME, kcu.column_name as COLUMN_NAME, tc.constraint_name as CONSTRAINT_NAME, tc.table_catalog as REFERENCED_TABLE_SCHEMA, ccu.table_name AS REFERENCED_TABLE_NAME, ccu.column_name AS REFERENCED_COLUMN_NAME FROM information_schema.table_constraints AS tc JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name WHERE constraint_type = 'FOREIGN KEY' AND ", 1); if (!(!schema) && Z_STRLEN_P(schema)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVS(_0, "tc.table_schema = '", schema, "' AND tc.table_name='", table, "'"); zephir_concat_self(&sql, _0 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SVS(_0, "tc.table_name='", table, "'"); zephir_concat_self(&sql, _0 TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, tableOptions) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Postgresql, _getTableOptions) { zval *definition_param = NULL; zval *definition = NULL; zephir_fetch_params(0, 1, 0, &definition_param); definition = definition_param; RETURN_STRING("", 1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect_Sqlite) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db\\Dialect, Sqlite, phalcon, db_dialect_sqlite, phalcon_db_dialect_ce, phalcon_db_dialect_sqlite_method_entry, 0); zend_declare_property_string(phalcon_db_dialect_sqlite_ce, SL("_escapeChar"), "\"", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, getColumnDefinition) { zephir_fcall_cache_entry *_8 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *column, *columnSql, *type = NULL, *typeValues = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *value = NULL, *valueSql, **_6, _7 = zval_used_for_init, *_9 = NULL, _10 = zval_used_for_init, *_11 = NULL, *_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column); ZEPHIR_INIT_VAR(columnSql); ZVAL_STRING(columnSql, "", 1); ZEPHIR_CALL_METHOD(&type, column, "gettype", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(type) == IS_STRING) { zephir_concat_self(&columnSql, type TSRMLS_CC); ZEPHIR_CALL_METHOD(&type, column, "gettypereference", NULL, 0); zephir_check_call_status(); } do { if (ZEPHIR_IS_LONG(type, 0)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("INTEGER") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 1)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DATE") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 2)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("VARCHAR") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 3)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("NUMERIC") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, column, "getscale", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "(", _0, ",", _2, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 4)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("DATETIME") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 17)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TIMESTAMP") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 5)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("CHARACTER") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "(", _0, ")"); zephir_concat_self(&columnSql, _1 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 6)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("TEXT") TSRMLS_CC); } break; } if (ZEPHIR_IS_LONG(type, 7)) { if (ZEPHIR_IS_EMPTY(columnSql)) { zephir_concat_self_str(&columnSql, SL("FLOAT") TSRMLS_CC); } break; } if (ZEPHIR_IS_EMPTY(columnSql)) { ZEPHIR_INIT_VAR(_3); object_init_ex(_3, phalcon_db_exception_ce); ZEPHIR_CALL_METHOD(&_0, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "Unrecognized SQLite data type at column ", _0); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/db/dialect/sqlite.zep", 118 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&typeValues, column, "gettypevalues", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(typeValues))) { if (Z_TYPE_P(typeValues) == IS_ARRAY) { ZEPHIR_INIT_VAR(valueSql); ZVAL_STRING(valueSql, "", 1); zephir_is_iterable(typeValues, &_5, &_4, 0, 0, "phalcon/db/dialect/sqlite.zep", 129); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(value, _6); ZEPHIR_SINIT_NVAR(_7); ZVAL_STRING(&_7, "\"", 0); ZEPHIR_CALL_FUNCTION(&_2, "addcslashes", &_8, 143, value, &_7); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "\"", _2, "\", "); zephir_concat_self(&valueSql, _9 TSRMLS_CC); } ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_SINIT_VAR(_10); ZVAL_LONG(&_10, -2); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, valueSql, 0 , -2 , 0); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "(", _3, ")"); zephir_concat_self(&columnSql, _9 TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_10); ZVAL_STRING(&_10, "\"", 0); ZEPHIR_CALL_FUNCTION(&_11, "addcslashes", &_8, 143, typeValues, &_10); zephir_check_call_status(); ZEPHIR_INIT_VAR(_12); ZEPHIR_CONCAT_SVS(_12, "(\"", _11, "\")"); zephir_concat_self(&columnSql, _12 TSRMLS_CC); } } } while(0); RETURN_CCTOR(columnSql); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addColumn) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *column, *sql, *defaultValue = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5, _6, *_7 = NULL, *_8, *_9 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &column); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVS(sql, "ALTER TABLE ", _0, " ADD COLUMN "); ZEPHIR_CALL_METHOD(&_1, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getcolumndefinition", NULL, 0, column); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "\"", _1, "\" ", _2); zephir_concat_self(&sql, _3 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_4)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); zephir_fast_strtoupper(_5, defaultValue); if (zephir_memnstr_str(_5, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/sqlite.zep", 152)) { zephir_concat_self_str(&sql, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_VAR(_6); ZVAL_STRING(&_6, "\"", 0); ZEPHIR_CALL_FUNCTION(&_7, "addcslashes", NULL, 143, defaultValue, &_6); zephir_check_call_status(); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVS(_8, " DEFAULT \"", _7, "\""); zephir_concat_self(&sql, _8 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_7, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_7)) { zephir_concat_self_str(&sql, SL(" NOT NULL") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_9, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_9)) { zephir_concat_self_str(&sql, SL(" PRIMARY KEY AUTOINCREMENT") TSRMLS_CC); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, modifyColumn) { zval *tableName_param = NULL, *schemaName_param = NULL, *column, *currentColumn = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &tableName_param, &schemaName_param, &column, ¤tColumn); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (!currentColumn) { currentColumn = ZEPHIR_GLOBAL(global_null); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Altering a DB column is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 175); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropColumn) { zval *tableName_param = NULL, *schemaName_param = NULL, *columnName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *columnName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &columnName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(columnName_param) != IS_STRING && Z_TYPE_P(columnName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'columnName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(columnName_param) == IS_STRING)) { zephir_get_strval(columnName, columnName_param); } else { ZEPHIR_INIT_VAR(columnName); ZVAL_EMPTY_STRING(columnName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Dropping DB column is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 183); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addIndex) { int ZEPHIR_LAST_CALL_STATUS; zval *tableName_param = NULL, *schemaName_param = NULL, *index, *sql, *indexType = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (!(ZEPHIR_IS_EMPTY(indexType))) { ZEPHIR_CONCAT_SVS(sql, "CREATE ", indexType, " INDEX \""); } else { ZVAL_STRING(sql, "CREATE INDEX \"", 1); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CALL_METHOD(&_0, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSVSVS(_1, schemaName, "\".\"", _0, "\" ON \"", tableName, "\" ("); zephir_concat_self(&sql, _1 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(&_0, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_VSVS(_1, _0, "\" ON \"", tableName, "\" ("); zephir_concat_self(&sql, _1 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_2, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcolumnlist", NULL, 44, _2); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_VS(_1, _0, ")"); zephir_concat_self(&sql, _1 TSRMLS_CC); RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropIndex) { zval *tableName_param = NULL, *schemaName_param = NULL, *indexName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *indexName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &indexName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(indexName_param) != IS_STRING && Z_TYPE_P(indexName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'indexName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(indexName_param) == IS_STRING)) { zephir_get_strval(indexName, indexName_param); } else { ZEPHIR_INIT_VAR(indexName); ZVAL_EMPTY_STRING(indexName); } if (!(!schemaName) && Z_STRLEN_P(schemaName)) { ZEPHIR_CONCAT_SVSVS(return_value, "DROP INDEX \"", schemaName, "\".\"", indexName, "\""); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "DROP INDEX \"", indexName, "\""); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addPrimaryKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *index; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &index); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Adding a primary key after table has been created is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 227); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropPrimaryKey) { zval *tableName_param = NULL, *schemaName_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Removing a primary key after table has been created is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 235); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, addForeignKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *reference; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &reference); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Adding a foreign key constraint to an existing table is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 243); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropForeignKey) { zval *tableName_param = NULL, *schemaName_param = NULL, *referenceName_param = NULL; zval *tableName = NULL, *schemaName = NULL, *referenceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &referenceName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } if (unlikely(Z_TYPE_P(referenceName_param) != IS_STRING && Z_TYPE_P(referenceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceName_param) == IS_STRING)) { zephir_get_strval(referenceName, referenceName_param); } else { ZEPHIR_INIT_VAR(referenceName); ZVAL_EMPTY_STRING(referenceName); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Dropping a foreign key constraint is not supported by SQLite", "phalcon/db/dialect/sqlite.zep", 251); return; } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, createTable) { zephir_fcall_cache_entry *_5 = NULL, *_14 = NULL, *_19 = NULL; HashTable *_1, *_17, *_21; HashPosition _0, _16, _20; int ZEPHIR_LAST_CALL_STATUS; zend_bool hasPrimary, _7, _9; zval *definition = NULL; zval *tableName_param = NULL, *schemaName_param = NULL, *definition_param = NULL, *columns, *table = NULL, *temporary = NULL, *options, *createLines, *columnLine = NULL, *column = NULL, *indexes, *index = NULL, *indexName = NULL, *indexType = NULL, *references, *reference = NULL, *defaultValue = NULL, *referenceSql = NULL, *onDelete = NULL, *onUpdate = NULL, *sql, **_2, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, _12 = zval_used_for_init, *_13 = NULL, *_15 = NULL, **_18, **_22; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &tableName_param, &schemaName_param, &definition_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } definition = definition_param; ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(temporary); ZVAL_BOOL(temporary, 0); ZEPHIR_OBS_VAR(options); if (zephir_array_isset_string_fetch(&options, definition, SS("options"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(temporary); zephir_array_isset_string_fetch(&temporary, options, SS("temporary"), 0 TSRMLS_CC); } ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, definition, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/db/dialect/sqlite.zep", 271); return; } ZEPHIR_INIT_VAR(sql); if (zephir_is_true(temporary)) { ZEPHIR_CONCAT_SVS(sql, "CREATE TEMPORARY TABLE ", table, " (\n\t"); } else { ZEPHIR_CONCAT_SVS(sql, "CREATE TABLE ", table, " (\n\t"); } hasPrimary = 0; ZEPHIR_INIT_VAR(createLines); array_init(createLines); zephir_is_iterable(columns, &_1, &_0, 0, 0, "phalcon/db/dialect/sqlite.zep", 329); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(column, _2); ZEPHIR_CALL_METHOD(&_3, column, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumndefinition", &_5, 0, column); zephir_check_call_status(); ZEPHIR_INIT_NVAR(columnLine); ZEPHIR_CONCAT_SVSV(columnLine, "`", _3, "` ", _4); ZEPHIR_CALL_METHOD(&_6, column, "isprimary", NULL, 0); zephir_check_call_status(); _7 = zephir_is_true(_6); if (_7) { _7 = !hasPrimary; } if (_7) { zephir_concat_self_str(&columnLine, SL(" PRIMARY KEY") TSRMLS_CC); hasPrimary = 1; } ZEPHIR_CALL_METHOD(&_8, column, "isautoincrement", NULL, 0); zephir_check_call_status(); _9 = zephir_is_true(_8); if (_9) { _9 = hasPrimary; } if (_9) { zephir_concat_self_str(&columnLine, SL(" AUTOINCREMENT") TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_10, column, "hasdefault", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_10)) { ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_11); zephir_fast_strtoupper(_11, defaultValue); if (zephir_memnstr_str(_11, SL("CURRENT_TIMESTAMP"), "phalcon/db/dialect/sqlite.zep", 309)) { zephir_concat_self_str(&columnLine, SL(" DEFAULT CURRENT_TIMESTAMP") TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_12); ZVAL_STRING(&_12, "\"", 0); ZEPHIR_CALL_FUNCTION(&_13, "addcslashes", &_14, 143, defaultValue, &_12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SVS(_15, " DEFAULT \"", _13, "\""); zephir_concat_self(&columnLine, _15 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_13, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_13)) { zephir_concat_self_str(&columnLine, SL(" NOT NULL") TSRMLS_CC); } zephir_array_append(&createLines, columnLine, PH_SEPARATE, "phalcon/db/dialect/sqlite.zep", 323); } ZEPHIR_OBS_VAR(indexes); if (zephir_array_isset_string_fetch(&indexes, definition, SS("indexes"), 0 TSRMLS_CC)) { zephir_is_iterable(indexes, &_17, &_16, 0, 0, "phalcon/db/dialect/sqlite.zep", 345); for ( ; zephir_hash_get_current_data_ex(_17, (void**) &_18, &_16) == SUCCESS ; zephir_hash_move_forward_ex(_17, &_16) ) { ZEPHIR_GET_HVALUE(index, _18); ZEPHIR_CALL_METHOD(&indexName, index, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&indexType, index, "gettype", NULL, 0); zephir_check_call_status(); _7 = ZEPHIR_IS_STRING(indexName, "PRIMARY"); if (_7) { _7 = !hasPrimary; } _9 = !(ZEPHIR_IS_EMPTY(indexType)); if (_9) { ZEPHIR_INIT_NVAR(_11); zephir_fast_strtoupper(_11, indexType); _9 = zephir_memnstr_str(_11, SL("UNIQUE"), "phalcon/db/dialect/sqlite.zep", 341); } if (_7) { ZEPHIR_CALL_METHOD(&_4, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcolumnlist", &_19, 44, _4); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SVS(_15, "PRIMARY KEY (", _3, ")"); zephir_array_append(&createLines, _15, PH_SEPARATE, "phalcon/db/dialect/sqlite.zep", 340); } else if (_9) { ZEPHIR_CALL_METHOD(&_8, index, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, this_ptr, "getcolumnlist", &_19, 44, _8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SVS(_15, "UNIQUE (", _6, ")"); zephir_array_append(&createLines, _15, PH_SEPARATE, "phalcon/db/dialect/sqlite.zep", 342); } } } ZEPHIR_OBS_VAR(references); if (zephir_array_isset_string_fetch(&references, definition, SS("references"), 0 TSRMLS_CC)) { zephir_is_iterable(references, &_21, &_20, 0, 0, "phalcon/db/dialect/sqlite.zep", 367); for ( ; zephir_hash_get_current_data_ex(_21, (void**) &_22, &_20) == SUCCESS ; zephir_hash_move_forward_ex(_21, &_20) ) { ZEPHIR_GET_HVALUE(reference, _22); ZEPHIR_CALL_METHOD(&_3, reference, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, reference, "getcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, this_ptr, "getcolumnlist", &_19, 44, _6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, reference, "getreferencedtable", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_13, reference, "getreferencedcolumns", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_10, this_ptr, "getcolumnlist", &_19, 44, _13); zephir_check_call_status(); ZEPHIR_INIT_NVAR(referenceSql); ZEPHIR_CONCAT_SVSVSSVSVS(referenceSql, "CONSTRAINT `", _3, "` FOREIGN KEY (", _4, ")", " REFERENCES `", _8, "`(", _10, ")"); ZEPHIR_CALL_METHOD(&onDelete, reference, "getondelete", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onDelete))) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SV(_15, " ON DELETE ", onDelete); zephir_concat_self(&referenceSql, _15 TSRMLS_CC); } ZEPHIR_CALL_METHOD(&onUpdate, reference, "getonupdate", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(onUpdate))) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SV(_15, " ON UPDATE ", onUpdate); zephir_concat_self(&referenceSql, _15 TSRMLS_CC); } zephir_array_append(&createLines, referenceSql, PH_SEPARATE, "phalcon/db/dialect/sqlite.zep", 365); } } ZEPHIR_INIT_NVAR(_11); zephir_fast_join_str(_11, SL(",\n\t"), createLines TSRMLS_CC); ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_VS(_15, _11, "\n)"); zephir_concat_self(&sql, _15 TSRMLS_CC); RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropTable) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *tableName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *sql, *table = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &tableName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&table, this_ptr, "preparetable", NULL, 0, tableName, schemaName); zephir_check_call_status(); ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SV(sql, "DROP TABLE IF EXISTS ", table); } else { ZEPHIR_CONCAT_SV(sql, "DROP TABLE ", table); } RETURN_CCTOR(sql); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, createView) { int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *viewName_param = NULL, *definition_param = NULL, *schemaName_param = NULL, *viewSql, *_0 = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &viewName_param, &definition_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } definition = definition_param; if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_OBS_VAR(viewSql); if (!(zephir_array_isset_string_fetch(&viewSql, definition, SS("sql"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'sql' is required in the definition array", "phalcon/db/dialect/sqlite.zep", 400); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); ZEPHIR_CONCAT_SVSV(return_value, "CREATE VIEW ", _0, " AS ", viewSql); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropView) { int ZEPHIR_LAST_CALL_STATUS; zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *view = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } ZEPHIR_CALL_METHOD(&view, this_ptr, "preparetable", NULL, 0, viewName, schemaName); zephir_check_call_status(); if (ifExists) { ZEPHIR_CONCAT_SV(return_value, "DROP VIEW IF EXISTS ", view); RETURN_MM(); } ZEPHIR_CONCAT_SV(return_value, "DROP VIEW ", view); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, tableExists) { zval *tableName_param = NULL, *schemaName_param = NULL; zval *tableName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &tableName_param, &schemaName_param); if (unlikely(Z_TYPE_P(tableName_param) != IS_STRING && Z_TYPE_P(tableName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tableName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tableName_param) == IS_STRING)) { zephir_get_strval(tableName, tableName_param); } else { ZEPHIR_INIT_VAR(tableName); ZVAL_EMPTY_STRING(tableName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM sqlite_master WHERE type='table' AND tbl_name='", tableName, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, viewExists) { zval *viewName_param = NULL, *schemaName_param = NULL; zval *viewName = NULL, *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewName_param, &schemaName_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } ZEPHIR_CONCAT_SVS(return_value, "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM sqlite_master WHERE type='view' AND tbl_name='", viewName, "'"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeColumns) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CONCAT_SVS(return_value, "PRAGMA table_info('", table, "')"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, listTables) { zval *schemaName_param = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } RETURN_MM_STRING("SELECT tbl_name FROM sqlite_master WHERE type = 'table' ORDER BY tbl_name", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, listViews) { zval *schemaName_param = NULL; zval *schemaName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &schemaName_param); if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { if (unlikely(Z_TYPE_P(schemaName_param) != IS_STRING && Z_TYPE_P(schemaName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schemaName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schemaName_param) == IS_STRING)) { zephir_get_strval(schemaName, schemaName_param); } else { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } } RETURN_MM_STRING("SELECT tbl_name FROM sqlite_master WHERE type = 'view' ORDER BY tbl_name", 1); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeIndexes) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CONCAT_SVS(return_value, "PRAGMA index_list('", table, "')"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeIndex) { zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } ZEPHIR_CONCAT_SVS(return_value, "PRAGMA index_info('", index, "')"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, describeReferences) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } ZEPHIR_CONCAT_SVS(return_value, "PRAGMA foreign_key_list('", table, "')"); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Dialect_Sqlite, tableOptions) { zval *table_param = NULL, *schema_param = NULL; zval *table = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &table_param, &schema_param); if (unlikely(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(table_param) == IS_STRING)) { zephir_get_strval(table, table_param); } else { ZEPHIR_INIT_VAR(table); ZVAL_EMPTY_STRING(table); } if (!schema_param) { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } else { zephir_get_strval(schema, schema_param); } RETURN_MM_STRING("", 1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Profiler_Item) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db\\Profiler, Item, phalcon, db_profiler_item, phalcon_db_profiler_item_method_entry, 0); zend_declare_property_null(phalcon_db_profiler_item_ce, SL("_sqlStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_profiler_item_ce, SL("_sqlVariables"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_profiler_item_ce, SL("_sqlBindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_profiler_item_ce, SL("_initialTime"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_profiler_item_ce, SL("_finalTime"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlStatement) { zval *sqlStatement_param = NULL; zval *sqlStatement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlStatement_param); zephir_get_strval(sqlStatement, sqlStatement_param); zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlStatement) { RETURN_MEMBER(this_ptr, "_sqlStatement"); } static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlVariables) { zval *sqlVariables_param = NULL; zval *sqlVariables = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlVariables_param); zephir_get_arrval(sqlVariables, sqlVariables_param); zephir_update_property_this(this_ptr, SL("_sqlVariables"), sqlVariables TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlVariables) { RETURN_MEMBER(this_ptr, "_sqlVariables"); } static PHP_METHOD(Phalcon_Db_Profiler_Item, setSqlBindTypes) { zval *sqlBindTypes_param = NULL; zval *sqlBindTypes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sqlBindTypes_param); zephir_get_arrval(sqlBindTypes, sqlBindTypes_param); zephir_update_property_this(this_ptr, SL("_sqlBindTypes"), sqlBindTypes TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getSqlBindTypes) { RETURN_MEMBER(this_ptr, "_sqlBindTypes"); } static PHP_METHOD(Phalcon_Db_Profiler_Item, setInitialTime) { zval *initialTime_param = NULL, *_0; double initialTime; zephir_fetch_params(0, 1, 0, &initialTime_param); initialTime = zephir_get_doubleval(initialTime_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_DOUBLE(_0, initialTime); zephir_update_property_this(this_ptr, SL("_initialTime"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getInitialTime) { RETURN_MEMBER(this_ptr, "_initialTime"); } static PHP_METHOD(Phalcon_Db_Profiler_Item, setFinalTime) { zval *finalTime_param = NULL, *_0; double finalTime; zephir_fetch_params(0, 1, 0, &finalTime_param); finalTime = zephir_get_doubleval(finalTime_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_DOUBLE(_0, finalTime); zephir_update_property_this(this_ptr, SL("_finalTime"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getFinalTime) { RETURN_MEMBER(this_ptr, "_finalTime"); } static PHP_METHOD(Phalcon_Db_Profiler_Item, getTotalElapsedSeconds) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finalTime"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_initialTime"), PH_NOISY_CC); zephir_sub_function(return_value, _0, _1); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include <ext/pdo/php_pdo_driver.h> ZEPHIR_INIT_CLASS(Phalcon_Db_Result_Pdo) { ZEPHIR_REGISTER_CLASS(Phalcon\\Db\\Result, Pdo, phalcon, db_result_pdo, phalcon_db_result_pdo_method_entry, 0); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_connection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_result"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_result_pdo_ce, SL("_fetchMode"), 5, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_pdoStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_sqlStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_bindParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_bindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_result_pdo_ce, SL("_rowCount"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_db_result_pdo_ce TSRMLS_CC, 1, phalcon_db_resultinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Db_Result_Pdo, __construct) { zval *connection, *result, *sqlStatement = NULL, *bindParams = NULL, *bindTypes = NULL; zephir_fetch_params(0, 2, 3, &connection, &result, &sqlStatement, &bindParams, &bindTypes); if (!sqlStatement) { sqlStatement = ZEPHIR_GLOBAL(global_null); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_connection"), connection TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_pdoStatement"), result TSRMLS_CC); if (Z_TYPE_P(sqlStatement) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_sqlStatement"), sqlStatement TSRMLS_CC); } if (Z_TYPE_P(bindParams) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_bindParams"), bindParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_bindTypes"), bindTypes TSRMLS_CC); } } static PHP_METHOD(Phalcon_Db_Result_Pdo, execute) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "execute", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Result_Pdo, fetch) { int ZEPHIR_LAST_CALL_STATUS; zval *fetchStyle = NULL, *cursorOrientation = NULL, *cursorOffset = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &fetchStyle, &cursorOrientation, &cursorOffset); if (!fetchStyle) { fetchStyle = ZEPHIR_GLOBAL(global_null); } if (!cursorOrientation) { cursorOrientation = ZEPHIR_GLOBAL(global_null); } if (!cursorOffset) { cursorOffset = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "fetch", NULL, 0, fetchStyle, cursorOrientation, cursorOffset); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Result_Pdo, fetchArray) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "fetch", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Result_Pdo, fetchAll) { int ZEPHIR_LAST_CALL_STATUS; zval *fetchStyle = NULL, *fetchArgument = NULL, *ctorArgs = NULL, *pdoStatement; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &fetchStyle, &fetchArgument, &ctorArgs); if (!fetchStyle) { fetchStyle = ZEPHIR_GLOBAL(global_null); } if (!fetchArgument) { fetchArgument = ZEPHIR_GLOBAL(global_null); } if (!ctorArgs) { ctorArgs = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(pdoStatement); zephir_read_property_this(&pdoStatement, this_ptr, SL("_pdoStatement"), PH_NOISY_CC); if (Z_TYPE_P(fetchStyle) == IS_LONG) { if (ZEPHIR_IS_LONG(fetchStyle, 8)) { ZEPHIR_RETURN_CALL_METHOD(pdoStatement, "fetchall", NULL, 0, fetchStyle, fetchArgument, ctorArgs); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_LONG(fetchStyle, 7)) { ZEPHIR_RETURN_CALL_METHOD(pdoStatement, "fetchall", NULL, 0, fetchStyle, fetchArgument); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_LONG(fetchStyle, 10)) { ZEPHIR_RETURN_CALL_METHOD(pdoStatement, "fetchall", NULL, 0, fetchStyle, fetchArgument); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(pdoStatement, "fetchall", NULL, 0, fetchStyle); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(pdoStatement, "fetchall", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Db_Result_Pdo, numRows) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *sqlStatement, *rowCount = NULL, *connection, *type = NULL, *pdoStatement, *matches, *result = NULL, *row = NULL, *_1, _2, *_3, *_4, *_5, *_6; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(rowCount); zephir_read_property_this(&rowCount, this_ptr, SL("_rowCount"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(rowCount)) { ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&type, connection, "gettype", NULL, 0); zephir_check_call_status(); _0 = ZEPHIR_IS_STRING(type, "mysql"); if (!(_0)) { _0 = ZEPHIR_IS_STRING(type, "pgsql"); } if (_0) { ZEPHIR_OBS_VAR(pdoStatement); zephir_read_property_this(&pdoStatement, this_ptr, SL("_pdoStatement"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&rowCount, pdoStatement, "rowcount", NULL, 0); zephir_check_call_status(); } if (ZEPHIR_IS_FALSE_IDENTICAL(rowCount)) { ZEPHIR_OBS_VAR(sqlStatement); zephir_read_property_this(&sqlStatement, this_ptr, SL("_sqlStatement"), PH_NOISY_CC); if (!(zephir_start_with_str(sqlStatement, SL("SELECT COUNT(*) ")))) { ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "/^SELECT\\s+(.*)/i", 0); zephir_preg_match(_1, &_2, sqlStatement, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { zephir_array_fetch_long(&_3, matches, 1, PH_NOISY | PH_READONLY, "phalcon/db/result/pdo.zep", 217 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVS(_4, "SELECT COUNT(*) \"numrows\" FROM (SELECT ", _3, ")"); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&result, connection, "query", NULL, 0, _4, _5, _6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&row, result, "fetch", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(rowCount); zephir_array_fetch_string(&rowCount, row, SL("numrows"), PH_NOISY, "phalcon/db/result/pdo.zep", 219 TSRMLS_CC); } } else { ZEPHIR_INIT_NVAR(rowCount); ZVAL_LONG(rowCount, 1); } } zephir_update_property_this(this_ptr, SL("_rowCount"), rowCount TSRMLS_CC); } RETURN_CCTOR(rowCount); } static PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek) { int ZEPHIR_LAST_CALL_STATUS; zval *number_param = NULL, *connection, *pdo = NULL, *sqlStatement, *bindParams, *statement = NULL, *_0 = NULL, *_1; long number; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &number_param); number = zephir_get_intval(number_param); { pdo_stmt_t *stmt; long n; ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&pdo, connection, "getinternalhandler", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(sqlStatement); zephir_read_property_this(&sqlStatement, this_ptr, SL("_sqlStatement"), PH_NOISY_CC); ZEPHIR_OBS_VAR(bindParams); zephir_read_property_this(&bindParams, this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&statement, pdo, "prepare", NULL, 0, sqlStatement); zephir_check_call_status(); if (Z_TYPE_P(statement) == IS_OBJECT) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, connection, "executeprepared", NULL, 0, statement, bindParams, _1); zephir_check_call_status(); ZEPHIR_CPY_WRT(statement, _0); } } else { ZEPHIR_CALL_METHOD(&statement, pdo, "query", NULL, 0, sqlStatement); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_pdoStatement"), statement TSRMLS_CC); stmt = (pdo_stmt_t*) zend_object_store_get_object(statement TSRMLS_CC); if (!stmt->dbh) { ZEPHIR_MM_RESTORE(); RETURN_FALSE; } n = -1; number--; while (n != number) { if (!stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) { ZEPHIR_MM_RESTORE(); RETURN_NULL(); } n++; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Db_Result_Pdo, setFetchMode) { zval *fetchMode_param = NULL, *colNoOrClassNameOrObject = NULL, *ctorargs = NULL, *pdoStatement, *_0 = NULL, *_1 = NULL, *_2; int fetchMode, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &fetchMode_param, &colNoOrClassNameOrObject, &ctorargs); fetchMode = zephir_get_intval(fetchMode_param); if (!colNoOrClassNameOrObject) { colNoOrClassNameOrObject = ZEPHIR_GLOBAL(global_null); } if (!ctorargs) { ctorargs = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(pdoStatement); zephir_read_property_this(&pdoStatement, this_ptr, SL("_pdoStatement"), PH_NOISY_CC); if (fetchMode == 8) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, fetchMode); ZEPHIR_CALL_METHOD(&_0, pdoStatement, "setfetchmode", NULL, 0, _1, colNoOrClassNameOrObject, ctorargs); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_ZVAL_NREF(_2); ZVAL_LONG(_2, fetchMode); zephir_update_property_this(this_ptr, SL("_fetchMode"), _2 TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } if (fetchMode == 9) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, fetchMode); ZEPHIR_CALL_METHOD(&_0, pdoStatement, "setfetchmode", NULL, 0, _1, colNoOrClassNameOrObject); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_ZVAL_NREF(_2); ZVAL_LONG(_2, fetchMode); zephir_update_property_this(this_ptr, SL("_fetchMode"), _2 TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } if (fetchMode == 7) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, fetchMode); ZEPHIR_CALL_METHOD(&_0, pdoStatement, "setfetchmode", NULL, 0, _1, colNoOrClassNameOrObject); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_ZVAL_NREF(_2); ZVAL_LONG(_2, fetchMode); zephir_update_property_this(this_ptr, SL("_fetchMode"), _2 TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, fetchMode); ZEPHIR_CALL_METHOD(&_0, pdoStatement, "setfetchmode", NULL, 0, _1); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_ZVAL_NREF(_2); ZVAL_LONG(_2, fetchMode); zephir_update_property_this(this_ptr, SL("_fetchMode"), _2 TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Db_Result_Pdo, getInternalResult) { RETURN_MEMBER(this_ptr, "_pdoStatement"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Debug_Dump) { ZEPHIR_REGISTER_CLASS(Phalcon\\Debug, Dump, phalcon, debug_dump, phalcon_debug_dump_method_entry, 0); zend_declare_property_bool(phalcon_debug_dump_ce, SL("_detailed"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_debug_dump_ce, SL("_methods"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_debug_dump_ce, SL("_styles"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Debug_Dump, getDetailed) { RETURN_MEMBER(this_ptr, "_detailed"); } static PHP_METHOD(Phalcon_Debug_Dump, setDetailed) { zval *detailed; zephir_fetch_params(0, 1, 0, &detailed); zephir_update_property_this(this_ptr, SL("_detailed"), detailed TSRMLS_CC); } static PHP_METHOD(Phalcon_Debug_Dump, __construct) { int ZEPHIR_LAST_CALL_STATUS; zend_bool detailed, _0; zval *styles_param = NULL, *detailed_param = NULL, *_1; zval *styles = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &styles_param, &detailed_param); if (!styles_param) { ZEPHIR_INIT_VAR(styles); array_init(styles); } else { zephir_get_arrval(styles, styles_param); } if (!detailed_param) { detailed = 0; } else { detailed = zephir_get_boolval(detailed_param); } _0 = zephir_is_true(styles); if (_0) { _0 = 1 != 1; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_debug_exception_ce, "The styles must be an array", "phalcon/debug/dump.zep", 56); return; } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstyles", NULL, 0, styles); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_methods"), _1 TSRMLS_CC); if (detailed) { zephir_update_property_this(this_ptr, SL("_detailed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_detailed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Debug_Dump, all) { zval *_1, *_2 = NULL; zval *_0; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "variables", 1); zephir_array_fast_append(_0, _1); ZEPHIR_CALL_FUNCTION(&_2, "func_get_args", NULL, 167); zephir_check_call_status(); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _0, _2); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug_Dump, getStyle) { zval *type_param = NULL, *style, *_0; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_styles"), PH_NOISY_CC); if (zephir_array_isset_fetch(&style, _0, type, 1 TSRMLS_CC)) { RETURN_CTOR(style); } else { RETURN_MM_STRING("color:gray", 1); } } static PHP_METHOD(Phalcon_Debug_Dump, setStyles) { zval *styles = NULL, *defaultStyles, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &styles); if (!styles) { ZEPHIR_CPY_WRT(styles, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(styles); } if (Z_TYPE_P(styles) == IS_NULL) { ZEPHIR_INIT_NVAR(styles); array_init(styles); } if (Z_TYPE_P(styles) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_debug_exception_ce, "The styles must be an array", "phalcon/debug/dump.zep", 100); return; } ZEPHIR_INIT_VAR(defaultStyles); zephir_create_array(defaultStyles, 11, 0 TSRMLS_CC); add_assoc_stringl_ex(defaultStyles, SS("pre"), SL("background-color:#f3f3f3; font-size:11px; padding:10px; border:1px solid #ccc; text-align:left; color:#333"), 1); add_assoc_stringl_ex(defaultStyles, SS("arr"), SL("color:red"), 1); add_assoc_stringl_ex(defaultStyles, SS("bool"), SL("color:green"), 1); add_assoc_stringl_ex(defaultStyles, SS("float"), SL("color:fuchsia"), 1); add_assoc_stringl_ex(defaultStyles, SS("int"), SL("color:blue"), 1); add_assoc_stringl_ex(defaultStyles, SS("null"), SL("color:black"), 1); add_assoc_stringl_ex(defaultStyles, SS("num"), SL("color:navy"), 1); add_assoc_stringl_ex(defaultStyles, SS("obj"), SL("color:purple"), 1); add_assoc_stringl_ex(defaultStyles, SS("other"), SL("color:maroon"), 1); add_assoc_stringl_ex(defaultStyles, SS("res"), SL("color:lime"), 1); add_assoc_stringl_ex(defaultStyles, SS("str"), SL("color:teal"), 1); ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(defaultStyles), &(styles) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_styles"), _0 TSRMLS_CC); RETURN_MM_MEMBER(this_ptr, "_styles"); } static PHP_METHOD(Phalcon_Debug_Dump, one) { int ZEPHIR_LAST_CALL_STATUS; zval *name = NULL; zval *variable, *name_param = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &variable, &name_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { zephir_get_strval(name, name_param); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "variable", NULL, 0, variable, name); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug_Dump, output) { zend_bool _15, _16, _17; HashTable *_8, *_25, *_36; HashPosition _7, _24, _35; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_11 = NULL, *_20 = NULL, *_22 = NULL, *_29 = NULL, *_30 = NULL, *_31 = NULL, *_33 = NULL; zval *_1 = NULL, *_12 = NULL, *_38 = NULL; int tab, ZEPHIR_LAST_CALL_STATUS; zval *name = NULL, *_0; zval *variable, *name_param = NULL, *tab_param = NULL, *key = NULL, *value = NULL, *output = NULL, *space, *type = NULL, *attr = NULL, *_2 = NULL, *_3 = NULL, _5 = zval_used_for_init, **_9, *_10 = NULL, *_13 = NULL, *_14 = NULL, *_18 = NULL, *_19 = NULL, *_21 = NULL, *_23, **_26, *_27 = NULL, *_28 = NULL, *_32, *_34, **_37, *_39 = NULL, _40; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &variable, &name_param, &tab_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { zephir_get_strval(name, name_param); } if (!tab_param) { tab = 1; } else { tab = zephir_get_intval(tab_param); } ZEPHIR_INIT_VAR(space); ZVAL_STRING(space, " ", 1); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); if (!(!name) && Z_STRLEN_P(name)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VS(_0, name, " "); ZEPHIR_CPY_WRT(output, _0); } if (Z_TYPE_P(variable) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "arr", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_1, SS(":count"), zephir_fast_count_int(variable TSRMLS_CC)); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "<b style =':style'>Array</b> (<span style =':style'>:count</span>) (\n", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); zephir_concat_self(&output, _2 TSRMLS_CC); zephir_is_iterable(variable, &_8, &_7, 0, 0, "phalcon/debug/dump.zep", 154); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(key, _8, _7); ZEPHIR_GET_HVALUE(value, _9); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "arr", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_13, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_12, SL(":key"), &key, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "[<span style=':style'>:key</span>] => ", 0); ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, _10, _13); zephir_concat_self(&output, _14 TSRMLS_CC); _15 = tab == 1; if (_15) { _15 = !ZEPHIR_IS_STRING(name, ""); } _16 = _15; if (_16) { _16 = !(Z_TYPE_P(key) == IS_LONG); } _17 = _16; if (_17) { _17 = ZEPHIR_IS_EQUAL(name, key); } if (_17) { continue; } else { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_19); ZVAL_LONG(_19, (tab + 1)); ZEPHIR_CALL_METHOD(&_18, this_ptr, "output", &_20, 168, value, _3, _19); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_VS(_21, _18, "\n"); zephir_concat_self(&output, _21 TSRMLS_CC); } } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, (tab - 1)); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_CONCAT_VVS(return_value, output, _10, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); zephir_get_class(_3, variable, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL(":class"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>Object</b> :class", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); zephir_concat_self(&output, _2 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_13, "get_parent_class", &_22, 169, variable); zephir_check_call_status(); if (zephir_is_true(_13)) { ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_18, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_18, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_18, "get_parent_class", &_22, 169, variable); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":parent"), &_18, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, " <b style=':style'>extends</b> :parent", 0); ZEPHIR_CALL_FUNCTION(&_18, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); zephir_concat_self(&output, _18 TSRMLS_CC); } zephir_concat_self_str(&output, SL(" (\n") TSRMLS_CC); _23 = zephir_fetch_nproperty_this(this_ptr, SL("_detailed"), PH_NOISY_CC); if (!(zephir_is_true(_23))) { ZEPHIR_CALL_FUNCTION(&_10, "get_object_vars", NULL, 24, variable); zephir_check_call_status(); zephir_is_iterable(_10, &_25, &_24, 0, 0, "phalcon/debug/dump.zep", 171); for ( ; zephir_hash_get_current_data_ex(_25, (void**) &_26, &_24) == SUCCESS ; zephir_hash_move_forward_ex(_25, &_24) ) { ZEPHIR_GET_HMKEY(key, _25, _24); ZEPHIR_GET_HVALUE(value, _26); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_13, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_27, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_27, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_12, SL(":key"), &key, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_12, SS(":type"), SL("public"), 1); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "-><span style=':style'>:key</span> (<span style=':style'>:type</span>) = ", 0); ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, _13, _27); zephir_concat_self(&output, _14 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_19); ZVAL_LONG(_19, (tab + 1)); ZEPHIR_CALL_METHOD(&_28, this_ptr, "output", &_20, 168, value, _3, _19); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_VS(_21, _28, "\n"); zephir_concat_self(&output, _21 TSRMLS_CC); } } else { do { ZEPHIR_MAKE_REF(variable); ZEPHIR_CALL_FUNCTION(&attr, "each", &_29, 170, variable); ZEPHIR_UNREF(variable); zephir_check_call_status(); if (!(zephir_is_true(attr))) { continue; } ZEPHIR_OBS_NVAR(key); zephir_array_fetch_string(&key, attr, SL("key"), PH_NOISY, "phalcon/debug/dump.zep", 180 TSRMLS_CC); ZEPHIR_OBS_NVAR(value); zephir_array_fetch_string(&value, attr, SL("value"), PH_NOISY, "phalcon/debug/dump.zep", 181 TSRMLS_CC); if (!(zephir_is_true(key))) { continue; } ZEPHIR_INIT_NVAR(_3); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "\\x00", 0); ZEPHIR_CALL_FUNCTION(&_10, "ord", &_30, 133, &_5); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_13, "chr", &_31, 131, _10); zephir_check_call_status(); zephir_fast_explode(_3, _13, key, LONG_MAX TSRMLS_CC); ZEPHIR_CPY_WRT(key, _3); ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "public", 1); if (zephir_array_isset_long(key, 1)) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "private", 1); zephir_array_fetch_long(&_32, key, 1, PH_NOISY | PH_READONLY, "phalcon/debug/dump.zep", 193 TSRMLS_CC); if (ZEPHIR_IS_STRING(_32, "*")) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "protected", 1); } } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_18, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_27, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_27, PH_COPY | PH_SEPARATE); ZEPHIR_MAKE_REF(key); ZEPHIR_CALL_FUNCTION(&_27, "end", &_33, 171, key); ZEPHIR_UNREF(key); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":key"), &_27, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_12, SL(":type"), &type, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "-><span style=':style'>:key</span> (<span style=':style'>:type</span>) = ", 0); ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, _18, _27); zephir_concat_self(&output, _14 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_19); ZVAL_LONG(_19, (tab + 1)); ZEPHIR_CALL_METHOD(&_28, this_ptr, "output", &_20, 168, value, _3, _19); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_VS(_21, _28, "\n"); zephir_concat_self(&output, _21 TSRMLS_CC); } while (zephir_is_true(attr)); } ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", NULL, 172, variable); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_13, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); zephir_get_class(_3, variable, 0 TSRMLS_CC); zephir_array_update_string(&_12, SL(":class"), &_3, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_12, SS(":count"), zephir_fast_count_int(attr TSRMLS_CC)); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, ":class <b style=':style'>methods</b>: (<span style=':style'>:count</span>) (\n", 0); ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, _10, _13); zephir_concat_self(&output, _14 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); zephir_get_class(_3, variable, 0 TSRMLS_CC); _34 = zephir_fetch_nproperty_this(this_ptr, SL("_methods"), PH_NOISY_CC); if (zephir_fast_in_array(_3, _34 TSRMLS_CC)) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_18, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_VS(_21, _18, "[already listed]\n"); zephir_concat_self(&output, _21 TSRMLS_CC); } else { zephir_is_iterable(attr, &_36, &_35, 0, 0, "phalcon/debug/dump.zep", 219); for ( ; zephir_hash_get_current_data_ex(_36, (void**) &_37, &_35) == SUCCESS ; zephir_hash_move_forward_ex(_36, &_35) ) { ZEPHIR_GET_HVALUE(value, _37); ZEPHIR_INIT_NVAR(_19); zephir_get_class(_19, variable, 0 TSRMLS_CC); zephir_update_property_array_append(this_ptr, SL("_methods"), _19 TSRMLS_CC); if (ZEPHIR_IS_STRING(value, "__construct")) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, (tab + 1)); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_19); ZVAL_STRING(_19, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13, this_ptr, "getstyle", &_4, 0, _19); zephir_check_temp_parameter(_19); zephir_check_call_status(); zephir_array_update_string(&_12, SL(":style"), &_13, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_12, SL(":method"), &value, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "-><span style=':style'>:method</span>(); [<b style=':style'>constructor</b>]\n", 0); ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_6, 54, &_5, _12); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, _10, _13); zephir_concat_self(&output, _14 TSRMLS_CC); } else { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, (tab + 1)); ZEPHIR_CALL_FUNCTION(&_27, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_38); zephir_create_array(_38, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_19); ZVAL_STRING(_19, "obj", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_28, this_ptr, "getstyle", &_4, 0, _19); zephir_check_temp_parameter(_19); zephir_check_call_status(); zephir_array_update_string(&_38, SL(":style"), &_28, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_38, SL(":method"), &value, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "-><span style=':style'>:method</span>();\n", 0); ZEPHIR_CALL_FUNCTION(&_28, "strtr", &_6, 54, &_5, _38); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_39); ZEPHIR_CONCAT_VV(_39, _27, _28); zephir_concat_self(&output, _39 TSRMLS_CC); } } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, tab); ZEPHIR_CALL_FUNCTION(&_18, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_VS(_21, _18, ")\n"); zephir_concat_self(&output, _21 TSRMLS_CC); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, (tab - 1)); ZEPHIR_CALL_FUNCTION(&_10, "str_repeat", &_11, 132, space, &_5); zephir_check_call_status(); ZEPHIR_CONCAT_VVS(return_value, output, _10, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_LONG) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "int", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>Integer</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _2); RETURN_MM(); } ZEPHIR_CALL_FUNCTION(&_2, "is_float", NULL, 173, variable); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "float", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_13, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_13, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>Float</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _13); RETURN_MM(); } if (zephir_is_numeric(variable)) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "num", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_1, SS(":length"), zephir_fast_strlen_ev(variable)); zephir_array_update_string(&_1, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>Numeric string</b> (<span style=':style'>:length</span>) \"<span style=':style'>:var</span>\"", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _2); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_STRING) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "str", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_1, SS(":length"), zephir_fast_strlen_ev(variable)); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 4); ZEPHIR_SINIT_VAR(_40); ZVAL_STRING(&_40, "utf-8", 0); ZEPHIR_CALL_FUNCTION(&_2, "htmlentities", NULL, 153, variable, &_5, &_40); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_27, "nl2br", NULL, 174, _2); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":var"), &_27, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>String</b> (<span style=':style'>:length</span>) \"<span style=':style'>:var</span>\"", 0); ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _27); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_BOOL) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "bool", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_LNVAR(_14); if (zephir_is_true(variable)) { ZEPHIR_INIT_NVAR(_14); ZVAL_STRING(_14, "TRUE", 1); } else { ZEPHIR_INIT_NVAR(_14); ZVAL_STRING(_14, "FALSE", 1); } zephir_array_update_string(&_1, SL(":var"), &_14, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>Boolean</b> (<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _2); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_NULL) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "null", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "<b style=':style'>NULL</b>", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _2); RETURN_MM(); } ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "other", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getstyle", &_4, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL(":style"), &_2, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL(":var"), &variable, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "(<span style=':style'>:var</span>)", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_6, 54, &_5, _1); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _2); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug_Dump, variable) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; zval *name = NULL; zval *variable, *name_param = NULL, *_1 = NULL, *_2, _3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &variable, &name_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { zephir_get_strval(name, name_param); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "pre", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "output", NULL, 0, variable, name); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":output"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "<pre style=':style'>:output</pre>", 0); ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 54, &_3, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Debug_Dump, variables) { zephir_fcall_cache_entry *_6 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *key = NULL, *value = NULL, *output, *_0 = NULL, **_3, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); ZEPHIR_CALL_FUNCTION(&_0, "func_get_args", NULL, 167); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/debug/dump.zep", 290); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SV(_5, "var ", key); ZEPHIR_CALL_METHOD(&_4, this_ptr, "one", &_6, 0, value, _5); zephir_check_call_status(); zephir_concat_self(&output, _4 TSRMLS_CC); } RETURN_CCTOR(output); } static PHP_METHOD(Phalcon_Debug_Dump, toJson) { zval *variable, _0; zephir_fetch_params(0, 1, 0, &variable); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, ((128 | 64) | 256)); zephir_json_encode(return_value, &(return_value), variable, zephir_get_intval(&_0) TSRMLS_CC); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Debug_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Debug, Exception, phalcon, debug_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, Exception, phalcon, di_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, FactoryDefault, phalcon, di_factorydefault, phalcon_di_ce, phalcon_di_factorydefault_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Di_FactoryDefault, __construct) { zval *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL; zval *_1; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_ce, this_ptr, "__construct", &_0, 76); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 21, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("router"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("dispatcher"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("url"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\MetaData\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsMetadata"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("response"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "cookies", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Response\\Cookies", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("cookies"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("request"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("filter"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("escaper"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("security"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("crypt"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Annotations\\Adapter\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("annotations"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "flash", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Flash\\Direct", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("flash"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "flashSession", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Flash\\Session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("flashSession"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "tag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Tag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("tag"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Session\\Adapter\\Files", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("session"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "sessionBag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Session\\Bag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("sessionBag"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "eventsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Events\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("eventsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "transactionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Transaction\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("transactionManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "assets", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Assets\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("assets"), &_2, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_services"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_Injectable) { ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Injectable, phalcon, di_injectable, phalcon_di_injectable_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_di_injectable_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_injectable_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_di_injectable_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_di_injectable_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Di_Injectable, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Di_Injectable, getDI) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *dependencyInjector = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); } RETURN_CCTOR(dependencyInjector); } static PHP_METHOD(Phalcon_Di_Injectable, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Di_Injectable, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Di_Injectable, __get) { zval *_4; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *propertyName_param = NULL, *dependencyInjector = NULL, *service = NULL, *persistent = NULL, *_0, *_2 = NULL, *_3 = NULL, *_5 = NULL; zval *propertyName = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &propertyName_param); if (unlikely(Z_TYPE_P(propertyName_param) != IS_STRING && Z_TYPE_P(propertyName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'propertyName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(propertyName_param) == IS_STRING)) { zephir_get_strval(propertyName, propertyName_param); } else { ZEPHIR_INIT_VAR(propertyName); ZVAL_EMPTY_STRING(propertyName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "A dependency injection object is required to access the application services", "phalcon/di/injectable.zep", 127); return; } } ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "has", NULL, 0, propertyName); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_CALL_METHOD(&service, dependencyInjector, "getshared", NULL, 0, propertyName); zephir_check_call_status(); zephir_update_property_zval_zval(this_ptr, propertyName, service TSRMLS_CC); RETURN_CCTOR(service); } if (ZEPHIR_IS_STRING(propertyName, "di")) { zephir_update_property_this(this_ptr, SL("di"), dependencyInjector TSRMLS_CC); RETURN_CCTOR(dependencyInjector); } if (ZEPHIR_IS_STRING(propertyName, "persistent")) { ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_get_class(_5, this_ptr, 0 TSRMLS_CC); zephir_array_fast_append(_4, _5); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "sessionBag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "get", NULL, 0, _5, _4); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CPY_WRT(persistent, _3); zephir_update_property_this(this_ptr, SL("persistent"), persistent TSRMLS_CC); RETURN_CCTOR(persistent); } ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SV(_6, "Access to undefined property ", propertyName); ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 2, _6); zephir_check_call_status(); RETURN_MM_NULL(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Di_InjectionAwareInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, InjectionAwareInterface, phalcon, di_injectionawareinterface, phalcon_di_injectionawareinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, setDI); ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, getDI); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_Service) { ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Service, phalcon, di_service, phalcon_di_service_method_entry, 0); zend_declare_property_null(phalcon_di_service_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_service_ce, SL("_definition"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_di_service_ce, SL("_shared"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_di_service_ce, SL("_resolved"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_di_service_ce, SL("_sharedInstance"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_di_service_ce TSRMLS_CC, 1, phalcon_di_serviceinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Di_Service, __construct) { zend_bool shared; zval *name_param = NULL, *definition, *shared_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!shared_param) { shared = 0; } else { shared = zephir_get_boolval(shared_param); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_definition"), definition TSRMLS_CC); if (shared) { zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Di_Service, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Di_Service, setShared) { zval *shared_param = NULL; zend_bool shared; zephir_fetch_params(0, 1, 0, &shared_param); shared = zephir_get_boolval(shared_param); if (shared) { zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Di_Service, isShared) { RETURN_MEMBER(this_ptr, "_shared"); } static PHP_METHOD(Phalcon_Di_Service, setSharedInstance) { zval *sharedInstance; zephir_fetch_params(0, 1, 0, &sharedInstance); zephir_update_property_this(this_ptr, SL("_sharedInstance"), sharedInstance TSRMLS_CC); } static PHP_METHOD(Phalcon_Di_Service, setDefinition) { zval *definition; zephir_fetch_params(0, 1, 0, &definition); zephir_update_property_this(this_ptr, SL("_definition"), definition TSRMLS_CC); } static PHP_METHOD(Phalcon_Di_Service, getDefinition) { RETURN_MEMBER(this_ptr, "_definition"); } static PHP_METHOD(Phalcon_Di_Service, resolve) { int ZEPHIR_LAST_CALL_STATUS; zend_bool found; zval *parameters = NULL, *dependencyInjector = NULL, *shared, *definition, *sharedInstance, *instance = NULL, *builder, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &dependencyInjector); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(shared); zephir_read_property_this(&shared, this_ptr, SL("_shared"), PH_NOISY_CC); if (zephir_is_true(shared)) { ZEPHIR_OBS_VAR(sharedInstance); zephir_read_property_this(&sharedInstance, this_ptr, SL("_sharedInstance"), PH_NOISY_CC); if (Z_TYPE_P(sharedInstance) != IS_NULL) { RETURN_CCTOR(sharedInstance); } } found = 1; ZEPHIR_INIT_VAR(instance); ZVAL_NULL(instance); ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(definition) == IS_STRING) { if (zephir_class_exists(definition, 1 TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, definition, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { found = 0; } } else { if (Z_TYPE_P(definition) == IS_OBJECT) { if (zephir_instance_of_ev(definition, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC_ARRAY(instance, definition, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC(instance, definition); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(instance, definition); } } else { if (Z_TYPE_P(definition) == IS_ARRAY) { ZEPHIR_INIT_VAR(builder); object_init_ex(builder, phalcon_di_service_builder_ce); if (zephir_has_constructor(builder TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, builder, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&instance, builder, "build", NULL, 176, dependencyInjector, definition, parameters); zephir_check_call_status(); } else { found = 0; } } } if (found == 0) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_di_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Service '", _1, "' cannot be resolved"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service.zep", 197 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(shared)) { zephir_update_property_this(this_ptr, SL("_sharedInstance"), instance TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_CCTOR(instance); } static PHP_METHOD(Phalcon_Di_Service, setParameter) { zval *parameter = NULL; zval *position_param = NULL, *parameter_param = NULL, *definition, *arguments = NULL; int position; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &position_param, ¶meter_param); position = zephir_get_intval(position_param); parameter = parameter_param; ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(definition) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to update its parameters", "phalcon/di/service.zep", 221); return; } ZEPHIR_OBS_VAR(arguments); if (zephir_array_isset_string_fetch(&arguments, definition, SS("arguments"), 0 TSRMLS_CC)) { zephir_array_update_long(&arguments, position, ¶meter, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { ZEPHIR_INIT_NVAR(arguments); zephir_create_array(arguments, 1, 0 TSRMLS_CC); zephir_array_update_long(&arguments, position, ¶meter, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); } zephir_array_update_string(&definition, SL("arguments"), &arguments, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_definition"), definition TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Di_Service, getParameter) { zval *position_param = NULL, *definition, *arguments, *parameter; int position; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &position_param); position = zephir_get_intval(position_param); ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(definition) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to obtain its parameters", "phalcon/di/service.zep", 258); return; } if (zephir_array_isset_string_fetch(&arguments, definition, SS("arguments"), 1 TSRMLS_CC)) { if (zephir_array_isset_long_fetch(¶meter, arguments, position, 1 TSRMLS_CC)) { RETURN_CTOR(parameter); } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Di_Service, isResolved) { RETURN_MEMBER(this_ptr, "_resolved"); } static PHP_METHOD(Phalcon_Di_Service, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *attributes_param = NULL, *name, *definition, *shared; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); attributes = attributes_param; ZEPHIR_OBS_VAR(name); if (!(zephir_array_isset_string_fetch(&name, attributes, SS("_name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The attribute '_name' is required", "phalcon/di/service.zep", 289); return; } ZEPHIR_OBS_VAR(definition); if (!(zephir_array_isset_string_fetch(&definition, attributes, SS("_definition"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The attribute '_definition' is required", "phalcon/di/service.zep", 293); return; } ZEPHIR_OBS_VAR(shared); if (!(zephir_array_isset_string_fetch(&shared, attributes, SS("_shared"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The attribute '_shared' is required", "phalcon/di/service.zep", 297); return; } object_init_ex(return_value, phalcon_di_service_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 64, name, definition, shared); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Di_ServiceInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, ServiceInterface, phalcon, di_serviceinterface, phalcon_di_serviceinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setShared); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, isShared); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setDefinition); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getDefinition); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, resolve); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setParameter); ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault_Cli) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di\\FactoryDefault, Cli, phalcon, di_factorydefault_cli, phalcon_di_factorydefault_ce, phalcon_di_factorydefault_cli_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Di_FactoryDefault_Cli, __construct) { zval *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL; zval *_1; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_cli_ce, this_ptr, "__construct", &_0, 175); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 10, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Phalcon\\Cli\\Router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("router"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Cli\\Dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("dispatcher"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\MetaData\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("modelsMetadata"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("filter"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Escaper", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("escaper"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Annotations\\Adapter\\Memory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("annotations"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Security", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("security"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "eventsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Events\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("eventsManager"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "transactionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Mvc\\Model\\Transaction\\Manager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_5); ZVAL_BOOL(_5, 1); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, 64, _3, _4, _5); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_array_update_string(&_1, SL("transactionManager"), &_2, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_services"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Di_Service_Builder) { ZEPHIR_REGISTER_CLASS(Phalcon\\Di\\Service, Builder, phalcon, di_service_builder, phalcon_di_service_builder_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Di_Service_Builder, _buildParameter) { zval *_2 = NULL; zval *argument = NULL; int position, ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector, *position_param = NULL, *argument_param = NULL, *type, *name = NULL, *value, *instanceArguments, *_0 = NULL, _1 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &dependencyInjector, &position_param, &argument_param); position = zephir_get_intval(position_param); argument = argument_param; ZEPHIR_OBS_VAR(type); if (!(zephir_array_isset_string_fetch(&type, argument, SS("type"), 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_di_exception_ce); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, position); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Argument at position ", &_1, " must have a type"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service/builder.zep", 49 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } do { if (ZEPHIR_IS_STRING(type, "service")) { ZEPHIR_OBS_VAR(name); if (!(zephir_array_isset_string_fetch(&name, argument, SS("name"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_di_exception_ce); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, position); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SV(_2, "Service 'name' is required in parameter on position ", &_1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service/builder.zep", 59 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The dependency injector container is not valid", "phalcon/di/service/builder.zep", 62); return; } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "get", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(type, "parameter")) { ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, argument, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_di_exception_ce); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, position); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SV(_2, "Service 'value' is required in parameter on position ", &_1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service/builder.zep", 71 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(value); } if (ZEPHIR_IS_STRING(type, "instance")) { ZEPHIR_OBS_NVAR(name); if (!(zephir_array_isset_string_fetch(&name, argument, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_di_exception_ce); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, position); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SV(_2, "Service 'className' is required in parameter on position ", &_1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service/builder.zep", 81 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The dependency injector container is not valid", "phalcon/di/service/builder.zep", 85); return; } ZEPHIR_OBS_VAR(instanceArguments); if (zephir_array_isset_string_fetch(&instanceArguments, argument, SS("arguments"), 0 TSRMLS_CC)) { ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "get", NULL, 0, name, instanceArguments); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "get", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_di_exception_ce); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, position); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SV(_2, "Unknown service type in parameter on position ", &_1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/di/service/builder.zep", 104 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Di_Service_Builder, _buildParameters) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *arguments = NULL; zval *dependencyInjector, *arguments_param = NULL, *position = NULL, *argument = NULL, *buildArguments, **_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &dependencyInjector, &arguments_param); arguments = arguments_param; ZEPHIR_INIT_VAR(buildArguments); array_init(buildArguments); zephir_is_iterable(arguments, &_1, &_0, 0, 0, "phalcon/di/service/builder.zep", 119); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(position, _1, _0); ZEPHIR_GET_HVALUE(argument, _2); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_buildparameter", &_4, 177, dependencyInjector, position, argument); zephir_check_call_status(); zephir_array_append(&buildArguments, _3, PH_SEPARATE, "phalcon/di/service/builder.zep", 117); } RETURN_CCTOR(buildArguments); } static PHP_METHOD(Phalcon_Di_Service_Builder, build) { HashTable *_3, *_9; HashPosition _2, _8; zephir_fcall_cache_entry *_1 = NULL, *_7 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *dependencyInjector, *definition_param = NULL, *parameters = NULL, *className, *arguments = NULL, *paramCalls = NULL, *methodPosition = NULL, *method = NULL, *methodName = NULL, *methodCall = NULL, *instance = NULL, *propertyPosition = NULL, *property = NULL, *propertyName = NULL, *propertyValue = NULL, *_0 = NULL, **_4, *_5 = NULL, *_6 = NULL, **_10, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &dependencyInjector, &definition_param, ¶meters); definition = definition_param; if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(className); if (!(zephir_array_isset_string_fetch(&className, definition, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Invalid service definition. Missing 'className' parameter", "phalcon/di/service/builder.zep", 140); return; } if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_VAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, className, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, className TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_OBS_VAR(arguments); if (zephir_array_isset_string_fetch(&arguments, definition, SS("arguments"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameters", &_1, 178, dependencyInjector, arguments); zephir_check_call_status(); ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, className, _0 TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, className TSRMLS_CC); zephir_check_call_status(); } } ZEPHIR_OBS_VAR(paramCalls); if (zephir_array_isset_string_fetch(¶mCalls, definition, SS("calls"), 0 TSRMLS_CC)) { if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has setter injection parameters but the constructor didn't return an instance", "phalcon/di/service/builder.zep", 177); return; } if (Z_TYPE_P(paramCalls) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/di/service/builder.zep", 181); return; } zephir_is_iterable(paramCalls, &_3, &_2, 0, 0, "phalcon/di/service/builder.zep", 233); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(methodPosition, _3, _2); ZEPHIR_GET_HVALUE(method, _4); if (Z_TYPE_P(method) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Method call must be an array on position ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 193 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(methodName); if (!(zephir_array_isset_string_fetch(&methodName, method, SS("method"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The method name is required on position ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 200 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(methodCall); zephir_create_array(methodCall, 2, 0 TSRMLS_CC); zephir_array_fast_append(methodCall, instance); zephir_array_fast_append(methodCall, methodName); ZEPHIR_OBS_NVAR(arguments); if (zephir_array_isset_string_fetch(&arguments, method, SS("arguments"), 0 TSRMLS_CC)) { if (Z_TYPE_P(arguments) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Call arguments must be an array ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 211 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_fast_count_int(arguments TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_5); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameters", &_1, 178, dependencyInjector, arguments); zephir_check_call_status(); ZEPHIR_CALL_USER_FUNC_ARRAY(_5, methodCall, _0); zephir_check_call_status(); continue; } } ZEPHIR_INIT_NVAR(_5); ZEPHIR_CALL_USER_FUNC(_5, methodCall); zephir_check_call_status(); } } ZEPHIR_OBS_NVAR(paramCalls); if (zephir_array_isset_string_fetch(¶mCalls, definition, SS("properties"), 0 TSRMLS_CC)) { if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has properties injection parameters but the constructor didn't return an instance", "phalcon/di/service/builder.zep", 241); return; } if (Z_TYPE_P(paramCalls) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/di/service/builder.zep", 245); return; } zephir_is_iterable(paramCalls, &_9, &_8, 0, 0, "phalcon/di/service/builder.zep", 279); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(propertyPosition, _9, _8); ZEPHIR_GET_HVALUE(property, _10); if (Z_TYPE_P(property) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Property must be an array on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_11, "phalcon/di/service/builder.zep", 257 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(propertyName); if (!(zephir_array_isset_string_fetch(&propertyName, property, SS("name"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The property name is required on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 264 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(propertyValue); if (!(zephir_array_isset_string_fetch(&propertyValue, property, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The property value is required on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 271 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameter", &_12, 177, dependencyInjector, propertyPosition, propertyValue); zephir_check_call_status(); zephir_update_property_zval_zval(instance, propertyName, _0 TSRMLS_CC); } } RETURN_CCTOR(instance); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Escaper_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Escaper, Exception, phalcon, escaper_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Events_Event) { ZEPHIR_REGISTER_CLASS(Phalcon\\Events, Event, phalcon, events_event, phalcon_events_event_method_entry, 0); zend_declare_property_null(phalcon_events_event_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_events_event_ce, SL("_source"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_events_event_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_events_event_ce, SL("_stopped"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_events_event_ce, SL("_cancelable"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Events_Event, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); zephir_get_strval(type, type_param); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Event, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Events_Event, getSource) { RETURN_MEMBER(this_ptr, "_source"); } static PHP_METHOD(Phalcon_Events_Event, setData) { zval *data; zephir_fetch_params(0, 1, 0, &data); zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); } static PHP_METHOD(Phalcon_Events_Event, getData) { RETURN_MEMBER(this_ptr, "_data"); } static PHP_METHOD(Phalcon_Events_Event, getCancelable) { RETURN_MEMBER(this_ptr, "_cancelable"); } static PHP_METHOD(Phalcon_Events_Event, __construct) { zend_bool cancelable; zval *type_param = NULL, *source, *data = NULL, *cancelable_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &type_param, &source, &data, &cancelable_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!cancelable_param) { cancelable = 1; } else { cancelable = zephir_get_boolval(cancelable_param); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_source"), source TSRMLS_CC); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); } if (cancelable != 1) { if (cancelable) { zephir_update_property_this(this_ptr, SL("_cancelable"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_cancelable"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Event, stop) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cancelable"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_events_exception_ce, "Trying to cancel a non-cancelable event", "phalcon/events/event.zep", 93); return; } if (1) { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Events_Event, isStopped) { RETURN_MEMBER(this_ptr, "_stopped"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Events_EventsAwareInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Events, EventsAwareInterface, phalcon, events_eventsawareinterface, phalcon_events_eventsawareinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Events_EventsAwareInterface, setEventsManager); ZEPHIR_DOC_METHOD(Phalcon_Events_EventsAwareInterface, getEventsManager); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Events_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Events, Exception, phalcon, events_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Events_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Events, Manager, phalcon, events_manager, phalcon_events_manager_method_entry, 0); zend_declare_property_null(phalcon_events_manager_ce, SL("_events"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_events_manager_ce, SL("_collect"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_events_manager_ce, SL("_enablePriorities"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_events_manager_ce, SL("_responses"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_events_manager_ce TSRMLS_CC, 1, phalcon_events_managerinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Events_Manager, attach) { int priority, ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priority_param = NULL, *priorityQueue = NULL, *_0, *_1, *_2 = NULL; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &eventType_param, &handler, &priority_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!priority_param) { priority = 100; } else { if (unlikely(Z_TYPE_P(priority_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'priority' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } priority = Z_LVAL_P(priority_param); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 56); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_enablePriorities"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(priorityQueue); if (zephir_is_true(_1)) { object_init_ex(priorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(priorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, priorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 1); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 185, _2); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } else { array_init(priorityQueue); } } if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, priority); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "insert", NULL, 186, handler, _2); zephir_check_call_status(); } else { zephir_array_append(&priorityQueue, handler, PH_SEPARATE, "phalcon/events/manager.zep", 82); zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Manager, detach) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *eventType_param = NULL, *handler, *priorityQueue, *newPriorityQueue, *key = NULL, *data = NULL, *_0, *_1 = NULL, *_2 = NULL, *_5, *_6, *_7; zval *eventType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &eventType_param, &handler); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object", "phalcon/events/manager.zep", 99); return; } ZEPHIR_OBS_VAR(priorityQueue); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (zephir_array_isset_fetch(&priorityQueue, _0, eventType, 0 TSRMLS_CC)) { if (Z_TYPE_P(priorityQueue) == IS_OBJECT) { ZEPHIR_INIT_VAR(newPriorityQueue); object_init_ex(newPriorityQueue, spl_ce_SplPriorityQueue); if (zephir_has_constructor(newPriorityQueue TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 1); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "setextractflags", NULL, 185, _1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "setextractflags", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "top", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, priorityQueue, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2))) { break; } ZEPHIR_CALL_METHOD(&data, priorityQueue, "current", &_3, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, priorityQueue, "next", &_4, 0); zephir_check_call_status(); zephir_array_fetch_string(&_5, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 116 TSRMLS_CC); if (!ZEPHIR_IS_IDENTICAL(_5, handler)) { zephir_array_fetch_string(&_6, data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); zephir_array_fetch_string(&_7, data, SL("priority"), PH_NOISY | PH_READONLY, "phalcon/events/manager.zep", 117 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, newPriorityQueue, "insert", &_8, 186, _6, _7); zephir_check_call_status(); } } zephir_update_property_array(this_ptr, SL("_events"), eventType, newPriorityQueue TSRMLS_CC); } else { ZEPHIR_CALL_FUNCTION(&key, "array_search", NULL, 187, handler, priorityQueue, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(key)) { zephir_array_unset(&priorityQueue, key, PH_SEPARATE); } zephir_update_property_array(this_ptr, SL("_events"), eventType, priorityQueue TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Manager, enablePriorities) { zval *enablePriorities_param = NULL; zend_bool enablePriorities; zephir_fetch_params(0, 1, 0, &enablePriorities_param); enablePriorities = zephir_get_boolval(enablePriorities_param); if (enablePriorities) { zephir_update_property_this(this_ptr, SL("_enablePriorities"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_enablePriorities"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Events_Manager, arePrioritiesEnabled) { RETURN_MEMBER(this_ptr, "_enablePriorities"); } static PHP_METHOD(Phalcon_Events_Manager, collectResponses) { zval *collect_param = NULL; zend_bool collect; zephir_fetch_params(0, 1, 0, &collect_param); collect = zephir_get_boolval(collect_param); if (collect) { zephir_update_property_this(this_ptr, SL("_collect"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_collect"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Events_Manager, isCollecting) { RETURN_MEMBER(this_ptr, "_collect"); } static PHP_METHOD(Phalcon_Events_Manager, getResponses) { RETURN_MEMBER(this_ptr, "_responses"); } static PHP_METHOD(Phalcon_Events_Manager, detachAll) { zval *type_param = NULL, *_0, *_1; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &type_param); if (!type_param) { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } else { if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } } if (ZEPHIR_IS_STRING_IDENTICAL(type, "")) { zephir_update_property_this(this_ptr, SL("_events"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (zephir_array_isset(_0, type)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); zephir_array_unset(&_1, type, PH_SEPARATE); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Manager, dettachAll) { int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &type_param); if (!type_param) { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } else { if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } } ZEPHIR_CALL_METHOD(NULL, this_ptr, "detachall", NULL, 0, type); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Events_Manager, fireQueue) { HashTable *_10; HashPosition _9; zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool collect, cancelable; zval *queue, *event, *status = NULL, *arguments = NULL, *eventName = NULL, *data = NULL, *iterator, *source = NULL, *handler = NULL, *_0, *_1, _2, *_3 = NULL, *_4, *_7 = NULL, **_11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &queue, &event); if (Z_TYPE_P(queue) != IS_ARRAY) { if (Z_TYPE_P(queue) == IS_OBJECT) { if (!(zephir_instance_of_ev(queue, spl_ce_SplPriorityQueue TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_events_exception_ce); ZEPHIR_INIT_VAR(_1); zephir_get_class(_1, queue, 0 TSRMLS_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Unexpected value type: expected object of type SplPriorityQueue, %s given", 0); ZEPHIR_CALL_FUNCTION(&_3, "sprintf", NULL, 188, &_2, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/events/manager.zep", 213 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "The queue is not valid", "phalcon/events/manager.zep", 216); return; } } ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); ZEPHIR_INIT_VAR(arguments); ZVAL_NULL(arguments); ZEPHIR_CALL_METHOD(&eventName, event, "gettype", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(eventName) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "The event type not valid", "phalcon/events/manager.zep", 225); return; } ZEPHIR_CALL_METHOD(&source, event, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&data, event, "getdata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, event, "getcancelable", NULL, 0); zephir_check_call_status(); cancelable = zephir_get_boolval(_3); ZEPHIR_OBS_VAR(_4); zephir_read_property_this(&_4, this_ptr, SL("_collect"), PH_NOISY_CC); collect = zephir_get_boolval(_4); if (Z_TYPE_P(queue) == IS_OBJECT) { ZEPHIR_INIT_VAR(iterator); if (zephir_clone(iterator, queue TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, iterator, "top", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_3, iterator, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_3))) { break; } ZEPHIR_CALL_METHOD(&handler, iterator, "current", &_5, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, iterator, "next", &_6, 0); zephir_check_call_status(); if (Z_TYPE_P(handler) == IS_OBJECT) { if (zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(arguments) == IS_NULL) { ZEPHIR_INIT_NVAR(arguments); zephir_create_array(arguments, 3, 0 TSRMLS_CC); zephir_array_fast_append(arguments, event); zephir_array_fast_append(arguments, source); zephir_array_fast_append(arguments, data); } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, handler, arguments); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_7, event, "isstopped", &_8, 0); zephir_check_call_status(); if (zephir_is_true(_7)) { break; } } } else { if ((zephir_method_exists(handler, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&status, handler, eventName, NULL, 0, event, source, data); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_7, event, "isstopped", &_8, 0); zephir_check_call_status(); if (zephir_is_true(_7)) { break; } } } } } } } else { zephir_is_iterable(queue, &_10, &_9, 0, 0, "phalcon/events/manager.zep", 364); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HVALUE(handler, _11); if (Z_TYPE_P(handler) == IS_OBJECT) { if (zephir_instance_of_ev(handler, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(arguments) == IS_NULL) { ZEPHIR_INIT_NVAR(arguments); zephir_create_array(arguments, 3, 0 TSRMLS_CC); zephir_array_fast_append(arguments, event); zephir_array_fast_append(arguments, source); zephir_array_fast_append(arguments, data); } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, handler, arguments); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_3, event, "isstopped", &_8, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { break; } } } else { if ((zephir_method_exists(handler, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&status, handler, eventName, NULL, 0, event, source, data); zephir_check_call_status(); if (collect) { zephir_update_property_array_append(this_ptr, SL("_responses"), status TSRMLS_CC); } if (cancelable) { ZEPHIR_CALL_METHOD(&_7, event, "isstopped", &_8, 0); zephir_check_call_status(); if (zephir_is_true(_7)) { break; } } } } } } } RETURN_CCTOR(status); } static PHP_METHOD(Phalcon_Events_Manager, fire) { zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool cancelable, _3; zval *eventType_param = NULL, *source, *data = NULL, *cancelable_param = NULL, *events, *eventParts, *type, *eventName, *event = NULL, *status = NULL, *fireEvents = NULL, *_0 = NULL, *_2; zval *eventType = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &eventType_param, &source, &data, &cancelable_param); if (unlikely(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventType_param) == IS_STRING)) { zephir_get_strval(eventType, eventType_param); } else { ZEPHIR_INIT_VAR(eventType); ZVAL_EMPTY_STRING(eventType); } if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!cancelable_param) { cancelable = 1; } else { cancelable = zephir_get_boolval(cancelable_param); } ZEPHIR_OBS_VAR(events); zephir_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) != IS_ARRAY) { RETURN_MM_NULL(); } if (!(zephir_memnstr_str(eventType, SL(":"), "phalcon/events/manager.zep", 392))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_events_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "Invalid event type ", eventType); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/events/manager.zep", 393 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(eventParts); zephir_fast_explode_str(eventParts, SL(":"), eventType, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(type); zephir_array_fetch_long(&type, eventParts, 0, PH_NOISY, "phalcon/events/manager.zep", 397 TSRMLS_CC); ZEPHIR_OBS_VAR(eventName); zephir_array_fetch_long(&eventName, eventParts, 1, PH_NOISY, "phalcon/events/manager.zep", 398 TSRMLS_CC); ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_collect"), PH_NOISY_CC); if (zephir_is_true(_2)) { zephir_update_property_this(this_ptr, SL("_responses"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } ZEPHIR_INIT_VAR(event); ZVAL_NULL(event); ZEPHIR_OBS_VAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, type, 0 TSRMLS_CC)) { _3 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_3)) { _3 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_3) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_NVAR(_0); if (cancelable) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_4, 189, eventName, source, data, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_5, 190, fireEvents, event); zephir_check_call_status(); } } ZEPHIR_OBS_NVAR(fireEvents); if (zephir_array_isset_fetch(&fireEvents, events, eventType, 0 TSRMLS_CC)) { _3 = Z_TYPE_P(fireEvents) == IS_OBJECT; if (!(_3)) { _3 = Z_TYPE_P(fireEvents) == IS_ARRAY; } if (_3) { if (Z_TYPE_P(event) == IS_NULL) { ZEPHIR_INIT_NVAR(event); object_init_ex(event, phalcon_events_event_ce); ZEPHIR_INIT_NVAR(_0); if (cancelable) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(NULL, event, "__construct", &_4, 189, eventName, source, data, _0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", &_5, 190, fireEvents, event); zephir_check_call_status(); } } RETURN_CCTOR(status); } static PHP_METHOD(Phalcon_Events_Manager, hasListeners) { zval *type_param = NULL, *_0; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, type)); } static PHP_METHOD(Phalcon_Events_Manager, getListeners) { zval *type_param = NULL, *events, *fireEvents; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } events = zephir_fetch_nproperty_this(this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) == IS_ARRAY) { if (zephir_array_isset_fetch(&fireEvents, events, type, 1 TSRMLS_CC)) { RETURN_CTOR(fireEvents); } } array_init(return_value); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Events_ManagerInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Events, ManagerInterface, phalcon, events_managerinterface, phalcon_events_managerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, attach); ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, detach); ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, detachAll); ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, fire); ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, getListeners); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Filter_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter, Exception, phalcon, filter_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Filter_UserFilterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter, UserFilterInterface, phalcon, filter_userfilterinterface, phalcon_filter_userfilterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Filter_UserFilterInterface, filter); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Flash_Direct) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Direct, phalcon, flash_direct, phalcon_flash_ce, phalcon_flash_direct_method_entry, 0); zend_class_implements(phalcon_flash_direct_ce TSRMLS_CC, 1, phalcon_flashinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Flash_Direct, message) { int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *message; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &message); zephir_get_strval(type, type_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputmessage", NULL, 0, type, message); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Flash_Direct, output) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL; HashTable *_1; HashPosition _0; zval *remove_param = NULL, *message = NULL, *messages, **_2; zend_bool remove; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &remove_param); if (!remove_param) { remove = 1; } else { remove = zephir_get_boolval(remove_param); } ZEPHIR_OBS_VAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_is_iterable(messages, &_1, &_0, 0, 0, "phalcon/flash/direct.zep", 53); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(message, _2); zend_print_zval(message, 0); } } if (remove) { ZEPHIR_CALL_PARENT(NULL, phalcon_flash_direct_ce, this_ptr, "clear", &_3, 197); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Flash_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Exception, phalcon, flash_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Flash_Session) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Session, phalcon, flash_session, phalcon_flash_ce, phalcon_flash_session_method_entry, 0); zend_declare_property_null(phalcon_flash_session_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_flash_session_ce TSRMLS_CC, 1, phalcon_flashinterface_ce); zend_class_implements(phalcon_flash_session_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Flash_Session, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Flash_Session, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Flash_Session, _getSessionMessages) { int ZEPHIR_LAST_CALL_STATUS; zval *remove_param = NULL, *dependencyInjector = NULL, *session = NULL, *messages = NULL, *_0, *_1 = NULL, *_2 = NULL; zend_bool remove; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &remove_param); remove = zephir_get_boolval(remove_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/flash/session.zep", 64); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "_flashMessages", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&messages, session, "get", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (remove == 1) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "_flashMessages", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_CCTOR(messages); } static PHP_METHOD(Phalcon_Flash_Session, _setSessionMessages) { int ZEPHIR_LAST_CALL_STATUS; zval *messages_param = NULL, *dependencyInjector = NULL, *session = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *messages = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &messages_param); messages = messages_param; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/flash/session.zep", 86); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "_flashMessages", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, session, "set", NULL, 0, _2, messages); zephir_check_temp_parameter(_2); zephir_check_call_status(); RETURN_CTOR(messages); } static PHP_METHOD(Phalcon_Flash_Session, message) { int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *message_param = NULL, *messages = NULL, *_0 = NULL; zval *type = NULL, *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &message_param); zephir_get_strval(type, type_param); zephir_get_strval(message, message_param); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 0); ZEPHIR_CALL_METHOD(&messages, this_ptr, "_getsessionmessages", NULL, 0, _0); zephir_check_call_status(); if (Z_TYPE_P(messages) != IS_ARRAY) { ZEPHIR_INIT_NVAR(messages); array_init(messages); } if (!(zephir_array_isset(messages, type))) { ZEPHIR_INIT_NVAR(_0); array_init(_0); zephir_array_update_zval(&messages, type, &_0, PH_COPY | PH_SEPARATE); } zephir_array_update_multi(&messages, &message TSRMLS_CC, SL("za"), 2, type); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_setsessionmessages", NULL, 0, messages); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Flash_Session, has) { int ZEPHIR_LAST_CALL_STATUS; zval *type = NULL, *messages = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &type); if (!type) { type = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 0); ZEPHIR_CALL_METHOD(&messages, this_ptr, "_getsessionmessages", NULL, 0, _0); zephir_check_call_status(); if (Z_TYPE_P(messages) == IS_ARRAY) { if (Z_TYPE_P(type) == IS_STRING) { RETURN_MM_BOOL(zephir_array_isset(messages, type)); } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Flash_Session, getMessages) { int ZEPHIR_LAST_CALL_STATUS; zend_bool remove; zval *type = NULL, *remove_param = NULL, *messages = NULL, *returnMessages, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &type, &remove_param); if (!type) { type = ZEPHIR_GLOBAL(global_null); } if (!remove_param) { remove = 1; } else { remove = zephir_get_boolval(remove_param); } ZEPHIR_INIT_VAR(_0); if (remove) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&messages, this_ptr, "_getsessionmessages", NULL, 0, _0); zephir_check_call_status(); if (Z_TYPE_P(type) != IS_STRING) { RETURN_CCTOR(messages); } if (!(zephir_array_isset_fetch(&returnMessages, messages, type, 1 TSRMLS_CC))) { array_init(return_value); RETURN_MM(); } RETURN_CTOR(returnMessages); } static PHP_METHOD(Phalcon_Flash_Session, output) { zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *remove_param = NULL, *type = NULL, *message = NULL, *messages = NULL, *_0, **_3; zend_bool remove; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &remove_param); if (!remove_param) { remove = 1; } else { remove = zephir_get_boolval(remove_param); } ZEPHIR_INIT_VAR(_0); if (remove) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&messages, this_ptr, "_getsessionmessages", NULL, 0, _0); zephir_check_call_status(); if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_is_iterable(messages, &_2, &_1, 0, 0, "phalcon/flash/session.zep", 162); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(type, _2, _1); ZEPHIR_GET_HVALUE(message, _3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_4, 0, type, message); zephir_check_call_status(); } } ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, this_ptr, "clear", &_5, 197); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Flash_Session, clear) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_getsessionmessages", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, this_ptr, "clear", &_1, 197); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element) { ZEPHIR_REGISTER_CLASS(Phalcon\\Forms, Element, phalcon, forms_element, phalcon_forms_element_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_forms_element_ce, SL("_form"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_value"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_label"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_attributes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_validators"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_element_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_forms_element_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *attributes = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &attributes); zephir_get_strval(name, name_param); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); if (Z_TYPE_P(attributes) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 3); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_messages"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Forms_Element, setForm) { zval *form; zephir_fetch_params(0, 1, 0, &form); zephir_update_property_this(this_ptr, SL("_form"), form TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, getForm) { RETURN_MEMBER(this_ptr, "_form"); } static PHP_METHOD(Phalcon_Forms_Element, setName) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Forms_Element, setFilters) { zend_bool _0; zval *filters; zephir_fetch_params(0, 1, 0, &filters); _0 = Z_TYPE_P(filters) != IS_STRING; if (_0) { _0 = Z_TYPE_P(filters) != IS_ARRAY; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_forms_exception_ce, "Wrong filter type added", "phalcon/forms/element.zep", 113); return; } zephir_update_property_this(this_ptr, SL("_filters"), filters TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, addFilter) { zval *_0 = NULL; zval *filter_param = NULL, *filters; zval *filter = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &filter_param); zephir_get_strval(filter, filter_param); filters = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); if (Z_TYPE_P(filters) == IS_ARRAY) { zephir_update_property_array_append(this_ptr, SL("_filters"), filter TSRMLS_CC); } else { if (Z_TYPE_P(filters) == IS_STRING) { ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, filters); zephir_array_fast_append(_0, filter); zephir_update_property_this(this_ptr, SL("_filters"), _0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); zephir_array_fast_append(_0, filter); zephir_update_property_this(this_ptr, SL("_filters"), _0 TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, getFilters) { RETURN_MEMBER(this_ptr, "_filters"); } static PHP_METHOD(Phalcon_Forms_Element, addValidators) { zend_bool merge; zval *validators_param = NULL, *merge_param = NULL, *currentValidators, *mergedValidators = NULL; zval *validators = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &validators_param, &merge_param); validators = validators_param; if (!merge_param) { merge = 1; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(currentValidators); zephir_read_property_this(¤tValidators, this_ptr, SL("_validators"), PH_NOISY_CC); if (Z_TYPE_P(currentValidators) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedValidators); zephir_fast_array_merge(mergedValidators, &(currentValidators), &(validators) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedValidators, validators); } zephir_update_property_this(this_ptr, SL("_validators"), mergedValidators TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, addValidator) { zval *validator; zephir_fetch_params(0, 1, 0, &validator); zephir_update_property_array_append(this_ptr, SL("_validators"), validator TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, getValidators) { RETURN_MEMBER(this_ptr, "_validators"); } static PHP_METHOD(Phalcon_Forms_Element, prepareAttributes) { int ZEPHIR_LAST_CALL_STATUS; zend_bool useChecked; zval *attributes = NULL, *useChecked_param = NULL, *value = NULL, *name, *widgetAttributes = NULL, *mergedAttributes = NULL, *defaultAttributes, *currentValue, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &attributes, &useChecked_param); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } if (!useChecked_param) { useChecked = 0; } else { useChecked = zephir_get_boolval(useChecked_param); } ZEPHIR_OBS_VAR(name); zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); if (Z_TYPE_P(attributes) != IS_ARRAY) { ZEPHIR_INIT_VAR(widgetAttributes); array_init(widgetAttributes); } else { ZEPHIR_CPY_WRT(widgetAttributes, attributes); } zephir_array_update_long(&widgetAttributes, 0, &name, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_OBS_VAR(defaultAttributes); zephir_read_property_this(&defaultAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC); if (Z_TYPE_P(defaultAttributes) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedAttributes); zephir_fast_array_merge(mergedAttributes, &(defaultAttributes), &(widgetAttributes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedAttributes, widgetAttributes); } ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { if (useChecked) { if (zephir_array_isset_string_fetch(¤tValue, mergedAttributes, SS("value"), 1 TSRMLS_CC)) { if (ZEPHIR_IS_EQUAL(currentValue, value)) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "checked", 1); zephir_array_update_string(&mergedAttributes, SL("checked"), &_0, PH_COPY | PH_SEPARATE); } } else { if (zephir_is_true(value)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "checked", 1); zephir_array_update_string(&mergedAttributes, SL("checked"), &_0, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&mergedAttributes, SL("value"), &value, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_string(&mergedAttributes, SL("value"), &value, PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(mergedAttributes); } static PHP_METHOD(Phalcon_Forms_Element, setAttribute) { zval *attribute_param = NULL, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &attribute_param, &value); zephir_get_strval(attribute, attribute_param); zephir_update_property_array(this_ptr, SL("_attributes"), attribute, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, getAttribute) { zval *attribute_param = NULL, *defaultValue = NULL, *attributes, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &attribute_param, &defaultValue); zephir_get_strval(attribute, attribute_param); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } attributes = zephir_fetch_nproperty_this(this_ptr, SL("_attributes"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, attributes, attribute, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Forms_Element, setAttributes) { zval *attributes_param = NULL; zval *attributes = NULL; zephir_fetch_params(0, 1, 0, &attributes_param); attributes = attributes_param; zephir_update_property_this(this_ptr, SL("_attributes"), attributes TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, getAttributes) { zval *attributes; attributes = zephir_fetch_nproperty_this(this_ptr, SL("_attributes"), PH_NOISY_CC); if (Z_TYPE_P(attributes) != IS_ARRAY) { array_init(return_value); return; } RETURN_CTORW(attributes); } static PHP_METHOD(Phalcon_Forms_Element, setUserOption) { zval *option_param = NULL, *value; zval *option = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &option_param, &value); zephir_get_strval(option, option_param); zephir_update_property_array(this_ptr, SL("_options"), option, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, getUserOption) { zval *option, *defaultValue = NULL, *value, *_0; zephir_fetch_params(0, 1, 1, &option, &defaultValue); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, option, 1 TSRMLS_CC)) { RETURN_CTORW(value); } RETVAL_ZVAL(defaultValue, 1, 0); return; } static PHP_METHOD(Phalcon_Forms_Element, setUserOptions) { zval *options; zephir_fetch_params(0, 1, 0, &options); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, getUserOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Forms_Element, setLabel) { zval *label_param = NULL; zval *label = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &label_param); zephir_get_strval(label, label_param); zephir_update_property_this(this_ptr, SL("_label"), label TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, getLabel) { RETURN_MEMBER(this_ptr, "_label"); } static PHP_METHOD(Phalcon_Forms_Element, label) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *attributes = NULL, *internalAttributes = NULL, *label, *name = NULL, *code = NULL, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { ZEPHIR_CPY_WRT(attributes, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(attributes); } ZEPHIR_CALL_METHOD(&internalAttributes, this_ptr, "getattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(name); if (!(zephir_array_isset_string_fetch(&name, internalAttributes, SS("id"), 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(name); zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); } if (Z_TYPE_P(attributes) == IS_ARRAY) { if (!(zephir_array_isset_string(attributes, SS("for")))) { zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_NVAR(attributes); zephir_create_array(attributes, 1, 0 TSRMLS_CC); zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "<label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_CE_STATIC(&code, phalcon_tag_ce, "renderattributes", &_0, 4, _1, attributes); zephir_check_temp_parameter(_1); zephir_check_call_status(); label = zephir_fetch_nproperty_this(this_ptr, SL("_label"), PH_NOISY_CC); if (zephir_is_true(label)) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, ">", label, "</label>"); zephir_concat_self(&code, _2 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, ">", name, "</label>"); zephir_concat_self(&code, _2 TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Forms_Element, setDefault) { zval *value; zephir_fetch_params(0, 1, 0, &value); zephir_update_property_this(this_ptr, SL("_value"), value TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, getDefault) { RETURN_MEMBER(this_ptr, "_value"); } static PHP_METHOD(Phalcon_Forms_Element, getValue) { zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL; zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *name, *form, *value = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(name); zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_OBS_VAR(form); zephir_read_property_this(&form, this_ptr, SL("_form"), PH_NOISY_CC); if (Z_TYPE_P(form) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&value, form, "getvalue", NULL, 0, name); zephir_check_call_status(); _0 = Z_TYPE_P(value) == IS_NULL; if (_0) { ZEPHIR_CALL_CE_STATIC(&_1, phalcon_tag_ce, "hasvalue", &_2, 5, name); zephir_check_call_status(); _0 = zephir_is_true(_1); } if (_0) { ZEPHIR_CALL_CE_STATIC(&value, phalcon_tag_ce, "getvalue", &_3, 6, name); zephir_check_call_status(); } } if (Z_TYPE_P(value) == IS_NULL) { ZEPHIR_OBS_NVAR(value); zephir_read_property_this(&value, this_ptr, SL("_value"), PH_NOISY_CC); } RETURN_CCTOR(value); } static PHP_METHOD(Phalcon_Forms_Element, getMessages) { RETURN_MEMBER(this_ptr, "_messages"); } static PHP_METHOD(Phalcon_Forms_Element, hasMessages) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); RETURN_BOOL(zephir_fast_count_int(_0 TSRMLS_CC) > 0); } static PHP_METHOD(Phalcon_Forms_Element, setMessages) { zval *group; zephir_fetch_params(0, 1, 0, &group); zephir_update_property_this(this_ptr, SL("_messages"), group TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element, appendMessage) { int ZEPHIR_LAST_CALL_STATUS; zval *message, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "appendmessage", NULL, 0, message); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, clear) { int ZEPHIR_LAST_CALL_STATUS; zval *_1, *_2; zephir_fcall_cache_entry *_0 = NULL; ZEPHIR_MM_GROW(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_CALL_CE_STATIC(NULL, phalcon_tag_ce, "setdefault", &_0, 7, _1, _2); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element, __toString) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_ElementInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Forms, ElementInterface, phalcon, forms_elementinterface, phalcon_forms_elementinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setForm); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getForm); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setName); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setFilters); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, addFilter); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getFilters); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, addValidators); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, addValidator); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getValidators); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, prepareAttributes); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setAttribute); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getAttribute); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setAttributes); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getAttributes); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setUserOption); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getUserOption); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setUserOptions); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getUserOptions); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setLabel); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getLabel); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, label); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setDefault); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getDefault); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getValue); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, hasMessages); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, setMessages); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, appendMessage); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, clear); ZEPHIR_DOC_METHOD(Phalcon_Forms_ElementInterface, render); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Exception, phalcon, forms_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Form) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Form, phalcon, forms_form, phalcon_di_injectable_ce, phalcon_forms_form_method_entry, 0); zend_declare_property_null(phalcon_forms_form_ce, SL("_position"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_entity"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_elements"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_elementsIndexed"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_forms_form_ce, SL("_validation"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_forms_form_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_forms_form_ce TSRMLS_CC, 1, zend_ce_iterator); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Form, setValidation) { zval *validation; zephir_fetch_params(0, 1, 0, &validation); zephir_update_property_this(this_ptr, SL("_validation"), validation TSRMLS_CC); } static PHP_METHOD(Phalcon_Forms_Form, getValidation) { RETURN_MEMBER(this_ptr, "_validation"); } static PHP_METHOD(Phalcon_Forms_Form, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *entity = NULL, *userOptions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &entity, &userOptions); if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } if (!userOptions) { userOptions = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(entity) != IS_NULL) { if (Z_TYPE_P(entity) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "The base entity is not valid", "phalcon/forms/form.zep", 65); return; } zephir_update_property_this(this_ptr, SL("_entity"), entity TSRMLS_CC); } if (Z_TYPE_P(userOptions) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_options"), userOptions TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, entity, userOptions); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Forms_Form, setAction) { zval *action; zephir_fetch_params(0, 1, 0, &action); zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Form, getAction) { RETURN_MEMBER(this_ptr, "_action"); } static PHP_METHOD(Phalcon_Forms_Form, setUserOption) { zval *option, *value; zephir_fetch_params(0, 2, 0, &option, &value); zephir_update_property_array(this_ptr, SL("_options"), option, value TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Form, getUserOption) { zval *option, *defaultValue = NULL, *value, *_0; zephir_fetch_params(0, 1, 1, &option, &defaultValue); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, option, 1 TSRMLS_CC)) { RETURN_CTORW(value); } RETVAL_ZVAL(defaultValue, 1, 0); return; } static PHP_METHOD(Phalcon_Forms_Form, setUserOptions) { zval *options_param = NULL; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Form, getUserOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Forms_Form, setEntity) { zval *entity; zephir_fetch_params(0, 1, 0, &entity); zephir_update_property_this(this_ptr, SL("_entity"), entity TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Form, getEntity) { RETURN_MEMBER(this_ptr, "_entity"); } static PHP_METHOD(Phalcon_Forms_Form, getElements) { RETURN_MEMBER(this_ptr, "_elements"); } static PHP_METHOD(Phalcon_Forms_Form, bind) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *data_param = NULL, *entity, *whitelist = NULL, *elements, *filter = NULL, *key = NULL, *value = NULL, *element = NULL, *filters = NULL, *dependencyInjector = NULL, *filteredValue = NULL, *method = NULL, **_2, *_4 = NULL, *_5 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &data_param, &entity, &whitelist); data = data_param; ZEPHIR_SEPARATE_PARAM(entity); if (!whitelist) { whitelist = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(elements); zephir_read_property_this(&elements, this_ptr, SL("_elements"), PH_NOISY_CC); if (Z_TYPE_P(elements) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "There are no elements in the form", "phalcon/forms/form.zep", 198); return; } ZEPHIR_INIT_VAR(filter); ZVAL_NULL(filter); zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/forms/form.zep", 255); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_OBS_NVAR(element); if (!(zephir_array_isset_fetch(&element, elements, key, 0 TSRMLS_CC))) { continue; } if (Z_TYPE_P(whitelist) == IS_ARRAY) { if (!(zephir_fast_in_array(key, whitelist TSRMLS_CC))) { continue; } } ZEPHIR_CALL_METHOD(&filters, element, "getfilters", NULL, 0); zephir_check_call_status(); if (zephir_is_true(filters)) { if (Z_TYPE_P(filter) != IS_OBJECT) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", &_3, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, dependencyInjector, "getshared", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CPY_WRT(filter, _4); } ZEPHIR_CALL_METHOD(&filteredValue, filter, "sanitize", NULL, 0, value, filters); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(filteredValue, value); } ZEPHIR_INIT_NVAR(_5); zephir_camelize(_5, key); ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "set", _5); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, method, NULL, 0, filteredValue); zephir_check_call_status(); continue; } zephir_update_property_zval_zval(entity, key, filteredValue TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Form, isValid) { zephir_fcall_cache_entry *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL; zval *_9 = NULL; HashTable *_4, *_7; HashPosition _3, _6; int ZEPHIR_LAST_CALL_STATUS; zend_bool notFailed; zval *data = NULL, *entity = NULL, *elements, *messages, *element = NULL, *validators = NULL, *name = NULL, *preparedValidators = NULL, *filters = NULL, *validator = NULL, *validation = NULL, *elementMessages = NULL, *_0, *_1, *_2 = NULL, **_5, **_8, *_14 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &entity); if (!data) { ZEPHIR_CPY_WRT(data, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(data); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(elements); zephir_read_property_this(&elements, this_ptr, SL("_elements"), PH_NOISY_CC); if (Z_TYPE_P(elements) != IS_ARRAY) { RETURN_MM_BOOL(1); } if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_OBS_NVAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, entity); zephir_check_call_status(); } else if (Z_TYPE_P(_0) == IS_OBJECT) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_entity"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, _1); zephir_check_call_status(); } if ((zephir_method_exists_ex(this_ptr, SS("beforevalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "beforevalidation", NULL, 0, data, entity); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } } notFailed = 1; ZEPHIR_INIT_VAR(messages); array_init(messages); zephir_is_iterable(elements, &_4, &_3, 0, 0, "phalcon/forms/form.zep", 370); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(element, _5); ZEPHIR_CALL_METHOD(&validators, element, "getvalidators", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(validators) == IS_ARRAY) { if (zephir_fast_count_int(validators TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(preparedValidators); array_init(preparedValidators); zephir_is_iterable(validators, &_7, &_6, 0, 0, "phalcon/forms/form.zep", 326); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(validator, _8); ZEPHIR_INIT_NVAR(_9); zephir_create_array(_9, 2, 0 TSRMLS_CC); zephir_array_fast_append(_9, name); zephir_array_fast_append(_9, validator); zephir_array_append(&preparedValidators, _9, PH_SEPARATE, "phalcon/forms/form.zep", 323); } ZEPHIR_CALL_METHOD(&validation, this_ptr, "getvalidation", &_10, 0); zephir_check_call_status(); if (Z_TYPE_P(validation) == IS_OBJECT) { if (zephir_instance_of_ev(validation, phalcon_validation_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, validation, "setvalidators", NULL, 0, preparedValidators); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(validation); object_init_ex(validation, phalcon_validation_ce); ZEPHIR_CALL_METHOD(NULL, validation, "__construct", &_11, 211, preparedValidators); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&filters, element, "getfilters", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(filters) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_2, element, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "setfilters", &_12, 212, _2, filters); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&elementMessages, validation, "validate", &_13, 213, data, entity); zephir_check_call_status(); if (zephir_fast_count_int(elementMessages TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_14, element, "getname", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&messages, _14, &elementMessages, PH_COPY | PH_SEPARATE); notFailed = 0; } } } } if (!(notFailed)) { zephir_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("aftervalidation") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, messages); zephir_check_call_status(); } RETURN_MM_BOOL(notFailed); } static PHP_METHOD(Phalcon_Forms_Form, getMessages) { HashTable *_2; HashPosition _1; zephir_fcall_cache_entry *_0 = NULL, *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *byItemName_param = NULL, *messages, *group, *elementMessages = NULL, **_3; zend_bool byItemName; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &byItemName_param); if (!byItemName_param) { byItemName = 0; } else { byItemName = zephir_get_boolval(byItemName_param); } ZEPHIR_OBS_VAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if (byItemName) { if (Z_TYPE_P(messages) != IS_ARRAY) { object_init_ex(return_value, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_0, 3); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(messages); } ZEPHIR_INIT_VAR(group); object_init_ex(group, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, group, "__construct", &_0, 3); zephir_check_call_status(); if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_is_iterable(messages, &_2, &_1, 0, 0, "phalcon/forms/form.zep", 407); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(elementMessages, _3); ZEPHIR_CALL_METHOD(NULL, group, "appendmessages", &_4, 214, elementMessages); zephir_check_call_status(); } } RETURN_CCTOR(group); } static PHP_METHOD(Phalcon_Forms_Form, getMessagesFor) { int ZEPHIR_LAST_CALL_STATUS; zval *name, *messages, *elementMessages, *group; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name); messages = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (zephir_array_isset_fetch(&elementMessages, messages, name, 1 TSRMLS_CC)) { RETURN_CTOR(elementMessages); } ZEPHIR_INIT_VAR(group); object_init_ex(group, phalcon_validation_message_group_ce); ZEPHIR_CALL_METHOD(NULL, group, "__construct", NULL, 3); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_messages"), name, group TSRMLS_CC); RETURN_CCTOR(group); } static PHP_METHOD(Phalcon_Forms_Form, hasMessagesFor) { zval *name, *_0; zephir_fetch_params(0, 1, 0, &name); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, name)); } static PHP_METHOD(Phalcon_Forms_Form, add) { HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zend_bool type, _0; zval *postion = NULL; zval *element, *postion_param = NULL, *type_param = NULL, *name = NULL, *key = NULL, *value = NULL, *elements, *_1, *_2, **_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &element, &postion_param, &type_param); if (!postion_param) { ZEPHIR_INIT_VAR(postion); ZVAL_EMPTY_STRING(postion); } else { zephir_get_strval(postion, postion_param); } if (!type_param) { type = 0; } else { type = zephir_get_boolval(type_param); } ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, element, "setform", NULL, 0, this_ptr); zephir_check_call_status(); _0 = ZEPHIR_IS_STRING(postion, ""); if (!(_0)) { ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_elements"), PH_NOISY_CC); _0 = Z_TYPE_P(_1) != IS_ARRAY; } if (_0) { zephir_update_property_array(this_ptr, SL("_elements"), name, element TSRMLS_CC); } else { ZEPHIR_INIT_VAR(elements); array_init(elements); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); zephir_is_iterable(_2, &_4, &_3, 0, 0, "phalcon/forms/form.zep", 496); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(key, _4, _3); ZEPHIR_GET_HVALUE(value, _5); if (ZEPHIR_IS_EQUAL(key, postion)) { if (type) { zephir_array_update_zval(&elements, name, &element, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&elements, name, &element, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&elements, key, &value, PH_COPY | PH_SEPARATE); } } zephir_update_property_this(this_ptr, SL("_elements"), elements TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Form, render) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *attributes = NULL, *element, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &attributes); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(element); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&element, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_forms_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Element with ID=", name, " is not part of the form"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/forms/form.zep", 513 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_RETURN_CALL_METHOD(element, "render", NULL, 0, attributes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Forms_Form, get) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *element, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(element); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (zephir_array_isset_fetch(&element, _0, name, 0 TSRMLS_CC)) { RETURN_CCTOR(element); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_forms_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Element with ID=", name, " is not part of the form"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/forms/form.zep", 530 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Forms_Form, label) { int ZEPHIR_LAST_CALL_STATUS; zval *attributes = NULL; zval *name_param = NULL, *attributes_param = NULL, *element, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!attributes_param) { ZEPHIR_INIT_VAR(attributes); array_init(attributes); } else { zephir_get_arrval(attributes, attributes_param); } ZEPHIR_OBS_VAR(element); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (zephir_array_isset_fetch(&element, _0, name, 0 TSRMLS_CC)) { ZEPHIR_RETURN_CALL_METHOD(element, "label", NULL, 0, attributes); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_forms_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Element with ID=", name, " is not part of the form"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/forms/form.zep", 544 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Forms_Form, getLabel) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *element, *label = NULL, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(element); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&element, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_forms_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Element with ID=", name, " is not part of the form"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/forms/form.zep", 555 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&label, element, "getlabel", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(label))) { RETURN_CTOR(name); } RETURN_CCTOR(label); } static PHP_METHOD(Phalcon_Forms_Form, getValue) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *entity, *method = NULL, *value = NULL, *data, *_0 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if ((zephir_method_exists_ex(this_ptr, SS("getcustomvalue") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcustomvalue", NULL, 0, name, entity, data); zephir_check_call_status(); RETURN_MM(); } if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); zephir_camelize(_0, name); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", _0); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(entity, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, entity, name, PH_SILENT_CC)) { RETURN_CCTOR(value); } } if (Z_TYPE_P(data) == IS_ARRAY) { ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, data, name, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } } ZEPHIR_INIT_NVAR(_0); zephir_camelize(_0, name); ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "get", _0); if ((zephir_method_exists(this_ptr, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Forms_Form, has) { zval *name_param = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, name)); } static PHP_METHOD(Phalcon_Forms_Form, remove) { zval *name_param = NULL, *elements, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } elements = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); if (zephir_array_isset(elements, name)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); zephir_array_unset(&_0, name, PH_SEPARATE); RETURN_MM_BOOL(1); } zephir_update_property_this(this_ptr, SL("_elementsIndexed"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Forms_Form, clear) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *fields = NULL, *elements, *element = NULL, **_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &fields); if (!fields) { fields = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(elements); zephir_read_property_this(&elements, this_ptr, SL("_elements"), PH_NOISY_CC); if (Z_TYPE_P(elements) == IS_ARRAY) { zephir_is_iterable(elements, &_1, &_0, 0, 0, "phalcon/forms/form.zep", 686); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(element, _2); if (Z_TYPE_P(fields) != IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, element, "clear", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&_3, element, "getname", NULL, 0); zephir_check_call_status(); if (zephir_fast_in_array(_3, fields TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, element, "clear", NULL, 0); zephir_check_call_status(); } } } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Form, count) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Forms_Form, rewind) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_position"), _0 TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elements"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_1, "array_values", NULL, 215, _0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_elementsIndexed"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Forms_Form, current) { zval *element, *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elementsIndexed"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); if (zephir_array_isset_fetch(&element, _0, _1, 1 TSRMLS_CC)) { RETURN_CTORW(element); } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Forms_Form, key) { RETURN_MEMBER(this_ptr, "_position"); } static PHP_METHOD(Phalcon_Forms_Form, next) { RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_position") TSRMLS_CC)); } static PHP_METHOD(Phalcon_Forms_Form, valid) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_elementsIndexed"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, _1)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Forms, Manager, phalcon, forms_manager, phalcon_forms_manager_method_entry, 0); zend_declare_property_null(phalcon_forms_manager_ce, SL("_forms"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Manager, create) { int ZEPHIR_LAST_CALL_STATUS; zval *name = NULL, *entity = NULL, *form; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &name, &entity); if (!name) { name = ZEPHIR_GLOBAL(global_null); } if (!entity) { entity = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(name) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "The form name must be string", "phalcon/forms/manager.zep", 41); return; } ZEPHIR_INIT_VAR(form); object_init_ex(form, phalcon_forms_form_ce); ZEPHIR_CALL_METHOD(NULL, form, "__construct", NULL, 216, entity); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_forms"), name, form TSRMLS_CC); RETURN_CCTOR(form); } static PHP_METHOD(Phalcon_Forms_Manager, get) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *form, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_OBS_VAR(form); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_forms"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&form, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_forms_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "There is no form with name='", name, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/forms/manager.zep", 57 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(form); } static PHP_METHOD(Phalcon_Forms_Manager, has) { zval *name_param = NULL, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_forms"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, name)); } static PHP_METHOD(Phalcon_Forms_Manager, set) { zval *name_param = NULL, *form; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &form); zephir_get_strval(name, name_param); zephir_update_property_array(this_ptr, SL("_forms"), name, form TSRMLS_CC); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Check) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Check, phalcon, forms_element_check, phalcon_forms_element_ce, phalcon_forms_element_check_method_entry, 0); zend_class_implements(phalcon_forms_element_check_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Check, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "checkfield", &_0, 198, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Date) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Date, phalcon, forms_element_date, phalcon_forms_element_ce, phalcon_forms_element_date_method_entry, 0); zend_class_implements(phalcon_forms_element_date_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Date, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "datefield", &_0, 199, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Email) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Email, phalcon, forms_element_email, phalcon_forms_element_ce, phalcon_forms_element_email_method_entry, 0); zend_class_implements(phalcon_forms_element_email_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Email, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "emailfield", &_0, 200, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_File) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, File, phalcon, forms_element_file, phalcon_forms_element_ce, phalcon_forms_element_file_method_entry, 0); zend_class_implements(phalcon_forms_element_file_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_File, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "filefield", &_0, 201, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Hidden) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Hidden, phalcon, forms_element_hidden, phalcon_forms_element_ce, phalcon_forms_element_hidden_method_entry, 0); zend_class_implements(phalcon_forms_element_hidden_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Hidden, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "hiddenfield", &_0, 202, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Numeric) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Numeric, phalcon, forms_element_numeric, phalcon_forms_element_ce, phalcon_forms_element_numeric_method_entry, 0); zend_class_implements(phalcon_forms_element_numeric_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Numeric, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "numericfield", &_0, 203, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Password) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Password, phalcon, forms_element_password, phalcon_forms_element_ce, phalcon_forms_element_password_method_entry, 0); zend_class_implements(phalcon_forms_element_password_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Password, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "passwordfield", &_0, 204, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Radio) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Radio, phalcon, forms_element_radio, phalcon_forms_element_ce, phalcon_forms_element_radio_method_entry, 0); zend_class_implements(phalcon_forms_element_radio_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Radio, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "radiofield", &_0, 205, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Select) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Select, phalcon, forms_element_select, phalcon_forms_element_ce, phalcon_forms_element_select_method_entry, 0); zend_declare_property_null(phalcon_forms_element_select_ce, SL("_optionsValues"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_forms_element_select_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Select, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *name_param = NULL, *options = NULL, *attributes = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &name_param, &options, &attributes); zephir_get_strval(name, name_param); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_optionsValues"), options TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_forms_element_select_ce, this_ptr, "__construct", &_0, 206, name, attributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Forms_Element_Select, setOptions) { zval *options; zephir_fetch_params(0, 1, 0, &options); zephir_update_property_this(this_ptr, SL("_optionsValues"), options TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Forms_Element_Select, getOptions) { RETURN_MEMBER(this_ptr, "_optionsValues"); } static PHP_METHOD(Phalcon_Forms_Element_Select, addOption) { HashTable *_1; HashPosition _0; zval *option, *key = NULL, *value = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &option); if (Z_TYPE_P(option) == IS_ARRAY) { zephir_is_iterable(option, &_1, &_0, 0, 0, "phalcon/forms/element/select.zep", 85); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); zephir_update_property_array(this_ptr, SL("_optionsValues"), key, value TSRMLS_CC); } } else { zephir_update_property_array_append(this_ptr, SL("_optionsValues"), option TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Forms_Element_Select, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_optionsValues"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_select_ce, "selectfield", &_0, 207, _1, _2); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Submit) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Submit, phalcon, forms_element_submit, phalcon_forms_element_ce, phalcon_forms_element_submit_method_entry, 0); zend_class_implements(phalcon_forms_element_submit_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Submit, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "submitbutton", &_0, 208, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Text) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Text, phalcon, forms_element_text, phalcon_forms_element_ce, phalcon_forms_element_text_method_entry, 0); zend_class_implements(phalcon_forms_element_text_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_Text, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "textfield", &_0, 209, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_TextArea) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, TextArea, phalcon, forms_element_textarea, phalcon_forms_element_ce, phalcon_forms_element_textarea_method_entry, 0); zend_class_implements(phalcon_forms_element_textarea_ce TSRMLS_CC, 1, phalcon_forms_elementinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Forms_Element_TextArea, render) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *attributes = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &attributes); if (!attributes) { attributes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "prepareattributes", NULL, 0, attributes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_ce, "textarea", &_0, 210, _1); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http, Cookie, phalcon, http_cookie, phalcon_http_cookie_method_entry, 0); zend_declare_property_bool(phalcon_http_cookie_ce, SL("_readed"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_http_cookie_ce, SL("_restored"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_http_cookie_ce, SL("_useEncryption"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_filter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_value"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_expire"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_http_cookie_ce, SL("_path"), "/", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_domain"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_cookie_ce, SL("_secure"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_http_cookie_ce, SL("_httpOnly"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_cookie_ce TSRMLS_CC, 1, phalcon_http_cookieinterface_ce); zend_class_implements(phalcon_http_cookie_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Cookie, __construct) { zval *name_param = NULL, *value = NULL, *expire = NULL, *path = NULL, *secure = NULL, *domain = NULL, *httpOnly = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &name_param, &value, &expire, &path, &secure, &domain, &httpOnly); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!value) { value = ZEPHIR_GLOBAL(global_null); } if (!expire) { ZEPHIR_INIT_VAR(expire); ZVAL_LONG(expire, 0); } if (!path) { ZEPHIR_INIT_VAR(path); ZVAL_STRING(path, "/", 1); } if (!secure) { secure = ZEPHIR_GLOBAL(global_null); } if (!domain) { domain = ZEPHIR_GLOBAL(global_null); } if (!httpOnly) { httpOnly = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); if (Z_TYPE_P(value) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_value"), value TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_expire"), expire TSRMLS_CC); if (Z_TYPE_P(path) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); } if (Z_TYPE_P(secure) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_secure"), secure TSRMLS_CC); } if (Z_TYPE_P(domain) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC); } if (Z_TYPE_P(httpOnly) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_httpOnly"), httpOnly TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Cookie, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Http_Cookie, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Http_Cookie, setValue) { zval *value; zephir_fetch_params(0, 1, 0, &value); zephir_update_property_this(this_ptr, SL("_value"), value TSRMLS_CC); if (1) { zephir_update_property_this(this_ptr, SL("_readed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_readed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Http_Cookie, getValue) { int ZEPHIR_LAST_CALL_STATUS; zval *filters = NULL, *defaultValue = NULL, *dependencyInjector = NULL, *value, *crypt = NULL, *decryptedValue = NULL, *filter = NULL, *_0, *_1, *_COOKIE, *_2, *_3, *_4, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_fetch_params(1, 0, 2, &filters, &defaultValue); if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(dependencyInjector); ZVAL_NULL(dependencyInjector); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_readed"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_OBS_VAR(value); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _COOKIE, _2, 0 TSRMLS_CC)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_useEncryption"), PH_NOISY_CC); if (zephir_is_true(_3)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'filter' service", "phalcon/http/cookie.zep", 152); return; } ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&crypt, dependencyInjector, "getshared", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&decryptedValue, crypt, "decryptbase64", NULL, 0, value); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(decryptedValue, value); } zephir_update_property_this(this_ptr, SL("_value"), decryptedValue TSRMLS_CC); if (Z_TYPE_P(filters) != IS_NULL) { ZEPHIR_OBS_VAR(filter); zephir_read_property_this(&filter, this_ptr, SL("_filter"), PH_NOISY_CC); if (Z_TYPE_P(filter) != IS_OBJECT) { if (Z_TYPE_P(dependencyInjector) == IS_NULL) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'filter' service", "phalcon/http/cookie.zep", 178); return; } } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&filter, dependencyInjector, "getshared", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_filter"), filter TSRMLS_CC); } ZEPHIR_RETURN_CALL_METHOD(filter, "sanitize", NULL, 0, decryptedValue, filters); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(decryptedValue); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } RETURN_MM_MEMBER(this_ptr, "_value"); } static PHP_METHOD(Phalcon_Http_Cookie, send) { zval *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *name, *value, *expire, *domain, *path, *secure, *httpOnly, *dependencyInjector, *definition, *session = NULL, *crypt = NULL, *encryptValue = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(name); zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_OBS_VAR(value); zephir_read_property_this(&value, this_ptr, SL("_value"), PH_NOISY_CC); ZEPHIR_OBS_VAR(expire); zephir_read_property_this(&expire, this_ptr, SL("_expire"), PH_NOISY_CC); ZEPHIR_OBS_VAR(domain); zephir_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY_CC); ZEPHIR_OBS_VAR(path); zephir_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY_CC); ZEPHIR_OBS_VAR(secure); zephir_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY_CC); ZEPHIR_OBS_VAR(httpOnly); zephir_read_property_this(&httpOnly, this_ptr, SL("_httpOnly"), PH_NOISY_CC); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'session' service", "phalcon/http/cookie.zep", 220); return; } ZEPHIR_INIT_VAR(definition); array_init(definition); if (!ZEPHIR_IS_LONG(expire, 0)) { zephir_array_update_string(&definition, SL("expire"), &expire, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(path))) { zephir_array_update_string(&definition, SL("path"), &path, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(domain))) { zephir_array_update_string(&definition, SL("domain"), &domain, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(secure))) { zephir_array_update_string(&definition, SL("secure"), &secure, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(httpOnly))) { zephir_array_update_string(&definition, SL("httpOnly"), &httpOnly, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(definition TSRMLS_CC)) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _0); ZEPHIR_CALL_METHOD(&_0, session, "isstarted", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "_PHCOOKIE_", name); ZEPHIR_CALL_METHOD(NULL, session, "set", NULL, 0, _2, definition); zephir_check_call_status(); } } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_useEncryption"), PH_NOISY_CC); if (zephir_is_true(_3)) { if (!(ZEPHIR_IS_EMPTY(value))) { if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'filter' service", "phalcon/http/cookie.zep", 260); return; } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "crypt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CPY_WRT(crypt, _0); zephir_get_strval(_4, value); ZEPHIR_CALL_METHOD(&encryptValue, crypt, "encryptbase64", NULL, 0, _4); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(encryptValue, value); } } else { ZEPHIR_CPY_WRT(encryptValue, value); } ZEPHIR_CALL_FUNCTION(NULL, "setcookie", NULL, 217, name, encryptValue, expire, path, domain, secure, httpOnly); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, restore) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector, *expire, *domain, *path, *secure, *httpOnly, *session = NULL, *definition = NULL, *_0, *_1, *_2 = NULL, *_3, *_4; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&session, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, session, "isstarted", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "_PHCOOKIE_", _3); ZEPHIR_CALL_METHOD(&definition, session, "get", NULL, 0, _4); zephir_check_call_status(); if (Z_TYPE_P(definition) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&expire, definition, SS("expire"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_expire"), expire TSRMLS_CC); } if (zephir_array_isset_string_fetch(&domain, definition, SS("domain"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC); } if (zephir_array_isset_string_fetch(&path, definition, SS("path"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); } if (zephir_array_isset_string_fetch(&secure, definition, SS("secure"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_secure"), secure TSRMLS_CC); } if (zephir_array_isset_string_fetch(&httpOnly, definition, SS("httpOnly"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_httpOnly"), httpOnly TSRMLS_CC); } } } } if (1) { zephir_update_property_this(this_ptr, SL("_restored"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_restored"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *name, *domain, *path, *secure, *httpOnly, *dependencyInjector = NULL, *session = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, _4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(name); zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_OBS_VAR(domain); zephir_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY_CC); ZEPHIR_OBS_VAR(path); zephir_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY_CC); ZEPHIR_OBS_VAR(secure); zephir_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY_CC); ZEPHIR_OBS_VAR(httpOnly); zephir_read_property_this(&httpOnly, this_ptr, SL("_httpOnly"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(session, _1); ZEPHIR_CALL_METHOD(&_1, session, "isstarted", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "_PHCOOKIE_", name); ZEPHIR_CALL_METHOD(NULL, session, "remove", NULL, 0, _3); zephir_check_call_status(); } } zephir_update_property_this(this_ptr, SL("_value"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); zephir_time(_2); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, (zephir_get_numberval(_2) - 691200)); ZEPHIR_CALL_FUNCTION(NULL, "setcookie", NULL, 217, name, ZEPHIR_GLOBAL(global_null), &_4, path, domain, secure, httpOnly); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Cookie, useEncryption) { zval *useEncryption_param = NULL; zend_bool useEncryption; zephir_fetch_params(0, 1, 0, &useEncryption_param); useEncryption = zephir_get_boolval(useEncryption_param); if (useEncryption) { zephir_update_property_this(this_ptr, SL("_useEncryption"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_useEncryption"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Http_Cookie, isUsingEncryption) { RETURN_MEMBER(this_ptr, "_useEncryption"); } static PHP_METHOD(Phalcon_Http_Cookie, setExpiration) { zval *expire_param = NULL, *_0, *_1; int expire, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expire_param); expire = zephir_get_intval(expire_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, expire); zephir_update_property_this(this_ptr, SL("_expire"), _1 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, getExpiration) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } RETURN_MM_MEMBER(this_ptr, "_expire"); } static PHP_METHOD(Phalcon_Http_Cookie, setPath) { int ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *_0; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &path_param); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Http_Cookie, getPath) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } RETURN_MM_MEMBER(this_ptr, "_path"); } static PHP_METHOD(Phalcon_Http_Cookie, setDomain) { int ZEPHIR_LAST_CALL_STATUS; zval *domain_param = NULL, *_0; zval *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &domain_param); if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, getDomain) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } RETURN_MM_MEMBER(this_ptr, "_domain"); } static PHP_METHOD(Phalcon_Http_Cookie, setSecure) { int ZEPHIR_LAST_CALL_STATUS; zval *secure_param = NULL, *_0; zend_bool secure; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &secure_param); secure = zephir_get_boolval(secure_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } if (secure) { zephir_update_property_this(this_ptr, SL("_secure"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_secure"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, getSecure) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } RETURN_MM_MEMBER(this_ptr, "_secure"); } static PHP_METHOD(Phalcon_Http_Cookie, setHttpOnly) { int ZEPHIR_LAST_CALL_STATUS; zval *httpOnly_param = NULL, *_0; zend_bool httpOnly; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &httpOnly_param); httpOnly = zephir_get_boolval(httpOnly_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } if (httpOnly) { zephir_update_property_this(this_ptr, SL("_httpOnly"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_httpOnly"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Cookie, getHttpOnly) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_restored"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "restore", NULL, 0); zephir_check_call_status(); } RETURN_MM_MEMBER(this_ptr, "_httpOnly"); } static PHP_METHOD(Phalcon_Http_Cookie, __toString) { zval *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getvalue", NULL, 0); zephir_check_call_status(); zephir_get_strval(_1, _0); RETURN_CTOR(_1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_CookieInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, CookieInterface, phalcon, http_cookieinterface, phalcon_http_cookieinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setValue); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getValue); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, send); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, useEncryption); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, isUsingEncryption); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setExpiration); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getExpiration); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setPath); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getPath); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setDomain); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getDomain); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setSecure); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getSecure); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, setHttpOnly); ZEPHIR_DOC_METHOD(Phalcon_Http_CookieInterface, getHttpOnly); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Request) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http, Request, phalcon, http_request, phalcon_http_request_method_entry, 0); zend_declare_property_null(phalcon_http_request_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_ce, SL("_rawBody"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_ce, SL("_filter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_ce, SL("_putCache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_request_ce TSRMLS_CC, 1, phalcon_http_requestinterface_ce); zend_class_implements(phalcon_http_request_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Request, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Http_Request, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Http_Request, get) { int ZEPHIR_LAST_CALL_STATUS; zend_bool notAllowEmpty, noRecursive; zval *name_param = NULL, *filters = NULL, *defaultValue = NULL, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, *_REQUEST, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_REQUEST, SS("_REQUEST") TSRMLS_CC); zephir_fetch_params(1, 0, 5, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } } if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!notAllowEmpty_param) { notAllowEmpty = 0; } else { notAllowEmpty = zephir_get_boolval(notAllowEmpty_param); } if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } ZEPHIR_INIT_VAR(_0); if (notAllowEmpty) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_INIT_VAR(_1); if (noRecursive) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 218, _REQUEST, name, filters, defaultValue, _0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getPost) { int ZEPHIR_LAST_CALL_STATUS; zend_bool notAllowEmpty, noRecursive; zval *name_param = NULL, *filters = NULL, *defaultValue = NULL, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, *_POST, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_fetch_params(1, 0, 5, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } } if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!notAllowEmpty_param) { notAllowEmpty = 0; } else { notAllowEmpty = zephir_get_boolval(notAllowEmpty_param); } if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } ZEPHIR_INIT_VAR(_0); if (notAllowEmpty) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_INIT_VAR(_1); if (noRecursive) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 218, _POST, name, filters, defaultValue, _0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getPut) { int ZEPHIR_LAST_CALL_STATUS; zend_bool notAllowEmpty, noRecursive; zval *name_param = NULL, *filters = NULL, *defaultValue = NULL, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, *put = NULL, *_0 = NULL, *_1, *_2; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 5, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } } if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!notAllowEmpty_param) { notAllowEmpty = 0; } else { notAllowEmpty = zephir_get_boolval(notAllowEmpty_param); } if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } ZEPHIR_OBS_VAR(put); zephir_read_property_this(&put, this_ptr, SL("_putCache"), PH_NOISY_CC); if (Z_TYPE_P(put) != IS_ARRAY) { ZEPHIR_INIT_NVAR(put); array_init(put); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getrawbody", NULL, 0); zephir_check_call_status(); ZEPHIR_MAKE_REF(put); ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 219, _0, put); ZEPHIR_UNREF(put); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_putCache"), put TSRMLS_CC); } ZEPHIR_INIT_VAR(_1); if (notAllowEmpty) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_INIT_VAR(_2); if (noRecursive) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 218, put, name, filters, defaultValue, _1, _2); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getQuery) { int ZEPHIR_LAST_CALL_STATUS; zend_bool notAllowEmpty, noRecursive; zval *name_param = NULL, *filters = NULL, *defaultValue = NULL, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, *_GET, *_0, *_1; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); zephir_fetch_params(1, 0, 5, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } } if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!notAllowEmpty_param) { notAllowEmpty = 0; } else { notAllowEmpty = zephir_get_boolval(notAllowEmpty_param); } if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } ZEPHIR_INIT_VAR(_0); if (notAllowEmpty) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_INIT_VAR(_1); if (noRecursive) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 218, _GET, name, filters, defaultValue, _0, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getHelper) { int ZEPHIR_LAST_CALL_STATUS; zend_bool notAllowEmpty, noRecursive, _3; zval *name = NULL; zval *source_param = NULL, *name_param = NULL, *filters = NULL, *defaultValue = NULL, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, *value = NULL, *filter = NULL, *dependencyInjector = NULL, *_0, *_1 = NULL, *_2 = NULL; zval *source = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 5, &source_param, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); zephir_get_arrval(source, source_param); if (!name_param) { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } else { if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } } if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!notAllowEmpty_param) { notAllowEmpty = 0; } else { notAllowEmpty = zephir_get_boolval(notAllowEmpty_param); } if (!noRecursive_param) { noRecursive = 0; } else { noRecursive = zephir_get_boolval(noRecursive_param); } if (ZEPHIR_IS_STRING_IDENTICAL(name, "")) { RETURN_CTOR(source); } ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_fetch(&value, source, name, 0 TSRMLS_CC))) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } if (Z_TYPE_P(filters) != IS_NULL) { ZEPHIR_OBS_VAR(filter); zephir_read_property_this(&filter, this_ptr, SL("_filter"), PH_NOISY_CC); if (Z_TYPE_P(filter) != IS_OBJECT) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "A dependency injection object is required to access the 'filter' service", "phalcon/http/request.zep", 175); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(filter, _1); zephir_update_property_this(this_ptr, SL("_filter"), filter TSRMLS_CC); } ZEPHIR_INIT_NVAR(_2); if (noRecursive) { ZVAL_BOOL(_2, 1); } else { ZVAL_BOOL(_2, 0); } ZEPHIR_CALL_METHOD(&_1, filter, "sanitize", NULL, 0, value, filters, _2); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _1); } _3 = ZEPHIR_IS_EMPTY(value); if (_3) { _3 = notAllowEmpty == 1; } if (_3) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } RETURN_CCTOR(value); } static PHP_METHOD(Phalcon_Http_Request, getServer) { zval *name_param = NULL, *serverValue, *_SERVER; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (zephir_array_isset_fetch(&serverValue, _SERVER, name, 1 TSRMLS_CC)) { RETURN_CTOR(serverValue); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Http_Request, has) { zval *name_param = NULL, *_REQUEST; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_REQUEST, SS("_REQUEST") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } RETURN_MM_BOOL(zephir_array_isset(_REQUEST, name)); } static PHP_METHOD(Phalcon_Http_Request, hasPost) { zval *name_param = NULL, *_POST; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } RETURN_MM_BOOL(zephir_array_isset(_POST, name)); } static PHP_METHOD(Phalcon_Http_Request, hasPut) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *put = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_CALL_METHOD(&put, this_ptr, "getput", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(zephir_array_isset(put, name)); } static PHP_METHOD(Phalcon_Http_Request, hasQuery) { zval *name_param = NULL, *_GET; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } RETURN_MM_BOOL(zephir_array_isset(_GET, name)); } static PHP_METHOD(Phalcon_Http_Request, hasServer) { zval *name_param = NULL, *_SERVER; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } RETURN_MM_BOOL(zephir_array_isset(_SERVER, name)); } static PHP_METHOD(Phalcon_Http_Request, getHeader) { int ZEPHIR_LAST_CALL_STATUS; zval *header_param = NULL, *value = NULL, *name, _0, _1, *_2 = NULL, *_SERVER, *_3; zval *header = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &header_param); if (unlikely(Z_TYPE_P(header_param) != IS_STRING && Z_TYPE_P(header_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'header' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(header_param) == IS_STRING)) { zephir_get_strval(header, header_param); } else { ZEPHIR_INIT_VAR(header); ZVAL_EMPTY_STRING(header); } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "-", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "_", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, header, &_0, &_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(name); zephir_fast_strtoupper(name, _2); ZEPHIR_OBS_VAR(value); if (zephir_array_isset_fetch(&value, _SERVER, name, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } ZEPHIR_OBS_NVAR(value); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "HTTP_", name); if (zephir_array_isset_fetch(&value, _SERVER, _3, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Http_Request, getScheme) { int ZEPHIR_LAST_CALL_STATUS; zval *https = NULL, *scheme = NULL, *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HTTPS", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&https, this_ptr, "getserver", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(https)) { ZEPHIR_INIT_VAR(scheme); if (ZEPHIR_IS_STRING(https, "off")) { ZVAL_STRING(scheme, "http", 1); } else { ZVAL_STRING(scheme, "https", 1); } } else { ZEPHIR_INIT_NVAR(scheme); ZVAL_STRING(scheme, "http", 1); } RETURN_CCTOR(scheme); } static PHP_METHOD(Phalcon_Http_Request, isAjax) { zend_bool _0; zval *_SERVER, *_1; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); _0 = zephir_array_isset_string(_SERVER, SS("HTTP_X_REQUESTED_WITH")); if (_0) { zephir_array_fetch_string(&_1, _SERVER, SL("HTTP_X_REQUESTED_WITH"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 293 TSRMLS_CC); _0 = ZEPHIR_IS_STRING_IDENTICAL(_1, "XMLHttpRequest"); } RETURN_BOOL(_0); } static PHP_METHOD(Phalcon_Http_Request, isSoapRequested) { int ZEPHIR_LAST_CALL_STATUS; zval *contentType = NULL, *_SERVER; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string(_SERVER, SS("HTTP_SOAPACTION"))) { RETURN_MM_BOOL(1); } else { ZEPHIR_CALL_METHOD(&contentType, this_ptr, "getcontenttype", NULL, 0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(contentType))) { RETURN_MM_BOOL(zephir_memnstr_str(contentType, SL("application/soap+xml"), "phalcon/http/request.zep", 308)); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Request, isSecureRequest) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getscheme", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "https")); } static PHP_METHOD(Phalcon_Http_Request, getRawBody) { zval *rawBody, *contents, _0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(rawBody); zephir_read_property_this(&rawBody, this_ptr, SL("_rawBody"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(rawBody)) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "php://input", 0); ZEPHIR_INIT_VAR(contents); zephir_file_get_contents(contents, &_0 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_rawBody"), contents TSRMLS_CC); RETURN_CCTOR(contents); } RETURN_CCTOR(rawBody); } static PHP_METHOD(Phalcon_Http_Request, getJsonRawBody) { int ZEPHIR_LAST_CALL_STATUS; zval *associative_param = NULL, *rawBody = NULL, _0; zend_bool associative; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &associative_param); if (!associative_param) { associative = 0; } else { associative = zephir_get_boolval(associative_param); } ZEPHIR_CALL_METHOD(&rawBody, this_ptr, "getrawbody", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(rawBody) != IS_STRING) { RETURN_MM_BOOL(0); } ZEPHIR_SINIT_VAR(_0); ZVAL_BOOL(&_0, (associative ? 1 : 0)); zephir_json_decode(return_value, &(return_value), rawBody, zephir_get_intval(&_0) TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getServerAddress) { int ZEPHIR_LAST_CALL_STATUS; zval *serverAddr, *_SERVER, _0; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_OBS_VAR(serverAddr); if (zephir_array_isset_string_fetch(&serverAddr, _SERVER, SS("SERVER_ADDR"), 0 TSRMLS_CC)) { RETURN_CCTOR(serverAddr); } ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "localhost", 0); ZEPHIR_RETURN_CALL_FUNCTION("gethostbyname", NULL, 220, &_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getServerName) { zval *serverName, *_SERVER; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&serverName, _SERVER, SS("SERVER_NAME"), 1 TSRMLS_CC)) { RETURN_CTORW(serverName); } RETURN_STRING("localhost", 1); } static PHP_METHOD(Phalcon_Http_Request, getHttpHost) { zend_bool _2, _3; zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *httpHost = NULL, *scheme = NULL, *name = NULL, *port = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HTTP_HOST", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&httpHost, this_ptr, "getserver", &_1, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(httpHost)) { RETURN_CCTOR(httpHost); } ZEPHIR_CALL_METHOD(&scheme, this_ptr, "getscheme", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "SERVER_NAME", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&name, this_ptr, "getserver", &_1, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "SERVER_PORT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&port, this_ptr, "getserver", &_1, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = ZEPHIR_IS_STRING(scheme, "http"); if (_2) { _2 = ZEPHIR_IS_LONG(port, 80); } if (_2) { RETURN_CCTOR(name); } _3 = ZEPHIR_IS_STRING(scheme, "https"); if (_3) { _3 = ZEPHIR_IS_LONG(port, 443); } if (_3) { RETURN_CCTOR(name); } ZEPHIR_CONCAT_VSV(return_value, name, ":", port); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getURI) { zval *requestURI, *_SERVER; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&requestURI, _SERVER, SS("REQUEST_URI"), 1 TSRMLS_CC)) { RETURN_CTORW(requestURI); } RETURN_STRING("", 1); } static PHP_METHOD(Phalcon_Http_Request, getClientAddress) { zval *trustForwardedHeader_param = NULL, *address = NULL, *_SERVER, *_0, *_1; zend_bool trustForwardedHeader; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &trustForwardedHeader_param); if (!trustForwardedHeader_param) { trustForwardedHeader = 0; } else { trustForwardedHeader = zephir_get_boolval(trustForwardedHeader_param); } ZEPHIR_INIT_VAR(address); ZVAL_NULL(address); if (trustForwardedHeader) { ZEPHIR_OBS_NVAR(address); zephir_array_isset_string_fetch(&address, _SERVER, SS("HTTP_X_FORWARDED_FOR"), 0 TSRMLS_CC); if (Z_TYPE_P(address) == IS_NULL) { ZEPHIR_OBS_NVAR(address); zephir_array_isset_string_fetch(&address, _SERVER, SS("HTTP_CLIENT_IP"), 0 TSRMLS_CC); } } if (Z_TYPE_P(address) == IS_NULL) { ZEPHIR_OBS_NVAR(address); zephir_array_isset_string_fetch(&address, _SERVER, SS("REMOTE_ADDR"), 0 TSRMLS_CC); } if (Z_TYPE_P(address) == IS_STRING) { if (zephir_memnstr_str(address, SL(","), "phalcon/http/request.zep", 468)) { ZEPHIR_INIT_VAR(_0); zephir_fast_explode_str(_0, SL(","), address, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_1, _0, 0, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 472 TSRMLS_CC); RETURN_CTOR(_1); } RETURN_CCTOR(address); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Request, getMethod) { zval *requestMethod, *_SERVER; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&requestMethod, _SERVER, SS("REQUEST_METHOD"), 1 TSRMLS_CC)) { RETURN_CTORW(requestMethod); } RETURN_STRING("", 1); } static PHP_METHOD(Phalcon_Http_Request, getUserAgent) { zval *userAgent, *_SERVER; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&userAgent, _SERVER, SS("HTTP_USER_AGENT"), 1 TSRMLS_CC)) { RETURN_CTORW(userAgent); } RETURN_STRING("", 1); } static PHP_METHOD(Phalcon_Http_Request, isValidHttpMethod) { zval *method_param = NULL, *lowerMethod; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &method_param); zephir_get_strval(method, method_param); ZEPHIR_INIT_VAR(lowerMethod); zephir_fast_strtoupper(lowerMethod, method); do { if (ZEPHIR_IS_STRING(method, "GET") || ZEPHIR_IS_STRING(method, "POST") || ZEPHIR_IS_STRING(method, "PUT") || ZEPHIR_IS_STRING(method, "DELETE") || ZEPHIR_IS_STRING(method, "HEAD") || ZEPHIR_IS_STRING(method, "OPTIONS") || ZEPHIR_IS_STRING(method, "PATCH")) { RETURN_MM_BOOL(1); } } while(0); RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Request, isMethod) { HashTable *_6; HashPosition _5; zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool strict, _0; zval *methods, *strict_param = NULL, *httpMethod = NULL, *method = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, **_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &methods, &strict_param); if (!strict_param) { strict = 0; } else { strict = zephir_get_boolval(strict_param); } ZEPHIR_CALL_METHOD(&httpMethod, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_STRING) { _0 = strict; if (_0) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "isvalidhttpmethod", &_2, 0, methods); zephir_check_call_status(); _0 = !zephir_is_true(_1); } if (_0) { ZEPHIR_INIT_VAR(_3); object_init_ex(_3, phalcon_http_request_exception_ce); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "Invalid HTTP method: ", methods); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/http/request.zep", 542 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(methods, httpMethod)); } if (Z_TYPE_P(methods) == IS_ARRAY) { zephir_is_iterable(methods, &_6, &_5, 0, 0, "phalcon/http/request.zep", 560); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(method, _7); _0 = strict; if (_0) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "isvalidhttpmethod", &_2, 0, method); zephir_check_call_status(); _0 = !zephir_is_true(_1); } if (_0) { if (Z_TYPE_P(method) == IS_STRING) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_http_request_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, "Invalid HTTP method: ", method); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/http/request.zep", 551 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "Invalid HTTP method: non-string", "phalcon/http/request.zep", 553); return; } } if (ZEPHIR_IS_EQUAL(method, httpMethod)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } if (strict) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "Invalid HTTP method: non-string", "phalcon/http/request.zep", 564); return; } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Request, isPost) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "POST")); } static PHP_METHOD(Phalcon_Http_Request, isGet) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "GET")); } static PHP_METHOD(Phalcon_Http_Request, isPut) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "PUT")); } static PHP_METHOD(Phalcon_Http_Request, isPatch) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "PATCH")); } static PHP_METHOD(Phalcon_Http_Request, isHead) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "HEAD")); } static PHP_METHOD(Phalcon_Http_Request, isDelete) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "DELETE")); } static PHP_METHOD(Phalcon_Http_Request, isOptions) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 221); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(_0, "OPTIONS")); } static PHP_METHOD(Phalcon_Http_Request, hasFiles) { zephir_fcall_cache_entry *_6 = NULL; HashTable *_1; HashPosition _0; int numberFiles = 0, ZEPHIR_LAST_CALL_STATUS; zval *onlySuccessful_param = NULL, *files = NULL, *file = NULL, *error = NULL, *_FILES, **_2, *_4 = NULL, *_5 = NULL; zend_bool onlySuccessful, _3; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &onlySuccessful_param); if (!onlySuccessful_param) { onlySuccessful = 0; } else { onlySuccessful = zephir_get_boolval(onlySuccessful_param); } ZEPHIR_CPY_WRT(files, _FILES); if (Z_TYPE_P(files) != IS_ARRAY) { RETURN_MM_LONG(0); } zephir_is_iterable(files, &_1, &_0, 0, 0, "phalcon/http/request.zep", 655); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(file, _2); ZEPHIR_OBS_NVAR(error); if (zephir_array_isset_string_fetch(&error, file, SS("error"), 0 TSRMLS_CC)) { if (Z_TYPE_P(error) != IS_ARRAY) { _3 = !zephir_is_true(error); if (!(_3)) { _3 = !onlySuccessful; } if (_3) { numberFiles++; } } if (Z_TYPE_P(error) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); if (onlySuccessful) { ZVAL_BOOL(_5, 1); } else { ZVAL_BOOL(_5, 0); } ZEPHIR_CALL_METHOD(&_4, this_ptr, "hasfilehelper", &_6, 222, error, _5); zephir_check_call_status(); numberFiles += zephir_get_numberval(_4); } } } RETURN_MM_LONG(numberFiles); } static PHP_METHOD(Phalcon_Http_Request, hasFileHelper) { zephir_fcall_cache_entry *_6 = NULL; HashTable *_1; HashPosition _0; int numberFiles = 0, ZEPHIR_LAST_CALL_STATUS; zend_bool onlySuccessful, _3; zval *data, *onlySuccessful_param = NULL, *value = NULL, **_2, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &data, &onlySuccessful_param); onlySuccessful = zephir_get_boolval(onlySuccessful_param); if (Z_TYPE_P(data) != IS_ARRAY) { RETURN_MM_LONG(1); } zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/http/request.zep", 682); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(value) != IS_ARRAY) { _3 = !zephir_is_true(value); if (!(_3)) { _3 = !onlySuccessful; } if (_3) { numberFiles++; } } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); if (onlySuccessful) { ZVAL_BOOL(_5, 1); } else { ZVAL_BOOL(_5, 0); } ZEPHIR_CALL_METHOD(&_4, this_ptr, "hasfilehelper", &_6, 222, value, _5); zephir_check_call_status(); numberFiles += zephir_get_numberval(_4); } } RETURN_MM_LONG(numberFiles); } static PHP_METHOD(Phalcon_Http_Request, getUploadedFiles) { zephir_fcall_cache_entry *_9 = NULL, *_18 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_11; HashPosition _0, _10; zval *files = NULL; zval *onlySuccessful_param = NULL, *superFiles = NULL, *prefix = NULL, *input = NULL, *smoothInput = NULL, *file = NULL, *dataFile = NULL, *_FILES, **_2, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, **_12, *_14, *_15 = NULL, *_16 = NULL, *_17; zend_bool onlySuccessful, _13; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &onlySuccessful_param); if (!onlySuccessful_param) { onlySuccessful = 0; } else { onlySuccessful = zephir_get_boolval(onlySuccessful_param); } ZEPHIR_INIT_VAR(files); array_init(files); ZEPHIR_INIT_NVAR(files); array_init(files); ZEPHIR_CPY_WRT(superFiles, _FILES); if (zephir_fast_count_int(superFiles TSRMLS_CC) > 0) { zephir_is_iterable(superFiles, &_1, &_0, 0, 0, "phalcon/http/request.zep", 720); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(prefix, _1, _0); ZEPHIR_GET_HVALUE(input, _2); ZEPHIR_OBS_NVAR(_3); zephir_array_fetch_string(&_3, input, SL("name"), PH_NOISY, "phalcon/http/request.zep", 698 TSRMLS_CC); if (Z_TYPE_P(_3) == IS_ARRAY) { zephir_array_fetch_string(&_4, input, SL("name"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 699 TSRMLS_CC); zephir_array_fetch_string(&_5, input, SL("type"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 699 TSRMLS_CC); zephir_array_fetch_string(&_6, input, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 699 TSRMLS_CC); zephir_array_fetch_string(&_7, input, SL("size"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 699 TSRMLS_CC); zephir_array_fetch_string(&_8, input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 699 TSRMLS_CC); ZEPHIR_CALL_METHOD(&smoothInput, this_ptr, "smoothfiles", &_9, 223, _4, _5, _6, _7, _8, prefix); zephir_check_call_status(); zephir_is_iterable(smoothInput, &_11, &_10, 0, 0, "phalcon/http/request.zep", 714); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HVALUE(file, _12); _13 = onlySuccessful == 0; if (!(_13)) { zephir_array_fetch_string(&_14, file, SL("error"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 702 TSRMLS_CC); _13 = ZEPHIR_IS_LONG(_14, 0); } if (_13) { ZEPHIR_INIT_NVAR(dataFile); zephir_create_array(dataFile, 5, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, file, SL("name"), PH_NOISY, "phalcon/http/request.zep", 704 TSRMLS_CC); zephir_array_update_string(&dataFile, SL("name"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, file, SL("type"), PH_NOISY, "phalcon/http/request.zep", 705 TSRMLS_CC); zephir_array_update_string(&dataFile, SL("type"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, file, SL("tmp_name"), PH_NOISY, "phalcon/http/request.zep", 706 TSRMLS_CC); zephir_array_update_string(&dataFile, SL("tmp_name"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, file, SL("size"), PH_NOISY, "phalcon/http/request.zep", 707 TSRMLS_CC); zephir_array_update_string(&dataFile, SL("size"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_15); zephir_array_fetch_string(&_15, file, SL("error"), PH_NOISY, "phalcon/http/request.zep", 709 TSRMLS_CC); zephir_array_update_string(&dataFile, SL("error"), &_15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_16); object_init_ex(_16, phalcon_http_request_file_ce); zephir_array_fetch_string(&_17, file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 711 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_18, 224, dataFile, _17); zephir_check_call_status(); zephir_array_append(&files, _16, PH_SEPARATE, "phalcon/http/request.zep", 711); } } } else { _13 = onlySuccessful == 0; if (!(_13)) { zephir_array_fetch_string(&_4, input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 715 TSRMLS_CC); _13 = ZEPHIR_IS_LONG(_4, 0); } if (_13) { ZEPHIR_INIT_NVAR(_16); object_init_ex(_16, phalcon_http_request_file_ce); ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_18, 224, input, prefix); zephir_check_call_status(); zephir_array_append(&files, _16, PH_SEPARATE, "phalcon/http/request.zep", 716); } } } } RETURN_CTOR(files); } static PHP_METHOD(Phalcon_Http_Request, smoothFiles) { zephir_fcall_cache_entry *_10 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_12; HashPosition _0, _11; zval *prefix = NULL; zval *names_param = NULL, *types_param = NULL, *tmp_names_param = NULL, *sizes_param = NULL, *errors_param = NULL, *prefix_param = NULL, *idx = NULL, *name = NULL, *file = NULL, *files, *parentFiles = NULL, *p = NULL, **_2, *_4 = NULL, *_5, *_6, *_7, *_8, *_9, **_13; zval *names = NULL, *types = NULL, *tmp_names = NULL, *sizes = NULL, *errors = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 6, 0, &names_param, &types_param, &tmp_names_param, &sizes_param, &errors_param, &prefix_param); names = names_param; types = types_param; tmp_names = tmp_names_param; sizes = sizes_param; errors = errors_param; zephir_get_strval(prefix, prefix_param); ZEPHIR_INIT_VAR(files); array_init(files); zephir_is_iterable(names, &_1, &_0, 0, 0, "phalcon/http/request.zep", 758); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(idx, _1, _0); ZEPHIR_GET_HVALUE(name, _2); ZEPHIR_INIT_NVAR(p); ZEPHIR_CONCAT_VSV(p, prefix, ".", idx); if (Z_TYPE_P(name) == IS_STRING) { ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 6, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("name"), &name, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_4); zephir_array_fetch(&_4, types, idx, PH_NOISY, "phalcon/http/request.zep", 741 TSRMLS_CC); zephir_array_update_string(&_3, SL("type"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_4); zephir_array_fetch(&_4, tmp_names, idx, PH_NOISY, "phalcon/http/request.zep", 742 TSRMLS_CC); zephir_array_update_string(&_3, SL("tmp_name"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_4); zephir_array_fetch(&_4, sizes, idx, PH_NOISY, "phalcon/http/request.zep", 743 TSRMLS_CC); zephir_array_update_string(&_3, SL("size"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_4); zephir_array_fetch(&_4, errors, idx, PH_NOISY, "phalcon/http/request.zep", 744 TSRMLS_CC); zephir_array_update_string(&_3, SL("error"), &_4, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_3, SL("key"), &p, PH_COPY | PH_SEPARATE); zephir_array_append(&files, _3, PH_SEPARATE, "phalcon/http/request.zep", 746); } if (Z_TYPE_P(name) == IS_ARRAY) { zephir_array_fetch(&_5, names, idx, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 750 TSRMLS_CC); zephir_array_fetch(&_6, types, idx, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 750 TSRMLS_CC); zephir_array_fetch(&_7, tmp_names, idx, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 750 TSRMLS_CC); zephir_array_fetch(&_8, sizes, idx, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 750 TSRMLS_CC); zephir_array_fetch(&_9, errors, idx, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 750 TSRMLS_CC); ZEPHIR_CALL_METHOD(&parentFiles, this_ptr, "smoothfiles", &_10, 223, _5, _6, _7, _8, _9, p); zephir_check_call_status(); zephir_is_iterable(parentFiles, &_12, &_11, 0, 0, "phalcon/http/request.zep", 755); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HVALUE(file, _13); zephir_array_append(&files, file, PH_SEPARATE, "phalcon/http/request.zep", 753); } } } RETURN_CCTOR(files); } static PHP_METHOD(Phalcon_Http_Request, getHeaders) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_9 = NULL; HashTable *_1; HashPosition _0; zval *headers; zval *name = NULL, *value = NULL, *contentHeaders, *_SERVER, **_2, *_3 = NULL, *_4 = NULL, _5 = zval_used_for_init, *_6 = NULL, _7 = zval_used_for_init, _8 = zval_used_for_init, *_10 = NULL, _11 = zval_used_for_init, _12 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_INIT_VAR(headers); array_init(headers); ZEPHIR_INIT_VAR(contentHeaders); zephir_create_array(contentHeaders, 2, 0 TSRMLS_CC); zephir_array_update_string(&contentHeaders, SL("CONTENT_TYPE"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&contentHeaders, SL("CONTENT_LENGTH"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_is_iterable(_SERVER, &_1, &_0, 0, 0, "phalcon/http/request.zep", 784); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(name, _1, _0); ZEPHIR_GET_HVALUE(value, _2); if (zephir_start_with_str(name, SL("HTTP_"))) { ZEPHIR_INIT_NVAR(_3); ZEPHIR_INIT_NVAR(_4); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 5); ZEPHIR_INIT_NVAR(_6); zephir_substr(_6, name, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_SINIT_NVAR(_7); ZVAL_STRING(&_7, "_", 0); ZEPHIR_SINIT_NVAR(_8); ZVAL_STRING(&_8, " ", 0); zephir_fast_str_replace(&_4, &_7, &_8, _6 TSRMLS_CC); zephir_fast_strtolower(_3, _4); ZEPHIR_CALL_FUNCTION(&name, "ucwords", &_9, 225, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_NVAR(_11); ZVAL_STRING(&_11, " ", 0); ZEPHIR_SINIT_NVAR(_12); ZVAL_STRING(&_12, "-", 0); zephir_fast_str_replace(&_10, &_11, &_12, name TSRMLS_CC); ZEPHIR_CPY_WRT(name, _10); zephir_array_update_zval(&headers, name, &value, PH_COPY | PH_SEPARATE); } else if (zephir_array_isset(contentHeaders, name)) { ZEPHIR_INIT_NVAR(_3); ZEPHIR_INIT_NVAR(_4); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "_", 0); ZEPHIR_SINIT_NVAR(_7); ZVAL_STRING(&_7, " ", 0); zephir_fast_str_replace(&_4, &_5, &_7, name TSRMLS_CC); zephir_fast_strtolower(_3, _4); ZEPHIR_CALL_FUNCTION(&name, "ucwords", &_9, 225, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_6); ZEPHIR_SINIT_NVAR(_8); ZVAL_STRING(&_8, " ", 0); ZEPHIR_SINIT_NVAR(_11); ZVAL_STRING(&_11, "-", 0); zephir_fast_str_replace(&_6, &_8, &_11, name TSRMLS_CC); ZEPHIR_CPY_WRT(name, _6); zephir_array_update_zval(&headers, name, &value, PH_COPY | PH_SEPARATE); } } RETURN_CTOR(headers); } static PHP_METHOD(Phalcon_Http_Request, getHTTPReferer) { zval *httpReferer, *_SERVER; zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); if (zephir_array_isset_string_fetch(&httpReferer, _SERVER, SS("HTTP_REFERER"), 1 TSRMLS_CC)) { RETURN_CTORW(httpReferer); } RETURN_STRING("", 1); } static PHP_METHOD(Phalcon_Http_Request, _getQualityHeader) { HashTable *_7, *_12; HashPosition _6, _11; zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *serverIndex_param = NULL, *name_param = NULL, *returnedParts, *part = NULL, *headerParts = NULL, *headerPart = NULL, *split = NULL, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, _3 = zval_used_for_init, *_4 = NULL, **_8, *_9 = NULL, *_10 = NULL, **_13, *_14 = NULL, *_15, *_16 = NULL, *_17 = NULL, *_18; zval *serverIndex = NULL, *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &serverIndex_param, &name_param); if (unlikely(Z_TYPE_P(serverIndex_param) != IS_STRING && Z_TYPE_P(serverIndex_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serverIndex' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(serverIndex_param) == IS_STRING)) { zephir_get_strval(serverIndex, serverIndex_param); } else { ZEPHIR_INIT_VAR(serverIndex); ZVAL_EMPTY_STRING(serverIndex); } if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_INIT_VAR(returnedParts); array_init(returnedParts); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getserver", NULL, 0, serverIndex); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "/,\\s*/", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, -1); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 1); ZEPHIR_CALL_FUNCTION(&_4, "preg_split", &_5, 226, &_1, _0, &_2, &_3); zephir_check_call_status(); zephir_is_iterable(_4, &_7, &_6, 0, 0, "phalcon/http/request.zep", 827); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(part, _8); ZEPHIR_INIT_NVAR(headerParts); array_init(headerParts); ZEPHIR_INIT_NVAR(_9); zephir_fast_trim(_9, part, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/\\s*;\\s*/", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, -1); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 1); ZEPHIR_CALL_FUNCTION(&_10, "preg_split", &_5, 226, &_1, _9, &_2, &_3); zephir_check_call_status(); zephir_is_iterable(_10, &_12, &_11, 0, 0, "phalcon/http/request.zep", 824); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HVALUE(headerPart, _13); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "=", 0); ZEPHIR_INIT_NVAR(_14); zephir_fast_strpos(_14, headerPart, &_1, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(_14)) { ZEPHIR_INIT_NVAR(split); zephir_fast_explode_str(split, SL("="), headerPart, 2 TSRMLS_CC); zephir_array_fetch_long(&_15, split, 0, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 813 TSRMLS_CC); if (ZEPHIR_IS_STRING_IDENTICAL(_15, "q")) { ZEPHIR_OBS_NVAR(_16); zephir_array_fetch_long(&_16, split, 1, PH_NOISY, "phalcon/http/request.zep", 814 TSRMLS_CC); ZEPHIR_INIT_NVAR(_17); ZVAL_DOUBLE(_17, zephir_get_doubleval(_16)); zephir_array_update_string(&headerParts, SL("quality"), &_17, PH_COPY | PH_SEPARATE); } else { zephir_array_fetch_long(&_18, split, 1, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 816 TSRMLS_CC); ZEPHIR_OBS_NVAR(_16); zephir_array_fetch_long(&_16, split, 0, PH_NOISY, "phalcon/http/request.zep", 816 TSRMLS_CC); zephir_array_update_zval(&headerParts, _16, &_18, PH_COPY | PH_SEPARATE); } } else { zephir_array_update_zval(&headerParts, name, &headerPart, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_17); ZVAL_DOUBLE(_17, 1.0); zephir_array_update_string(&headerParts, SL("quality"), &_17, PH_COPY | PH_SEPARATE); } } zephir_array_append(&returnedParts, headerParts, PH_SEPARATE, "phalcon/http/request.zep", 824); } RETURN_CCTOR(returnedParts); } static PHP_METHOD(Phalcon_Http_Request, _getBestQuality) { HashTable *_1; HashPosition _0; double quality, acceptQuality; int i; zval *name = NULL; zval *qualityParts_param = NULL, *name_param = NULL, *selectedName = NULL, *accept = NULL, **_2, *_3 = NULL; zval *qualityParts = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &qualityParts_param, &name_param); zephir_get_arrval(qualityParts, qualityParts_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } i = 0; quality = 0.0; ZEPHIR_INIT_VAR(selectedName); ZVAL_STRING(selectedName, "", 1); zephir_is_iterable(qualityParts, &_1, &_0, 0, 0, "phalcon/http/request.zep", 856); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(accept, _2); if (i == 0) { ZEPHIR_OBS_NVAR(_3); zephir_array_fetch_string(&_3, accept, SL("quality"), PH_NOISY, "phalcon/http/request.zep", 845 TSRMLS_CC); quality = zephir_get_doubleval(_3); ZEPHIR_OBS_NVAR(selectedName); zephir_array_fetch(&selectedName, accept, name, PH_NOISY, "phalcon/http/request.zep", 846 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(_3); zephir_array_fetch_string(&_3, accept, SL("quality"), PH_NOISY, "phalcon/http/request.zep", 848 TSRMLS_CC); acceptQuality = zephir_get_doubleval(_3); if (acceptQuality > quality) { quality = acceptQuality; ZEPHIR_OBS_NVAR(selectedName); zephir_array_fetch(&selectedName, accept, name, PH_NOISY, "phalcon/http/request.zep", 851 TSRMLS_CC); } } i++; } RETURN_CCTOR(selectedName); } static PHP_METHOD(Phalcon_Http_Request, getContentType) { zval *contentType = NULL, *_SERVER; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_OBS_VAR(contentType); if (zephir_array_isset_string_fetch(&contentType, _SERVER, SS("CONTENT_TYPE"), 0 TSRMLS_CC)) { RETURN_CCTOR(contentType); } else { ZEPHIR_OBS_NVAR(contentType); if (zephir_array_isset_string_fetch(&contentType, _SERVER, SS("HTTP_CONTENT_TYPE"), 0 TSRMLS_CC)) { RETURN_CCTOR(contentType); } } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Http_Request, getAcceptableContent) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HTTP_ACCEPT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "accept", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getqualityheader", NULL, 227, _0, _1); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getBestAccept) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getacceptablecontent", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "accept", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getbestquality", NULL, 228, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getClientCharsets) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HTTP_ACCEPT_CHARSET", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "charset", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getqualityheader", NULL, 227, _0, _1); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getBestCharset) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getclientcharsets", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "charset", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getbestquality", NULL, 228, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getLanguages) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HTTP_ACCEPT_LANGUAGE", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "language", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getqualityheader", NULL, 227, _0, _1); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getBestLanguage) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getlanguages", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "language", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getbestquality", NULL, 228, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Request, getBasicAuth) { zend_bool _0; zval *auth, *_SERVER, *_1, *_2; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); _0 = zephir_array_isset_string(_SERVER, SS("PHP_AUTH_USER")); if (_0) { _0 = zephir_array_isset_string(_SERVER, SS("PHP_AUTH_PW")); } if (_0) { ZEPHIR_INIT_VAR(auth); array_init(auth); zephir_array_fetch_string(&_1, _SERVER, SL("PHP_AUTH_USER"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 938 TSRMLS_CC); zephir_array_update_string(&auth, SL("username"), &_1, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_2, _SERVER, SL("PHP_AUTH_PW"), PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 939 TSRMLS_CC); zephir_array_update_string(&auth, SL("password"), &_2, PH_COPY | PH_SEPARATE); RETURN_CCTOR(auth); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Http_Request, getDigestAuth) { HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zval *auth; zval *digest, *matches, *match = NULL, *_SERVER, *_0, *_1, *_2 = NULL, **_5, *_6, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_INIT_VAR(auth); array_init(auth); ZEPHIR_OBS_VAR(digest); if (zephir_array_isset_string_fetch(&digest, _SERVER, SS("PHP_AUTH_DIGEST"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "#(\\w+)=(['\"]?)([^'\" ,]+)\\2#", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 2); ZEPHIR_MAKE_REF(matches); ZEPHIR_CALL_FUNCTION(&_2, "preg_match_all", NULL, 28, _0, digest, matches, _1); zephir_check_temp_parameter(_0); ZEPHIR_UNREF(matches); zephir_check_call_status(); if (!(zephir_is_true(_2))) { RETURN_CTOR(auth); } if (Z_TYPE_P(matches) == IS_ARRAY) { zephir_is_iterable(matches, &_4, &_3, 0, 0, "phalcon/http/request.zep", 964); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(match, _5); zephir_array_fetch_long(&_6, match, 3, PH_NOISY | PH_READONLY, "phalcon/http/request.zep", 962 TSRMLS_CC); ZEPHIR_OBS_NVAR(_7); zephir_array_fetch_long(&_7, match, 1, PH_NOISY, "phalcon/http/request.zep", 962 TSRMLS_CC); zephir_array_update_zval(&auth, _7, &_6, PH_COPY | PH_SEPARATE); } } } RETURN_CTOR(auth); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_RequestInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, RequestInterface, phalcon, http_requestinterface, phalcon_http_requestinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPost); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getQuery); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServer); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, has); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPost); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPut); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasQuery); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasServer); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHeader); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getScheme); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isAjax); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSoapRequested); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSecureRequest); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getRawBody); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerAddress); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerName); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHttpHost); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientAddress); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getMethod); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUserAgent); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isMethod); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPost); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isGet); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPut); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isHead); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isDelete); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isOptions); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasFiles); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUploadedFiles); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHTTPReferer); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getAcceptableContent); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestAccept); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientCharsets); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestCharset); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getLanguages); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestLanguage); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBasicAuth); ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getDigestAuth); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http, Response, phalcon, http_response, phalcon_http_response_method_entry, 0); zend_declare_property_bool(phalcon_http_response_ce, SL("_sent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_content"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_headers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_cookies"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_file"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_ce, SL("_statusCodes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_response_ce TSRMLS_CC, 1, phalcon_http_responseinterface_ce); zend_class_implements(phalcon_http_response_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Response, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *content = NULL, *code = NULL, *status = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &content, &code, &status); if (!content) { content = ZEPHIR_GLOBAL(global_null); } if (!code) { code = ZEPHIR_GLOBAL(global_null); } if (!status) { status = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(content) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); } if (Z_TYPE_P(code) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, code, status); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Response, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Http_Response, getDI) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *dependencyInjector = NULL, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection object is required to access the 'url' service", "phalcon/http/response.zep", 98); return; } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } RETURN_CCTOR(dependencyInjector); } static PHP_METHOD(Phalcon_Http_Response, setStatusCode) { zval *_10; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL; zend_bool _4; HashTable *_2; HashPosition _1; zval *message = NULL, *_13, *_15; zval *code_param = NULL, *message_param = NULL, *headers = NULL, *currentHeadersRaw = NULL, *key = NULL, *defaultMessage, *_0 = NULL, **_3, _5 = zval_used_for_init, *_6 = NULL, *_9, *_11, *_12, _14; int code, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &code_param, &message_param); code = zephir_get_intval(code_param); if (!message_param) { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } else { zephir_get_strval(message, message_param); } ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(¤tHeadersRaw, headers, "toarray", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(currentHeadersRaw) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(currentHeadersRaw, &_2, &_1, 0, 0, "phalcon/http/response.zep", 130); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); _4 = Z_TYPE_P(key) == IS_STRING; if (_4) { ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "HTTP/", 0); ZEPHIR_CALL_FUNCTION(&_6, "strstr", &_7, 235, key, &_5); zephir_check_call_status(); _4 = zephir_is_true(_6); } if (_4) { ZEPHIR_CALL_METHOD(NULL, headers, "remove", &_8, 0, key); zephir_check_call_status(); } } } if (ZEPHIR_IS_STRING_IDENTICAL(message, "")) { ZEPHIR_OBS_VAR(_9); zephir_read_property_this(&_9, this_ptr, SL("_statusCodes"), PH_NOISY_CC); if (Z_TYPE_P(_9) != IS_ARRAY) { ZEPHIR_INIT_VAR(_10); zephir_create_array(_10, 59, 0 TSRMLS_CC); add_index_stringl(_10, 100, SL("Continue"), 1); add_index_stringl(_10, 101, SL("Switching Protocols"), 1); add_index_stringl(_10, 102, SL("Processing"), 1); add_index_stringl(_10, 200, SL("OK"), 1); add_index_stringl(_10, 201, SL("Created"), 1); add_index_stringl(_10, 202, SL("Accepted"), 1); add_index_stringl(_10, 203, SL("Non-Authoritative Information"), 1); add_index_stringl(_10, 204, SL("No Content"), 1); add_index_stringl(_10, 205, SL("Reset Content"), 1); add_index_stringl(_10, 206, SL("Partial Content"), 1); add_index_stringl(_10, 207, SL("Multi-status"), 1); add_index_stringl(_10, 208, SL("Already Reported"), 1); add_index_stringl(_10, 300, SL("Multiple Choices"), 1); add_index_stringl(_10, 301, SL("Moved Permanently"), 1); add_index_stringl(_10, 302, SL("Found"), 1); add_index_stringl(_10, 303, SL("See Other"), 1); add_index_stringl(_10, 304, SL("Not Modified"), 1); add_index_stringl(_10, 305, SL("Use Proxy"), 1); add_index_stringl(_10, 306, SL("Switch Proxy"), 1); add_index_stringl(_10, 307, SL("Temporary Redirect"), 1); add_index_stringl(_10, 400, SL("Bad Request"), 1); add_index_stringl(_10, 401, SL("Unauthorized"), 1); add_index_stringl(_10, 402, SL("Payment Required"), 1); add_index_stringl(_10, 403, SL("Forbidden"), 1); add_index_stringl(_10, 404, SL("Not Found"), 1); add_index_stringl(_10, 405, SL("Method Not Allowed"), 1); add_index_stringl(_10, 406, SL("Not Acceptable"), 1); add_index_stringl(_10, 407, SL("Proxy Authentication Required"), 1); add_index_stringl(_10, 408, SL("Request Time-out"), 1); add_index_stringl(_10, 409, SL("Conflict"), 1); add_index_stringl(_10, 410, SL("Gone"), 1); add_index_stringl(_10, 411, SL("Length Required"), 1); add_index_stringl(_10, 412, SL("Precondition Failed"), 1); add_index_stringl(_10, 413, SL("Request Entity Too Large"), 1); add_index_stringl(_10, 414, SL("Request-URI Too Large"), 1); add_index_stringl(_10, 415, SL("Unsupported Media Type"), 1); add_index_stringl(_10, 416, SL("Requested range not satisfiable"), 1); add_index_stringl(_10, 417, SL("Expectation Failed"), 1); add_index_stringl(_10, 418, SL("I'm a teapot"), 1); add_index_stringl(_10, 422, SL("Unprocessable Entity"), 1); add_index_stringl(_10, 423, SL("Locked"), 1); add_index_stringl(_10, 424, SL("Failed Dependency"), 1); add_index_stringl(_10, 425, SL("Unordered Collection"), 1); add_index_stringl(_10, 426, SL("Upgrade Required"), 1); add_index_stringl(_10, 428, SL("Precondition Required"), 1); add_index_stringl(_10, 429, SL("Too Many Requests"), 1); add_index_stringl(_10, 431, SL("Request Header Fields Too Large"), 1); add_index_stringl(_10, 500, SL("Internal Server Error"), 1); add_index_stringl(_10, 501, SL("Not Implemented"), 1); add_index_stringl(_10, 502, SL("Bad Gateway"), 1); add_index_stringl(_10, 503, SL("Service Unavailable"), 1); add_index_stringl(_10, 504, SL("Gateway Time-out"), 1); add_index_stringl(_10, 505, SL("HTTP Version not supported"), 1); add_index_stringl(_10, 506, SL("Variant Also Negotiates"), 1); add_index_stringl(_10, 507, SL("Insufficient Storage"), 1); add_index_stringl(_10, 508, SL("Loop Detected"), 1); add_index_stringl(_10, 511, SL("Network Authentication Required"), 1); zephir_update_property_this(this_ptr, SL("_statusCodes"), _10 TSRMLS_CC); } _11 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); if (!(zephir_array_isset_long(_11, code))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Non-standard statuscode given without a message", "phalcon/http/response.zep", 204); return; } _12 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); ZEPHIR_OBS_VAR(defaultMessage); zephir_array_fetch_long(&defaultMessage, _12, code, PH_NOISY, "phalcon/http/response.zep", 207 TSRMLS_CC); zephir_get_strval(message, defaultMessage); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, code); ZEPHIR_INIT_VAR(_13); ZEPHIR_CONCAT_SVSV(_13, "HTTP/1.1 ", &_5, " ", message); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _13); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_14); ZVAL_LONG(&_14, code); ZEPHIR_INIT_VAR(_15); ZEPHIR_CONCAT_VSV(_15, &_14, " ", message); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Status", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, _0, _15); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, getStatusCode) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "Status", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Http_Response, setHeaders) { zval *headers; zephir_fetch_params(0, 1, 0, &headers); zephir_update_property_this(this_ptr, SL("_headers"), headers TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Http_Response, getHeaders) { int ZEPHIR_LAST_CALL_STATUS; zval *headers = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(headers); zephir_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); if (Z_TYPE_P(headers) == IS_NULL) { ZEPHIR_INIT_NVAR(headers); object_init_ex(headers, phalcon_http_response_headers_ce); if (zephir_has_constructor(headers TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, headers, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_headers"), headers TSRMLS_CC); } RETURN_CCTOR(headers); } static PHP_METHOD(Phalcon_Http_Response, setCookies) { zval *cookies; zephir_fetch_params(0, 1, 0, &cookies); zephir_update_property_this(this_ptr, SL("_cookies"), cookies TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Http_Response, getCookies) { RETURN_MEMBER(this_ptr, "_cookies"); } static PHP_METHOD(Phalcon_Http_Response, setHeader) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *value, *headers = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &value); zephir_get_strval(name, name_param); ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, name, value); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setRawHeader) { int ZEPHIR_LAST_CALL_STATUS; zval *header_param = NULL, *headers = NULL; zval *header = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &header_param); zephir_get_strval(header, header_param); ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, header); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, resetHeaders) { int ZEPHIR_LAST_CALL_STATUS; zval *headers = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, headers, "reset", NULL, 0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setExpires) { int ZEPHIR_LAST_CALL_STATUS; zval *datetime, *date, *_0, *_1 = NULL, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &datetime); ZEPHIR_INIT_VAR(date); if (zephir_clone(date, datetime TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, php_date_get_timezone_ce()); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "UTC", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, date, "settimezone", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "D, d M Y H:i:s", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, date, "format", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VS(_3, _2, " GMT"); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Expires", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, _1, _3); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setCache) { zval *_1, *_3; zval *minutes_param = NULL, *date, _0, _2, *_4; int minutes, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &minutes_param); if (unlikely(Z_TYPE_P(minutes_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'minutes' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } minutes = Z_LVAL_P(minutes_param); ZEPHIR_INIT_VAR(date); object_init_ex(date, php_date_get_date_ce()); ZEPHIR_CALL_METHOD(NULL, date, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, minutes); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "+", &_0, " minutes"); ZEPHIR_CALL_METHOD(NULL, date, "modify", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setexpires", NULL, 0, date); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, ((minutes * 60))); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "max-age=", &_2); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Cache-Control", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, _4, _3); zephir_check_temp_parameter(_4); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setNotModified) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 304); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "Not modified", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setContentType) { int ZEPHIR_LAST_CALL_STATUS; zval *contentType_param = NULL, *charset = NULL, *headers = NULL, *_0 = NULL, *_1; zval *contentType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &contentType_param, &charset); zephir_get_strval(contentType, contentType_param); if (!charset) { charset = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(charset) == IS_NULL) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Content-Type", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, _0, contentType); zephir_check_temp_parameter(_0); zephir_check_call_status(); } else { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, contentType, "; charset=", charset); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Content-Type", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, _0, _1); zephir_check_temp_parameter(_0); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setEtag) { int ZEPHIR_LAST_CALL_STATUS; zval *etag_param = NULL, *headers = NULL, *_0; zval *etag = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &etag_param); zephir_get_strval(etag, etag_param); ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Etag", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "set", NULL, 0, _0, etag); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, redirect) { int statusCode, ZEPHIR_LAST_CALL_STATUS; zend_bool externalRedirect, _0; zval *location = NULL, *externalRedirect_param = NULL, *statusCode_param = NULL, *header = NULL, *url = NULL, *dependencyInjector = NULL, *matched, *message = NULL, *view = NULL, _1 = zval_used_for_init, *_2 = NULL, *_3, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &location, &externalRedirect_param, &statusCode_param); if (!location) { ZEPHIR_CPY_WRT(location, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(location); } if (!externalRedirect_param) { externalRedirect = 0; } else { externalRedirect = zephir_get_boolval(externalRedirect_param); } if (!statusCode_param) { statusCode = 302; } else { statusCode = zephir_get_intval(statusCode_param); } if (!(zephir_is_true(location))) { ZEPHIR_INIT_NVAR(location); ZVAL_STRING(location, "", 1); } if (externalRedirect) { ZEPHIR_CPY_WRT(header, location); } else { _0 = Z_TYPE_P(location) == IS_STRING; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "://", 0); ZEPHIR_CALL_FUNCTION(&_2, "strstr", NULL, 235, location, &_1); zephir_check_call_status(); _0 = zephir_is_true(_2); } if (_0) { ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/^[^:\\/?#]++:/", 0); ZEPHIR_INIT_VAR(matched); zephir_preg_match(matched, &_1, location, _3, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(matched)) { ZEPHIR_CPY_WRT(header, location); } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } else { ZEPHIR_INIT_NVAR(header); ZVAL_NULL(header); } } ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(header))) { ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(url, _2); ZEPHIR_CALL_METHOD(&header, url, "get", NULL, 0, location); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "has", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&view, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (zephir_instance_of_ev(view, phalcon_mvc_viewinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, view, "disable", NULL, 0); zephir_check_call_status(); } } _0 = statusCode < 300; if (!(_0)) { _0 = statusCode > 308; } if (_0) { statusCode = 302; _5 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); ZEPHIR_OBS_VAR(message); zephir_array_fetch_long(&message, _5, 302, PH_NOISY, "phalcon/http/response.zep", 481 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(message); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_statusCodes"), PH_NOISY_CC); zephir_array_isset_long_fetch(&message, _5, statusCode, 0 TSRMLS_CC); } ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, statusCode); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, _4, message); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Location", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, _4, header); zephir_check_temp_parameter(_4); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setContent) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); zephir_get_strval(content, content_param); zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setJsonContent) { zval *content, *jsonOptions = NULL, *depth = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &content, &jsonOptions, &depth); if (!jsonOptions) { ZEPHIR_INIT_VAR(jsonOptions); ZVAL_LONG(jsonOptions, 0); } if (!depth) { ZEPHIR_INIT_VAR(depth); ZVAL_LONG(depth, 512); } ZEPHIR_INIT_VAR(_0); zephir_json_encode(_0, &(_0), content, zephir_get_intval(jsonOptions) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_content"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, appendContent) { int ZEPHIR_LAST_CALL_STATUS; zval *content, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcontent", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VV(_1, _0, content); zephir_update_property_this(this_ptr, SL("_content"), _1 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, getContent) { RETURN_MEMBER(this_ptr, "_content"); } static PHP_METHOD(Phalcon_Http_Response, isSent) { RETURN_MEMBER(this_ptr, "_sent"); } static PHP_METHOD(Phalcon_Http_Response, sendHeaders) { int ZEPHIR_LAST_CALL_STATUS; zval *headers; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(headers); zephir_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); if (Z_TYPE_P(headers) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, headers, "send", NULL, 0); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, sendCookies) { int ZEPHIR_LAST_CALL_STATUS; zval *cookies; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(cookies); zephir_read_property_this(&cookies, this_ptr, SL("_cookies"), PH_NOISY_CC); if (Z_TYPE_P(cookies) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, cookies, "send", NULL, 0); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, send) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *headers, *cookies, *content, *file, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_sent"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Response was already sent", "phalcon/http/response.zep", 588); return; } ZEPHIR_OBS_VAR(headers); zephir_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); if (Z_TYPE_P(headers) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, headers, "send", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(cookies); zephir_read_property_this(&cookies, this_ptr, SL("_cookies"), PH_NOISY_CC); if (Z_TYPE_P(cookies) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, cookies, "send", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(content); zephir_read_property_this(&content, this_ptr, SL("_content"), PH_NOISY_CC); if (Z_TYPE_P(content) != IS_NULL) { zend_print_zval(content, 0); } else { ZEPHIR_OBS_VAR(file); zephir_read_property_this(&file, this_ptr, SL("_file"), PH_NOISY_CC); _1 = Z_TYPE_P(file) == IS_STRING; if (_1) { _1 = (zephir_fast_strlen_ev(file)) ? 1 : 0; } if (_1) { ZEPHIR_CALL_FUNCTION(NULL, "readfile", NULL, 236, file); zephir_check_call_status(); } } if (1) { zephir_update_property_this(this_ptr, SL("_sent"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_sent"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response, setFileToSend) { int ZEPHIR_LAST_CALL_STATUS; zval *filePath_param = NULL, *attachmentName = NULL, *attachment = NULL, *basePath = NULL, *headers = NULL, *_0 = NULL, *_1; zval *filePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &filePath_param, &attachmentName, &attachment); zephir_get_strval(filePath, filePath_param); if (!attachmentName) { attachmentName = ZEPHIR_GLOBAL(global_null); } if (!attachment) { attachment = ZEPHIR_GLOBAL(global_true); } if (Z_TYPE_P(attachmentName) != IS_STRING) { ZEPHIR_INIT_VAR(basePath); zephir_basename(basePath, filePath TSRMLS_CC); } else { ZEPHIR_CPY_WRT(basePath, attachmentName); } if (zephir_is_true(attachment)) { ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Content-Description: File Transfer", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Content-Type: application/octet-stream", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "Content-Disposition: attachment; filename=", basePath); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Content-Transfer-Encoding: binary", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, headers, "setraw", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_file"), filePath TSRMLS_CC); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_ResponseInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, ResponseInterface, phalcon, http_responseinterface, phalcon_http_responseinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setStatusCode); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getHeaders); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setHeader); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setRawHeader); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, resetHeaders); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setExpires); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setNotModified); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContentType); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, redirect); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContent); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setJsonContent); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, appendContent); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getContent); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendHeaders); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendCookies); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, send); ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setFileToSend); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Cookie, Exception, phalcon, http_cookie_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Request_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Request, Exception, phalcon, http_request_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Request_File) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Request, File, phalcon, http_request_file, phalcon_http_request_file_method_entry, 0); zend_declare_property_null(phalcon_http_request_file_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_tmp"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_size"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_realType"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_error"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_key"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_request_file_ce, SL("_extension"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_request_file_ce TSRMLS_CC, 1, phalcon_http_request_fileinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Request_File, getError) { RETURN_MEMBER(this_ptr, "_error"); } static PHP_METHOD(Phalcon_Http_Request_File, getKey) { RETURN_MEMBER(this_ptr, "_key"); } static PHP_METHOD(Phalcon_Http_Request_File, getExtension) { RETURN_MEMBER(this_ptr, "_extension"); } static PHP_METHOD(Phalcon_Http_Request_File, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *key = NULL, *name, *tempName, *size, *type, *error, _0 = zval_used_for_init, *_1 = NULL, *_2 = NULL; zval *file = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &file_param, &key); file = file_param; if (!key) { key = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(name); if (zephir_array_isset_string_fetch(&name, file, SS("name"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "PATHINFO_EXTENSION", 0); ZEPHIR_CALL_FUNCTION(&_1, "defined", NULL, 229, &_0); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 4); ZEPHIR_CALL_FUNCTION(&_2, "pathinfo", NULL, 72, name, &_0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_extension"), _2 TSRMLS_CC); } } if (zephir_array_isset_string_fetch(&tempName, file, SS("tmp_name"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_tmp"), tempName TSRMLS_CC); } if (zephir_array_isset_string_fetch(&size, file, SS("size"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_size"), size TSRMLS_CC); } if (zephir_array_isset_string_fetch(&type, file, SS("type"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); } if (zephir_array_isset_string_fetch(&error, file, SS("error"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_error"), error TSRMLS_CC); } if (zephir_is_true(key)) { zephir_update_property_this(this_ptr, SL("_key"), key TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Request_File, getSize) { RETURN_MEMBER(this_ptr, "_size"); } static PHP_METHOD(Phalcon_Http_Request_File, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Http_Request_File, getTempName) { RETURN_MEMBER(this_ptr, "_tmp"); } static PHP_METHOD(Phalcon_Http_Request_File, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Http_Request_File, getRealType) { int ZEPHIR_LAST_CALL_STATUS; zval *finfo = NULL, *mime = NULL, _0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 16); ZEPHIR_CALL_FUNCTION(&finfo, "finfo_open", NULL, 230, &_0); zephir_check_call_status(); if (Z_TYPE_P(finfo) != IS_RESOURCE) { RETURN_MM_STRING("", 1); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_tmp"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 231, finfo, _1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 232, finfo); zephir_check_call_status(); RETURN_CCTOR(mime); } static PHP_METHOD(Phalcon_Http_Request_File, isUploadedFile) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *tmp = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&tmp, this_ptr, "gettempname", NULL, 0); zephir_check_call_status(); _0 = Z_TYPE_P(tmp) == IS_STRING; if (_0) { ZEPHIR_CALL_FUNCTION(&_1, "is_uploaded_file", NULL, 233, tmp); zephir_check_call_status(); _0 = zephir_is_true(_1); } RETURN_MM_BOOL(_0); } static PHP_METHOD(Phalcon_Http_Request_File, moveTo) { int ZEPHIR_LAST_CALL_STATUS; zval *destination_param = NULL, *_0; zval *destination = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &destination_param); if (unlikely(Z_TYPE_P(destination_param) != IS_STRING && Z_TYPE_P(destination_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'destination' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(destination_param) == IS_STRING)) { zephir_get_strval(destination, destination_param); } else { ZEPHIR_INIT_VAR(destination); ZVAL_EMPTY_STRING(destination); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tmp"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_FUNCTION("move_uploaded_file", NULL, 234, _0, destination); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Request_FileInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Request, FileInterface, phalcon, http_request_fileinterface, phalcon_http_request_fileinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getSize); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getTempName); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getRealType); ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, moveTo); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Cookies) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Response, Cookies, phalcon, http_response_cookies, phalcon_http_response_cookies_method_entry, 0); zend_declare_property_null(phalcon_http_response_cookies_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("_registered"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("_useEncryption"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_http_response_cookies_ce, SL("_cookies"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_http_response_cookies_ce TSRMLS_CC, 1, phalcon_http_response_cookiesinterface_ce); zend_class_implements(phalcon_http_response_cookies_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Response_Cookies, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Http_Response_Cookies, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Http_Response_Cookies, useEncryption) { zval *useEncryption_param = NULL; zend_bool useEncryption; zephir_fetch_params(0, 1, 0, &useEncryption_param); useEncryption = zephir_get_boolval(useEncryption_param); if (useEncryption) { zephir_update_property_this(this_ptr, SL("_useEncryption"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_useEncryption"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Http_Response_Cookies, isUsingEncryption) { RETURN_MEMBER(this_ptr, "_useEncryption"); } static PHP_METHOD(Phalcon_Http_Response_Cookies, set) { zval *_3; zend_bool secure, httpOnly; int expire, ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *value = NULL, *expire_param = NULL, *path_param = NULL, *secure_param = NULL, *domain_param = NULL, *httpOnly_param = NULL, *cookie = NULL, *encryption, *dependencyInjector, *response = NULL, *_0, *_1, *_2 = NULL, *_4 = NULL, *_5, *_6; zval *name = NULL, *path = NULL, *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &name_param, &value, &expire_param, &path_param, &secure_param, &domain_param, &httpOnly_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!value) { value = ZEPHIR_GLOBAL(global_null); } if (!expire_param) { expire = 0; } else { expire = zephir_get_intval(expire_param); } if (!path_param) { ZEPHIR_INIT_VAR(path); ZVAL_STRING(path, "/", 1); } else { zephir_get_strval(path, path_param); } if (!secure_param) { secure = 0; } else { secure = zephir_get_boolval(secure_param); } if (!domain_param) { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } else { if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } } if (!httpOnly_param) { httpOnly = 0; } else { httpOnly = zephir_get_boolval(httpOnly_param); } ZEPHIR_OBS_VAR(encryption); zephir_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cookie); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&cookie, _0, name, 0 TSRMLS_CC))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 7, 0 TSRMLS_CC); zephir_array_fast_append(_3, name); zephir_array_fast_append(_3, value); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, expire); zephir_array_fast_append(_3, _4); zephir_array_fast_append(_3, path); ZEPHIR_INIT_NVAR(_4); ZVAL_BOOL(_4, secure); zephir_array_fast_append(_3, _4); zephir_array_fast_append(_3, domain); ZEPHIR_INIT_NVAR(_4); ZVAL_BOOL(_4, httpOnly); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Cookie", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, _1, "get", NULL, 0, _4, _3); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(cookie, _2); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, cookie, "setdi", NULL, 0, _5); zephir_check_call_status(); if (zephir_is_true(encryption)) { ZEPHIR_CALL_METHOD(NULL, cookie, "useencryption", NULL, 0, encryption); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(NULL, cookie, "setvalue", NULL, 0, value); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, expire); ZEPHIR_CALL_METHOD(NULL, cookie, "setexpiration", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setpath", NULL, 0, path); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); if (secure) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(NULL, cookie, "setsecure", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, cookie, "setdomain", NULL, 0, domain); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); if (httpOnly) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, cookie, "sethttponly", NULL, 0, _6); zephir_check_call_status(); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_registered"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_cookie_exception_ce, "A dependency injection object is required to access the 'response' service", "phalcon/http/response/cookies.zep", 130); return; } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&response, dependencyInjector, "getshared", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, response, "setcookies", NULL, 0, this_ptr); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Http_Response_Cookies, get) { int ZEPHIR_LAST_CALL_STATUS; zval *_3; zval *name_param = NULL, *dependencyInjector, *encryption, *cookie = NULL, *_0, *_1, *_2 = NULL, *_4; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(cookie); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (zephir_array_isset_fetch(&cookie, _0, name, 0 TSRMLS_CC)) { RETURN_CCTOR(cookie); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_fast_append(_3, name); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Phalcon\\Http\\Cookie", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, _1, "get", NULL, 0, _4, _3); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(cookie, _2); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, cookie, "setdi", NULL, 0, dependencyInjector); zephir_check_call_status(); ZEPHIR_OBS_VAR(encryption); zephir_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY_CC); if (zephir_is_true(encryption)) { ZEPHIR_CALL_METHOD(NULL, cookie, "useencryption", NULL, 0, encryption); zephir_check_call_status(); } } zephir_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC); RETURN_CCTOR(cookie); } static PHP_METHOD(Phalcon_Http_Response_Cookies, has) { zval *name_param = NULL, *_0, *_COOKIE; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (zephir_array_isset(_0, name)) { RETURN_MM_BOOL(1); } if (zephir_array_isset(_COOKIE, name)) { RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Response_Cookies, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *cookie, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(cookie); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); if (zephir_array_isset_fetch(&cookie, _0, name, 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, cookie, "delete", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Response_Cookies, send) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *cookie = NULL, *_0 = NULL, *_1, **_4; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 55); zephir_check_call_status(); if (!(zephir_is_true(_0))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/http/response/cookies.zep", 236); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(cookie, _4); ZEPHIR_CALL_METHOD(NULL, cookie, "send", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Response_Cookies, reset) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_cookies"), _0 TSRMLS_CC); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response_CookiesInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, CookiesInterface, phalcon, http_response_cookiesinterface, phalcon_http_response_cookiesinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, useEncryption); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, isUsingEncryption); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, set); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, has); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, send); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, reset); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Response, Exception, phalcon, http_response_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Headers) { ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Response, Headers, phalcon, http_response_headers, phalcon_http_response_headers_method_entry, 0); zend_declare_property_null(phalcon_http_response_headers_ce, SL("_headers"), ZEND_ACC_PROTECTED TSRMLS_CC); phalcon_http_response_headers_ce->create_object = zephir_init_properties_Phalcon_Http_Response_Headers; zend_class_implements(phalcon_http_response_headers_ce TSRMLS_CC, 1, phalcon_http_response_headersinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Http_Response_Headers, set) { zval *name_param = NULL, *value_param = NULL; zval *name = NULL, *value = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &value_param); zephir_get_strval(name, name_param); zephir_get_strval(value, value_param); zephir_update_property_array(this_ptr, SL("_headers"), name, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Response_Headers, get) { zval *name_param = NULL, *headers, *headerValue; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); headers = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); if (zephir_array_isset_fetch(&headerValue, headers, name, 1 TSRMLS_CC)) { RETURN_CTOR(headerValue); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Response_Headers, setRaw) { zval *header_param = NULL; zval *header = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &header_param); zephir_get_strval(header, header_param); zephir_update_property_array(this_ptr, SL("_headers"), header, ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Response_Headers, remove) { zval *header_param = NULL, *headers; zval *header = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &header_param); zephir_get_strval(header, header_param); ZEPHIR_OBS_VAR(headers); zephir_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); zephir_array_unset(&headers, header, PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_headers"), headers TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Response_Headers, send) { zephir_fcall_cache_entry *_6 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *header = NULL, *value = NULL, *_0 = NULL, *_1, **_4, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 55); zephir_check_call_status(); if (!(zephir_is_true(_0))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/http/response/headers.zep", 90); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(header, _3, _2); ZEPHIR_GET_HVALUE(value, _4); if (!(ZEPHIR_IS_EMPTY(value))) { ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_VSV(_5, header, ": ", value); ZEPHIR_CALL_FUNCTION(NULL, "header", &_6, 237, _5, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(NULL, "header", &_6, 237, header, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); } } RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Http_Response_Headers, reset) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_headers"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Http_Response_Headers, toArray) { RETURN_MEMBER(this_ptr, "_headers"); } static PHP_METHOD(Phalcon_Http_Response_Headers, __set_state) { zephir_fcall_cache_entry *_3 = NULL; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *headers, *key = NULL, *value = NULL, *dataHeaders, **_2; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); data = data_param; ZEPHIR_INIT_VAR(headers); object_init_ex(headers, phalcon_http_response_headers_ce); if (zephir_has_constructor(headers TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, headers, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(dataHeaders); if (zephir_array_isset_string_fetch(&dataHeaders, data, SS("_headers"), 0 TSRMLS_CC)) { zephir_is_iterable(dataHeaders, &_1, &_0, 0, 0, "phalcon/http/response/headers.zep", 122); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CALL_METHOD(NULL, headers, "set", &_3, 238, key, value); zephir_check_call_status(); } } RETURN_CCTOR(headers); } static zend_object_value zephir_init_properties_Phalcon_Http_Response_Headers(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_headers"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Http_Response_HeadersInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, HeadersInterface, phalcon, http_response_headersinterface, phalcon_http_response_headersinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, set); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, setRaw); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, send); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, reset); ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Image, Adapter, phalcon, image_adapter, phalcon_image_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_image_adapter_ce, SL("_image"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_file"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_realpath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_width"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_height"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_image_adapter_ce, SL("_mime"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_image_adapter_ce, SL("_checked"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Image_Adapter, getImage) { RETURN_MEMBER(this_ptr, "_image"); } static PHP_METHOD(Phalcon_Image_Adapter, getRealpath) { RETURN_MEMBER(this_ptr, "_realpath"); } static PHP_METHOD(Phalcon_Image_Adapter, getWidth) { RETURN_MEMBER(this_ptr, "_width"); } static PHP_METHOD(Phalcon_Image_Adapter, getHeight) { RETURN_MEMBER(this_ptr, "_height"); } static PHP_METHOD(Phalcon_Image_Adapter, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Image_Adapter, getMime) { RETURN_MEMBER(this_ptr, "_mime"); } static PHP_METHOD(Phalcon_Image_Adapter, resize) { zephir_fcall_cache_entry *_12 = NULL; zend_bool _0, _4; double ratio; zval *width_param = NULL, *height_param = NULL, *master_param = NULL, *_1 = NULL, *_2, *_3, *_5, *_6, *_7 = NULL, *_8, _9, *_10 = NULL, *_11 = NULL, _13, *_14 = NULL, *_15 = NULL, *_16; int width, height, master, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param); if (!width_param) { width = 0; } else { width = zephir_get_intval(width_param); } if (!height_param) { height = 0; } else { height = zephir_get_intval(height_param); } if (!master_param) { master = 4; } else { master = zephir_get_intval(master_param); } if (master == 7) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 80); return; } } else { if (master == 4) { _0 = !width; if (!(_0)) { _0 = !height; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 88); return; } ZEPHIR_INIT_VAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } master = zephir_get_numberval(_1); } if (master == 5) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 97); return; } ZEPHIR_INIT_LNVAR(_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 3); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); } master = zephir_get_numberval(_1); } do { if (master == 2) { if (!(width)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/image/adapter.zep", 107); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); break; } if (master == 3) { if (!(height)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/image/adapter.zep", 114); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * height), _3 TSRMLS_CC)); break; } if (master == 6) { _4 = !width; if (!(_4)) { _4 = !height; } if (_4) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 121); return; } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_1); div_function(_1, _2, _3 TSRMLS_CC); ratio = zephir_get_numberval(_1); if ((zephir_safe_div_long_long(width, height TSRMLS_CC)) > ratio) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC)); } else { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_5) * height), _6 TSRMLS_CC)); } break; } if (master == 1) { if (!(width)) { ZEPHIR_OBS_VAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_width"), PH_NOISY_CC); width = zephir_get_intval(_7); } if (!(height)) { ZEPHIR_OBS_NVAR(_7); zephir_read_property_this(&_7, this_ptr, SL("_height"), PH_NOISY_CC); width = zephir_get_intval(_7); } break; } } while(0); } ZEPHIR_INIT_VAR(_8); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, width); zephir_round(_8, &_9, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_10); ZVAL_LONG(_10, 1); ZEPHIR_CALL_FUNCTION(&_11, "max", &_12, 69, _8, _10); zephir_check_call_status(); width = zephir_get_intval(_11); ZEPHIR_INIT_NVAR(_10); ZEPHIR_SINIT_VAR(_13); ZVAL_LONG(&_13, height); zephir_round(_10, &_13, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_14); ZVAL_LONG(_14, 1); ZEPHIR_CALL_FUNCTION(&_15, "max", &_12, 69, _10, _14); zephir_check_call_status(); height = zephir_get_intval(_15); ZEPHIR_INIT_NVAR(_14); ZVAL_LONG(_14, width); ZEPHIR_INIT_VAR(_16); ZVAL_LONG(_16, height); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resize", NULL, 0, _14, _16); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, liquidRescale) { zval *width_param = NULL, *height_param = NULL, *deltaX_param = NULL, *rigidity_param = NULL, *_0, *_1, *_2, *_3; int width, height, deltaX, rigidity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &width_param, &height_param, &deltaX_param, &rigidity_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); if (!deltaX_param) { deltaX = 0; } else { deltaX = zephir_get_intval(deltaX_param); } if (!rigidity_param) { rigidity = 0; } else { rigidity = zephir_get_intval(rigidity_param); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, width); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, height); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, deltaX); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, rigidity); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_liquidrescale", NULL, 0, _0, _1, _2, _3); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, crop) { zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, _0, *_1, *_2, *_3 = NULL, _4, *_5, *_6, *_7, *_8; int width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &width_param, &height_param, &offsetX_param, &offsetY_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); if (!offsetX_param) { offsetX = 0; } else { offsetX = zephir_get_intval(offsetX_param); } if (!offsetY_param) { offsetY = 0; } else { offsetY = zephir_get_intval(offsetY_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, offsetX); if (Z_TYPE_P(&_0) == IS_NULL) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); offsetX = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - width)), 2 TSRMLS_CC))); } else { if (offsetX < 0) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); offsetX = ((zephir_get_numberval(_1) - width) + offsetX); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); if (ZEPHIR_LT_LONG(_2, offsetX)) { ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_width"), PH_NOISY_CC); offsetX = zephir_get_intval(_3); } } ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, offsetY); if (Z_TYPE_P(&_4) == IS_NULL) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); offsetY = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - height)), 2 TSRMLS_CC))); } else { if (offsetY < 0) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); offsetY = ((zephir_get_numberval(_1) - height) + offsetY); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if (ZEPHIR_LT_LONG(_2, offsetY)) { ZEPHIR_OBS_NVAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_height"), PH_NOISY_CC); offsetY = zephir_get_intval(_3); } } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); if (width > ((zephir_get_numberval(_1) - offsetX))) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); width = (zephir_get_numberval(_2) - offsetX); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if (height > ((zephir_get_numberval(_1) - offsetY))) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); height = (zephir_get_numberval(_2) - offsetY); } ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, width); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, height); ZEPHIR_INIT_VAR(_7); ZVAL_LONG(_7, offsetX); ZEPHIR_INIT_VAR(_8); ZVAL_LONG(_8, offsetY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_crop", NULL, 0, _5, _6, _7, _8); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, rotate) { zval *degrees_param = NULL, *_0; int degrees, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, °rees_param); degrees = zephir_get_intval(degrees_param); if (degrees > 180) { degrees %= 360; if (degrees > 180) { degrees -= 360; } } else { while (1) { if (!(degrees < -180)) { break; } degrees += 360; } } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, degrees); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_rotate", NULL, 0, _0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, flip) { zend_bool _0; zval *direction_param = NULL, *_1; int direction, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &direction_param); direction = zephir_get_intval(direction_param); _0 = direction != 11; if (_0) { _0 = direction != 12; } if (_0) { direction = 11; } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, direction); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_flip", NULL, 0, _1); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, sharpen) { zval *amount_param = NULL, *_0; int amount, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); if (amount > 100) { amount = 100; } else if (amount < 1) { amount = 1; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, amount); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_sharpen", NULL, 0, _0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, reflection) { zend_bool fadeIn, _0; zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, *_1, *_2, *_3, *_4, *_5; int height, opacity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &height_param, &opacity_param, &fadeIn_param); height = zephir_get_intval(height_param); if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } if (!fadeIn_param) { fadeIn = 0; } else { fadeIn = zephir_get_boolval(fadeIn_param); } _0 = height <= 0; if (!(_0)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _0 = ZEPHIR_LT_LONG(_1, height); } if (_0) { ZEPHIR_OBS_VAR(_2); zephir_read_property_this(&_2, this_ptr, SL("_height"), PH_NOISY_CC); height = zephir_get_intval(_2); } if (opacity < 0) { opacity = 0; } else if (opacity > 100) { opacity = 100; } ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, height); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, opacity); ZEPHIR_INIT_VAR(_5); if (fadeIn) { ZVAL_BOOL(_5, 1); } else { ZVAL_BOOL(_5, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_reflection", NULL, 0, _3, _4, _5); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, watermark) { int offsetX, offsetY, opacity, tmp, ZEPHIR_LAST_CALL_STATUS; zval *watermark, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &watermark, &offsetX_param, &offsetY_param, &opacity_param); if (!offsetX_param) { offsetX = 0; } else { offsetX = zephir_get_intval(offsetX_param); } if (!offsetY_param) { offsetY = 0; } else { offsetY = zephir_get_intval(offsetY_param); } if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, watermark, "getwidth", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_sub_function(_2, _0, _1); tmp = zephir_get_numberval(_2); if (offsetX < 0) { offsetX = 0; } else if (offsetX > tmp) { offsetX = tmp; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, watermark, "getheight", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); zephir_sub_function(_3, _0, _1); tmp = zephir_get_numberval(_3); if (offsetY < 0) { offsetY = 0; } else if (offsetY > tmp) { offsetY = tmp; } if (opacity < 0) { opacity = 0; } else if (opacity > 100) { opacity = 100; } ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, offsetX); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, offsetY); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, opacity); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_watermark", NULL, 0, watermark, _4, _5, _6); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, text) { zend_bool _0; int opacity, size, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *offsetX = NULL, *offsetY = NULL, *opacity_param = NULL, *color_param = NULL, *size_param = NULL, *fontfile_param = NULL, *colors = NULL, _1, _2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8, *_9, *_10; zval *text = NULL, *color = NULL, *fontfile = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 6, &text_param, &offsetX, &offsetY, &opacity_param, &color_param, &size_param, &fontfile_param); zephir_get_strval(text, text_param); if (!offsetX) { offsetX = ZEPHIR_GLOBAL(global_false); } if (!offsetY) { offsetY = ZEPHIR_GLOBAL(global_false); } if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } if (!color_param) { ZEPHIR_INIT_VAR(color); ZVAL_STRING(color, "000000", 1); } else { zephir_get_strval(color, color_param); } if (!size_param) { size = 12; } else { size = zephir_get_intval(size_param); } if (!fontfile_param) { ZEPHIR_INIT_VAR(fontfile); ZVAL_EMPTY_STRING(fontfile); } else { zephir_get_strval(fontfile, fontfile_param); } if (opacity < 0) { opacity = 0; } else { if (opacity > 100) { opacity = 100; } } _0 = zephir_fast_strlen_ev(color) > 1; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, color, 0 , 1 , 0); _0 = ZEPHIR_IS_STRING_IDENTICAL(_3, "#"); } if (_0) { ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(_5); zephir_substr(_5, color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(color, _5); } if (zephir_fast_strlen_ev(color) == 3) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "/./", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "$0$0", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 29, _5, _6, color); zephir_check_temp_parameter(_5); zephir_check_temp_parameter(_6); zephir_check_call_status(); zephir_get_strval(color, _7); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_7, "str_split", NULL, 70, color, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "hexdec", 0); ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 71, &_4, _7); zephir_check_call_status(); zephir_array_fetch_long(&_8, colors, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); zephir_array_fetch_long(&_9, colors, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); zephir_array_fetch_long(&_10, colors, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 335 TSRMLS_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, opacity); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, size); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_text", NULL, 0, text, offsetX, offsetY, _5, _8, _9, _10, _6, fontfile); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, mask) { int ZEPHIR_LAST_CALL_STATUS; zval *watermark; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &watermark); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_mask", NULL, 0, watermark); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, background) { zend_bool _0; int opacity, ZEPHIR_LAST_CALL_STATUS; zval *color_param = NULL, *opacity_param = NULL, *colors = NULL, _1, _2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_6, *_7 = NULL, *_8, *_9, *_10; zval *color = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &color_param, &opacity_param); zephir_get_strval(color, color_param); if (!opacity_param) { opacity = 100; } else { opacity = zephir_get_intval(opacity_param); } _0 = zephir_fast_strlen_ev(color) > 1; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, color, 0 , 1 , 0); _0 = ZEPHIR_IS_STRING_IDENTICAL(_3, "#"); } if (_0) { ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_VAR(_5); zephir_substr(_5, color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(color, _5); } if (zephir_fast_strlen_ev(color) == 3) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "/./", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "$0$0", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 29, _5, _6, color); zephir_check_temp_parameter(_5); zephir_check_temp_parameter(_6); zephir_check_call_status(); zephir_get_strval(color, _7); } ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 2); ZEPHIR_CALL_FUNCTION(&_7, "str_split", NULL, 70, color, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "hexdec", 0); ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 71, &_4, _7); zephir_check_call_status(); zephir_array_fetch_long(&_8, colors, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); zephir_array_fetch_long(&_9, colors, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); zephir_array_fetch_long(&_10, colors, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter.zep", 366 TSRMLS_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, opacity); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_background", NULL, 0, _8, _9, _10, _5); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, blur) { zval *radius_param = NULL, *_0; int radius, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &radius_param); radius = zephir_get_intval(radius_param); if (radius < 1) { radius = 1; } else if (radius > 100) { radius = 100; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, radius); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_blur", NULL, 0, _0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, pixelate) { zval *amount_param = NULL, *_0; int amount, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); if (amount < 2) { amount = 2; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, amount); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_pixelate", NULL, 0, _0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, save) { int quality, ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *quality_param = NULL, *_0, *_2; zval *file = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &file_param, &quality_param); if (!file_param) { ZEPHIR_INIT_VAR(file); ZVAL_EMPTY_STRING(file); } else { zephir_get_strval(file, file_param); } if (!quality_param) { quality = 100; } else { quality = zephir_get_intval(quality_param); } if (!(!(!file) && Z_STRLEN_P(file))) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_realpath"), PH_NOISY_CC); zephir_get_strval(_1, _0); ZEPHIR_CPY_WRT(file, _1); } if (quality < 1) { quality = 1; } else if (quality > 100) { quality = 100; } ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, quality); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_save", NULL, 0, file, _2); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Image_Adapter, render) { int quality, ZEPHIR_LAST_CALL_STATUS; zval *ext_param = NULL, *quality_param = NULL, *_0, _1, *_2 = NULL, *_4; zval *ext = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &ext_param, &quality_param); if (!ext_param) { ZEPHIR_INIT_VAR(ext); ZVAL_EMPTY_STRING(ext); } else { zephir_get_strval(ext, ext_param); } if (!quality_param) { quality = 100; } else { quality = zephir_get_intval(quality_param); } if (!(!(!ext) && Z_STRLEN_P(ext))) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 4); ZEPHIR_CALL_FUNCTION(&_2, "pathinfo", NULL, 72, _0, &_1); zephir_check_call_status(); zephir_get_strval(_3, _2); ZEPHIR_CPY_WRT(ext, _3); } if (ZEPHIR_IS_EMPTY(ext)) { ZEPHIR_INIT_NVAR(ext); ZVAL_STRING(ext, "png", 1); } if (quality < 1) { quality = 1; } else if (quality > 100) { quality = 100; } ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, quality); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_render", NULL, 0, ext, _4); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Image_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Image, AdapterInterface, phalcon, image_adapterinterface, phalcon_image_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, resize); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, crop); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, rotate); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, flip); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, sharpen); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, reflection); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, watermark); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, text); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, mask); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, background); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, blur); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, pixelate); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, save); ZEPHIR_DOC_METHOD(Phalcon_Image_AdapterInterface, render); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Image_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image, Exception, phalcon, image_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Gd) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Gd, phalcon, image_adapter_gd, phalcon_image_adapter_ce, phalcon_image_adapter_gd_method_entry, 0); zend_declare_property_bool(phalcon_image_adapter_gd_ce, SL("_checked"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_image_adapter_gd_ce TSRMLS_CC, 1, phalcon_image_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Image_Adapter_Gd, check) { int ZEPHIR_LAST_CALL_STATUS; zval *version = NULL, *info = NULL, *matches, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3 = NULL, *_4, _5, _6, *_7 = NULL, *_8, *_9; ZEPHIR_MM_GROW(); _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC); if (zephir_is_true(_0)) { RETURN_MM_BOOL(1); } if (!((zephir_function_exists_ex(SS("gd_info") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "GD is either not installed or not enabled, check your configuration", "phalcon/image/adapter/gd.zep", 39); return; } ZEPHIR_INIT_VAR(version); ZVAL_NULL(version); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "GD_VERSION", 0); ZEPHIR_CALL_FUNCTION(&_2, "defined", NULL, 229, &_1); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(version); ZEPHIR_GET_CONSTANT(version, "GD_VERSION"); } else { ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 239); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(_3); zephir_array_fetch_string(&_4, info, SL("GD Version"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 47 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/\\d+\\.\\d+(?:\\.\\d+)?/", 0); zephir_preg_match(_3, &_1, _4, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_3)) { ZEPHIR_OBS_NVAR(version); zephir_array_fetch_long(&version, matches, 0, PH_NOISY, "phalcon/image/adapter/gd.zep", 48 TSRMLS_CC); } } ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "2.0.1", 0); ZEPHIR_SINIT_VAR(_6); ZVAL_STRING(&_6, ">=", 0); ZEPHIR_CALL_FUNCTION(&_7, "version_compare", NULL, 240, version, &_5, &_6); zephir_check_call_status(); if (!(zephir_is_true(_7))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_image_exception_ce); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SV(_8, "Phalcon\\Image\\Adapter\\GD requires GD version '2.0.1' or greater, you have ", version); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/image/adapter/gd.zep", 53 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked"), &ZEPHIR_GLOBAL(global_true) TSRMLS_CC); _9 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC); RETURN_CTOR(_9); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, __construct) { zend_bool _16; zephir_fcall_cache_entry *_15 = NULL; int width, height, ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *width_param = NULL, *height_param = NULL, *imageinfo = NULL, *_0, *_1, *_2, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, *_9, *_10, *_11 = NULL, *_12 = NULL, *_13, *_14 = NULL, _17, _18; zval *file = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); if (unlikely(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(file_param) == IS_STRING)) { zephir_get_strval(file, file_param); } else { ZEPHIR_INIT_VAR(file); ZVAL_EMPTY_STRING(file); } if (!width_param) { width = 0; } else { width = zephir_get_intval(width_param); } if (!height_param) { height = 0; } else { height = zephir_get_intval(height_param); } _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_SELF(NULL, "check", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); if ((zephir_file_exists(_1 TSRMLS_CC) == SUCCESS)) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_3, "realpath", NULL, 63, _2); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_realpath"), _3 TSRMLS_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&imageinfo, "getimagesize", NULL, 241, _4); zephir_check_call_status(); if (zephir_is_true(imageinfo)) { zephir_array_fetch_long(&_5, imageinfo, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 77 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_width"), _5 TSRMLS_CC); zephir_array_fetch_long(&_6, imageinfo, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 78 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_height"), _6 TSRMLS_CC); zephir_array_fetch_long(&_7, imageinfo, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 79 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_type"), _7 TSRMLS_CC); zephir_array_fetch_string(&_8, imageinfo, SL("mime"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 80 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_mime"), _8 TSRMLS_CC); } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(_9, 1)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_11, "imagecreatefromgif", NULL, 242, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_9, 2)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_11, "imagecreatefromjpeg", NULL, 243, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_9, 3)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_11, "imagecreatefrompng", NULL, 244, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_9, 15)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_11, "imagecreatefromwbmp", NULL, 245, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_9, 16)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_11, "imagecreatefromxbm", NULL, 246, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _11 TSRMLS_CC); break; } _10 = zephir_fetch_nproperty_this(this_ptr, SL("_mime"), PH_NOISY_CC); if (zephir_is_true(_10)) { ZEPHIR_INIT_VAR(_12); object_init_ex(_12, phalcon_image_exception_ce); _13 = zephir_fetch_nproperty_this(this_ptr, SL("_mime"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_14); ZEPHIR_CONCAT_SVS(_14, "Installed GD does not support ", _13, " images"); ZEPHIR_CALL_METHOD(NULL, _12, "__construct", NULL, 9, _14); zephir_check_call_status(); zephir_throw_exception_debug(_12, "phalcon/image/adapter/gd.zep", 101 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Installed GD does not support such images", "phalcon/image/adapter/gd.zep", 103); return; } break; } while(0); _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_15, 247, _10, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); } else { _16 = !width; if (!(_16)) { _16 = !height; } if (_16) { ZEPHIR_INIT_NVAR(_12); object_init_ex(_12, phalcon_image_exception_ce); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_SV(_14, "Failed to create image from file ", _2); ZEPHIR_CALL_METHOD(NULL, _12, "__construct", NULL, 9, _14); zephir_check_call_status(); zephir_throw_exception_debug(_12, "phalcon/image/adapter/gd.zep", 112 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_SINIT_VAR(_17); ZVAL_LONG(&_17, width); ZEPHIR_SINIT_VAR(_18); ZVAL_LONG(&_18, height); ZEPHIR_CALL_FUNCTION(&_3, "imagecreatetruecolor", NULL, 248, &_17, &_18); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _3 TSRMLS_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 249, _4, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_15, 247, _9, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_realpath"), _10 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_13); ZVAL_LONG(_13, width); zephir_update_property_this(this_ptr, SL("_width"), _13 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_13); ZVAL_LONG(_13, height); zephir_update_property_this(this_ptr, SL("_height"), _13 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_13); ZVAL_LONG(_13, 3); zephir_update_property_this(this_ptr, SL("_type"), _13 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_13); ZVAL_STRING(_13, "image/png", 1); zephir_update_property_this(this_ptr, SL("_mime"), _13 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _resize) { zephir_fcall_cache_entry *_8 = NULL, *_18 = NULL, *_23 = NULL, *_25 = NULL; zend_bool _4, _7; zval *width_param = NULL, *height_param = NULL, *image = NULL, *pre_width = NULL, *pre_height = NULL, *reduction_width, *reduction_height, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3, *_5, _6 = zval_used_for_init, *_9, *_10, *_11, _12 = zval_used_for_init, _13 = zval_used_for_init, _14 = zval_used_for_init, _15 = zval_used_for_init, *_16 = NULL, *_17, *_19, *_20, _21, *_22 = NULL, *_24 = NULL; int width, height, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &width_param, &height_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION"); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "5.5.0", 0); ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 240, _0, &_1); zephir_check_call_status(); if (ZEPHIR_LT_LONG(_2, 0)) { ZEPHIR_OBS_VAR(pre_width); zephir_read_property_this(&pre_width, this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_OBS_VAR(pre_height); zephir_read_property_this(&pre_height, this_ptr, SL("_height"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _4 = width > (zephir_safe_div_zval_long(_3, 2 TSRMLS_CC)); if (_4) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _4 = height > (zephir_safe_div_zval_long(_5, 2 TSRMLS_CC)); } if (_4) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (width * 1.1)); ZEPHIR_INIT_VAR(reduction_width); zephir_round(reduction_width, &_1, NULL, NULL TSRMLS_CC); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, (height * 1.1)); ZEPHIR_INIT_VAR(reduction_height); zephir_round(reduction_height, &_6, NULL, NULL TSRMLS_CC); while (1) { _7 = ZEPHIR_LT_LONG(reduction_width, zephir_safe_div_zval_long(pre_width, 2 TSRMLS_CC)); if (_7) { _7 = ZEPHIR_LT_LONG(reduction_height, zephir_safe_div_zval_long(pre_height, 2 TSRMLS_CC)); } if (!(_7)) { break; } ZEPHIR_INIT_NVAR(pre_width); ZVAL_DOUBLE(pre_width, 2); ZEPHIR_INIT_NVAR(pre_height); ZVAL_DOUBLE(pre_height, 2); } ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", &_8, 0, pre_width, pre_height); zephir_check_call_status(); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _10 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _11 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_12); ZVAL_LONG(&_12, 0); ZEPHIR_SINIT_VAR(_13); ZVAL_LONG(&_13, 0); ZEPHIR_SINIT_VAR(_14); ZVAL_LONG(&_14, 0); ZEPHIR_SINIT_VAR(_15); ZVAL_LONG(&_15, 0); ZEPHIR_CALL_FUNCTION(&_16, "imagecopyresized", NULL, 250, image, _9, &_12, &_13, &_14, &_15, pre_width, pre_height, _10, _11); zephir_check_call_status(); if (zephir_is_true(_16)) { _17 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_18, 251, _17); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); } } ZEPHIR_INIT_VAR(_19); ZVAL_LONG(_19, width); ZEPHIR_INIT_VAR(_20); ZVAL_LONG(_20, height); ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", &_8, 0, _19, _20); zephir_check_call_status(); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 0); ZEPHIR_SINIT_NVAR(_13); ZVAL_LONG(&_13, 0); ZEPHIR_SINIT_NVAR(_14); ZVAL_LONG(&_14, 0); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, width); ZEPHIR_SINIT_VAR(_21); ZVAL_LONG(&_21, height); ZEPHIR_CALL_FUNCTION(&_16, "imagecopyresampled", NULL, 252, image, _9, &_6, &_12, &_13, &_14, &_15, &_21, pre_width, pre_height); zephir_check_call_status(); if (zephir_is_true(_16)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_18, 251, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "imagesx", &_23, 253, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _22 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_24, "imagesy", &_25, 254, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _24 TSRMLS_CC); } } else { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, width); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, height); ZEPHIR_CALL_FUNCTION(&image, "imagescale", NULL, 255, _3, &_6, &_12); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_18, 251, _5); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "imagesx", &_23, 253, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _16 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "imagesy", &_25, 254, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _22 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _crop) { zephir_fcall_cache_entry *_15 = NULL, *_17 = NULL, *_19 = NULL; zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, *image = NULL, *rect, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3 = NULL, *_4, *_5, _6, _7, _8, _9, _10, _11, _12, *_13 = NULL, *_14, *_16 = NULL, *_18 = NULL; int width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); offsetX = zephir_get_intval(offsetX_param); offsetY = zephir_get_intval(offsetY_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION"); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "5.5.0", 0); ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 240, _0, &_1); zephir_check_call_status(); if (ZEPHIR_LT_LONG(_2, 0)) { ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, width); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, height); ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, _3, _4); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, offsetX); ZEPHIR_SINIT_VAR(_8); ZVAL_LONG(&_8, offsetY); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, width); ZEPHIR_SINIT_VAR(_10); ZVAL_LONG(&_10, height); ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, width); ZEPHIR_SINIT_VAR(_12); ZVAL_LONG(&_12, height); ZEPHIR_CALL_FUNCTION(&_13, "imagecopyresampled", NULL, 252, image, _5, &_1, &_6, &_7, &_8, &_9, &_10, &_11, &_12); zephir_check_call_status(); if (zephir_is_true(_13)) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_15, 251, _14); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "imagesx", &_17, 253, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _16 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_18, "imagesy", &_19, 254, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _18 TSRMLS_CC); } } else { ZEPHIR_INIT_VAR(rect); zephir_create_array(rect, 4, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, offsetX); zephir_array_update_string(&rect, SL("x"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, offsetY); zephir_array_update_string(&rect, SL("y"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, width); zephir_array_update_string(&rect, SL("width"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); zephir_array_update_string(&rect, SL("height"), &_3, PH_COPY | PH_SEPARATE); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&image, "imagecrop", NULL, 256, _5, rect); zephir_check_call_status(); _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_15, 251, _14); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_13, "imagesx", &_17, 253, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _13 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_16, "imagesy", &_19, 254, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _16 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _rotate) { zval *degrees_param = NULL, *image = NULL, *transparent = NULL, *width = NULL, *height = NULL, *_0, _1 = zval_used_for_init, _2 = zval_used_for_init, _3 = zval_used_for_init, _4 = zval_used_for_init, *_5, *_6, _7, *_8 = NULL, *_9; int degrees, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, °rees_param); degrees = zephir_get_intval(degrees_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 0); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 127); ZEPHIR_CALL_FUNCTION(&transparent, "imagecolorallocatealpha", NULL, 257, _0, &_1, &_2, &_3, &_4); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (360 - degrees)); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 1); ZEPHIR_CALL_FUNCTION(&image, "imagerotate", NULL, 258, _5, &_1, transparent, &_2); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 247, image, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&width, "imagesx", NULL, 253, image); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&height, "imagesy", NULL, 254, image); zephir_check_call_status(); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 0); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 100); ZEPHIR_CALL_FUNCTION(&_8, "imagecopymerge", NULL, 259, _6, image, &_1, &_2, &_3, &_4, width, height, &_7); zephir_check_call_status(); if (zephir_is_true(_8)) { _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, _9); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_width"), width TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_height"), height TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _flip) { zephir_fcall_cache_entry *_13 = NULL, *_16 = NULL; zval *direction_param = NULL, *image = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3, *_4, *_5, *_6, *_7, *_8, _9 = zval_used_for_init, _10 = zval_used_for_init, _11 = zval_used_for_init, _12 = zval_used_for_init, *_14 = NULL, *_15 = NULL; int direction, x, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &direction_param); direction = zephir_get_intval(direction_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION"); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "5.5.0", 0); ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 240, _0, &_1); zephir_check_call_status(); if (ZEPHIR_LT_LONG(_2, 0)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, _3, _4); zephir_check_call_status(); if (direction == 11) { x = 0; while (1) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_5, x))) { break; } x++; _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, x); ZEPHIR_SINIT_NVAR(_9); ZVAL_LONG(&_9, 0); ZEPHIR_SINIT_NVAR(_10); ZVAL_LONG(&_10, ((zephir_get_numberval(_7) - x) - 1)); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, 0); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 1); ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_13, 260, image, _6, &_1, &_9, &_10, &_11, &_12, _8); zephir_check_call_status(); } } else { x = 0; while (1) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_5, x))) { break; } x++; _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_9); ZVAL_LONG(&_9, x); ZEPHIR_SINIT_NVAR(_10); ZVAL_LONG(&_10, 0); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, ((zephir_get_numberval(_7) - x) - 1)); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 1); ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_13, 260, image, _6, &_1, &_9, &_10, &_11, _8, &_12); zephir_check_call_status(); } } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, _5); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_14, "imagesx", NULL, 253, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _14 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_15, "imagesy", NULL, 254, image); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _15 TSRMLS_CC); } else { if (direction == 11) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 1); ZEPHIR_CALL_FUNCTION(NULL, "imageflip", &_16, 261, _3, &_1); zephir_check_call_status(); } else { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 2); ZEPHIR_CALL_FUNCTION(NULL, "imageflip", &_16, 261, _4, &_1); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _sharpen) { zval *_3 = NULL; zval *amount_param = NULL, *matrix, *_0, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5, _6, _7, *_8 = NULL, *_9, *_10 = NULL, *_11, *_12 = NULL; int amount, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, (-18 + ((amount * 0.08)))); ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 193, &_1); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 2); zephir_round(_0, _2, &_1, NULL TSRMLS_CC); amount = zephir_get_intval(_0); ZEPHIR_INIT_VAR(matrix); zephir_create_array(matrix, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); zephir_array_fast_append(matrix, _3); ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, amount); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); zephir_array_fast_append(matrix, _3); ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, -1); zephir_array_fast_append(_3, _4); zephir_array_fast_append(matrix, _3); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, (amount - 8)); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_CALL_FUNCTION(&_8, "imageconvolution", NULL, 262, _5, matrix, &_6, &_7); zephir_check_call_status(); if (zephir_is_true(_8)) { _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_10, "imagesx", NULL, 253, _9); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _10 TSRMLS_CC); _11 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_12, "imagesy", NULL, 254, _11); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _12 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _reflection) { zephir_fcall_cache_entry *_6 = NULL, *_13 = NULL, *_23 = NULL; zend_bool fadeIn; zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, *reflection = NULL, *line = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3, *_4, *_5 = NULL, *_7, *_8, *_9, _10 = zval_used_for_init, _11 = zval_used_for_init, _12 = zval_used_for_init, *_14, *_15, *_16 = NULL, *_17, *_18, *_19, _20 = zval_used_for_init, _21 = zval_used_for_init, _22 = zval_used_for_init, *_24, *_25 = NULL, *_26 = NULL; int height, opacity, stepping, offset, src_y, dst_y, dst_opacity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); height = zephir_get_intval(height_param); opacity = zephir_get_intval(opacity_param); fadeIn = zephir_get_boolval(fadeIn_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127))); ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 193, &_1); zephir_check_call_status(); zephir_round(_0, _2, NULL, NULL TSRMLS_CC); opacity = zephir_get_intval(_0); if (opacity < 127) { stepping = (long) (zephir_safe_div_long_long(((127 - opacity)), height TSRMLS_CC)); } else { stepping = (long) (zephir_safe_div_long_long(127, height TSRMLS_CC)); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, (zephir_get_numberval(_4) + height)); ZEPHIR_CALL_METHOD(&reflection, this_ptr, "_create", &_6, 0, _3, _5); zephir_check_call_status(); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_VAR(_10); ZVAL_LONG(&_10, 0); ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, 0); ZEPHIR_SINIT_VAR(_12); ZVAL_LONG(&_12, 0); ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_13, 260, reflection, _7, &_1, &_10, &_11, &_12, _8, _9); zephir_check_call_status(); offset = 0; while (1) { if (!(height >= offset)) { break; } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); src_y = ((zephir_get_numberval(_14) - offset) - 1); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); dst_y = (zephir_get_numberval(_15) + offset); if (fadeIn) { ZEPHIR_INIT_NVAR(_5); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (opacity + ((stepping * ((height - offset)))))); zephir_round(_5, &_1, NULL, NULL TSRMLS_CC); dst_opacity = zephir_get_intval(_5); } else { ZEPHIR_INIT_NVAR(_16); ZEPHIR_SINIT_NVAR(_10); ZVAL_LONG(&_10, (opacity + ((stepping * offset)))); zephir_round(_16, &_10, NULL, NULL TSRMLS_CC); dst_opacity = zephir_get_intval(_16); } _17 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_16); ZVAL_LONG(_16, 1); ZEPHIR_CALL_METHOD(&line, this_ptr, "_create", &_6, 0, _17, _16); zephir_check_call_status(); _18 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _19 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, 0); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 0); ZEPHIR_SINIT_NVAR(_20); ZVAL_LONG(&_20, 0); ZEPHIR_SINIT_NVAR(_21); ZVAL_LONG(&_21, src_y); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, 1); ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_13, 260, line, _18, &_11, &_12, &_20, &_21, _19, &_22); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, 4); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, 0); ZEPHIR_SINIT_NVAR(_20); ZVAL_LONG(&_20, 0); ZEPHIR_SINIT_NVAR(_21); ZVAL_LONG(&_21, 0); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, dst_opacity); ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_23, 263, line, &_11, &_12, &_20, &_21, &_22); zephir_check_call_status(); _24 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_11); ZVAL_LONG(&_11, 0); ZEPHIR_SINIT_NVAR(_12); ZVAL_LONG(&_12, dst_y); ZEPHIR_SINIT_NVAR(_20); ZVAL_LONG(&_20, 0); ZEPHIR_SINIT_NVAR(_21); ZVAL_LONG(&_21, 0); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, 1); ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_13, 260, reflection, line, &_11, &_12, &_20, &_21, _24, &_22); zephir_check_call_status(); offset++; } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, _14); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), reflection TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_25, "imagesx", NULL, 253, reflection); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _25 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_26, "imagesy", NULL, 254, reflection); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _26 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _watermark) { int offsetX, offsetY, opacity, width, height, ZEPHIR_LAST_CALL_STATUS; zval *watermark, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *overlay = NULL, *color = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, _4 = zval_used_for_init, *_5 = NULL, _6 = zval_used_for_init, _7 = zval_used_for_init, _8 = zval_used_for_init, *_9, *_10, _11, _12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &watermark, &offsetX_param, &offsetY_param, &opacity_param); offsetX = zephir_get_intval(offsetX_param); offsetY = zephir_get_intval(offsetY_param); opacity = zephir_get_intval(opacity_param); ZEPHIR_CALL_METHOD(&_0, watermark, "render", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&overlay, "imagecreatefromstring", NULL, 264, _0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 247, overlay, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 253, overlay); zephir_check_call_status(); width = zephir_get_intval(_1); ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 254, overlay); zephir_check_call_status(); height = zephir_get_intval(_2); if (opacity < 100) { ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_DOUBLE(&_4, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127))); ZEPHIR_CALL_FUNCTION(&_5, "abs", NULL, 193, &_4); zephir_check_call_status(); zephir_round(_3, _5, NULL, NULL TSRMLS_CC); opacity = zephir_get_intval(_3); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 127); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, 127); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 127); ZEPHIR_SINIT_VAR(_8); ZVAL_LONG(&_8, opacity); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 257, overlay, &_4, &_6, &_7, &_8); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 3); ZEPHIR_CALL_FUNCTION(NULL, "imagelayereffect", NULL, 265, overlay, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 0); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, width); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, height); ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", NULL, 266, overlay, &_4, &_6, &_7, &_8, color); zephir_check_call_status(); } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 249, _9, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, offsetX); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, offsetY); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, 0); ZEPHIR_SINIT_VAR(_11); ZVAL_LONG(&_11, width); ZEPHIR_SINIT_VAR(_12); ZVAL_LONG(&_12, height); ZEPHIR_CALL_FUNCTION(&_5, "imagecopy", NULL, 260, _10, overlay, &_4, &_6, &_7, &_8, &_11, &_12); zephir_check_call_status(); if (zephir_is_true(_5)) { ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, overlay); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _text) { zend_bool _9, _10, _11; zephir_fcall_cache_entry *_3 = NULL, *_17 = NULL; int offsetX, offsetY, opacity, r, g, b, size, angle, s0 = 0, s1 = 0, s4 = 0, s5 = 0, width, height, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *r_param = NULL, *g_param = NULL, *b_param = NULL, *size_param = NULL, *fontfile_param = NULL, *space = NULL, *color = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, _4 = zval_used_for_init, *_5, *_6, *_7, *_8, *_12 = NULL, *_13 = NULL, *_14, _15 = zval_used_for_init, _16 = zval_used_for_init, *_18, *_19; zval *text = NULL, *fontfile = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 9, 0, &text_param, &offsetX_param, &offsetY_param, &opacity_param, &r_param, &g_param, &b_param, &size_param, &fontfile_param); zephir_get_strval(text, text_param); offsetX = zephir_get_intval(offsetX_param); offsetY = zephir_get_intval(offsetY_param); opacity = zephir_get_intval(opacity_param); r = zephir_get_intval(r_param); g = zephir_get_intval(g_param); b = zephir_get_intval(b_param); size = zephir_get_intval(size_param); zephir_get_strval(fontfile, fontfile_param); ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127))); ZEPHIR_CALL_FUNCTION(&_2, "abs", &_3, 193, &_1); zephir_check_call_status(); zephir_round(_0, _2, NULL, NULL TSRMLS_CC); opacity = zephir_get_intval(_0); if (!(!fontfile) && Z_STRLEN_P(fontfile)) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, size); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 0); ZEPHIR_CALL_FUNCTION(&space, "imagettfbbox", NULL, 267, &_1, &_4, fontfile, text); zephir_check_call_status(); if (zephir_array_isset_long(space, 0)) { ZEPHIR_OBS_VAR(_5); zephir_array_fetch_long(&_5, space, 0, PH_NOISY, "phalcon/image/adapter/gd.zep", 351 TSRMLS_CC); s0 = zephir_get_intval(_5); ZEPHIR_OBS_VAR(_6); zephir_array_fetch_long(&_6, space, 1, PH_NOISY, "phalcon/image/adapter/gd.zep", 352 TSRMLS_CC); s1 = zephir_get_intval(_6); ZEPHIR_OBS_VAR(_7); zephir_array_fetch_long(&_7, space, 4, PH_NOISY, "phalcon/image/adapter/gd.zep", 353 TSRMLS_CC); s4 = zephir_get_intval(_7); ZEPHIR_OBS_VAR(_8); zephir_array_fetch_long(&_8, space, 5, PH_NOISY, "phalcon/image/adapter/gd.zep", 354 TSRMLS_CC); s5 = zephir_get_intval(_8); } _9 = !s0; if (!(_9)) { _9 = !s1; } _10 = _9; if (!(_10)) { _10 = !s4; } _11 = _10; if (!(_11)) { _11 = !s5; } if (_11) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Call to imagettfbbox() failed", "phalcon/image/adapter/gd.zep", 358); return; } ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (s4 - s0)); ZEPHIR_CALL_FUNCTION(&_12, "abs", &_3, 193, &_1); zephir_check_call_status(); width = (zephir_get_numberval(_12) + 10); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, (s5 - s1)); ZEPHIR_CALL_FUNCTION(&_13, "abs", &_3, 193, &_1); zephir_check_call_status(); height = (zephir_get_numberval(_13) + 10); if (offsetX < 0) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); offsetX = ((zephir_get_numberval(_14) - width) + offsetX); } if (offsetY < 0) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); offsetY = ((zephir_get_numberval(_14) - height) + offsetY); } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, r); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, g); ZEPHIR_SINIT_VAR(_15); ZVAL_LONG(&_15, b); ZEPHIR_SINIT_VAR(_16); ZVAL_LONG(&_16, opacity); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", &_17, 257, _14, &_1, &_4, &_15, &_16); zephir_check_call_status(); angle = 0; _18 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, size); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, angle); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, offsetX); ZEPHIR_SINIT_NVAR(_16); ZVAL_LONG(&_16, offsetY); ZEPHIR_CALL_FUNCTION(NULL, "imagettftext", NULL, 268, _18, &_1, &_4, &_15, &_16, color, fontfile, text); zephir_check_call_status(); } else { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, size); ZEPHIR_CALL_FUNCTION(&_12, "imagefontwidth", NULL, 269, &_1); zephir_check_call_status(); width = (zephir_get_intval(_12) * zephir_fast_strlen_ev(text)); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, size); ZEPHIR_CALL_FUNCTION(&_13, "imagefontheight", NULL, 270, &_1); zephir_check_call_status(); height = zephir_get_intval(_13); if (offsetX < 0) { _18 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); offsetX = ((zephir_get_numberval(_18) - width) + offsetX); } if (offsetY < 0) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); offsetY = ((zephir_get_numberval(_14) - height) + offsetY); } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, r); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, g); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, b); ZEPHIR_SINIT_NVAR(_16); ZVAL_LONG(&_16, opacity); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", &_17, 257, _14, &_1, &_4, &_15, &_16); zephir_check_call_status(); _19 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, size); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, offsetX); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, offsetY); ZEPHIR_CALL_FUNCTION(NULL, "imagestring", NULL, 271, _19, &_1, &_4, &_15, text, color); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _mask) { zend_bool _12; zephir_fcall_cache_entry *_3 = NULL, *_10 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_24 = NULL; int mask_width, mask_height, x, y, alpha, ZEPHIR_LAST_CALL_STATUS; zval *mask, *maskImage = NULL, *newimage = NULL, *tempImage = NULL, *color = NULL, *index = NULL, *r = NULL, *g = NULL, *b = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4, *_5, _6 = zval_used_for_init, _7 = zval_used_for_init, _8 = zval_used_for_init, _9 = zval_used_for_init, *_11, *_13, *_14, *_15, *_16, *_17, _18, _19, *_23; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &mask); ZEPHIR_CALL_METHOD(&_0, mask, "render", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&maskImage, "imagecreatefromstring", NULL, 264, _0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 253, maskImage); zephir_check_call_status(); mask_width = zephir_get_intval(_1); ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 254, maskImage); zephir_check_call_status(); mask_height = zephir_get_intval(_2); alpha = 127; ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_3, 247, maskImage, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&newimage, this_ptr, "_create", NULL, 0, _4, _5); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", &_3, 247, newimage, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_SINIT_VAR(_8); ZVAL_LONG(&_8, 0); ZEPHIR_SINIT_VAR(_9); ZVAL_LONG(&_9, alpha); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", &_10, 257, newimage, &_6, &_7, &_8, &_9); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_CALL_FUNCTION(NULL, "imagefill", NULL, 272, newimage, &_6, &_7, color); zephir_check_call_status(); _11 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _12 = !ZEPHIR_IS_LONG(_11, mask_width); if (!(_12)) { _13 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); _12 = !ZEPHIR_IS_LONG(_13, mask_height); } if (_12) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&tempImage, "imagecreatetruecolor", NULL, 248, _14, _15); zephir_check_call_status(); _16 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _17 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, 0); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, 0); ZEPHIR_SINIT_NVAR(_9); ZVAL_LONG(&_9, 0); ZEPHIR_SINIT_VAR(_18); ZVAL_LONG(&_18, mask_width); ZEPHIR_SINIT_VAR(_19); ZVAL_LONG(&_19, mask_height); ZEPHIR_CALL_FUNCTION(NULL, "imagecopyresampled", NULL, 252, tempImage, maskImage, &_6, &_7, &_8, &_9, _16, _17, &_18, &_19); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_20, 251, maskImage); zephir_check_call_status(); ZEPHIR_CPY_WRT(maskImage, tempImage); } x = 0; while (1) { _14 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_14, x))) { break; } y = 0; while (1) { _15 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_15, y))) { break; } ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, x); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, y); ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_21, 273, maskImage, &_6, &_7); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_22, 274, maskImage, index); zephir_check_call_status(); if (zephir_array_isset_string(color, SS("red"))) { zephir_array_fetch_string(&_23, color, SL("red"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 431 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_6); ZVAL_DOUBLE(&_6, zephir_safe_div_zval_long(_23, 2 TSRMLS_CC)); alpha = (127 - zephir_get_intval(&_6)); } _16 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, x); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, y); ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_21, 273, _16, &_7, &_8); zephir_check_call_status(); _17 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_22, 274, _17, index); zephir_check_call_status(); ZEPHIR_OBS_NVAR(r); zephir_array_fetch_string(&r, color, SL("red"), PH_NOISY, "phalcon/image/adapter/gd.zep", 436 TSRMLS_CC); ZEPHIR_OBS_NVAR(g); zephir_array_fetch_string(&g, color, SL("green"), PH_NOISY, "phalcon/image/adapter/gd.zep", 436 TSRMLS_CC); ZEPHIR_OBS_NVAR(b); zephir_array_fetch_string(&b, color, SL("blue"), PH_NOISY, "phalcon/image/adapter/gd.zep", 436 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, alpha); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", &_10, 257, newimage, r, g, b, &_7); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, x); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, y); ZEPHIR_CALL_FUNCTION(NULL, "imagesetpixel", &_24, 275, newimage, &_7, &_8, color); zephir_check_call_status(); y++; } x++; } _14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_20, 251, _14); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", &_20, 251, maskImage); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), newimage TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _background) { zval *r_param = NULL, *g_param = NULL, *b_param = NULL, *opacity_param = NULL, *background = NULL, *color = NULL, *_0, *_1, _2 = zval_used_for_init, _3 = zval_used_for_init, _4 = zval_used_for_init, _5 = zval_used_for_init, *_6, *_7, *_8, *_9 = NULL, *_10; int r, g, b, opacity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &r_param, &g_param, &b_param, &opacity_param); r = zephir_get_intval(r_param); g = zephir_get_intval(g_param); b = zephir_get_intval(b_param); opacity = zephir_get_intval(opacity_param); opacity = (long) (((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127))); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&background, this_ptr, "_create", NULL, 0, _0, _1); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, r); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, g); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, b); ZEPHIR_SINIT_VAR(_5); ZVAL_LONG(&_5, opacity); ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 257, background, &_2, &_3, &_4, &_5); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 249, background, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 0); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, 0); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 0); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 0); ZEPHIR_CALL_FUNCTION(&_9, "imagecopy", NULL, 260, background, _6, &_2, &_3, &_4, &_5, _7, _8); zephir_check_call_status(); if (zephir_is_true(_9)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, _10); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), background TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _blur) { zephir_fcall_cache_entry *_2 = NULL; zval *radius_param = NULL, *_0, _1 = zval_used_for_init; int radius, i, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &radius_param); radius = zephir_get_intval(radius_param); i = 0; while (1) { if (!(i < radius)) { break; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 7); ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_2, 263, _0, &_1); zephir_check_call_status(); i++; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _pixelate) { zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; zval *amount_param = NULL, *color = NULL, *_0, *_1, *_2, _3 = zval_used_for_init, _4 = zval_used_for_init, *_6, _7 = zval_used_for_init, _8 = zval_used_for_init; int amount, x, y, x1, y1, x2, y2, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); x = 0; while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_0, x))) { break; } y = 0; while (1) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); if (!(ZEPHIR_GT_LONG(_1, y))) { break; } x1 = (x + zephir_safe_div_long_long(amount, 2 TSRMLS_CC)); y1 = (y + zephir_safe_div_long_long(amount, 2 TSRMLS_CC)); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, x1); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, y1); ZEPHIR_CALL_FUNCTION(&color, "imagecolorat", &_5, 273, _2, &_3, &_4); zephir_check_call_status(); x2 = (x + amount); y2 = (y + amount); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_3); ZVAL_LONG(&_3, x); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, y); ZEPHIR_SINIT_NVAR(_7); ZVAL_LONG(&_7, x2); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, y2); ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", &_9, 266, _6, &_3, &_4, &_7, &_8, color); zephir_check_call_status(); y += amount; } x += amount; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _save) { zend_bool _8; zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; int quality, ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *quality_param = NULL, *ext = NULL, _0 = zval_used_for_init, *_1, *_2 = NULL, *_3 = NULL, *_5 = NULL, *_7, *_9 = NULL, *_10 = NULL, *_11; zval *file = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &file_param, &quality_param); zephir_get_strval(file, file_param); quality = zephir_get_intval(quality_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 4); ZEPHIR_CALL_FUNCTION(&ext, "pathinfo", NULL, 72, file, &_0); zephir_check_call_status(); if (!(zephir_is_true(ext))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&ext, "image_type_to_extension", NULL, 276, _1, ZEPHIR_GLOBAL(global_false)); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_2); zephir_fast_strtolower(_2, ext); ZEPHIR_CPY_WRT(ext, _2); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "gif", 0); ZEPHIR_CALL_FUNCTION(&_3, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_3, 0)) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 1); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_5, "image_type_to_mime_type", &_6, 278, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_mime"), _5 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 279, _7, file); zephir_check_call_status(); RETURN_MM_BOOL(1); } ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "jpg", 0); ZEPHIR_CALL_FUNCTION(&_5, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); _8 = ZEPHIR_IS_LONG(_5, 0); if (!(_8)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "jpeg", 0); ZEPHIR_CALL_FUNCTION(&_9, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); _8 = ZEPHIR_IS_LONG(_9, 0); } if (_8) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 2); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_10, "image_type_to_mime_type", &_6, 278, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_mime"), _10 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, quality); ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 280, _7, file, &_0); zephir_check_call_status(); RETURN_MM_BOOL(1); } ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "png", 0); ZEPHIR_CALL_FUNCTION(&_5, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_5, 0)) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 3); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_10, "image_type_to_mime_type", &_6, 278, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_mime"), _10 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 281, _7, file); zephir_check_call_status(); RETURN_MM_BOOL(1); } ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "wbmp", 0); ZEPHIR_CALL_FUNCTION(&_5, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_5, 0)) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 15); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_10, "image_type_to_mime_type", &_6, 278, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_mime"), _10 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 282, _7, file); zephir_check_call_status(); RETURN_MM_BOOL(1); } ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "xbm", 0); ZEPHIR_CALL_FUNCTION(&_5, "strcmp", &_4, 277, ext, &_0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_5, 0)) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 16); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_10, "image_type_to_mime_type", &_6, 278, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_mime"), _10 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 283, _7, file); zephir_check_call_status(); RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_image_exception_ce); ZEPHIR_INIT_VAR(_11); ZEPHIR_CONCAT_SVS(_11, "Installed GD does not support '", ext, "' images"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _11); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/image/adapter/gd.zep", 544 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _render) { zend_bool _7; zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; int quality, ZEPHIR_LAST_CALL_STATUS; zval *ext_param = NULL, *quality_param = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_4, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12; zval *ext = NULL, *_13; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &ext_param, &quality_param); zephir_get_strval(ext, ext_param); quality = zephir_get_intval(quality_param); ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, ext); zephir_get_strval(ext, _0); ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "gif", 0); ZEPHIR_CALL_FUNCTION(&_2, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_2, 0)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 279, _4); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_5, 284); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "jpg", 0); ZEPHIR_CALL_FUNCTION(&_6, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); _7 = ZEPHIR_IS_LONG(_6, 0); if (!(_7)) { ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "jpeg", 0); ZEPHIR_CALL_FUNCTION(&_8, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); _7 = ZEPHIR_IS_LONG(_8, 0); } if (_7) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, quality); ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 280, _4, ZEPHIR_GLOBAL(global_null), &_1); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_5, 284); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "png", 0); ZEPHIR_CALL_FUNCTION(&_9, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_9, 0)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 281, _4); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_5, 284); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "wbmp", 0); ZEPHIR_CALL_FUNCTION(&_10, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_10, 0)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 282, _4); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_5, 284); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "xbm", 0); ZEPHIR_CALL_FUNCTION(&_11, "strcmp", &_3, 277, ext, &_1); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_11, 0)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 283, _4, ZEPHIR_GLOBAL(global_null)); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_5, 284); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(_12); object_init_ex(_12, phalcon_image_exception_ce); ZEPHIR_INIT_VAR(_13); ZEPHIR_CONCAT_SVS(_13, "Installed GD does not support '", ext, "' images"); ZEPHIR_CALL_METHOD(NULL, _12, "__construct", NULL, 9, _13); zephir_check_call_status(); zephir_throw_exception_debug(_12, "phalcon/image/adapter/gd.zep", 572 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Image_Adapter_Gd, _create) { zval *width_param = NULL, *height_param = NULL, *image = NULL, _0, _1; int width, height, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &width_param, &height_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, width); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, height); ZEPHIR_CALL_FUNCTION(&image, "imagecreatetruecolor", NULL, 248, &_0, &_1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 249, image, ZEPHIR_GLOBAL(global_false)); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 247, image, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); RETURN_CCTOR(image); } static PHP_METHOD(Phalcon_Image_Adapter_Gd, __destruct) { int ZEPHIR_LAST_CALL_STATUS; zval *image; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(image); zephir_read_property_this(&image, this_ptr, SL("_image"), PH_NOISY_CC); if (Z_TYPE_P(image) == IS_RESOURCE) { ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 251, image); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Imagick) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Imagick, phalcon, image_adapter_imagick, phalcon_image_adapter_ce, phalcon_image_adapter_imagick_method_entry, 0); zend_declare_property_long(phalcon_image_adapter_imagick_ce, SL("_version"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_bool(phalcon_image_adapter_imagick_ce, SL("_checked"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_image_adapter_imagick_ce TSRMLS_CC, 1, phalcon_image_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, check) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, _1, _2 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_checked") TSRMLS_CC); if (zephir_is_true(_0)) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "imagick", 0); if (!(zephir_class_exists(&_1, 1 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick is not installed, or the extension is not loaded", "phalcon/image/adapter/imagick.zep", 54); return; } ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Imagick::IMAGICK_EXTNUM", 0); ZEPHIR_CALL_FUNCTION(&_3, "defined", NULL, 229, &_2); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "Imagick::IMAGICK_EXTNUM", 0); ZEPHIR_CALL_FUNCTION(&_4, "constant", NULL, 191, &_2); zephir_check_call_status(); zephir_update_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_version"), &_4 TSRMLS_CC); } zephir_update_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_checked"), &ZEPHIR_GLOBAL(global_true) TSRMLS_CC); _5 = zephir_fetch_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_checked") TSRMLS_CC); RETURN_CTOR(_5); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __construct) { zend_bool _17; int width, height, ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *width_param = NULL, *height_param = NULL, *image = NULL, *_0, *_1, *_2, *_3, *_4 = NULL, *_5, *_6 = NULL, *_7, *_8 = NULL, *_9, *_10 = NULL, *_11 = NULL, *_12, _13, *_14 = NULL, *_15, *_16, *_18 = NULL, *_19; zval *file = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); if (unlikely(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(file_param) == IS_STRING)) { zephir_get_strval(file, file_param); } else { ZEPHIR_INIT_VAR(file); ZVAL_EMPTY_STRING(file); } if (!width_param) { width = 0; } else { width = zephir_get_intval(width_param); } if (!height_param) { height = 0; } else { height = zephir_get_intval(height_param); } _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_checked") TSRMLS_CC); if (!(zephir_is_true(_0))) { ZEPHIR_CALL_SELF(NULL, "check", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), _1 TSRMLS_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); if ((zephir_file_exists(_2 TSRMLS_CC) == SUCCESS)) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_4, "realpath", NULL, 63, _3); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_realpath"), _4 TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_realpath"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _5, "readimage", NULL, 0, _7); zephir_check_call_status(); if (!(zephir_is_true(_6))) { ZEPHIR_INIT_VAR(_8); object_init_ex(_8, phalcon_image_exception_ce); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_SVS(_10, "Imagick::readImage ", _9, " failed"); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/image/adapter/imagick.zep", 85 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_11, _9, "getimagealphachannel", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_11))) { _12 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_13); ZVAL_STRING(&_13, "Imagick::ALPHACHANNEL_SET", 0); ZEPHIR_CALL_FUNCTION(&_14, "constant", NULL, 191, &_13); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _12, "setimagealphachannel", NULL, 0, _14); zephir_check_call_status(); } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(_9, 1)) { _12 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&image, _12, "coalesceimages", NULL, 0); zephir_check_call_status(); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _15, "clear", NULL, 0); zephir_check_call_status(); _16 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _16, "destroy", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); } } else { _17 = !width; if (!(_17)) { _17 = !height; } if (_17) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_image_exception_ce); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SV(_10, "Failed to create image from file ", _3); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/image/adapter/imagick.zep", 101 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_INIT_VAR(_18); ZVAL_STRING(_18, "transparent", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 0, _18); zephir_check_temp_parameter(_18); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_18); ZVAL_LONG(_18, width); ZEPHIR_INIT_VAR(_19); ZVAL_LONG(_19, height); ZEPHIR_CALL_METHOD(NULL, _5, "newimage", NULL, 0, _18, _19, _8); zephir_check_call_status(); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_18); ZVAL_STRING(_18, "png", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _7, "setformat", NULL, 0, _18); zephir_check_temp_parameter(_18); zephir_check_call_status(); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_18); ZVAL_STRING(_18, "png", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _9, "setimageformat", NULL, 0, _18); zephir_check_temp_parameter(_18); zephir_check_call_status(); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_realpath"), _12 TSRMLS_CC); } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_4, _3, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _4 TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _5, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _6 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_11, _7, "getimagetype", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_type"), _11 TSRMLS_CC); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_14, _15, "getimageformat", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SV(_10, "image/", _14); zephir_update_property_this(this_ptr, SL("_mime"), _10 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _resize) { zval *width_param = NULL, *height_param = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL; int width, height, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &width_param, &height_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _0, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); while (1) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, width); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); ZEPHIR_CALL_METHOD(NULL, _2, "scaleimage", NULL, 0, _1, _3); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_5, _4, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_5)) { break; } } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_5, _2, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _5 TSRMLS_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _4, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _liquidRescale) { zval *width_param = NULL, *height_param = NULL, *deltaX_param = NULL, *rigidity_param = NULL, *ret = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6, *_7 = NULL, *_8 = NULL; int width, height, deltaX, rigidity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &width_param, &height_param, &deltaX_param, &rigidity_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); deltaX = zephir_get_intval(deltaX_param); rigidity = zephir_get_intval(rigidity_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _0, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); while (1) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, width); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, deltaX); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, rigidity); ZEPHIR_CALL_METHOD(&ret, _2, "liquidrescaleimage", NULL, 0, _1, _3, _4, _5); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::liquidRescale failed", "phalcon/image/adapter/imagick.zep", 151); return; } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_7, _6, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_7)) { break; } } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_7, _2, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _7 TSRMLS_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_8, _6, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _8 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _crop) { zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_7 = NULL; zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, *image, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_6 = NULL, *_8 = NULL; int width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); width = zephir_get_intval(width_param); height = zephir_get_intval(height_param); offsetX = zephir_get_intval(offsetX_param); offsetY = zephir_get_intval(offsetY_param); ZEPHIR_OBS_VAR(image); zephir_read_property_this(&image, this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(NULL, image, "setiteratorindex", NULL, 0, _0); zephir_check_call_status(); while (1) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, width); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, height); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, offsetX); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, offsetY); ZEPHIR_CALL_METHOD(NULL, image, "cropimage", &_4, 0, _0, _1, _2, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, width); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, height); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, image, "setimagepage", &_5, 0, _0, _1, _2, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, image, "nextimage", &_7, 0); zephir_check_call_status(); if (!(zephir_is_true(_6))) { break; } } ZEPHIR_CALL_METHOD(&_6, image, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _6 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_8, image, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _8 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _rotate) { zval *degrees_param = NULL, *pixel, *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6 = NULL, *_7, *_8 = NULL, *_9 = NULL; int degrees, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, °rees_param); degrees = zephir_get_intval(degrees_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _0, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_VAR(pixel); object_init_ex(pixel, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, pixel, "__construct", NULL, 0); zephir_check_call_status(); while (1) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, degrees); ZEPHIR_CALL_METHOD(NULL, _2, "rotateimage", NULL, 0, pixel, _1); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 0); ZEPHIR_CALL_METHOD(NULL, _3, "setimagepage", NULL, 0, _4, _5, _1, _6); zephir_check_call_status(); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_8, _7, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_8)) { break; } } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_8, _2, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _8 TSRMLS_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_9, _3, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _9 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _flip) { zval *direction_param = NULL, *func = NULL, *_0, *_1, *_2, *_3, *_4 = NULL; int direction, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &direction_param); direction = zephir_get_intval(direction_param); ZEPHIR_INIT_VAR(func); ZVAL_STRING(func, "flipImage", 1); if (direction == 11) { ZEPHIR_INIT_NVAR(func); ZVAL_STRING(func, "flopImage", 1); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _0, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); while (1) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD_ZVAL(NULL, _2, func, NULL, 0); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_4, _3, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { break; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _sharpen) { zval *amount_param = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, *_4 = NULL, *_5, *_6 = NULL; int amount, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); ZEPHIR_INIT_VAR(_0); if (amount < 5) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 5); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, amount); } amount = zephir_get_numberval(_0); amount = (long) (zephir_safe_div_long_long(((amount * 3.0)), 100 TSRMLS_CC)); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, _1, "setiteratorindex", NULL, 0, _2); zephir_check_call_status(); while (1) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, amount); ZEPHIR_CALL_METHOD(NULL, _3, "sharpenimage", NULL, 0, _2, _4); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _5, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_6)) { break; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _reflection) { zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_13 = NULL, *_15 = NULL, *_16 = NULL, *_19 = NULL, *_21 = NULL, *_24 = NULL, *_25 = NULL, *_27 = NULL, *_29 = NULL, *_31 = NULL, *_33 = NULL; zend_bool fadeIn, _34; zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, *reflection, *fade, *pseudo = NULL, *image, *pixel, *ret = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL, *_12 = NULL, _14 = zval_used_for_init, *_17 = NULL, *_18 = NULL, *_20 = NULL, *_22, *_23, *_26, *_28, *_30, *_32; int height, opacity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); height = zephir_get_intval(height_param); opacity = zephir_get_intval(opacity_param); fadeIn = zephir_get_boolval(fadeIn_param); _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_imagick_ce, SL("_version") TSRMLS_CC); ZEPHIR_INIT_VAR(reflection); if (ZEPHIR_GE_LONG(_0, 30100)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); if (zephir_clone(reflection, _1 TSRMLS_CC) == FAILURE) { RETURN_MM(); } } else { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "clone", NULL, 0); zephir_check_call_status(); if (zephir_clone(reflection, _2 TSRMLS_CC) == FAILURE) { RETURN_MM(); } } ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, reflection, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(NULL, reflection, "flipimage", &_4, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, reflection, "getimagewidth", &_5, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 0); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); ZEPHIR_CALL_METHOD(NULL, reflection, "cropimage", &_8, 0, _2, _3, _6, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, reflection, "getimagewidth", &_10, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 0); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 0); ZEPHIR_CALL_METHOD(NULL, reflection, "setimagepage", &_11, 0, _9, _3, _6, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_12, reflection, "nextimage", &_13, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_12)) { break; } } if (fadeIn) { ZEPHIR_INIT_VAR(pseudo); ZVAL_STRING(pseudo, "gradient:black-transparent", 1); } else { ZEPHIR_INIT_NVAR(pseudo); ZVAL_STRING(pseudo, "gradient:transparent-black", 1); } ZEPHIR_INIT_VAR(fade); object_init_ex(fade, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, fade, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, reflection, "getimagewidth", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, reflection, "getimageheight", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, fade, "newpseudoimage", NULL, 0, _2, _9, pseudo); zephir_check_call_status(); opacity /= 100; ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, reflection, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); while (1) { ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::COMPOSITE_DSTOUT", 0); ZEPHIR_CALL_FUNCTION(&_12, "constant", &_15, 191, &_14); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 0); ZEPHIR_CALL_METHOD(&ret, reflection, "compositeimage", &_16, 0, fade, _12, _3, _6); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 287); return; } ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::EVALUATE_MULTIPLY", 0); ZEPHIR_CALL_FUNCTION(&_17, "constant", &_15, 191, &_14); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::CHANNEL_ALPHA", 0); ZEPHIR_CALL_FUNCTION(&_18, "constant", &_15, 191, &_14); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, opacity); ZEPHIR_CALL_METHOD(NULL, reflection, "evaluateimage", &_19, 0, _17, _3, _18); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_20, reflection, "nextimage", &_21, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_20)) { break; } } ZEPHIR_CALL_METHOD(NULL, fade, "destroy", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(image); object_init_ex(image, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, image, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(pixel); object_init_ex(pixel, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, pixel, "__construct", NULL, 0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _1, "getimageheight", NULL, 0); zephir_check_call_status(); height = (zephir_get_numberval(_2) + height); _22 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, _22, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); while (1) { _23 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, height); ZEPHIR_CALL_METHOD(NULL, image, "newimage", &_24, 0, _23, _3, pixel); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::ALPHACHANNEL_SET", 0); ZEPHIR_CALL_FUNCTION(&_9, "constant", &_15, 191, &_14); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "setimagealphachannel", &_25, 0, _9); zephir_check_call_status(); _26 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_12, _26, "getcolorspace", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "setcolorspace", &_27, 0, _12); zephir_check_call_status(); _28 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_17, _28, "getimagedelay", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "setimagedelay", &_29, 0, _17); zephir_check_call_status(); _30 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::COMPOSITE_SRC", 0); ZEPHIR_CALL_FUNCTION(&_18, "constant", &_15, 191, &_14); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 0); ZEPHIR_CALL_METHOD(&ret, image, "compositeimage", &_31, 0, _30, _18, _3, _6); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 312); return; } _32 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_20, _32, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_20)) { break; } } ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, image, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, reflection, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); while (1) { ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "Imagick::COMPOSITE_OVER", 0); ZEPHIR_CALL_FUNCTION(&_2, "constant", &_15, 191, &_14); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(&ret, image, "compositeimage", &_31, 0, reflection, _2, _3, _1); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 327); return; } ZEPHIR_CALL_METHOD(&_9, image, "nextimage", &_33, 0); zephir_check_call_status(); _34 = ZEPHIR_IS_FALSE_IDENTICAL(_9); if (!(_34)) { ZEPHIR_CALL_METHOD(&_12, reflection, "nextimage", NULL, 0); zephir_check_call_status(); _34 = ZEPHIR_IS_FALSE_IDENTICAL(_12); } if (_34) { break; } } ZEPHIR_CALL_METHOD(NULL, reflection, "destroy", NULL, 0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _1, "clear", NULL, 0); zephir_check_call_status(); _23 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _23, "destroy", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), image TSRMLS_CC); _26 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_2, _26, "getimagewidth", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_width"), _2 TSRMLS_CC); _28 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_9, _28, "getimageheight", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_height"), _9 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _watermark) { zephir_fcall_cache_entry *_6 = NULL; int offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS; zval *image, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *watermark, *ret = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_7 = NULL, *_8, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &image, &offsetX_param, &offsetY_param, &opacity_param); offsetX = zephir_get_intval(offsetX_param); offsetY = zephir_get_intval(offsetY_param); opacity = zephir_get_intval(opacity_param); opacity = (long) (zephir_safe_div_long_long(opacity, 100 TSRMLS_CC)); ZEPHIR_INIT_VAR(watermark); object_init_ex(watermark, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, watermark, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, watermark, "readimageblob", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, opacity); ZEPHIR_CALL_METHOD(NULL, watermark, "setimageopacity", NULL, 0, _1); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _2, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); while (1) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "Imagick::COMPOSITE_OVER", 0); ZEPHIR_CALL_FUNCTION(&_5, "constant", &_6, 191, &_4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, offsetX); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, offsetY); ZEPHIR_CALL_METHOD(&ret, _3, "compositeimage", NULL, 0, watermark, _5, _1, _7); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 364); return; } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_9, _8, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_9)) { break; } } ZEPHIR_CALL_METHOD(NULL, watermark, "clear", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, watermark, "destroy", NULL, 0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _text) { zephir_fcall_cache_entry *_7 = NULL; zend_bool _6; int opacity, r, g, b, size, x, y, ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *offsetX = NULL, *offsetY = NULL, *opacity_param = NULL, *r_param = NULL, *g_param = NULL, *b_param = NULL, *size_param = NULL, *fontfile_param = NULL, *draw, *color = NULL, *gravity = NULL, _0 = zval_used_for_init, _1, _2, _3, *_4, *_5 = NULL, *_8, *_9, *_10, *_11 = NULL; zval *text = NULL, *fontfile = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 9, 0, &text_param, &offsetX, &offsetY, &opacity_param, &r_param, &g_param, &b_param, &size_param, &fontfile_param); zephir_get_strval(text, text_param); ZEPHIR_SEPARATE_PARAM(offsetX); ZEPHIR_SEPARATE_PARAM(offsetY); opacity = zephir_get_intval(opacity_param); r = zephir_get_intval(r_param); g = zephir_get_intval(g_param); b = zephir_get_intval(b_param); size = zephir_get_intval(size_param); zephir_get_strval(fontfile, fontfile_param); opacity = (long) (zephir_safe_div_long_long(opacity, 100 TSRMLS_CC)); ZEPHIR_INIT_VAR(draw); object_init_ex(draw, zephir_get_internal_ce(SS("imagickdraw") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, draw, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "rgb(%d, %d, %d)", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, r); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, g); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, b); ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 188, &_0, &_1, &_2, &_3); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); object_init_ex(_4, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 0, color); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, draw, "setfillcolor", NULL, 0, _4); zephir_check_call_status(); if (!(!fontfile) && Z_STRLEN_P(fontfile)) { ZEPHIR_CALL_METHOD(NULL, draw, "setfont", NULL, 0, fontfile); zephir_check_call_status(); } if (size) { ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, size); ZEPHIR_CALL_METHOD(NULL, draw, "setfontsize", NULL, 0, _5); zephir_check_call_status(); } if (opacity) { ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, opacity); ZEPHIR_CALL_METHOD(NULL, draw, "setfillopacity", NULL, 0, _5); zephir_check_call_status(); } ZEPHIR_INIT_VAR(gravity); ZVAL_NULL(gravity); if (Z_TYPE_P(offsetX) == IS_BOOL) { if (Z_TYPE_P(offsetY) == IS_BOOL) { ZEPHIR_INIT_NVAR(offsetX); ZVAL_LONG(offsetX, 0); ZEPHIR_INIT_NVAR(offsetY); ZVAL_LONG(offsetY, 0); _6 = zephir_is_true(offsetX); if (_6) { _6 = zephir_is_true(offsetY); } if (_6) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { if (zephir_is_true(offsetX)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_EAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { if (zephir_is_true(offsetY)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTH", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_CENTER", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } } } else { if (Z_TYPE_P(offsetY) == IS_LONG) { y = zephir_get_intval(offsetY); if (zephir_is_true(offsetX)) { ZEPHIR_INIT_NVAR(offsetX); if (y < 0) { ZVAL_LONG(offsetX, 0); ZEPHIR_INIT_NVAR(offsetY); ZVAL_LONG(offsetY, (y * -1)); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetX, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_NORTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(offsetX); if (y < 0) { ZVAL_LONG(offsetX, 0); ZEPHIR_INIT_NVAR(offsetY); ZVAL_LONG(offsetY, (y * -1)); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTH", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetX, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_NORTH", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } } } } else { if (Z_TYPE_P(offsetX) == IS_LONG) { x = zephir_get_intval(offsetX); if (zephir_is_true(offsetX)) { if (Z_TYPE_P(offsetY) == IS_BOOL) { if (zephir_is_true(offsetY)) { ZEPHIR_INIT_NVAR(offsetY); if (x < 0) { ZEPHIR_INIT_NVAR(offsetX); ZVAL_LONG(offsetX, (x * -1)); ZVAL_LONG(offsetY, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetY, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTH", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(offsetY); if (x < 0) { ZEPHIR_INIT_NVAR(offsetX); ZVAL_LONG(offsetX, (x * -1)); ZVAL_LONG(offsetY, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_EAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetY, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_WEST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } } else { if (Z_TYPE_P(offsetY) == IS_LONG) { x = zephir_get_intval(offsetX); y = zephir_get_intval(offsetY); if (x < 0) { ZEPHIR_INIT_NVAR(offsetX); if (y < 0) { ZVAL_LONG(offsetX, (x * -1)); ZEPHIR_INIT_NVAR(offsetY); ZVAL_LONG(offsetY, (y * -1)); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetX, (x * -1)); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_NORTHEAST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(offsetX); if (y < 0) { ZVAL_LONG(offsetX, 0); ZEPHIR_INIT_NVAR(offsetY); ZVAL_LONG(offsetY, (y * -1)); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_SOUTHWEST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } else { ZVAL_LONG(offsetX, 0); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::GRAVITY_NORTHWEST", 0); ZEPHIR_CALL_FUNCTION(&gravity, "constant", &_7, 191, &_0); zephir_check_call_status(); } } } } } } } ZEPHIR_CALL_METHOD(NULL, draw, "setgravity", NULL, 0, gravity); zephir_check_call_status(); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, 0); ZEPHIR_CALL_METHOD(NULL, _8, "setiteratorindex", NULL, 0, _5); zephir_check_call_status(); while (1) { _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, 0); ZEPHIR_CALL_METHOD(NULL, _9, "annotateimage", NULL, 0, draw, offsetX, offsetY, _5, text); zephir_check_call_status(); _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_11, _10, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_11)) { break; } } ZEPHIR_CALL_METHOD(NULL, draw, "destroy", NULL, 0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _mask) { zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *image, *mask, *ret = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3, *_4, _5 = zval_used_for_init, *_6 = NULL, *_8 = NULL, *_9, *_10 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &image); ZEPHIR_INIT_VAR(mask); object_init_ex(mask, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mask, "__construct", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, mask, "readimageblob", NULL, 0, _0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, _1, "setiteratorindex", NULL, 0, _2); zephir_check_call_status(); while (1) { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 1); ZEPHIR_CALL_METHOD(NULL, _3, "setimagematte", NULL, 0, _2); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "Imagick::COMPOSITE_DSTIN", 0); ZEPHIR_CALL_FUNCTION(&_6, "constant", &_7, 191, &_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); ZEPHIR_CALL_METHOD(&ret, _4, "compositeimage", NULL, 0, mask, _6, _2, _8); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 531); return; } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_10, _9, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_10)) { break; } } ZEPHIR_CALL_METHOD(NULL, mask, "clear", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, mask, "destroy", NULL, 0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _background) { zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_16 = NULL, *_19 = NULL, *_23 = NULL; zval *r_param = NULL, *g_param = NULL, *b_param = NULL, *opacity_param = NULL, *background, *color = NULL, *pixel1, *pixel2, *ret = NULL, _0 = zval_used_for_init, _1, _2, _3, *_4 = NULL, *_5, *_6, *_7, *_9 = NULL, *_11 = NULL, *_15 = NULL, *_17, *_18 = NULL, *_20, *_21 = NULL, *_22 = NULL, *_24; int r, g, b, opacity, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &r_param, &g_param, &b_param, &opacity_param); r = zephir_get_intval(r_param); g = zephir_get_intval(g_param); b = zephir_get_intval(b_param); opacity = zephir_get_intval(opacity_param); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "rgb(%d, %d, %d)", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, r); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, g); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, b); ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 188, &_0, &_1, &_2, &_3); zephir_check_call_status(); ZEPHIR_INIT_VAR(pixel1); object_init_ex(pixel1, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, pixel1, "__construct", NULL, 0, color); zephir_check_call_status(); opacity = (long) (zephir_safe_div_long_long(opacity, 100 TSRMLS_CC)); ZEPHIR_INIT_VAR(pixel2); object_init_ex(pixel2, zephir_get_internal_ce(SS("imagickpixel") TSRMLS_CC)); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "transparent", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, pixel2, "__construct", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_INIT_VAR(background); object_init_ex(background, zephir_get_internal_ce(SS("imagick") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, background, "__construct", NULL, 0); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, 0); ZEPHIR_CALL_METHOD(NULL, _5, "setiteratorindex", NULL, 0, _4); zephir_check_call_status(); while (1) { _6 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, background, "newimage", &_8, 0, _6, _7, pixel1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, background, "getimagealphachannel", &_10, 0); zephir_check_call_status(); if (!(zephir_is_true(_9))) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::ALPHACHANNEL_SET", 0); ZEPHIR_CALL_FUNCTION(&_11, "constant", &_12, 191, &_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, background, "setimagealphachannel", &_13, 0, _11); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, background, "setimagebackgroundcolor", &_14, 0, pixel2); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::EVALUATE_MULTIPLY", 0); ZEPHIR_CALL_FUNCTION(&_11, "constant", &_12, 191, &_0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::CHANNEL_ALPHA", 0); ZEPHIR_CALL_FUNCTION(&_15, "constant", &_12, 191, &_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, opacity); ZEPHIR_CALL_METHOD(NULL, background, "evaluateimage", &_16, 0, _11, _4, _15); zephir_check_call_status(); _17 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_18, _17, "getcolorspace", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, background, "setcolorspace", &_19, 0, _18); zephir_check_call_status(); _20 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::COMPOSITE_DISSOLVE", 0); ZEPHIR_CALL_FUNCTION(&_21, "constant", &_12, 191, &_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, 0); ZEPHIR_INIT_NVAR(_22); ZVAL_LONG(_22, 0); ZEPHIR_CALL_METHOD(&ret, background, "compositeimage", &_23, 0, _20, _21, _4, _22); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(ret)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/image/adapter/imagick.zep", 570); return; } _24 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_11, _24, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_11)) { break; } } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _6, "clear", NULL, 0); zephir_check_call_status(); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _7, "destroy", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_image"), background TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _blur) { zval *radius_param = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5 = NULL; int radius, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &radius_param); radius = zephir_get_intval(radius_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, _0, "setiteratorindex", NULL, 0, _1); zephir_check_call_status(); while (1) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, radius); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 100); ZEPHIR_CALL_METHOD(NULL, _2, "blurimage", NULL, 0, _1, _3); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_5, _4, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_5)) { break; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _pixelate) { zval *amount_param = NULL, *_0, *_1, *_2, *_3 = NULL, *_4, *_5 = NULL, *_6, *_7, *_8, *_9, *_10 = NULL; int amount, width, height, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &amount_param); amount = zephir_get_intval(amount_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); width = (long) (zephir_safe_div_zval_long(_0, amount TSRMLS_CC)); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); height = (long) (zephir_safe_div_zval_long(_1, amount TSRMLS_CC)); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(NULL, _2, "setiteratorindex", NULL, 0, _3); zephir_check_call_status(); while (1) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, width); ZEPHIR_INIT_NVAR(_5); ZVAL_LONG(_5, height); ZEPHIR_CALL_METHOD(NULL, _4, "scaleimage", NULL, 0, _3, _5); zephir_check_call_status(); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _6, "scaleimage", NULL, 0, _7, _8); zephir_check_call_status(); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_10, _9, "nextimage", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_10)) { break; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _save) { zend_bool _13; zephir_fcall_cache_entry *_9 = NULL; int quality, ZEPHIR_LAST_CALL_STATUS; zval *file_param = NULL, *quality_param = NULL, *ext = NULL, *fp = NULL, _0 = zval_used_for_init, *_1, *_2, *_3, *_4 = NULL, *_5, *_6 = NULL, *_7, *_8 = NULL, *_10, *_11, *_12 = NULL, *_14 = NULL, *_15 = NULL, *_16, *_17; zval *file = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &file_param, &quality_param); zephir_get_strval(file, file_param); quality = zephir_get_intval(quality_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 4); ZEPHIR_CALL_FUNCTION(&ext, "pathinfo", NULL, 72, file, &_0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _1, "setformat", NULL, 0, ext); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _2, "setimageformat", NULL, 0, ext); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_4, _3, "getimagetype", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_type"), _4 TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_6, _5, "getimageformat", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, "image/", _6); zephir_update_property_this(this_ptr, SL("_mime"), _7 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "gif", 0); ZEPHIR_CALL_FUNCTION(&_8, "strcasecmp", &_9, 19, ext, &_0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_8, 0)) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _10, "optimizeimagelayers", NULL, 0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "w", 0); ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 285, file, &_0); zephir_check_call_status(); _11 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _11, "writeimagesfile", NULL, 0, fp); zephir_check_call_status(); zephir_fclose(fp TSRMLS_CC); RETURN_MM_NULL(); } else { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "jpg", 0); ZEPHIR_CALL_FUNCTION(&_12, "strcasecmp", &_9, 19, ext, &_0); zephir_check_call_status(); _13 = ZEPHIR_IS_LONG(_12, 0); if (!(_13)) { ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "jpeg", 0); ZEPHIR_CALL_FUNCTION(&_14, "strcasecmp", &_9, 19, ext, &_0); zephir_check_call_status(); _13 = ZEPHIR_IS_LONG(_14, 0); } if (_13) { _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "Imagick::COMPRESSION_JPEG", 0); ZEPHIR_CALL_FUNCTION(&_15, "constant", NULL, 191, &_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _10, "setimagecompression", NULL, 0, _15); zephir_check_call_status(); } _11 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_16); ZVAL_LONG(_16, quality); ZEPHIR_CALL_METHOD(NULL, _11, "setimagecompressionquality", NULL, 0, _16); zephir_check_call_status(); _17 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _17, "writeimage", NULL, 0, file); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, _render) { zend_bool _7; zephir_fcall_cache_entry *_5 = NULL; int quality, ZEPHIR_LAST_CALL_STATUS; zval *extension_param = NULL, *quality_param = NULL, *image, *_0 = NULL, *_1 = NULL, *_2, _3 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10; zval *extension = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &extension_param, &quality_param); zephir_get_strval(extension, extension_param); quality = zephir_get_intval(quality_param); ZEPHIR_OBS_VAR(image); zephir_read_property_this(&image, this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, image, "setformat", NULL, 0, extension); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "setimageformat", NULL, 0, extension); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "stripimage", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, image, "getimagetype", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_type"), _0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, image, "getimageformat", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "image/", _1); zephir_update_property_this(this_ptr, SL("_mime"), _2 TSRMLS_CC); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "gif", 0); ZEPHIR_CALL_FUNCTION(&_4, "strcasecmp", &_5, 19, extension, &_3); zephir_check_call_status(); if (ZEPHIR_IS_LONG_IDENTICAL(_4, 0)) { ZEPHIR_CALL_METHOD(NULL, image, "optimizeimagelayers", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "jpg", 0); ZEPHIR_CALL_FUNCTION(&_6, "strcasecmp", &_5, 19, extension, &_3); zephir_check_call_status(); _7 = ZEPHIR_IS_LONG_IDENTICAL(_6, 0); if (!(_7)) { ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "jpeg", 0); ZEPHIR_CALL_FUNCTION(&_8, "strcasecmp", &_5, 19, extension, &_3); zephir_check_call_status(); _7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 0); } if (_7) { ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "Imagick::COMPRESSION_JPEG", 0); ZEPHIR_CALL_FUNCTION(&_9, "constant", NULL, 191, &_3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, image, "setimagecompression", NULL, 0, _9); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_10); ZVAL_LONG(_10, quality); ZEPHIR_CALL_METHOD(NULL, image, "setimagecompressionquality", NULL, 0, _10); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(image, "getimageblob", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __destruct) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1, *_2; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_image"), PH_NOISY_CC); if (zephir_instance_of_ev(_0, zephir_get_internal_ce(SS("imagick") TSRMLS_CC) TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _1, "clear", NULL, 0); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _2, "destroy", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, getInternalImInstance) { RETURN_MEMBER(this_ptr, "_image"); } static PHP_METHOD(Phalcon_Image_Adapter_Imagick, setResourceLimit) { zval *type_param = NULL, *limit_param = NULL, *_0, *_1, *_2; int type, limit, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &limit_param); type = zephir_get_intval(type_param); limit = zephir_get_intval(limit_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, type); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, limit); ZEPHIR_CALL_METHOD(NULL, _0, "setresourcelimit", NULL, 0, _1, _2); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Loader_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Loader, Exception, phalcon, loader_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Adapter, phalcon, logger_adapter, phalcon_logger_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_bool(phalcon_logger_adapter_ce, SL("_transaction"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_adapter_ce, SL("_queue"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_adapter_ce, SL("_formatter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_logger_adapter_ce, SL("_logLevel"), 9, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Adapter, setLogLevel) { zval *level_param = NULL, *_0; int level; zephir_fetch_params(0, 1, 0, &level_param); level = zephir_get_intval(level_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, level); zephir_update_property_this(this_ptr, SL("_logLevel"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Logger_Adapter, getLogLevel) { RETURN_MEMBER(this_ptr, "_logLevel"); } static PHP_METHOD(Phalcon_Logger_Adapter, setFormatter) { zval *formatter; zephir_fetch_params(0, 1, 0, &formatter); zephir_update_property_this(this_ptr, SL("_formatter"), formatter TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Logger_Adapter, begin) { if (1) { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Logger_Adapter, commit) { zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *queue, *message = NULL, *_0, **_3, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "There is no active transaction", "phalcon/logger/adapter.zep", 107); return; } if (0) { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); if (Z_TYPE_P(queue) == IS_ARRAY) { zephir_is_iterable(queue, &_2, &_1, 0, 0, "phalcon/logger/adapter.zep", 125); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(message, _3); ZEPHIR_CALL_METHOD(&_4, message, "getmessage", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, message, "gettype", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, message, "gettime", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, message, "getcontext", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "loginternal", &_8, 0, _4, _5, _6, _7); zephir_check_call_status(); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, rollback) { zval *transaction, *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(transaction); zephir_read_property_this(&transaction, this_ptr, SL("_transaction"), PH_NOISY_CC); if (!(zephir_is_true(transaction))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "There is no active transaction", "phalcon/logger/adapter.zep", 139); return; } if (0) { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_transaction"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_queue"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, isTransaction) { RETURN_MEMBER(this_ptr, "_transaction"); } static PHP_METHOD(Phalcon_Logger_Adapter, critical) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, emergency) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, debug) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 7); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, error) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, info) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 6); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, notice) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 5); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, warning) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 4); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, alert) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Logger_Adapter, log) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1; zval *context = NULL; zval *type, *message = NULL, *context_param = NULL, *timestamp, *toggledMessage = NULL, *toggledType = NULL, *_2, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &type, &message, &context_param); if (!message) { message = ZEPHIR_GLOBAL(global_null); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } _0 = Z_TYPE_P(type) == IS_STRING; if (_0) { _0 = Z_TYPE_P(message) == IS_LONG; } if (_0) { ZEPHIR_CPY_WRT(toggledMessage, type); ZEPHIR_CPY_WRT(toggledType, message); } else { _1 = Z_TYPE_P(type) == IS_STRING; if (_1) { _1 = Z_TYPE_P(message) == IS_NULL; } if (_1) { ZEPHIR_CPY_WRT(toggledMessage, type); ZEPHIR_CPY_WRT(toggledType, message); } else { ZEPHIR_CPY_WRT(toggledMessage, message); ZEPHIR_CPY_WRT(toggledType, type); } } if (Z_TYPE_P(toggledType) == IS_NULL) { ZEPHIR_INIT_NVAR(toggledType); ZVAL_LONG(toggledType, 7); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_logLevel"), PH_NOISY_CC); if (ZEPHIR_GE(_2, toggledType)) { ZEPHIR_INIT_VAR(timestamp); zephir_time(timestamp); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(_4); object_init_ex(_4, phalcon_logger_item_ce); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 53, toggledMessage, toggledType, timestamp, context); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_queue"), _4 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(NULL, this_ptr, "loginternal", NULL, 0, toggledMessage, toggledType, timestamp, context); zephir_check_call_status(); } } RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger, AdapterInterface, phalcon, logger_adapterinterface, phalcon_logger_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, setFormatter); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, getFormatter); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, setLogLevel); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, getLogLevel); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, log); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, begin); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, commit); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, rollback); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, close); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, debug); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, error); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, info); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, notice); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, warning); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, alert); ZEPHIR_DOC_METHOD(Phalcon_Logger_AdapterInterface, emergency); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Exception, phalcon, logger_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Formatter, phalcon, logger_formatter, phalcon_logger_formatter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Formatter, getTypeString) { zval *type_param = NULL; int type; zephir_fetch_params(0, 1, 0, &type_param); type = zephir_get_intval(type_param); do { if (type == 7) { RETURN_STRING("DEBUG", 1); } if (type == 3) { RETURN_STRING("ERROR", 1); } if (type == 4) { RETURN_STRING("WARNING", 1); } if (type == 1) { RETURN_STRING("CRITICAL", 1); } if (type == 8) { RETURN_STRING("CUSTOM", 1); } if (type == 2) { RETURN_STRING("ALERT", 1); } if (type == 5) { RETURN_STRING("NOTICE", 1); } if (type == 6) { RETURN_STRING("INFO", 1); } if (type == 0) { RETURN_STRING("EMERGENCY", 1); } if (type == 9) { RETURN_STRING("SPECIAL", 1); } } while(0); RETURN_STRING("CUSTOM", 1); } static PHP_METHOD(Phalcon_Logger_Formatter, interpolate) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool _0; zval *message_param = NULL, *context = NULL, *replace, *key = NULL, *value = NULL, **_3, *_4 = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context); zephir_get_strval(message, message_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(context) == IS_ARRAY; if (_0) { _0 = zephir_fast_count_int(context TSRMLS_CC) > 0; } if (_0) { ZEPHIR_INIT_VAR(replace); array_init(replace); zephir_is_iterable(context, &_2, &_1, 0, 0, "phalcon/logger/formatter.zep", 89); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "{", key, "}"); zephir_array_update_zval(&replace, _4, &value, PH_COPY | PH_SEPARATE); } ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 54, message, replace); zephir_check_call_status(); RETURN_MM(); } RETURN_CTOR(message); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_FormatterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger, FormatterInterface, phalcon, logger_formatterinterface, phalcon_logger_formatterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Logger_FormatterInterface, format); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Item) { ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Item, phalcon, logger_item, phalcon_logger_item_method_entry, 0); zend_declare_property_null(phalcon_logger_item_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_item_ce, SL("_message"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_item_ce, SL("_time"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_item_ce, SL("_context"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Item, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Logger_Item, getMessage) { RETURN_MEMBER(this_ptr, "_message"); } static PHP_METHOD(Phalcon_Logger_Item, getTime) { RETURN_MEMBER(this_ptr, "_time"); } static PHP_METHOD(Phalcon_Logger_Item, getContext) { RETURN_MEMBER(this_ptr, "_context"); } static PHP_METHOD(Phalcon_Logger_Item, __construct) { int type, time; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &message_param, &type_param, &time_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); if (!time_param) { time = 0; } else { time = zephir_get_intval(time_param); } if (!context) { context = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, type); zephir_update_property_this(this_ptr, SL("_type"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, time); zephir_update_property_this(this_ptr, SL("_time"), _0 TSRMLS_CC); if (Z_TYPE_P(context) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_context"), context TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Multiple) { ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Multiple, phalcon, logger_multiple, phalcon_logger_multiple_method_entry, 0); zend_declare_property_null(phalcon_logger_multiple_ce, SL("_loggers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_multiple_ce, SL("_formatter"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Multiple, getLoggers) { RETURN_MEMBER(this_ptr, "_loggers"); } static PHP_METHOD(Phalcon_Logger_Multiple, getFormatter) { RETURN_MEMBER(this_ptr, "_formatter"); } static PHP_METHOD(Phalcon_Logger_Multiple, push) { zval *logger; zephir_fetch_params(0, 1, 0, &logger); zephir_update_property_array_append(this_ptr, SL("_loggers"), logger TSRMLS_CC); } static PHP_METHOD(Phalcon_Logger_Multiple, setFormatter) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *formatter, *loggers, *logger = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &formatter); ZEPHIR_OBS_VAR(loggers); zephir_read_property_this(&loggers, this_ptr, SL("_loggers"), PH_NOISY_CC); if (Z_TYPE_P(loggers) == IS_ARRAY) { zephir_is_iterable(loggers, &_1, &_0, 0, 0, "phalcon/logger/multiple.zep", 59); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(logger, _2); ZEPHIR_CALL_METHOD(NULL, logger, "setformatter", NULL, 0, formatter); zephir_check_call_status(); } } zephir_update_property_this(this_ptr, SL("_formatter"), formatter TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, log) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *context = NULL; zval *type, *message = NULL, *context_param = NULL, *loggers, *logger = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &type, &message, &context_param); if (!message) { message = ZEPHIR_GLOBAL(global_null); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_OBS_VAR(loggers); zephir_read_property_this(&loggers, this_ptr, SL("_loggers"), PH_NOISY_CC); if (Z_TYPE_P(loggers) == IS_ARRAY) { zephir_is_iterable(loggers, &_1, &_0, 0, 0, "phalcon/logger/multiple.zep", 75); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(logger, _2); ZEPHIR_CALL_METHOD(NULL, logger, "log", NULL, 0, type, message, context); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, critical) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, emergency) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, debug) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 7); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, error) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, info) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 6); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, notice) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 5); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, warning) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 4); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Multiple, alert) { int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message_param = NULL, *context_param = NULL, *_0; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &context_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!context_param) { ZEPHIR_INIT_VAR(context); array_init(context); } else { context = context_param; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_File) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, File, phalcon, logger_adapter_file, phalcon_logger_adapter_ce, phalcon_logger_adapter_file_method_entry, 0); zend_declare_property_null(phalcon_logger_adapter_file_ce, SL("_fileHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_adapter_file_ce, SL("_path"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_logger_adapter_file_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_logger_adapter_file_ce TSRMLS_CC, 1, phalcon_logger_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Adapter_File, getPath) { RETURN_MEMBER(this_ptr, "_path"); } static PHP_METHOD(Phalcon_Logger_Adapter_File, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *options = NULL, *mode = NULL, *handler = NULL, *_0; zval *name = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &options); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(mode); ZVAL_NULL(mode); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_NVAR(mode); if (zephir_array_isset_string_fetch(&mode, options, SS("mode"), 0 TSRMLS_CC)) { if (zephir_memnstr_str(mode, SL("r"), "phalcon/logger/adapter/file.zep", 73)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Logger must be opened in append or write mode", "phalcon/logger/adapter/file.zep", 74); return; } } } if (Z_TYPE_P(mode) == IS_NULL) { ZEPHIR_INIT_NVAR(mode); ZVAL_STRING(mode, "ab", 1); } ZEPHIR_CALL_FUNCTION(&handler, "fopen", NULL, 285, name, mode); zephir_check_call_status(); if (Z_TYPE_P(handler) != IS_RESOURCE) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_logger_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Can't open log file at '", name, "'"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/logger/adapter/file.zep", 88 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_property_this(this_ptr, SL("_path"), name TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_fileHandler"), handler TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_File, getFormatter) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_formatter"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_logger_formatter_line_ce); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 289); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_formatter"), _1 TSRMLS_CC); } RETURN_MM_MEMBER(this_ptr, "_formatter"); } static PHP_METHOD(Phalcon_Logger_Adapter_File, logInternal) { zval *context = NULL; int type, time, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context_param = NULL, *fileHandler, *_0 = NULL, *_1 = NULL, *_2, *_3; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &message_param, &type_param, &time_param, &context_param); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); time = zephir_get_intval(time_param); zephir_get_arrval(context, context_param); ZEPHIR_OBS_VAR(fileHandler); zephir_read_property_this(&fileHandler, this_ptr, SL("_fileHandler"), PH_NOISY_CC); if (Z_TYPE_P(fileHandler) != IS_RESOURCE) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Cannot send message to the log because it is invalid", "phalcon/logger/adapter/file.zep", 117); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getformatter", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, type); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, time); ZEPHIR_CALL_METHOD(&_1, _0, "format", NULL, 0, message, _2, _3, context); zephir_check_call_status(); zephir_fwrite(NULL, fileHandler, _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_File, close) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_fileHandler"), PH_NOISY_CC); RETURN_BOOL(zephir_fclose(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Logger_Adapter_File, __wakeup) { int ZEPHIR_LAST_CALL_STATUS; zval *path, *mode = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(path); zephir_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY_CC); if (Z_TYPE_P(path) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Invalid data passed to Phalcon\\Logger\\Adapter\\File::__wakeup()", "phalcon/logger/adapter/file.zep", 140); return; } ZEPHIR_OBS_VAR(mode); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!(zephir_array_isset_string_fetch(&mode, _0, SS("mode"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(mode); ZVAL_STRING(mode, "ab", 1); } if (Z_TYPE_P(mode) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Invalid data passed to Phalcon\\Logger\\Adapter\\File::__wakeup()", "phalcon/logger/adapter/file.zep", 148); return; } if (zephir_memnstr_str(mode, SL("r"), "phalcon/logger/adapter/file.zep", 151)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Logger must be opened in append or write mode", "phalcon/logger/adapter/file.zep", 152); return; } ZEPHIR_CALL_FUNCTION(&_1, "fopen", NULL, 285, path, mode); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_fileHandler"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Firephp) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Firephp, phalcon, logger_adapter_firephp, phalcon_logger_adapter_ce, phalcon_logger_adapter_firephp_method_entry, 0); zend_declare_property_null(phalcon_logger_adapter_firephp_ce, SL("_initialized"), ZEND_ACC_PRIVATE|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_logger_adapter_firephp_ce, SL("_index"), ZEND_ACC_PRIVATE|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_logger_adapter_firephp_ce TSRMLS_CC, 1, phalcon_logger_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Adapter_Firephp, getFormatter) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_formatter"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_logger_formatter_firephp_ce); if (zephir_has_constructor(_1 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_formatter"), _1 TSRMLS_CC); } RETURN_MM_MEMBER(this_ptr, "_formatter"); } static PHP_METHOD(Phalcon_Logger_Adapter_Firephp, logInternal) { HashTable *_8; HashPosition _7; zephir_fcall_cache_entry *_3 = NULL; zval *context = NULL; int type, time, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context_param = NULL, *chunk = NULL, *format = NULL, *chString = NULL, *content = NULL, *key = NULL, *_0, *_1 = NULL, _2 = zval_used_for_init, *_4 = NULL, *_5, *_6, **_9, *_10, *_11; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &message_param, &type_param, &time_param, &context_param); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); time = zephir_get_intval(time_param); zephir_get_arrval(context, context_param); _0 = zephir_fetch_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_index") TSRMLS_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_ZVAL_NREF(_1); ZVAL_LONG(_1, 1); zephir_update_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_index"), &_1 TSRMLS_CC); } _1 = zephir_fetch_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_initialized") TSRMLS_CC); if (!ZEPHIR_IS_TRUE_IDENTICAL(_1)) { ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 237, &_2); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 237, &_2); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "X-Wf-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1", 0); ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 237, &_2); zephir_check_call_status(); zephir_update_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_initialized"), &ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_4, this_ptr, "getformatter", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, type); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, time); ZEPHIR_CALL_METHOD(&format, _4, "format", NULL, 0, message, _5, _6, context); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 4500); ZEPHIR_CALL_FUNCTION(&chunk, "str_split", NULL, 70, format, &_2); zephir_check_call_status(); zephir_is_iterable(chunk, &_8, &_7, 0, 0, "phalcon/logger/adapter/firephp.zep", 102); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(key, _8, _7); ZEPHIR_GET_HVALUE(chString, _9); ZEPHIR_OBS_NVAR(_1); zephir_read_static_property_ce(&_1, phalcon_logger_adapter_firephp_ce, SL("_index") TSRMLS_CC); ZEPHIR_INIT_NVAR(content); ZEPHIR_CONCAT_SVSV(content, "X-Wf-1-1-1-", _1, ": ", chString); if (zephir_array_isset_long(chunk, (zephir_get_numberval(key) + 1))) { zephir_concat_self_str(&content, SL("|\\") TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 237, content); zephir_check_call_status(); _10 = zephir_fetch_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_index") TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_11); ZVAL_LONG(_11, (zephir_get_numberval(_10) + 1)); zephir_update_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_index"), &_11 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_Firephp, close) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Stream) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Stream, phalcon, logger_adapter_stream, phalcon_logger_adapter_ce, phalcon_logger_adapter_stream_method_entry, 0); zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("_stream"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_logger_adapter_stream_ce TSRMLS_CC, 1, phalcon_logger_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Adapter_Stream, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *options = NULL, *mode = NULL, *stream = NULL, *_0; zval *name = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &options); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(mode); if (zephir_array_isset_string_fetch(&mode, options, SS("mode"), 0 TSRMLS_CC)) { if (zephir_memnstr_str(mode, SL("r"), "phalcon/logger/adapter/stream.zep", 61)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Stream must be opened in append or write mode", "phalcon/logger/adapter/stream.zep", 62); return; } } else { ZEPHIR_INIT_NVAR(mode); ZVAL_STRING(mode, "ab", 1); } ZEPHIR_CALL_FUNCTION(&stream, "fopen", NULL, 285, name, mode); zephir_check_call_status(); if (!(zephir_is_true(stream))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_logger_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Can't open stream '", name, "'"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/logger/adapter/stream.zep", 73 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_property_this(this_ptr, SL("_stream"), stream TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_Stream, getFormatter) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_formatter"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_logger_formatter_line_ce); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 289); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_formatter"), _1 TSRMLS_CC); } RETURN_MM_MEMBER(this_ptr, "_formatter"); } static PHP_METHOD(Phalcon_Logger_Adapter_Stream, logInternal) { zval *context = NULL; int type, time, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context_param = NULL, *stream, *_0 = NULL, *_1 = NULL, *_2, *_3; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &message_param, &type_param, &time_param, &context_param); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); time = zephir_get_intval(time_param); zephir_get_arrval(context, context_param); ZEPHIR_OBS_VAR(stream); zephir_read_property_this(&stream, this_ptr, SL("_stream"), PH_NOISY_CC); if (Z_TYPE_P(stream) != IS_RESOURCE) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Cannot send message to the log because it is invalid", "phalcon/logger/adapter/stream.zep", 100); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getformatter", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, type); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, time); ZEPHIR_CALL_METHOD(&_1, _0, "format", NULL, 0, message, _2, _3, context); zephir_check_call_status(); zephir_fwrite(NULL, stream, _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_Stream, close) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_stream"), PH_NOISY_CC); RETURN_BOOL(zephir_fclose(_0 TSRMLS_CC)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Syslog) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Syslog, phalcon, logger_adapter_syslog, phalcon_logger_adapter_ce, phalcon_logger_adapter_syslog_method_entry, 0); zend_declare_property_bool(phalcon_logger_adapter_syslog_ce, SL("_opened"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_logger_adapter_syslog_ce TSRMLS_CC, 1, phalcon_logger_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *name, *options = NULL, *option = NULL, *facility = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (zephir_is_true(name)) { ZEPHIR_OBS_VAR(option); if (!(zephir_array_isset_string_fetch(&option, options, SS("option"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(option); ZVAL_LONG(option, 4); } ZEPHIR_OBS_VAR(facility); if (!(zephir_array_isset_string_fetch(&facility, options, SS("facility"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(facility); ZVAL_LONG(facility, 8); } ZEPHIR_CALL_FUNCTION(NULL, "openlog", NULL, 290, name, option, facility); zephir_check_call_status(); if (1) { zephir_update_property_this(this_ptr, SL("_opened"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_opened"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, getFormatter) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_formatter"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_logger_formatter_syslog_ce); if (zephir_has_constructor(_1 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_formatter"), _1 TSRMLS_CC); } RETURN_MM_MEMBER(this_ptr, "_formatter"); } static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, logInternal) { zval *context = NULL; int type, time, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *time_param = NULL, *context_param = NULL, *appliedFormat = NULL, *_0 = NULL, *_1, *_2, *_3, *_4; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &message_param, &type_param, &time_param, &context_param); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); time = zephir_get_intval(time_param); zephir_get_arrval(context, context_param); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getformatter", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, type); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, time); ZEPHIR_CALL_METHOD(&appliedFormat, _0, "format", NULL, 0, message, _1, _2, context); zephir_check_call_status(); if (Z_TYPE_P(appliedFormat) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "The formatted message is not valid", "phalcon/logger/adapter/syslog.zep", 99); return; } zephir_array_fetch_long(&_3, appliedFormat, 0, PH_NOISY | PH_READONLY, "phalcon/logger/adapter/syslog.zep", 102 TSRMLS_CC); zephir_array_fetch_long(&_4, appliedFormat, 1, PH_NOISY | PH_READONLY, "phalcon/logger/adapter/syslog.zep", 102 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(NULL, "syslog", NULL, 291, _3, _4); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, close) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_opened"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_FUNCTION(NULL, "closelog", NULL, 292); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Firephp) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Firephp, phalcon, logger_formatter_firephp, phalcon_logger_formatter_ce, phalcon_logger_formatter_firephp_method_entry, 0); zend_declare_property_bool(phalcon_logger_formatter_firephp_ce, SL("_showBacktrace"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_logger_formatter_firephp_ce, SL("_enableLabels"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_logger_formatter_firephp_ce TSRMLS_CC, 1, phalcon_logger_formatterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, getTypeString) { zval *type_param = NULL; int type; zephir_fetch_params(0, 1, 0, &type_param); type = zephir_get_intval(type_param); do { if (type == 0 || type == 1 || type == 3) { RETURN_STRING("ERROR", 1); } if (type == 2 || type == 4) { RETURN_STRING("WARN", 1); } if (type == 6 || type == 5 || type == 8) { RETURN_STRING("INFO", 1); } if (type == 7 || type == 9) { RETURN_STRING("LOG", 1); } } while(0); RETURN_STRING("CUSTOM", 1); } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, setShowBacktrace) { zval *isShow_param = NULL; zend_bool isShow; zephir_fetch_params(0, 0, 1, &isShow_param); if (!isShow_param) { isShow = 0; } else { isShow = zephir_get_boolval(isShow_param); } if (isShow) { zephir_update_property_this(this_ptr, SL("_showBacktrace"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_showBacktrace"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, getShowBacktrace) { RETURN_MEMBER(this_ptr, "_showBacktrace"); } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, enableLabels) { zval *isEnable_param = NULL; zend_bool isEnable; zephir_fetch_params(0, 0, 1, &isEnable_param); if (!isEnable_param) { isEnable = 0; } else { isEnable = zephir_get_boolval(isEnable_param); } if (isEnable) { zephir_update_property_this(this_ptr, SL("_enableLabels"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_enableLabels"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, labelsEnabled) { RETURN_MEMBER(this_ptr, "_enableLabels"); } static PHP_METHOD(Phalcon_Logger_Formatter_Firephp, format) { zval *_18; HashTable *_7; HashPosition _6; zend_bool param, _11, _14; int type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta, *body = NULL, *backtrace = NULL, *encoded, *len, *lastTrace = NULL, *_0 = NULL, *_1 = NULL, *_2, *backtraceItem = NULL, *key = NULL, _3 = zval_used_for_init, _4, *_5, **_8, *_9, *_10, *_12, *_13, *_15, *_16, *_17; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message_param, &type_param, ×tamp_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); zephir_get_strval(message, _0); } ZEPHIR_INIT_VAR(meta); zephir_create_array(meta, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, type); ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettypestring", NULL, 0, _1); zephir_check_call_status(); zephir_array_update_string(&meta, SL("Type"), &_0, PH_COPY | PH_SEPARATE); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_2)) { param = 0; ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_VERSION"); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "5.3.6", 0); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "<", 0); ZEPHIR_CALL_FUNCTION(&_0, "version_compare", NULL, 240, _1, &_3, &_4); zephir_check_call_status(); if (!(zephir_is_true(_0))) { param = (2) ? 1 : 0; } ZEPHIR_SINIT_NVAR(_3); ZVAL_BOOL(&_3, (param ? 1 : 0)); ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 152, &_3); zephir_check_call_status(); ZEPHIR_MAKE_REF(backtrace); ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 171, backtrace); ZEPHIR_UNREF(backtrace); zephir_check_call_status(); if (zephir_array_isset_string(lastTrace, SS("file"))) { zephir_array_fetch_string(&_5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 133 TSRMLS_CC); zephir_array_update_string(&meta, SL("File"), &_5, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(lastTrace, SS("line"))) { zephir_array_fetch_string(&_5, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 137 TSRMLS_CC); zephir_array_update_string(&meta, SL("Line"), &_5, PH_COPY | PH_SEPARATE); } zephir_is_iterable(backtrace, &_7, &_6, 1, 0, "phalcon/logger/formatter/firephp.zep", 146); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(key, _7, _6); ZEPHIR_GET_HVALUE(backtraceItem, _8); zephir_array_unset_string(&backtraceItem, SS("object"), PH_SEPARATE); zephir_array_unset_string(&backtraceItem, SS("args"), PH_SEPARATE); zephir_array_update_zval(&backtrace, key, &backtraceItem, PH_COPY | PH_SEPARATE); } } _9 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (zephir_is_true(_9)) { zephir_array_update_string(&meta, SL("Label"), &message, PH_COPY | PH_SEPARATE); } _10 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _11 = !zephir_is_true(_10); if (_11) { _12 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _11 = !zephir_is_true(_12); } _13 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); _14 = zephir_is_true(_13); if (_14) { _15 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); _14 = !zephir_is_true(_15); } if (_11) { ZEPHIR_CPY_WRT(body, message); } else if (_14) { ZEPHIR_INIT_NVAR(body); ZVAL_STRING(body, "", 1); } else { ZEPHIR_INIT_NVAR(body); array_init(body); _16 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC); if (zephir_is_true(_16)) { zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE); } _17 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC); if (!(zephir_is_true(_17))) { zephir_array_update_string(&body, SL("message"), &message, PH_COPY | PH_SEPARATE); } } ZEPHIR_INIT_VAR(_18); zephir_create_array(_18, 2, 0 TSRMLS_CC); zephir_array_fast_append(_18, meta); zephir_array_fast_append(_18, body); ZEPHIR_INIT_VAR(encoded); zephir_json_encode(encoded, &(encoded), _18, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(len); ZVAL_LONG(len, zephir_fast_strlen_ev(encoded)); ZEPHIR_CONCAT_VSVS(return_value, len, "|", encoded, "|"); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Json) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Json, phalcon, logger_formatter_json, phalcon_logger_formatter_ce, phalcon_logger_formatter_json_method_entry, 0); zend_class_implements(phalcon_logger_formatter_json_ce TSRMLS_CC, 1, phalcon_logger_formatterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Formatter_Json, format) { zval *_2; int type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *_0 = NULL, *_1, *_3 = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message_param, &type_param, ×tamp_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); zephir_get_strval(message, _0); } ZEPHIR_INIT_VAR(_1); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, type); ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettypestring", NULL, 0, _3); zephir_check_call_status(); zephir_array_update_string(&_2, SL("type"), &_0, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_2, SL("message"), &message, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, timestamp); zephir_array_update_string(&_2, SL("timestamp"), &_3, PH_COPY | PH_SEPARATE); zephir_json_encode(_1, &(_1), _2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZEPHIR_GET_CONSTANT(_3, "PHP_EOL"); ZEPHIR_CONCAT_VV(return_value, _1, _3); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Line) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Line, phalcon, logger_formatter_line, phalcon_logger_formatter_ce, phalcon_logger_formatter_line_method_entry, 0); zend_declare_property_string(phalcon_logger_formatter_line_ce, SL("_dateFormat"), "D, d M y H:i:s O", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_logger_formatter_line_ce, SL("_format"), "[%date%][%type%] %message%", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_logger_formatter_line_ce TSRMLS_CC, 1, phalcon_logger_formatterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Formatter_Line, getDateFormat) { RETURN_MEMBER(this_ptr, "_dateFormat"); } static PHP_METHOD(Phalcon_Logger_Formatter_Line, setDateFormat) { zval *dateFormat_param = NULL; zval *dateFormat = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &dateFormat_param); zephir_get_strval(dateFormat, dateFormat_param); zephir_update_property_this(this_ptr, SL("_dateFormat"), dateFormat TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Formatter_Line, getFormat) { RETURN_MEMBER(this_ptr, "_format"); } static PHP_METHOD(Phalcon_Logger_Formatter_Line, setFormat) { zval *format_param = NULL; zval *format = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &format_param); zephir_get_strval(format, format_param); zephir_update_property_this(this_ptr, SL("_format"), format TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Logger_Formatter_Line, __construct) { zval *format = NULL, *dateFormat = NULL; zephir_fetch_params(0, 0, 2, &format, &dateFormat); if (!format) { format = ZEPHIR_GLOBAL(global_null); } if (!dateFormat) { dateFormat = ZEPHIR_GLOBAL(global_null); } if (zephir_is_true(format)) { zephir_update_property_this(this_ptr, SL("_format"), format TSRMLS_CC); } if (zephir_is_true(dateFormat)) { zephir_update_property_this(this_ptr, SL("_dateFormat"), dateFormat TSRMLS_CC); } } static PHP_METHOD(Phalcon_Logger_Formatter_Line, format) { int type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *format = NULL, *_0 = NULL, *_1, _2 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_5; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message_param, &type_param, ×tamp_param, &context); zephir_get_strval(message, message_param); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(format); zephir_read_property_this(&format, this_ptr, SL("_format"), PH_NOISY_CC); if (zephir_memnstr_str(format, SL("%date%"), "phalcon/logger/formatter/line.zep", 81)) { ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dateFormat"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, timestamp); ZEPHIR_CALL_FUNCTION(&_3, "date", NULL, 293, _1, &_2); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "%date%", 0); zephir_fast_str_replace(&_0, &_2, _3, format TSRMLS_CC); ZEPHIR_CPY_WRT(format, _0); } if (zephir_memnstr_str(format, SL("%type%"), "phalcon/logger/formatter/line.zep", 88)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, type); ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettypestring", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "%type%", 0); zephir_fast_str_replace(&_0, &_2, _3, format TSRMLS_CC); ZEPHIR_CPY_WRT(format, _0); } ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "%message%", 0); zephir_fast_str_replace(&_0, &_2, message, format TSRMLS_CC); ZEPHIR_INIT_NVAR(_4); ZEPHIR_GET_CONSTANT(_4, "PHP_EOL"); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_VV(_5, _0, _4); ZEPHIR_CPY_WRT(format, _5); if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "interpolate", NULL, 0, format, context); zephir_check_call_status(); RETURN_MM(); } RETURN_CCTOR(format); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Syslog) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Syslog, phalcon, logger_formatter_syslog, phalcon_logger_formatter_ce, phalcon_logger_formatter_syslog_method_entry, 0); zend_class_implements(phalcon_logger_formatter_syslog_ce TSRMLS_CC, 1, phalcon_logger_formatterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Logger_Formatter_Syslog, format) { int type, timestamp, ZEPHIR_LAST_CALL_STATUS; zval *message = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &message, &type_param, ×tamp_param, &context); ZEPHIR_SEPARATE_PARAM(message); type = zephir_get_intval(type_param); timestamp = zephir_get_intval(timestamp_param); if (!context) { context = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(context) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); ZEPHIR_CPY_WRT(message, _0); } zephir_create_array(return_value, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, type); zephir_array_fast_append(return_value, _1); zephir_array_fast_append(return_value, message); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Application, phalcon, mvc_application, phalcon_di_injectable_ce, phalcon_mvc_application_method_entry, 0); zend_declare_property_null(phalcon_mvc_application_ce, SL("_defaultModule"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_application_ce, SL("_modules"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_application_ce, SL("_implicitView"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Application, __construct) { zval *dependencyInjector = NULL; zephir_fetch_params(0, 0, 1, &dependencyInjector); if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Application, useImplicitView) { zval *implicitView_param = NULL; zend_bool implicitView; zephir_fetch_params(0, 1, 0, &implicitView_param); implicitView = zephir_get_boolval(implicitView_param); if (implicitView) { zephir_update_property_this(this_ptr, SL("_implicitView"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_implicitView"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Application, registerModules) { zend_bool merge; zval *modules_param = NULL, *merge_param = NULL, *registeredModules, *_0; zval *modules = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &modules_param, &merge_param); zephir_get_arrval(modules, modules_param); if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge == 0) { zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); } else { ZEPHIR_OBS_VAR(registeredModules); zephir_read_property_this(®isteredModules, this_ptr, SL("_modules"), PH_NOISY_CC); if (Z_TYPE_P(registeredModules) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(registeredModules), &(modules) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modules"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Application, getModules) { RETURN_MEMBER(this_ptr, "_modules"); } static PHP_METHOD(Phalcon_Mvc_Application, getModule) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL, *module, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } ZEPHIR_OBS_VAR(module); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modules"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&module, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_application_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Module '", name, "' isn't registered in the application container"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/application.zep", 159 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(module); } static PHP_METHOD(Phalcon_Mvc_Application, setDefaultModule) { zval *defaultModule_param = NULL; zval *defaultModule = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &defaultModule_param); if (unlikely(Z_TYPE_P(defaultModule_param) != IS_STRING && Z_TYPE_P(defaultModule_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultModule' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(defaultModule_param) == IS_STRING)) { zephir_get_strval(defaultModule, defaultModule_param); } else { ZEPHIR_INIT_VAR(defaultModule); ZVAL_EMPTY_STRING(defaultModule); } zephir_update_property_this(this_ptr, SL("_defaultModule"), defaultModule TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Application, getDefaultModule) { RETURN_MEMBER(this_ptr, "_defaultModule"); } static PHP_METHOD(Phalcon_Mvc_Application, handle) { zval *_6; int ZEPHIR_LAST_CALL_STATUS; zend_bool returnedResponse, _3; zval *uri = NULL, *dependencyInjector, *eventsManager = NULL, *router = NULL, *dispatcher = NULL, *response = NULL, *view = NULL, *module = NULL, *moduleObject = NULL, *moduleName = NULL, *className = NULL, *path, *implicitView, *controller = NULL, *possibleResponse = NULL, *renderStatus = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "A dependency injection object is required to access internal services", "phalcon/mvc/application.zep", 196); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "application:boot", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _1); ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, uri); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&moduleName, router, "getmodulename", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(moduleName))) { ZEPHIR_OBS_NVAR(moduleName); zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC); } ZEPHIR_INIT_VAR(moduleObject); ZVAL_NULL(moduleObject); if (zephir_is_true(moduleName)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:beforeStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, moduleName); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_METHOD(&module, this_ptr, "getmodule", NULL, 0, moduleName); zephir_check_call_status(); _3 = Z_TYPE_P(module) != IS_ARRAY; if (_3) { _3 = Z_TYPE_P(module) != IS_OBJECT; } if (_3) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/mvc/application.zep", 247); return; } if (Z_TYPE_P(module) == IS_ARRAY) { ZEPHIR_OBS_VAR(className); if (!(zephir_array_isset_string_fetch(&className, module, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(className); ZVAL_STRING(className, "Module", 1); } ZEPHIR_OBS_VAR(path); if (zephir_array_isset_string_fetch(&path, module, SS("path"), 0 TSRMLS_CC)) { if (!(zephir_class_exists(className, zephir_is_true(ZEPHIR_GLOBAL(global_false)) TSRMLS_CC))) { if ((zephir_file_exists(path TSRMLS_CC) == SUCCESS)) { if (zephir_require_zval(path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } } else { ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_mvc_application_exception_ce); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVS(_4, "Module definition path '", path, "' doesn't exist"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/mvc/application.zep", 270 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } ZEPHIR_CALL_METHOD(&_5, dependencyInjector, "get", NULL, 0, className); zephir_check_call_status(); ZEPHIR_CPY_WRT(moduleObject, _5); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerautoloaders", NULL, 0, dependencyInjector); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerservices", NULL, 0, dependencyInjector); zephir_check_call_status(); } else { if (zephir_instance_of_ev(module, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 1, 0 TSRMLS_CC); zephir_array_fast_append(_6, dependencyInjector); ZEPHIR_INIT_NVAR(moduleObject); ZEPHIR_CALL_USER_FUNC_ARRAY(moduleObject, module, _6); zephir_check_call_status(); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/mvc/application.zep", 291); return; } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:afterStartModule", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, moduleObject); zephir_check_temp_parameter(_2); zephir_check_call_status(); } } ZEPHIR_OBS_VAR(implicitView); zephir_read_property_this(&implicitView, this_ptr, SL("_implicitView"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(implicitView)) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "view", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(view, _1); } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(dispatcher, _1); ZEPHIR_CALL_METHOD(&_1, router, "getmodulename", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodulename", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, router, "getnamespacename", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setnamespacename", NULL, 0, _5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, router, "getcontrollername", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setcontrollername", NULL, 0, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, router, "getactionname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setactionname", NULL, 0, _8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_9, router, "getparams", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _9); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(implicitView)) { ZEPHIR_CALL_METHOD(NULL, view, "start", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:beforeHandleRequest", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, dispatcher); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_METHOD(&controller, dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&possibleResponse, dispatcher, "getreturnedvalue", NULL, 0); zephir_check_call_status(); _3 = Z_TYPE_P(possibleResponse) == IS_BOOL; if (_3) { _3 = ZEPHIR_IS_FALSE(possibleResponse); } if (_3) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(response, _1); } else { if (Z_TYPE_P(possibleResponse) == IS_OBJECT) { returnedResponse = zephir_instance_of_ev(possibleResponse, phalcon_http_responseinterface_ce TSRMLS_CC); } else { returnedResponse = 0; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:afterHandleRequest", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, controller); zephir_check_temp_parameter(_2); zephir_check_call_status(); } if (returnedResponse == 0) { if (ZEPHIR_IS_TRUE_IDENTICAL(implicitView)) { if (Z_TYPE_P(controller) == IS_OBJECT) { ZEPHIR_INIT_VAR(renderStatus); ZVAL_BOOL(renderStatus, 1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:viewRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&renderStatus, eventsManager, "fire", NULL, 0, _2, this_ptr, view); zephir_check_temp_parameter(_2); zephir_check_call_status(); } if (!ZEPHIR_IS_FALSE_IDENTICAL(renderStatus)) { ZEPHIR_CALL_METHOD(&_1, dispatcher, "getcontrollername", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, dispatcher, "getactionname", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_10, dispatcher, "getparams", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, view, "render", NULL, 0, _1, _5, _10); zephir_check_call_status(); } } } } if (ZEPHIR_IS_TRUE_IDENTICAL(implicitView)) { ZEPHIR_CALL_METHOD(NULL, view, "finish", NULL, 0); zephir_check_call_status(); } if (returnedResponse == 0) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(response, _5); if (ZEPHIR_IS_TRUE_IDENTICAL(implicitView)) { ZEPHIR_CALL_METHOD(&_5, view, "getcontent", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, response, "setcontent", NULL, 0, _5); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(response, possibleResponse); } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "application:beforeSendResponse", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, response); zephir_check_temp_parameter(_2); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, response, "sendheaders", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, response, "sendcookies", NULL, 0); zephir_check_call_status(); RETURN_CCTOR(response); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc, Collection, phalcon, mvc_collection, phalcon_mvc_collection_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_id"), ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_modelsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_source"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_collection_ce, SL("_operationMade"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_connection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_errorMessages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_reserved"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_ce, SL("_disableEvents"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_collection_ce, SL("_skipped"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_NONE"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_CREATE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_UPDATE"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_DELETE"), 3 TSRMLS_CC); zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_mvc_collectioninterface_ce); zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, zend_ce_serializable); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *dependencyInjector = NULL, *modelsManager = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &dependencyInjector, &modelsManager); if (!dependencyInjector) { ZEPHIR_CPY_WRT(dependencyInjector, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(dependencyInjector); } if (!modelsManager) { ZEPHIR_CPY_WRT(modelsManager, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(modelsManager); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/collection.zep", 82); return; } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); if (Z_TYPE_P(modelsManager) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "collectionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&modelsManager, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(modelsManager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The injected service 'modelsManager' is not valid", "phalcon/mvc/collection.zep", 93); return; } } zephir_update_property_this(this_ptr, SL("_modelsManager"), modelsManager TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, modelsManager, "initialize", NULL, 0, this_ptr); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, setId) { int ZEPHIR_LAST_CALL_STATUS; zval *id, *mongoId = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id); if (Z_TYPE_P(id) != IS_OBJECT) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "isusingimplicitobjectids", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(mongoId); object_init_ex(mongoId, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mongoId, "__construct", NULL, 0, id); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(mongoId, id); } } else { ZEPHIR_CPY_WRT(mongoId, id); } zephir_update_property_this(this_ptr, SL("_id"), mongoId TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, getId) { RETURN_MEMBER(this_ptr, "_id"); } static PHP_METHOD(Phalcon_Mvc_Collection, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Collection, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Collection, setEventsManager) { int ZEPHIR_LAST_CALL_STATUS; zval *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventsManager); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setcustomeventsmanager", NULL, 0, this_ptr, eventsManager); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, getEventsManager) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getcustomeventsmanager", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, getCollectionManager) { RETURN_MEMBER(this_ptr, "_modelsManager"); } static PHP_METHOD(Phalcon_Mvc_Collection, getReservedAttributes) { zval *reserved = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(reserved); zephir_read_static_property_ce(&reserved, phalcon_mvc_collection_ce, SL("_reserved") TSRMLS_CC); if (Z_TYPE_P(reserved) == IS_NULL) { ZEPHIR_INIT_NVAR(reserved); zephir_create_array(reserved, 5, 0 TSRMLS_CC); zephir_array_update_string(&reserved, SL("_connection"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&reserved, SL("_dependencyInjector"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&reserved, SL("_source"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&reserved, SL("_operationMade"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&reserved, SL("_errorMessages"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_update_static_property_ce(phalcon_mvc_collection_ce, SL("_reserved"), &reserved TSRMLS_CC); } RETURN_CCTOR(reserved); } static PHP_METHOD(Phalcon_Mvc_Collection, useImplicitObjectIds) { int ZEPHIR_LAST_CALL_STATUS; zval *useImplicitObjectIds_param = NULL, *_0, *_1; zend_bool useImplicitObjectIds; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &useImplicitObjectIds_param); useImplicitObjectIds = zephir_get_boolval(useImplicitObjectIds_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); if (useImplicitObjectIds) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "useimplicitobjectids", NULL, 0, this_ptr, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, setSource) { zval *source_param = NULL; zval *source = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &source_param); if (unlikely(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(source_param) == IS_STRING)) { zephir_get_strval(source, source_param); } else { ZEPHIR_INIT_VAR(source); ZVAL_EMPTY_STRING(source); } zephir_update_property_this(this_ptr, SL("_source"), source TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Collection, getSource) { zval *source = NULL, *collection = NULL, *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(source); zephir_read_property_this(&source, this_ptr, SL("_source"), PH_NOISY_CC); if (!(zephir_is_true(source))) { ZEPHIR_CPY_WRT(collection, this_ptr); ZEPHIR_INIT_VAR(_0); zephir_get_class_ns(_0, collection, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(source); zephir_uncamelize(source, _0); zephir_update_property_this(this_ptr, SL("_source"), source TSRMLS_CC); } RETURN_CCTOR(source); } static PHP_METHOD(Phalcon_Mvc_Collection, setConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *connectionService_param = NULL, *_0; zval *connectionService = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setconnectionservice", NULL, 0, this_ptr, connectionService); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Collection, getConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getconnectionservice", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, getConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *connection = NULL, *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); if (Z_TYPE_P(connection) != IS_OBJECT) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&connection, _0, "getconnection", NULL, 0, this_ptr); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_connection"), connection TSRMLS_CC); } RETURN_CCTOR(connection); } static PHP_METHOD(Phalcon_Mvc_Collection, readAttribute) { zval *attribute_param = NULL, *_0; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attribute_param); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } if (!(zephir_isset_property_zval(this_ptr, attribute TSRMLS_CC))) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(_0); zephir_read_property_zval(&_0, this_ptr, attribute, PH_NOISY_CC); RETURN_CCTOR(_0); } static PHP_METHOD(Phalcon_Mvc_Collection, writeAttribute) { zval *attribute_param = NULL, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &attribute_param, &value); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } zephir_update_property_zval_zval(this_ptr, attribute, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, cloneResult) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *document = NULL; zval *collection, *document_param = NULL, *clonedCollection, *key = NULL, *value = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &collection, &document_param); document = document_param; ZEPHIR_INIT_VAR(clonedCollection); if (zephir_clone(clonedCollection, collection TSRMLS_CC) == FAILURE) { RETURN_MM(); } zephir_is_iterable(document, &_1, &_0, 0, 0, "phalcon/mvc/collection.zep", 325); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CALL_METHOD(NULL, clonedCollection, "writeattribute", &_3, 0, key, value); zephir_check_call_status(); } if ((zephir_method_exists_ex(clonedCollection, SS("afterfetch") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, clonedCollection, "afterfetch", NULL, 0); zephir_check_call_status(); } RETURN_CCTOR(clonedCollection); } static PHP_METHOD(Phalcon_Mvc_Collection, _getResultset) { zephir_fcall_cache_entry *_5 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zend_bool unique; zval *params, *collection, *connection, *unique_param = NULL, *source = NULL, *mongoCollection = NULL, *conditions = NULL, *base = NULL, *documentsCursor = NULL, *fields, *skip, *limit, *sort, *document = NULL, *collections, *_0 = NULL, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, ¶ms, &collection, &connection, &unique_param); unique = zephir_get_boolval(unique_param); ZEPHIR_CALL_METHOD(&source, collection, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 348); return; } ZEPHIR_CALL_METHOD(&mongoCollection, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); if (Z_TYPE_P(mongoCollection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Couldn't select mongo collection", "phalcon/mvc/collection.zep", 354); return; } ZEPHIR_OBS_VAR(conditions); if (!(zephir_array_isset_long_fetch(&conditions, params, 0, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(conditions); if (!(zephir_array_isset_string_fetch(&conditions, params, SS("conditions"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(conditions); array_init(conditions); } } if (Z_TYPE_P(conditions) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Find parameters must be an array", "phalcon/mvc/collection.zep", 367); return; } ZEPHIR_OBS_VAR(fields); if (zephir_array_isset_string_fetch(&fields, params, SS("fields"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&documentsCursor, mongoCollection, "find", NULL, 0, conditions, fields); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&documentsCursor, mongoCollection, "find", NULL, 0, conditions); zephir_check_call_status(); } ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_string_fetch(&limit, params, SS("limit"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "limit", NULL, 0, limit); zephir_check_call_status(); } ZEPHIR_OBS_VAR(sort); if (zephir_array_isset_string_fetch(&sort, params, SS("sort"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "sort", NULL, 0, sort); zephir_check_call_status(); } ZEPHIR_OBS_VAR(skip); if (zephir_array_isset_string_fetch(&skip, params, SS("skip"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "skip", NULL, 0, skip); zephir_check_call_status(); } if (zephir_array_isset_string(params, SS("fields"))) { ZEPHIR_INIT_VAR(base); object_init_ex(base, phalcon_mvc_collection_document_ce); if (zephir_has_constructor(base TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, base, "__construct", NULL, 0); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(base, collection); } if (unique == 1) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "rewind", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&document, documentsCursor, "current", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(document) != IS_ARRAY) { RETURN_MM_BOOL(0); } ZEPHIR_RETURN_CALL_STATIC("cloneresult", NULL, 0, base, document); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(collections); array_init(collections); ZEPHIR_CALL_FUNCTION(&_0, "iterator_to_array", NULL, 294, documentsCursor); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/collection.zep", 440); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(document, _3); ZEPHIR_CALL_STATIC(&_4, "cloneresult", &_5, 0, base, document); zephir_check_call_status(); zephir_array_append(&collections, _4, PH_SEPARATE, "phalcon/mvc/collection.zep", 437); } RETURN_CCTOR(collections); } static PHP_METHOD(Phalcon_Mvc_Collection, _getGroupResultset) { zend_bool _0, _1; int ZEPHIR_LAST_CALL_STATUS; zval *params, *collection, *connection, *source = NULL, *mongoCollection = NULL, *conditions = NULL, *limit, *sort = NULL, *documentsCursor = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, ¶ms, &collection, &connection); ZEPHIR_CALL_METHOD(&source, collection, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 457); return; } ZEPHIR_CALL_METHOD(&mongoCollection, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); ZEPHIR_OBS_VAR(conditions); if (!(zephir_array_isset_long_fetch(&conditions, params, 0, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(conditions); if (!(zephir_array_isset_string_fetch(&conditions, params, SS("conditions"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(conditions); array_init(conditions); } } _0 = zephir_array_isset_string(params, SS("limit")); if (!(_0)) { _0 = zephir_array_isset_string(params, SS("sort")); } _1 = _0; if (!(_1)) { _1 = zephir_array_isset_string(params, SS("skip")); } if (_1) { ZEPHIR_CALL_METHOD(&documentsCursor, mongoCollection, "find", NULL, 0, conditions); zephir_check_call_status(); ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_string_fetch(&limit, params, SS("limit"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "limit", NULL, 0, limit); zephir_check_call_status(); } ZEPHIR_OBS_VAR(sort); if (zephir_array_isset_string_fetch(&sort, params, SS("sort"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "sort", NULL, 0, sort); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(sort); if (zephir_array_isset_string_fetch(&sort, params, SS("skip"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, documentsCursor, "skip", NULL, 0, sort); zephir_check_call_status(); } RETURN_MM_LONG(zephir_fast_count_int(documentsCursor TSRMLS_CC)); } ZEPHIR_RETURN_CALL_METHOD(mongoCollection, "count", NULL, 0, conditions); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, _preSave) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool disableEvents, exists; zval *dependencyInjector, *disableEvents_param = NULL, *exists_param = NULL, *eventName = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &dependencyInjector, &disableEvents_param, &exists_param); disableEvents = zephir_get_boolval(disableEvents_param); exists = zephir_get_boolval(exists_param); if (!(disableEvents)) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "beforeValidation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(eventName); if (!(exists)) { ZVAL_STRING(eventName, "beforeValidationOnCreate", 1); } else { ZVAL_STRING(eventName, "beforeValidationOnUpdate", 1); } ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, eventName); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "validation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { if (!(disableEvents)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "onValidationFails", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_MM_BOOL(0); } if (!(disableEvents)) { ZEPHIR_INIT_NVAR(eventName); if (!(exists)) { ZVAL_STRING(eventName, "afterValidationOnCreate", 1); } else { ZVAL_STRING(eventName, "afterValidationOnUpdate", 1); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, eventName); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterValidation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeSave", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(eventName); if (exists) { ZVAL_STRING(eventName, "beforeUpdate", 1); } else { ZVAL_STRING(eventName, "beforeCreate", 1); } ZEPHIR_CALL_METHOD(&_5, this_ptr, "fireeventcancel", &_2, 0, eventName); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_5)) { RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Collection, _postSave) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *disableEvents_param = NULL, *success_param = NULL, *exists_param = NULL, *eventName, *_1 = NULL; zend_bool disableEvents, success, exists; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &disableEvents_param, &success_param, &exists_param); disableEvents = zephir_get_boolval(disableEvents_param); success = zephir_get_boolval(success_param); exists = zephir_get_boolval(exists_param); if (success == 1) { if (!(disableEvents)) { ZEPHIR_INIT_VAR(eventName); if (exists == 1) { ZVAL_STRING(eventName, "afterUpdate", 1); } else { ZVAL_STRING(eventName, "afterCreate", 1); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_0, 0, eventName); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "afterSave", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_0, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_MM_BOOL(success); } if (!(disableEvents)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "notSave", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_0, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); if (disableEvents) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_canceloperation", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Collection, validate) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *validator, *message = NULL, *_0 = NULL, *_1 = NULL, **_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &validator); ZEPHIR_CALL_METHOD(&_0, validator, "validate", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(&_1, validator, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/collection.zep", 653); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(message, _4); zephir_update_property_array_append(this_ptr, SL("_errorMessages"), message TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, validationHasFailed) { zval *errorMessages; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(errorMessages); zephir_read_property_this(&errorMessages, this_ptr, SL("_errorMessages"), PH_NOISY_CC); if (Z_TYPE_P(errorMessages) == IS_ARRAY) { if (zephir_fast_count_int(errorMessages TSRMLS_CC)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Collection, fireEvent) { int ZEPHIR_LAST_CALL_STATUS; zval *eventName_param = NULL, *_0; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } if ((zephir_method_exists(this_ptr, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, eventName, NULL, 0); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "notifyevent", NULL, 0, eventName, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, fireEventCancel) { int ZEPHIR_LAST_CALL_STATUS; zval *eventName_param = NULL, *_0 = NULL, *_1; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } if ((zephir_method_exists(this_ptr, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&_0, this_ptr, eventName, NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, _1, "notifyevent", NULL, 0, eventName, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Collection, _cancelOperation) { int ZEPHIR_LAST_CALL_STATUS; zval *disableEvents_param = NULL, *eventName, *_0; zend_bool disableEvents; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &disableEvents_param); disableEvents = zephir_get_boolval(disableEvents_param); if (!(disableEvents)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_operationMade"), PH_NOISY_CC); ZEPHIR_INIT_VAR(eventName); if (ZEPHIR_IS_LONG(_0, 3)) { ZVAL_STRING(eventName, "notDeleted", 1); } else { ZVAL_STRING(eventName, "notSaved", 1); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, eventName); zephir_check_call_status(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Collection, _exists) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zval *collection, *id, *mongoId = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &collection); ZEPHIR_OBS_VAR(id); if (!(zephir_fetch_property(&id, this_ptr, SL("_id"), PH_SILENT_CC))) { RETURN_MM_BOOL(0); } if (Z_TYPE_P(id) == IS_OBJECT) { ZEPHIR_CPY_WRT(mongoId, id); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, _0, "isusingimplicitobjectids", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_NVAR(mongoId); object_init_ex(mongoId, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mongoId, "__construct", NULL, 0, id); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_id"), mongoId TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mongoId, id); } } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_update_string(&_2, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, collection, "count", NULL, 0, _2); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_GT_LONG(_1, 0)); } static PHP_METHOD(Phalcon_Mvc_Collection, getMessages) { RETURN_MEMBER(this_ptr, "_errorMessages"); } static PHP_METHOD(Phalcon_Mvc_Collection, appendMessage) { zval *message; zephir_fetch_params(0, 1, 0, &message); zephir_update_property_array_append(this_ptr, SL("_errorMessages"), message TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Collection, save) { zval *_3; int ZEPHIR_LAST_CALL_STATUS; zend_bool success; zval *dependencyInjector, *connection = NULL, *exists = NULL, *source = NULL, *data = NULL, *status = NULL, *id, *ok, *collection = NULL, *disableEvents, *_0, *_1, *_2 = NULL, *_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/collection.zep", 844); return; } ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 849); return; } ZEPHIR_CALL_METHOD(&connection, this_ptr, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&collection, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&exists, this_ptr, "_exists", NULL, 0, collection); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(exists)) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 1); zephir_update_property_this(this_ptr, SL("_operationMade"), _0 TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 2); zephir_update_property_this(this_ptr, SL("_operationMade"), _0 TSRMLS_CC); } ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_errorMessages"), _1 TSRMLS_CC); ZEPHIR_OBS_VAR(disableEvents); zephir_read_static_property_ce(&disableEvents, phalcon_mvc_collection_ce, SL("_disableEvents") TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "_presave", NULL, 295, dependencyInjector, disableEvents, exists); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); success = 0; ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("w"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&status, collection, "save", NULL, 0, data, _3); zephir_check_call_status(); if (Z_TYPE_P(status) == IS_ARRAY) { ZEPHIR_OBS_VAR(ok); if (zephir_array_isset_string_fetch(&ok, status, SS("ok"), 0 TSRMLS_CC)) { if (zephir_is_true(ok)) { success = 1; if (ZEPHIR_IS_FALSE_IDENTICAL(exists)) { ZEPHIR_OBS_VAR(id); if (zephir_array_isset_string_fetch(&id, data, SS("_id"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_id"), id TSRMLS_CC); } } } } } else { success = 0; } ZEPHIR_INIT_VAR(_4); if (success) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_postsave", NULL, 296, disableEvents, _4, exists); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, findById) { zval *_4, *_5; int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *id, *className, *collection, *mongoId = NULL, *_0 = NULL, *_2 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id); if (Z_TYPE_P(id) != IS_OBJECT) { ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(collection); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(collection, _1); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_2, collection, "getcollectionmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, _2, "isusingimplicitobjectids", NULL, 0, collection); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(mongoId); object_init_ex(mongoId, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mongoId, "__construct", NULL, 0, id); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(mongoId, id); } } else { ZEPHIR_CPY_WRT(mongoId, id); } ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_5, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); zephir_array_fast_append(_4, _5); ZEPHIR_RETURN_CALL_STATIC("findfirst", NULL, 0, _4); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, findFirst) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *parameters_param = NULL, *className, *collection, *connection = NULL, *_0 = NULL, *_2; zval *parameters = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters_param); if (!parameters_param) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { zephir_get_arrval(parameters, parameters_param); } ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(collection); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(collection, _1); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&connection, collection, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_RETURN_CALL_STATIC("_getresultset", NULL, 0, parameters, collection, connection, _2); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, find) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *parameters_param = NULL, *className, *collection, *_0 = NULL, *_2 = NULL, *_3; zval *parameters = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters_param); if (!parameters_param) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { zephir_get_arrval(parameters, parameters_param); } ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(collection); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(collection, _1); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_2, collection, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, 0); ZEPHIR_RETURN_CALL_STATIC("_getresultset", NULL, 0, parameters, collection, _2, _3); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, count) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *parameters_param = NULL, *className, *collection, *connection = NULL, *_0 = NULL; zval *parameters = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters_param); if (!parameters_param) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { zephir_get_arrval(parameters, parameters_param); } ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(collection); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(collection, _1); if (zephir_has_constructor(collection TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, collection, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&connection, collection, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_STATIC("_getgroupresultset", NULL, 0, parameters, collection, connection); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, aggregate) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *parameters_param = NULL, *className, *model, *connection = NULL, *source = NULL, *_0 = NULL, *_2 = NULL; zval *parameters = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters_param); if (!parameters_param) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { zephir_get_arrval(parameters, parameters_param); } ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(model); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(model, _1); if (zephir_has_constructor(model TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, model, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&connection, model, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 1061); return; } ZEPHIR_CALL_METHOD(&_2, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(_2, "aggregate", NULL, 0, parameters); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, summatory) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *field_param = NULL, *conditions = NULL, *finalize = NULL, *className, *model, *connection = NULL, *source = NULL, *collection = NULL, *initial, *reduce = NULL, *group = NULL, *retval, *firstRetval, *_0 = NULL, *_2 = NULL, *_4; zval *field = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &field_param, &conditions, &finalize); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!finalize) { finalize = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(className); zephir_get_called_class(className TSRMLS_CC); ZEPHIR_INIT_VAR(model); zephir_fetch_safe_class(_0, className); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(model, _1); if (zephir_has_constructor(model TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, model, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&connection, model, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 1083); return; } ZEPHIR_CALL_METHOD(&collection, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); ZEPHIR_INIT_VAR(initial); zephir_create_array(initial, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); array_init(_2); zephir_array_update_string(&initial, SL("summatory"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSVSVS(_3, "function (curr, result) { if (typeof result.summatory[curr.", field, "] === \"undefined\") { result.summatory[curr.", field, "] = 1; } else { result.summatory[curr.", field, "]++; } }"); ZEPHIR_CPY_WRT(reduce, _3); ZEPHIR_INIT_NVAR(_2); array_init(_2); ZEPHIR_CALL_METHOD(&group, collection, "group", NULL, 0, _2, initial, reduce); zephir_check_call_status(); if (zephir_array_isset_string_fetch(&retval, group, SS("retval"), 1 TSRMLS_CC)) { if (zephir_array_isset_long_fetch(&firstRetval, retval, 0, 1 TSRMLS_CC)) { if (zephir_array_isset_string(firstRetval, SS("summatory"))) { zephir_array_fetch_string(&_4, firstRetval, SL("summatory"), PH_NOISY | PH_READONLY, "phalcon/mvc/collection.zep", 1103 TSRMLS_CC); RETURN_CTOR(_4); } RETURN_CTOR(firstRetval); } RETURN_CTOR(retval); } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, delete) { zval *_4, *_5; int ZEPHIR_LAST_CALL_STATUS; zend_bool success; zval *disableEvents, *status = NULL, *id, *connection = NULL, *source = NULL, *collection = NULL, *mongoId = NULL, *ok, *_0 = NULL, *_1 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(id); if (!(zephir_fetch_property(&id, this_ptr, SL("_id"), PH_SILENT_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The document cannot be deleted because it doesn't exist", "phalcon/mvc/collection.zep", 1131); return; } ZEPHIR_OBS_VAR(disableEvents); zephir_read_static_property_ce(&disableEvents, phalcon_mvc_collection_ce, SL("_disableEvents") TSRMLS_CC); if (!(zephir_is_true(disableEvents))) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "beforeDelete", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_skipped"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_2)) { RETURN_MM_BOOL(1); } ZEPHIR_CALL_METHOD(&connection, this_ptr, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(source)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/mvc/collection.zep", 1150); return; } ZEPHIR_CALL_METHOD(&collection, connection, "selectcollection", NULL, 0, source); zephir_check_call_status(); if (Z_TYPE_P(id) == IS_OBJECT) { ZEPHIR_CPY_WRT(mongoId, id); } else { _3 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, _3, "isusingimplicitobjectids", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_NVAR(mongoId); object_init_ex(mongoId, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, mongoId, "__construct", NULL, 0, id); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(mongoId, id); } } success = 0; ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_5, SL("w"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&status, collection, "remove", NULL, 0, _4, _5); zephir_check_call_status(); if (Z_TYPE_P(status) != IS_ARRAY) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(ok); if (zephir_array_isset_string_fetch(&ok, status, SS("ok"), 0 TSRMLS_CC)) { if (zephir_is_true(ok)) { success = 1; if (!(zephir_is_true(disableEvents))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterDelete", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } } } else { success = 0; } RETURN_MM_BOOL(success); } static PHP_METHOD(Phalcon_Mvc_Collection, addBehavior) { int ZEPHIR_LAST_CALL_STATUS; zval *behavior, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &behavior); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "addbehavior", NULL, 0, this_ptr, behavior); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection, skipOperation) { zval *skip_param = NULL; zend_bool skip; zephir_fetch_params(0, 1, 0, &skip_param); skip = zephir_get_boolval(skip_param); if (skip) { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Collection, toArray) { HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *data, *reserved = NULL, *key = NULL, *value = NULL, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&reserved, this_ptr, "getreservedattributes", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(data); array_init(data); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/collection.zep", 1244); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); if (ZEPHIR_IS_STRING(key, "_id")) { if (zephir_is_true(value)) { zephir_array_update_zval(&data, key, &value, PH_COPY | PH_SEPARATE); } } else { if (!(zephir_array_isset(reserved, key))) { zephir_array_update_zval(&data, key, &value, PH_COPY | PH_SEPARATE); } } } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Collection, serialize) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 74, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Collection, unserialize) { HashTable *_3; HashPosition _2; zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *attributes = NULL, *dependencyInjector = NULL, *manager = NULL, *key = NULL, *value = NULL, *_1, **_4; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); if (unlikely(Z_TYPE_P(data_param) != IS_STRING && Z_TYPE_P(data_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'data' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(data_param) == IS_STRING)) { zephir_get_strval(data, data_param); } else { ZEPHIR_INIT_VAR(data); ZVAL_EMPTY_STRING(data); } ZEPHIR_CALL_FUNCTION(&attributes, "unserialize", NULL, 75, data); zephir_check_call_status(); if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "A dependency injector container is required to obtain the services related to the ODM", "phalcon/mvc/collection.zep", 1273); return; } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "collectionManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&manager, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(manager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The injected service 'collectionManager' is not valid", "phalcon/mvc/collection.zep", 1286); return; } zephir_update_property_this(this_ptr, SL("_modelsManager"), manager TSRMLS_CC); zephir_is_iterable(attributes, &_3, &_2, 0, 0, "phalcon/mvc/collection.zep", 1300); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(key, _3, _2); ZEPHIR_GET_HVALUE(value, _4); zephir_update_property_zval_zval(this_ptr, key, value TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_CollectionInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, CollectionInterface, phalcon, mvc_collectioninterface, phalcon_mvc_collectioninterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, setId); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getId); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getReservedAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getSource); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, setConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, cloneResult); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, fireEvent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, fireEventCancel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, validationHasFailed); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, appendMessage); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, save); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, findById); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, findFirst); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, find); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, count); ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, delete); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Controller) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Controller, phalcon, mvc_controller, phalcon_di_injectable_ce, phalcon_mvc_controller_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_class_implements(phalcon_mvc_controller_ce TSRMLS_CC, 1, phalcon_mvc_controllerinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Controller, __construct) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_ControllerInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ControllerInterface, phalcon, mvc_controllerinterface, NULL); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Dispatcher, phalcon, mvc_dispatcher, phalcon_dispatcher_ce, phalcon_mvc_dispatcher_method_entry, 0); zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("_handlerSuffix"), "Controller", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("_defaultHandler"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("_defaultAction"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_dispatcher_ce TSRMLS_CC, 1, phalcon_mvc_dispatcherinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerSuffix) { zval *controllerSuffix_param = NULL; zval *controllerSuffix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &controllerSuffix_param); if (unlikely(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { zephir_get_strval(controllerSuffix, controllerSuffix_param); } else { ZEPHIR_INIT_VAR(controllerSuffix); ZVAL_EMPTY_STRING(controllerSuffix); } zephir_update_property_this(this_ptr, SL("_handlerSuffix"), controllerSuffix TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, setDefaultController) { zval *controllerName_param = NULL; zval *controllerName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &controllerName_param); if (unlikely(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerName_param) == IS_STRING)) { zephir_get_strval(controllerName, controllerName_param); } else { ZEPHIR_INIT_VAR(controllerName); ZVAL_EMPTY_STRING(controllerName); } zephir_update_property_this(this_ptr, SL("_defaultHandler"), controllerName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerName) { zval *controllerName_param = NULL; zval *controllerName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &controllerName_param); if (unlikely(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerName_param) == IS_STRING)) { zephir_get_strval(controllerName, controllerName_param); } else { ZEPHIR_INIT_VAR(controllerName); ZVAL_EMPTY_STRING(controllerName); } zephir_update_property_this(this_ptr, SL("_handlerName"), controllerName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerName) { RETURN_MEMBER(this_ptr, "_handlerName"); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousControllerName) { RETURN_MEMBER(this_ptr, "_previousHandlerName"); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousActionName) { RETURN_MEMBER(this_ptr, "_previousActionName"); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, _throwDispatchException) { int exceptionCode, ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *exceptionCode_param = NULL, *dependencyInjector, *response = NULL, *exception, *_0 = NULL, *_1 = NULL, *_2, *_3 = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!exceptionCode_param) { exceptionCode = 0; } else { exceptionCode = zephir_get_intval(exceptionCode_param); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_dispatcher_exception_ce); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "A dependency injection container is required to access the 'response' service", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/dispatcher.zep", 120 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "response", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CPY_WRT(response, _3); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 404); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Not Found", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, response, "setstatuscode", NULL, 0, _0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(exception); object_init_ex(exception, phalcon_mvc_dispatcher_exception_ce); ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, exceptionCode); ZEPHIR_CALL_METHOD(NULL, exception, "__construct", NULL, 9, message, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_handleexception", NULL, 0, exception); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } zephir_throw_exception_debug(exception, "phalcon/mvc/dispatcher.zep", 142 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Dispatcher, _handleException) { int ZEPHIR_LAST_CALL_STATUS; zval *exception, *eventsManager = NULL, *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &exception); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "dispatch:beforeException", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _2, this_ptr, exception); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerClass) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethandlerclass", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getLastController) { RETURN_MEMBER(this_ptr, "_lastHandler"); } static PHP_METHOD(Phalcon_Mvc_Dispatcher, getActiveController) { RETURN_MEMBER(this_ptr, "_activeHandler"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_DispatcherInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, DispatcherInterface, phalcon, mvc_dispatcherinterface, phalcon_mvc_dispatcherinterface_method_entry); zend_class_implements(phalcon_mvc_dispatcherinterface_ce TSRMLS_CC, 1, phalcon_dispatcherinterface_ce); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerSuffix); ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setDefaultController); ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getControllerName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getLastController); ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getActiveController); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_EntityInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, EntityInterface, phalcon, mvc_entityinterface, phalcon_mvc_entityinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, readAttribute); ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, writeAttribute); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Micro, phalcon, mvc_micro, phalcon_di_injectable_ce, phalcon_mvc_micro_method_entry, 0); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_handlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_router"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_stopped"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_notFoundHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_errorHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_activeHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_beforeHandlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_afterHandlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_finishHandlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_ce, SL("_returnedValue"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_micro_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Micro, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &dependencyInjector); if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { if (zephir_instance_of_ev(dependencyInjector, phalcon_diinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, dependencyInjector); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Micro, setDI) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector, *_0 = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &dependencyInjector); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "application", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "has", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "application", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, dependencyInjector, "set", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Micro, map) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "add", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, get) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addget", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, post) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addpost", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, put) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addput", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, patch) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addpatch", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, head) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addhead", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "adddelete", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, options) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *router = NULL, *route = NULL, *_0 = NULL; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&route, router, "addoptions", NULL, 0, routePattern); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, route, "getrouteid", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_handlers"), _0, handler TSRMLS_CC); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Micro, mount) { zend_bool _5, _6; zephir_fcall_cache_entry *_4 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *collection, *mainHandler = NULL, *handlers = NULL, *lazyHandler = NULL, *prefix = NULL, *methods = NULL, *pattern = NULL, *subHandler = NULL, *realHandler = NULL, *prefixedPattern = NULL, *route = NULL, *handler = NULL, *name = NULL, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &collection); ZEPHIR_CALL_METHOD(&mainHandler, collection, "gethandler", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(mainHandler)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Collection requires a main handler", "phalcon/mvc/micro.zep", 374); return; } ZEPHIR_CALL_METHOD(&handlers, collection, "gethandlers", NULL, 0); zephir_check_call_status(); if (!(zephir_fast_count_int(handlers TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "There are no handlers to mount", "phalcon/mvc/micro.zep", 379); return; } if (Z_TYPE_P(handlers) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_0, collection, "islazy", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(lazyHandler); object_init_ex(lazyHandler, phalcon_mvc_micro_lazyloader_ce); ZEPHIR_CALL_METHOD(NULL, lazyHandler, "__construct", NULL, 297, mainHandler); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(lazyHandler, mainHandler); } ZEPHIR_CALL_METHOD(&prefix, collection, "getprefix", NULL, 0); zephir_check_call_status(); zephir_is_iterable(handlers, &_2, &_1, 0, 0, "phalcon/mvc/micro.zep", 437); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(handler, _3); if (Z_TYPE_P(handler) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "One of the registered handlers is invalid", "phalcon/mvc/micro.zep", 401); return; } ZEPHIR_OBS_NVAR(methods); zephir_array_fetch_long(&methods, handler, 0, PH_NOISY, "phalcon/mvc/micro.zep", 404 TSRMLS_CC); ZEPHIR_OBS_NVAR(pattern); zephir_array_fetch_long(&pattern, handler, 1, PH_NOISY, "phalcon/mvc/micro.zep", 405 TSRMLS_CC); ZEPHIR_OBS_NVAR(subHandler); zephir_array_fetch_long(&subHandler, handler, 2, PH_NOISY, "phalcon/mvc/micro.zep", 406 TSRMLS_CC); ZEPHIR_OBS_NVAR(name); zephir_array_fetch_long(&name, handler, 3, PH_NOISY, "phalcon/mvc/micro.zep", 407 TSRMLS_CC); ZEPHIR_INIT_NVAR(realHandler); zephir_create_array(realHandler, 2, 0 TSRMLS_CC); zephir_array_fast_append(realHandler, lazyHandler); zephir_array_fast_append(realHandler, subHandler); if (!(ZEPHIR_IS_EMPTY(prefix))) { if (ZEPHIR_IS_STRING(pattern, "/")) { ZEPHIR_CPY_WRT(prefixedPattern, prefix); } else { ZEPHIR_INIT_NVAR(prefixedPattern); ZEPHIR_CONCAT_VV(prefixedPattern, prefix, pattern); } } else { ZEPHIR_CPY_WRT(prefixedPattern, pattern); } ZEPHIR_CALL_METHOD(&route, this_ptr, "map", &_4, 0, prefixedPattern, realHandler); zephir_check_call_status(); _5 = Z_TYPE_P(methods) == IS_STRING; if (_5) { _5 = !ZEPHIR_IS_STRING(methods, ""); } _6 = _5; if (!(_6)) { _6 = Z_TYPE_P(methods) == IS_ARRAY; } if (_6) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } if (Z_TYPE_P(name) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "setname", NULL, 0, name); zephir_check_call_status(); } } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro, notFound) { zval *handler; zephir_fetch_params(0, 1, 0, &handler); zephir_update_property_this(this_ptr, SL("_notFoundHandler"), handler TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro, error) { zval *handler; zephir_fetch_params(0, 1, 0, &handler); zephir_update_property_this(this_ptr, SL("_errorHandler"), handler TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro, getRouter) { int ZEPHIR_LAST_CALL_STATUS; zval *router = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(router); zephir_read_property_this(&router, this_ptr, SL("_router"), PH_NOISY_CC); if (Z_TYPE_P(router) != IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&router, this_ptr, "getsharedservice", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, router, "clear", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, router, "removeextraslashes", NULL, 0, _0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_router"), router TSRMLS_CC); } RETURN_CCTOR(router); } static PHP_METHOD(Phalcon_Mvc_Micro, setService) { int ZEPHIR_LAST_CALL_STATUS; zend_bool shared; zval *serviceName_param = NULL, *definition, *shared_param = NULL, *dependencyInjector = NULL, *_0; zval *serviceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &serviceName_param, &definition, &shared_param); if (unlikely(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(serviceName_param) == IS_STRING)) { zephir_get_strval(serviceName, serviceName_param); } else { ZEPHIR_INIT_VAR(serviceName); ZVAL_EMPTY_STRING(serviceName); } if (!shared_param) { shared = 0; } else { shared = zephir_get_boolval(shared_param); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_NVAR(dependencyInjector); object_init_ex(dependencyInjector, phalcon_di_factorydefault_ce); ZEPHIR_CALL_METHOD(NULL, dependencyInjector, "__construct", NULL, 175); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_INIT_VAR(_0); if (shared) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "set", NULL, 298, serviceName, definition, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, hasService) { int ZEPHIR_LAST_CALL_STATUS; zval *serviceName_param = NULL, *dependencyInjector = NULL; zval *serviceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &serviceName_param); if (unlikely(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(serviceName_param) == IS_STRING)) { zephir_get_strval(serviceName, serviceName_param); } else { ZEPHIR_INIT_VAR(serviceName); ZVAL_EMPTY_STRING(serviceName); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_NVAR(dependencyInjector); object_init_ex(dependencyInjector, phalcon_di_factorydefault_ce); ZEPHIR_CALL_METHOD(NULL, dependencyInjector, "__construct", NULL, 175); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "has", NULL, 299, serviceName); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, getService) { int ZEPHIR_LAST_CALL_STATUS; zval *serviceName_param = NULL, *dependencyInjector = NULL; zval *serviceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &serviceName_param); if (unlikely(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(serviceName_param) == IS_STRING)) { zephir_get_strval(serviceName, serviceName_param); } else { ZEPHIR_INIT_VAR(serviceName); ZVAL_EMPTY_STRING(serviceName); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_NVAR(dependencyInjector); object_init_ex(dependencyInjector, phalcon_di_factorydefault_ce); ZEPHIR_CALL_METHOD(NULL, dependencyInjector, "__construct", NULL, 175); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "get", NULL, 300, serviceName); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, getSharedService) { int ZEPHIR_LAST_CALL_STATUS; zval *serviceName, *dependencyInjector = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &serviceName); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_NVAR(dependencyInjector); object_init_ex(dependencyInjector, phalcon_di_factorydefault_ce); ZEPHIR_CALL_METHOD(NULL, dependencyInjector, "__construct", NULL, 175); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_RETURN_CALL_METHOD(dependencyInjector, "getshared", NULL, 301, serviceName); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, handle) { zval *_17; HashTable *_6, *_10, *_15; HashPosition _5, _9, _14; int ZEPHIR_LAST_CALL_STATUS; zval *uri = NULL, *dependencyInjector, *eventsManager = NULL, *status = NULL, *router = NULL, *matchedRoute = NULL, *handler = NULL, *beforeHandlers, *params = NULL, *returnedValue = NULL, *e = NULL, *errorHandler, *afterHandlers, *notFoundHandler, *finishHandlers, *finish = NULL, *before = NULL, *after = NULL, *_0 = NULL, *_1 = NULL, *_2, *_3 = NULL, *_4 = NULL, **_7, *_8, **_11, *_12, *_13 = NULL, **_16; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "A dependency injection container is required to access required micro services", "phalcon/mvc/micro.zep", 586); return; } /* try_start_1: */ ZEPHIR_INIT_VAR(returnedValue); ZVAL_NULL(returnedValue); ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "micro:beforeHandleRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&router, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, uri); zephir_check_call_status_or_jump(try_end_1); ZEPHIR_CALL_METHOD(&matchedRoute, router, "getmatchedroute", NULL, 0); zephir_check_call_status_or_jump(try_end_1); if (Z_TYPE_P(matchedRoute) == IS_OBJECT) { ZEPHIR_OBS_VAR(handler); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_handlers"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, matchedRoute, "getrouteid", NULL, 0); zephir_check_call_status_or_jump(try_end_1); if (!(zephir_array_isset_fetch(&handler, _2, _0, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_micro_exception_ce); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Matched route doesn't have an associated handler", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_temp_parameter(_3); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(_1, "phalcon/mvc/micro.zep", 620 TSRMLS_CC); goto try_end_1; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "micro:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { RETURN_MM_BOOL(0); } else { ZEPHIR_OBS_NVAR(handler); zephir_read_property_this(&handler, this_ptr, SL("_activeHandler"), PH_NOISY_CC); } } ZEPHIR_OBS_VAR(beforeHandlers); zephir_read_property_this(&beforeHandlers, this_ptr, SL("_beforeHandlers"), PH_NOISY_CC); if (Z_TYPE_P(beforeHandlers) == IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_is_iterable(beforeHandlers, &_6, &_5, 0, 0, "phalcon/mvc/micro.zep", 687); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(before, _7); if (Z_TYPE_P(before) == IS_OBJECT) { if (zephir_instance_of_ev(before, phalcon_mvc_micro_middlewareinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&status, before, "call", NULL, 0, this_ptr); zephir_check_call_status_or_jump(try_end_1); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_stopped"), PH_NOISY_CC); if (zephir_is_true(_8)) { break; } continue; } } if (!(zephir_is_callable(before TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_micro_exception_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "'before' handler is not callable", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_temp_parameter(_3); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(_1, "phalcon/mvc/micro.zep", 670 TSRMLS_CC); goto try_end_1; } ZEPHIR_INIT_NVAR(_1); ZEPHIR_CALL_USER_FUNC(_1, before); zephir_check_call_status_or_jump(try_end_1); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_stopped"), PH_NOISY_CC); if (zephir_is_true(_8)) { RETURN_CCTOR(status); } } } ZEPHIR_CALL_METHOD(¶ms, router, "getparams", NULL, 0); zephir_check_call_status_or_jump(try_end_1); ZEPHIR_INIT_NVAR(returnedValue); ZEPHIR_CALL_USER_FUNC_ARRAY(returnedValue, handler, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), returnedValue TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "micro:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _3, this_ptr); zephir_check_temp_parameter(_3); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_OBS_VAR(afterHandlers); zephir_read_property_this(&afterHandlers, this_ptr, SL("_afterHandlers"), PH_NOISY_CC); if (Z_TYPE_P(afterHandlers) == IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_is_iterable(afterHandlers, &_10, &_9, 0, 0, "phalcon/mvc/micro.zep", 742); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HVALUE(after, _11); if (Z_TYPE_P(after) == IS_OBJECT) { if (zephir_instance_of_ev(after, phalcon_mvc_micro_middlewareinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&status, after, "call", NULL, 0, this_ptr); zephir_check_call_status_or_jump(try_end_1); _12 = zephir_fetch_nproperty_this(this_ptr, SL("_stopped"), PH_NOISY_CC); if (zephir_is_true(_12)) { break; } continue; } } if (!(zephir_is_callable(after TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_micro_exception_ce); ZEPHIR_INIT_NVAR(_13); ZVAL_STRING(_13, "One of the 'after' handlers is not callable", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _13); zephir_check_temp_parameter(_13); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(_3, "phalcon/mvc/micro.zep", 737 TSRMLS_CC); goto try_end_1; } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC(status, after); zephir_check_call_status_or_jump(try_end_1); } } } else { ZEPHIR_OBS_NVAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "micro:beforeNotFound", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_VAR(notFoundHandler); zephir_read_property_this(¬FoundHandler, this_ptr, SL("_notFoundHandler"), PH_NOISY_CC); if (!(zephir_is_callable(notFoundHandler TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_micro_exception_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "Not-Found handler is not callable or is not defined", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_temp_parameter(_3); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(_1, "phalcon/mvc/micro.zep", 761 TSRMLS_CC); goto try_end_1; } ZEPHIR_INIT_NVAR(returnedValue); ZEPHIR_CALL_USER_FUNC(returnedValue, notFoundHandler); zephir_check_call_status_or_jump(try_end_1); } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "micro:afterHandleRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _1, this_ptr, returnedValue); zephir_check_temp_parameter(_1); zephir_check_call_status_or_jump(try_end_1); } ZEPHIR_OBS_VAR(finishHandlers); zephir_read_property_this(&finishHandlers, this_ptr, SL("_finishHandlers"), PH_NOISY_CC); if (Z_TYPE_P(finishHandlers) == IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_INIT_NVAR(params); ZVAL_NULL(params); zephir_is_iterable(finishHandlers, &_15, &_14, 0, 0, "phalcon/mvc/micro.zep", 832); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(finish, _16); if (Z_TYPE_P(finish) == IS_OBJECT) { if (zephir_instance_of_ev(finish, phalcon_mvc_micro_middlewareinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&status, finish, "call", NULL, 0, this_ptr); zephir_check_call_status_or_jump(try_end_1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_stopped"), PH_NOISY_CC); if (zephir_is_true(_2)) { break; } continue; } } if (!(zephir_is_callable(finish TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_micro_exception_ce); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "One of the 'finish' handlers is not callable", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_temp_parameter(_3); zephir_check_call_status_or_jump(try_end_1); zephir_throw_exception_debug(_1, "phalcon/mvc/micro.zep", 813 TSRMLS_CC); goto try_end_1; } if (Z_TYPE_P(params) == IS_NULL) { ZEPHIR_INIT_NVAR(params); zephir_create_array(params, 1, 0 TSRMLS_CC); zephir_array_fast_append(params, this_ptr); } ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, finish, params); zephir_check_call_status_or_jump(try_end_1); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_stopped"), PH_NOISY_CC); if (zephir_is_true(_8)) { break; } } } try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_OBS_NVAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "micro:beforeException", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&returnedValue, eventsManager, "fire", NULL, 0, _1, this_ptr, e); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_OBS_VAR(errorHandler); zephir_read_property_this(&errorHandler, this_ptr, SL("_errorHandler"), PH_NOISY_CC); if (zephir_is_true(errorHandler)) { if (!(zephir_is_callable(errorHandler TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Error handler is not callable", "phalcon/mvc/micro.zep", 851); return; } ZEPHIR_INIT_VAR(_17); zephir_create_array(_17, 1, 0 TSRMLS_CC); zephir_array_fast_append(_17, e); ZEPHIR_INIT_NVAR(returnedValue); ZEPHIR_CALL_USER_FUNC_ARRAY(returnedValue, errorHandler, _17); zephir_check_call_status(); if (Z_TYPE_P(returnedValue) == IS_OBJECT) { if (!(zephir_instance_of_ev(returnedValue, phalcon_http_responseinterface_ce TSRMLS_CC))) { zephir_throw_exception_debug(e, "phalcon/mvc/micro.zep", 860 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { if (!ZEPHIR_IS_FALSE_IDENTICAL(returnedValue)) { zephir_throw_exception_debug(e, "phalcon/mvc/micro.zep", 864 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } else { if (!ZEPHIR_IS_FALSE_IDENTICAL(returnedValue)) { zephir_throw_exception_debug(e, "phalcon/mvc/micro.zep", 870 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } } if (Z_TYPE_P(returnedValue) == IS_OBJECT) { if (zephir_instance_of_ev(returnedValue, phalcon_http_responseinterface_ce TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, returnedValue, "send", NULL, 0); zephir_check_call_status(); } } RETURN_CCTOR(returnedValue); } static PHP_METHOD(Phalcon_Mvc_Micro, stop) { if (1) { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_stopped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Micro, setActiveHandler) { zval *activeHandler; zephir_fetch_params(0, 1, 0, &activeHandler); zephir_update_property_this(this_ptr, SL("_activeHandler"), activeHandler TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Micro, getActiveHandler) { RETURN_MEMBER(this_ptr, "_activeHandler"); } static PHP_METHOD(Phalcon_Mvc_Micro, getReturnedValue) { RETURN_MEMBER(this_ptr, "_returnedValue"); } static PHP_METHOD(Phalcon_Mvc_Micro, offsetExists) { int ZEPHIR_LAST_CALL_STATUS; zval *alias; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &alias); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasservice", NULL, 0, alias); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, offsetSet) { int ZEPHIR_LAST_CALL_STATUS; zval *alias, *definition; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &alias, &definition); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setservice", NULL, 0, alias, definition); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Micro, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *alias; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &alias); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getservice", NULL, 0, alias); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Micro, offsetUnset) { zval *alias; zephir_fetch_params(0, 1, 0, &alias); RETVAL_ZVAL(alias, 1, 0); return; } static PHP_METHOD(Phalcon_Mvc_Micro, before) { zval *handler; zephir_fetch_params(0, 1, 0, &handler); zephir_update_property_array_append(this_ptr, SL("_beforeHandlers"), handler TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro, after) { zval *handler; zephir_fetch_params(0, 1, 0, &handler); zephir_update_property_array_append(this_ptr, SL("_afterHandlers"), handler TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro, finish) { zval *handler; zephir_fetch_params(0, 1, 0, &handler); zephir_update_property_array_append(this_ptr, SL("_finishHandlers"), handler TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro, getHandlers) { RETURN_MEMBER(this_ptr, "_handlers"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc, Model, phalcon, mvc_model, phalcon_mvc_model_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_model_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_modelsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_modelsMetaData"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_errorMessages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_ce, SL("_operationMade"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_ce, SL("_dirtyState"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_transaction"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_uniqueKey"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_uniqueParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_uniqueTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_skipped"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_related"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_ce, SL("_snapshot"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_NONE"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_CREATE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_UPDATE"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_DELETE"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_PERSISTENT"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_TRANSIENT"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_DETACHED"), 2 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); zend_class_implements(phalcon_mvc_model_ce TSRMLS_CC, 1, phalcon_mvc_modelinterface_ce); zend_class_implements(phalcon_mvc_model_ce TSRMLS_CC, 1, phalcon_mvc_model_resultinterface_ce); zend_class_implements(phalcon_mvc_model_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_mvc_model_ce TSRMLS_CC, 1, zend_ce_serializable); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *dependencyInjector = NULL, *modelsManager = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &dependencyInjector, &modelsManager); if (!dependencyInjector) { ZEPHIR_CPY_WRT(dependencyInjector, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(dependencyInjector); } if (!modelsManager) { ZEPHIR_CPY_WRT(modelsManager, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(modelsManager); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model.zep", 134); return; } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); if (Z_TYPE_P(modelsManager) != IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(modelsManager, _1); if (Z_TYPE_P(modelsManager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The injected service 'modelsManager' is not valid", "phalcon/mvc/model.zep", 145); return; } } zephir_update_property_this(this_ptr, SL("_modelsManager"), modelsManager TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, modelsManager, "initialize", NULL, 0, this_ptr); zephir_check_call_status(); if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model, setEventsManager) { int ZEPHIR_LAST_CALL_STATUS; zval *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventsManager); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setcustomeventsmanager", NULL, 0, this_ptr, eventsManager); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, getEventsManager) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getcustomeventsmanager", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, getModelsMetaData) { int ZEPHIR_LAST_CALL_STATUS; zval *metaData = NULL, *dependencyInjector = NULL, *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_modelsMetaData"), PH_NOISY_CC); if (Z_TYPE_P(metaData) != IS_OBJECT) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model.zep", 214); return; } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(metaData, _1); if (Z_TYPE_P(metaData) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The injected service 'modelsMetadata' is not valid", "phalcon/mvc/model.zep", 222); return; } zephir_update_property_this(this_ptr, SL("_modelsMetaData"), metaData TSRMLS_CC); } RETURN_CCTOR(metaData); } static PHP_METHOD(Phalcon_Mvc_Model, getModelsManager) { RETURN_MEMBER(this_ptr, "_modelsManager"); } static PHP_METHOD(Phalcon_Mvc_Model, setTransaction) { zval *transaction; zephir_fetch_params(0, 1, 0, &transaction); zephir_update_property_this(this_ptr, SL("_transaction"), transaction TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model, setSource) { int ZEPHIR_LAST_CALL_STATUS; zval *source_param = NULL, *_0; zval *source = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &source_param); if (unlikely(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(source_param) == IS_STRING)) { zephir_get_strval(source, source_param); } else { ZEPHIR_INIT_VAR(source); ZVAL_EMPTY_STRING(source); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setmodelsource", NULL, 0, this_ptr, source); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, getSource) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getmodelsource", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, setSchema) { int ZEPHIR_LAST_CALL_STATUS; zval *schema_param = NULL, *_0; zval *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &schema_param); if (unlikely(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schema_param) == IS_STRING)) { zephir_get_strval(schema, schema_param); } else { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "setmodelschema", NULL, 0, this_ptr, schema); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, getSchema) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getmodelschema", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, setConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *connectionService_param = NULL, *_0; zval *connectionService = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setconnectionservice", NULL, 0, this_ptr, connectionService); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, setReadConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *connectionService_param = NULL, *_0; zval *connectionService = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "setreadconnectionservice", NULL, 0, this_ptr, connectionService); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, setWriteConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *connectionService_param = NULL, *_0; zval *connectionService = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "setwriteconnectionservice", NULL, 0, this_ptr, connectionService); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, getReadConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getreadconnectionservice", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getwriteconnectionservice", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, setDirtyState) { zval *dirtyState_param = NULL, *_0; int dirtyState; zephir_fetch_params(0, 1, 0, &dirtyState_param); dirtyState = zephir_get_intval(dirtyState_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, dirtyState); zephir_update_property_this(this_ptr, SL("_dirtyState"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model, getDirtyState) { RETURN_MEMBER(this_ptr, "_dirtyState"); } static PHP_METHOD(Phalcon_Mvc_Model, getReadConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *transaction = NULL, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC); ZEPHIR_CPY_WRT(transaction, _0); if (Z_TYPE_P(transaction) == IS_OBJECT) { ZEPHIR_RETURN_CALL_METHOD(transaction, "getconnection", NULL, 0); zephir_check_call_status(); RETURN_MM(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getreadconnection", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *transaction = NULL, *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_transaction"), PH_NOISY_CC); ZEPHIR_CPY_WRT(transaction, _0); if (Z_TYPE_P(transaction) == IS_OBJECT) { ZEPHIR_RETURN_CALL_METHOD(transaction, "getconnection", NULL, 0); zephir_check_call_status(); RETURN_MM(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getwriteconnection", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, assign) { zephir_fcall_cache_entry *_9 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_5; HashPosition _0, _4; zval *data_param = NULL, *dataColumnMap = NULL, *whiteList = NULL, *key = NULL, *keyMapped = NULL, *value = NULL, *attribute = NULL, *attributeField = NULL, *possibleSetter = NULL, *metaData = NULL, *columnMap = NULL, *dataMapped = NULL, **_2, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &data_param, &dataColumnMap, &whiteList); data = data_param; if (!dataColumnMap) { dataColumnMap = ZEPHIR_GLOBAL(global_null); } if (!whiteList) { whiteList = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(dataColumnMap) == IS_ARRAY) { ZEPHIR_INIT_VAR(dataMapped); array_init(dataMapped); zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 443); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_OBS_NVAR(keyMapped); if (zephir_array_isset_fetch(&keyMapped, dataColumnMap, key, 0 TSRMLS_CC)) { zephir_array_update_zval(&dataMapped, keyMapped, &value, PH_COPY | PH_SEPARATE); } } } else { ZEPHIR_CPY_WRT(dataMapped, data); } if (zephir_fast_count_int(dataMapped TSRMLS_CC) == 0) { RETURN_THIS(); } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } ZEPHIR_CALL_METHOD(&_3, metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); zephir_is_iterable(_3, &_5, &_4, 0, 0, "phalcon/mvc/model.zep", 495); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(attribute, _6); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, attribute, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "Column '", attribute, "' doesn\\'t make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_9, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model.zep", 465 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } } else { ZEPHIR_CPY_WRT(attributeField, attribute); } ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, dataMapped, attributeField, 0 TSRMLS_CC)) { if (Z_TYPE_P(whiteList) == IS_ARRAY) { if (!(zephir_fast_in_array(attributeField, whiteList TSRMLS_CC))) { continue; } } ZEPHIR_INIT_NVAR(_7); zephir_camelize(_7, attributeField); ZEPHIR_INIT_NVAR(possibleSetter); ZEPHIR_CONCAT_SV(possibleSetter, "set", _7); if ((zephir_method_exists(this_ptr, possibleSetter TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, possibleSetter, NULL, 0, value); zephir_check_call_status(); } else { zephir_update_property_zval_zval(this_ptr, attributeField, value TSRMLS_CC); } } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMap) { zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; HashTable *_2; HashPosition _1; zend_bool keepSnapshots, _6; int dirtyState, ZEPHIR_LAST_CALL_STATUS; zval *data = NULL; zval *base, *data_param = NULL, *columnMap, *dirtyState_param = NULL, *keepSnapshots_param = NULL, *instance, *attribute = NULL, *key = NULL, *value = NULL, *castValue = NULL, *attributeName = NULL, *_0 = NULL, **_3, *_4 = NULL, *_7, _8 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 2, &base, &data_param, &columnMap, &dirtyState_param, &keepSnapshots_param); data = data_param; if (!dirtyState_param) { dirtyState = 0; } else { dirtyState = zephir_get_intval(dirtyState_param); } if (!keepSnapshots_param) { keepSnapshots = 0; } else { keepSnapshots = zephir_get_boolval(keepSnapshots_param); } ZEPHIR_INIT_VAR(instance); if (zephir_clone(instance, base TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, dirtyState); ZEPHIR_CALL_METHOD(NULL, instance, "setdirtystate", NULL, 0, _0); zephir_check_call_status(); zephir_is_iterable(data, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 595); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); if (Z_TYPE_P(key) == IS_STRING) { if (Z_TYPE_P(columnMap) != IS_ARRAY) { zephir_update_property_zval_zval(instance, key, value TSRMLS_CC); continue; } ZEPHIR_OBS_NVAR(attribute); if (!(zephir_array_isset_fetch(&attribute, columnMap, key, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", key, "' doesn't make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model.zep", 538 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } if (Z_TYPE_P(attribute) != IS_ARRAY) { zephir_update_property_zval_zval(instance, attribute, value TSRMLS_CC); continue; } _6 = !ZEPHIR_IS_STRING(value, ""); if (_6) { _6 = Z_TYPE_P(value) != IS_NULL; } if (_6) { zephir_array_fetch_long(&_7, attribute, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 550 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_7, 0)) { ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, 10); ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_9, 26, value, &_8); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(_7, 9) || ZEPHIR_IS_LONG(_7, 3) || ZEPHIR_IS_LONG(_7, 7)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_DOUBLE(castValue, zephir_get_doubleval(value)); break; } if (ZEPHIR_IS_LONG(_7, 8)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_BOOL(castValue, zephir_get_boolval(value)); break; } ZEPHIR_CPY_WRT(castValue, value); break; } while(0); } else { zephir_array_fetch_long(&_7, attribute, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 571 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_7, 0) || ZEPHIR_IS_LONG(_7, 9) || ZEPHIR_IS_LONG(_7, 3) || ZEPHIR_IS_LONG(_7, 7) || ZEPHIR_IS_LONG(_7, 8)) { ZEPHIR_INIT_NVAR(castValue); ZVAL_NULL(castValue); break; } ZEPHIR_CPY_WRT(castValue, value); break; } while(0); } ZEPHIR_OBS_NVAR(attributeName); zephir_array_fetch_long(&attributeName, attribute, 0, PH_NOISY, "phalcon/mvc/model.zep", 587 TSRMLS_CC); zephir_update_property_zval_zval(instance, attributeName, castValue TSRMLS_CC); } } if (keepSnapshots) { ZEPHIR_CALL_METHOD(NULL, instance, "setsnapshotdata", NULL, 0, data, columnMap); zephir_check_call_status(); } if ((zephir_method_exists_ex(instance, SS("afterfetch") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, instance, "afterfetch", NULL, 0); zephir_check_call_status(); } RETURN_CCTOR(instance); } static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMapHydrate) { zephir_fcall_cache_entry *_5 = NULL; HashTable *_1; HashPosition _0; int hydrationMode, ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *columnMap, *hydrationMode_param = NULL, *hydrateArray, *hydrateObject, *key = NULL, *value = NULL, *attribute = NULL, **_2, *_3 = NULL, *_4 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &data_param, &columnMap, &hydrationMode_param); data = data_param; hydrationMode = zephir_get_intval(hydrationMode_param); if (Z_TYPE_P(columnMap) != IS_ARRAY) { if (hydrationMode == 1) { RETURN_CTOR(data); } } if (hydrationMode == 1) { ZEPHIR_INIT_VAR(hydrateArray); array_init(hydrateArray); } else { ZEPHIR_INIT_VAR(hydrateObject); object_init(hydrateObject); } zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 669); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(key) == IS_STRING) { if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attribute); if (!(zephir_array_isset_fetch(&attribute, columnMap, key, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", key, "' doesn't make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 648 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } if (hydrationMode == 1) { zephir_array_update_zval(&hydrateArray, attribute, &value, PH_COPY | PH_SEPARATE); } else { zephir_update_property_zval_zval(hydrateObject, attribute, value TSRMLS_CC); } } else { if (hydrationMode == 1) { zephir_array_update_zval(&hydrateArray, key, &value, PH_COPY | PH_SEPARATE); } else { zephir_update_property_zval_zval(hydrateObject, key, value TSRMLS_CC); } } } } if (hydrationMode == 1) { RETURN_CCTOR(hydrateArray); } RETURN_CCTOR(hydrateObject); } static PHP_METHOD(Phalcon_Mvc_Model, cloneResult) { HashTable *_2; HashPosition _1; int dirtyState, ZEPHIR_LAST_CALL_STATUS; zval *data = NULL; zval *base, *data_param = NULL, *dirtyState_param = NULL, *instance, *key = NULL, *value = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &base, &data_param, &dirtyState_param); data = data_param; if (!dirtyState_param) { dirtyState = 0; } else { dirtyState = zephir_get_intval(dirtyState_param); } ZEPHIR_INIT_VAR(instance); if (zephir_clone(instance, base TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, dirtyState); ZEPHIR_CALL_METHOD(NULL, instance, "setdirtystate", NULL, 0, _0); zephir_check_call_status(); zephir_is_iterable(data, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 716); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); if (Z_TYPE_P(key) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid key in array data provided to dumpResult()", "phalcon/mvc/model.zep", 708); return; } zephir_update_property_zval_zval(instance, key, value TSRMLS_CC); } if ((zephir_method_exists_ex(instance, SS("afterfetch") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, instance, "afterfetch", NULL, 0); zephir_check_call_status(); } RETURN_CCTOR(instance); } static PHP_METHOD(Phalcon_Mvc_Model, find) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters = NULL, *params = NULL, *builder = NULL, *query = NULL, *bindParams, *bindTypes, *cache, *resultset = NULL, *hydration, *dependencyInjector = NULL, *manager = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _1); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); array_init(params); if (Z_TYPE_P(parameters) != IS_NULL) { zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/mvc/model.zep", 762); } } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_CALL_METHOD(&builder, manager, "createbuilder", NULL, 0, params); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); zephir_get_called_class(_2 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, builder, "from", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(bindParams); if (zephir_array_isset_string_fetch(&bindParams, params, SS("bind"), 0 TSRMLS_CC)) { if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(NULL, query, "setbindparams", NULL, 0, bindParams, _3); zephir_check_call_status(); } ZEPHIR_OBS_VAR(bindTypes); if (zephir_array_isset_string_fetch(&bindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(NULL, query, "setbindtypes", NULL, 0, bindTypes, _3); zephir_check_call_status(); } } } ZEPHIR_OBS_VAR(cache); if (zephir_array_isset_string_fetch(&cache, params, SS("cache"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, query, "cache", NULL, 0, cache); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&resultset, query, "execute", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(resultset) == IS_OBJECT) { ZEPHIR_OBS_VAR(hydration); if (zephir_array_isset_string_fetch(&hydration, params, SS("hydration"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, resultset, "sethydratemode", NULL, 0, hydration); zephir_check_call_status(); } } RETURN_CCTOR(resultset); } static PHP_METHOD(Phalcon_Mvc_Model, findFirst) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *parameters = NULL, *params = NULL, *builder = NULL, *query = NULL, *bindParams, *bindTypes, *cache, *dependencyInjector = NULL, *manager = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _1); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); array_init(params); if (Z_TYPE_P(parameters) != IS_NULL) { zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/mvc/model.zep", 849); } } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_CALL_METHOD(&builder, manager, "createbuilder", NULL, 0, params); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); zephir_get_called_class(_2 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, builder, "from", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 1); ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(bindParams); if (zephir_array_isset_string_fetch(&bindParams, params, SS("bind"), 0 TSRMLS_CC)) { if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(NULL, query, "setbindparams", NULL, 0, bindParams, _3); zephir_check_call_status(); } ZEPHIR_OBS_VAR(bindTypes); if (zephir_array_isset_string_fetch(&bindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(NULL, query, "setbindtypes", NULL, 0, bindTypes, _3); zephir_check_call_status(); } } } ZEPHIR_OBS_VAR(cache); if (zephir_array_isset_string_fetch(&cache, params, SS("cache"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, query, "cache", NULL, 0, cache); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(NULL, query, "setuniquerow", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(query, "execute", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, query) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *dependencyInjector = NULL, *criteria = NULL, *_1 = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &dependencyInjector); if (!dependencyInjector) { ZEPHIR_CPY_WRT(dependencyInjector, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(dependencyInjector); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); } ZEPHIR_INIT_VAR(criteria); if (zephir_instance_of_ev(dependencyInjector, phalcon_diinterface_ce TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "Phalcon\\Mvc\\Model\\Criteria", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "get", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(criteria, _1); } else { object_init_ex(criteria, phalcon_mvc_model_criteria_ce); if (zephir_has_constructor(criteria TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, criteria, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, criteria, "setdi", NULL, 302, dependencyInjector); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_2); zephir_get_called_class(_2 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, criteria, "setmodelname", NULL, 303, _2); zephir_check_call_status(); RETURN_CCTOR(criteria); } static PHP_METHOD(Phalcon_Mvc_Model, _exists) { zend_bool _6; zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL; HashTable *_1; HashPosition _0; int numberEmpty, numberPrimary, ZEPHIR_LAST_CALL_STATUS; zval *metaData, *connection, *table = NULL, *uniqueParams = NULL, *uniqueTypes = NULL, *uniqueKey = NULL, *columnMap = NULL, *primaryKeys = NULL, *wherePk, *field = NULL, *attributeField = NULL, *value = NULL, *bindDataTypes = NULL, *joinWhere, *num = NULL, *type = NULL, *schema = NULL, *source = NULL, **_2, *_3 = NULL, *_4 = NULL, *_7 = NULL, *_9 = NULL, *_10, *_11, *_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &metaData, &connection, &table); if (!table) { ZEPHIR_CPY_WRT(table, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(table); } ZEPHIR_INIT_VAR(uniqueParams); ZVAL_NULL(uniqueParams); ZEPHIR_INIT_VAR(uniqueTypes); ZVAL_NULL(uniqueTypes); ZEPHIR_OBS_VAR(uniqueKey); zephir_read_property_this(&uniqueKey, this_ptr, SL("_uniqueKey"), PH_NOISY_CC); if (Z_TYPE_P(uniqueKey) == IS_NULL) { ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); zephir_check_call_status(); numberPrimary = zephir_fast_count_int(primaryKeys TSRMLS_CC); if (!(numberPrimary)) { RETURN_MM_BOOL(0); } if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } numberEmpty = 0; ZEPHIR_INIT_VAR(wherePk); array_init(wherePk); ZEPHIR_INIT_NVAR(uniqueParams); array_init(uniqueParams); ZEPHIR_INIT_NVAR(uniqueTypes); array_init(uniqueTypes); zephir_is_iterable(primaryKeys, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 1020); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(field, _2); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 984 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, field); } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { _6 = Z_TYPE_P(value) == IS_NULL; if (!(_6)) { _6 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); } if (_6) { numberEmpty++; } zephir_array_append(&uniqueParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1002); } else { zephir_array_append(&uniqueParams, ZEPHIR_GLOBAL(global_null), PH_SEPARATE, "phalcon/mvc/model.zep", 1005); numberEmpty++; } ZEPHIR_OBS_NVAR(type); if (!(zephir_array_isset_fetch(&type, bindDataTypes, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", field, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 1010 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&uniqueTypes, type, PH_SEPARATE, "phalcon/mvc/model.zep", 1013); ZEPHIR_CALL_METHOD(&_7, connection, "escapeidentifier", &_8, 0, field); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_VS(_9, _7, " = ?"); zephir_array_append(&wherePk, _9, PH_SEPARATE, "phalcon/mvc/model.zep", 1014); } if (numberPrimary == numberEmpty) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(joinWhere); zephir_fast_join_str(joinWhere, SL(" AND "), wherePk TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_uniqueKey"), joinWhere TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_uniqueParams"), uniqueParams TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_uniqueTypes"), uniqueTypes TSRMLS_CC); ZEPHIR_CPY_WRT(uniqueKey, joinWhere); } _10 = zephir_fetch_nproperty_this(this_ptr, SL("_dirtyState"), PH_NOISY_CC); if (!(zephir_is_true(_10))) { RETURN_MM_BOOL(1); } if (Z_TYPE_P(uniqueKey) == IS_NULL) { ZEPHIR_OBS_NVAR(uniqueKey); zephir_read_property_this(&uniqueKey, this_ptr, SL("_uniqueKey"), PH_NOISY_CC); } if (Z_TYPE_P(uniqueParams) == IS_NULL) { ZEPHIR_OBS_NVAR(uniqueParams); zephir_read_property_this(&uniqueParams, this_ptr, SL("_uniqueParams"), PH_NOISY_CC); } if (Z_TYPE_P(uniqueTypes) == IS_NULL) { ZEPHIR_OBS_NVAR(uniqueTypes); zephir_read_property_this(&uniqueTypes, this_ptr, SL("_uniqueTypes"), PH_NOISY_CC); } ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_NVAR(table); zephir_create_array(table, 2, 0 TSRMLS_CC); zephir_array_fast_append(table, schema); zephir_array_fast_append(table, source); } else { ZEPHIR_CPY_WRT(table, source); } ZEPHIR_CALL_METHOD(&_7, connection, "escapeidentifier", NULL, 0, table); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSV(_9, "SELECT COUNT(*) \"rowcount\" FROM ", _7, " WHERE ", uniqueKey); ZEPHIR_INIT_NVAR(_3); ZVAL_NULL(_3); ZEPHIR_CALL_METHOD(&num, connection, "fetchone", NULL, 0, _9, _3, uniqueParams, uniqueTypes); zephir_check_call_status(); zephir_array_fetch_string(&_11, num, SL("rowcount"), PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 1070 TSRMLS_CC); if (zephir_is_true(_11)) { ZEPHIR_INIT_ZVAL_NREF(_12); ZVAL_LONG(_12, 0); zephir_update_property_this(this_ptr, SL("_dirtyState"), _12 TSRMLS_CC); RETURN_MM_BOOL(1); } else { ZEPHIR_INIT_ZVAL_NREF(_12); ZVAL_LONG(_12, 1); zephir_update_property_this(this_ptr, SL("_dirtyState"), _12 TSRMLS_CC); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model, _groupResult) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *functionName_param = NULL, *alias_param = NULL, *parameters, *params = NULL, *distinctColumn, *groupColumn = NULL, *columns = NULL, *bindParams = NULL, *bindTypes = NULL, *resultset = NULL, *cache, *firstRow = NULL, *groupColumns, *builder = NULL, *query = NULL, *dependencyInjector = NULL, *manager = NULL, *_1 = NULL, *_2 = NULL, *_3; zval *functionName = NULL, *alias = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &functionName_param, &alias_param, ¶meters); if (unlikely(Z_TYPE_P(functionName_param) != IS_STRING && Z_TYPE_P(functionName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'functionName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(functionName_param) == IS_STRING)) { zephir_get_strval(functionName, functionName_param); } else { ZEPHIR_INIT_VAR(functionName); ZVAL_EMPTY_STRING(functionName); } if (unlikely(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(alias_param) == IS_STRING)) { zephir_get_strval(alias, alias_param); } else { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _1); if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); array_init(params); if (Z_TYPE_P(parameters) != IS_NULL) { zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/mvc/model.zep", 1100); } } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_OBS_VAR(groupColumn); if (!(zephir_array_isset_string_fetch(&groupColumn, params, SS("column"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(groupColumn); ZVAL_STRING(groupColumn, "*", 1); } ZEPHIR_OBS_VAR(distinctColumn); if (zephir_array_isset_string_fetch(&distinctColumn, params, SS("distinct"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(columns); ZEPHIR_CONCAT_VSVSV(columns, functionName, "(DISTINCT ", distinctColumn, ") AS ", alias); } else { ZEPHIR_OBS_VAR(groupColumns); ZEPHIR_INIT_NVAR(columns); if (zephir_array_isset_string_fetch(&groupColumns, params, SS("group"), 0 TSRMLS_CC)) { ZEPHIR_CONCAT_VSVSVSV(columns, groupColumns, ", ", functionName, "(", groupColumn, ") AS ", alias); } else { ZEPHIR_CONCAT_VSVSV(columns, functionName, "(", groupColumn, ") AS ", alias); } } ZEPHIR_CALL_METHOD(&builder, manager, "createbuilder", NULL, 0, params); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, builder, "columns", NULL, 0, columns); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); zephir_get_called_class(_2 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, builder, "from", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(bindParams); ZVAL_NULL(bindParams); ZEPHIR_INIT_VAR(bindTypes); ZVAL_NULL(bindTypes); ZEPHIR_OBS_NVAR(bindParams); if (zephir_array_isset_string_fetch(&bindParams, params, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(bindTypes); zephir_array_isset_string_fetch(&bindTypes, params, SS("bindTypes"), 0 TSRMLS_CC); } ZEPHIR_OBS_VAR(cache); if (zephir_array_isset_string_fetch(&cache, params, SS("cache"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, query, "cache", NULL, 0, cache); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&resultset, query, "execute", NULL, 0, bindParams, bindTypes); zephir_check_call_status(); if (zephir_array_isset_string(params, SS("group"))) { RETURN_CCTOR(resultset); } ZEPHIR_CALL_METHOD(&firstRow, resultset, "getfirst", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(_3); zephir_read_property_zval(&_3, firstRow, alias, PH_NOISY_CC); RETURN_CCTOR(_3); } static PHP_METHOD(Phalcon_Mvc_Model, count) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *result = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "COUNT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "rowcount", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_SELF(&result, "_groupresult", NULL, 0, _0, _1, parameters); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(result) == IS_STRING) { RETURN_MM_LONG(zephir_get_intval(result)); } RETURN_CCTOR(result); } static PHP_METHOD(Phalcon_Mvc_Model, sum) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "SUM", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "sumatory", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_groupresult", NULL, 0, _0, _1, parameters); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, maximum) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "MAX", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "maximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_groupresult", NULL, 0, _0, _1, parameters); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, minimum) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "MIN", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "minimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_groupresult", NULL, 0, _0, _1, parameters); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, average) { int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "AVG", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "average", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_SELF("_groupresult", NULL, 0, _0, _1, parameters); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, fireEvent) { int ZEPHIR_LAST_CALL_STATUS; zval *eventName_param = NULL, *_0; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } if ((zephir_method_exists(this_ptr, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, eventName, NULL, 0); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "notifyevent", NULL, 0, eventName, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, fireEventCancel) { int ZEPHIR_LAST_CALL_STATUS; zval *eventName_param = NULL, *_0 = NULL, *_1; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } if ((zephir_method_exists(this_ptr, eventName TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&_0, this_ptr, eventName, NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_0, _1, "notifyevent", NULL, 0, eventName, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _cancelOperation) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_operationMade"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(_0, 3)) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "notDeleted", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "notSaved", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, appendMessage) { zval *message; zephir_fetch_params(0, 1, 0, &message); zephir_update_property_array_append(this_ptr, SL("_errorMessages"), message TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model, validate) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *validator, *message = NULL, *_0 = NULL, *_1 = NULL, **_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &validator); ZEPHIR_CALL_METHOD(&_0, validator, "validate", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(&_1, validator, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 1400); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(message, _4); zephir_update_property_array_append(this_ptr, SL("_errorMessages"), message TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, validationHasFailed) { zval *errorMessages; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(errorMessages); zephir_read_property_this(&errorMessages, this_ptr, SL("_errorMessages"), PH_NOISY_CC); if (Z_TYPE_P(errorMessages) == IS_ARRAY) { RETURN_MM_BOOL(zephir_fast_count_int(errorMessages TSRMLS_CC) > 0); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model, getMessages) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_3; HashPosition _2; zend_bool _0; zval *filter = NULL, *filtered, *message = NULL, *_1, **_4, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &filter); if (!filter) { filter = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(filter) == IS_STRING; if (_0) { _0 = !(ZEPHIR_IS_EMPTY(filter)); } if (_0) { ZEPHIR_INIT_VAR(filtered); array_init(filtered); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_errorMessages"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 1466); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(message, _4); ZEPHIR_CALL_METHOD(&_5, message, "getfield", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_5, filter)) { zephir_array_append(&filtered, message, PH_SEPARATE, "phalcon/mvc/model.zep", 1463); } } RETURN_CCTOR(filtered); } RETURN_MM_MEMBER(this_ptr, "_errorMessages"); } static PHP_METHOD(Phalcon_Mvc_Model, _checkForeignKeysRestrict) { zval *_14 = NULL; zephir_fcall_cache_entry *_6 = NULL, *_18 = NULL, *_19 = NULL; HashTable *_2, *_8; HashPosition _1, _7; zend_bool error, validateWithNulls = 0, _12; int action, numberNull, ZEPHIR_LAST_CALL_STATUS; zval *manager = NULL, *belongsTo = NULL, *foreignKey = NULL, *relation = NULL, *conditions = NULL, *position = NULL, *bindParams = NULL, *extraConditions = NULL, *message = NULL, *fields = NULL, *referencedFields = NULL, *field = NULL, *referencedModel = NULL, *value = NULL, *allowNulls = NULL, *_0, **_3, *_4 = NULL, *_5 = NULL, **_9, *_10, *_11 = NULL, *_13 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&belongsTo, manager, "getbelongsto", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_fast_count_int(belongsTo TSRMLS_CC)) { error = 0; zephir_is_iterable(belongsTo, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 1609); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(relation, _3); ZEPHIR_CALL_METHOD(&foreignKey, relation, "getforeignkey", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(foreignKey)) { action = 1; if (Z_TYPE_P(foreignKey) == IS_ARRAY) { if (zephir_array_isset_string(foreignKey, SS("action"))) { ZEPHIR_OBS_NVAR(_4); zephir_array_fetch_string(&_4, foreignKey, SL("action"), PH_NOISY, "phalcon/mvc/model.zep", 1510 TSRMLS_CC); action = zephir_get_intval(_4); } } if (action == 1) { ZEPHIR_CALL_METHOD(&_5, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, manager, "load", &_6, 0, _5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(conditions); array_init(conditions); ZEPHIR_INIT_NVAR(bindParams); array_init(bindParams); numberNull = 0; ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(fields) == IS_ARRAY) { zephir_is_iterable(fields, &_8, &_7, 0, 0, "phalcon/mvc/model.zep", 1546); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(position, _8, _7); ZEPHIR_GET_HVALUE(field, _9); ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, field, PH_SILENT_CC); zephir_array_fetch(&_10, referencedFields, position, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 1539 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSV(_11, "[", _10, "] = ?", position); zephir_array_append(&conditions, _11, PH_SEPARATE, "phalcon/mvc/model.zep", 1539); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1540); if (Z_TYPE_P(value) == IS_NULL) { numberNull++; } } validateWithNulls = numberNull == zephir_fast_count_int(fields TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, fields, PH_SILENT_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, "[", referencedFields, "] = ?0"); zephir_array_append(&conditions, _11, PH_SEPARATE, "phalcon/mvc/model.zep", 1551); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1552); if (Z_TYPE_P(value) == IS_NULL) { validateWithNulls = 1; } } ZEPHIR_OBS_NVAR(extraConditions); if (zephir_array_isset_string_fetch(&extraConditions, foreignKey, SS("conditions"), 0 TSRMLS_CC)) { zephir_array_append(&conditions, extraConditions, PH_SEPARATE, "phalcon/mvc/model.zep", 1563); } if (validateWithNulls) { ZEPHIR_OBS_NVAR(allowNulls); if (zephir_array_isset_string_fetch(&allowNulls, foreignKey, SS("allowNulls"), 0 TSRMLS_CC)) { validateWithNulls = zephir_get_boolval(allowNulls); } else { validateWithNulls = 0; } } _12 = !validateWithNulls; if (_12) { ZEPHIR_INIT_NVAR(_14); zephir_create_array(_14, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_15); zephir_fast_join_str(_15, SL(" AND "), conditions TSRMLS_CC); zephir_array_fast_append(_14, _15); zephir_array_update_string(&_14, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_13, referencedModel, "count", NULL, 0, _14); zephir_check_call_status(); _12 = !zephir_is_true(_13); } if (_12) { ZEPHIR_OBS_NVAR(message); if (!(zephir_array_isset_string_fetch(&message, foreignKey, SS("message"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(message); if (Z_TYPE_P(fields) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_15); zephir_fast_join_str(_15, SL(", "), fields TSRMLS_CC); ZEPHIR_CONCAT_SVS(message, "Value of fields \"", _15, "\" does not exist on referenced table"); } else { ZEPHIR_CONCAT_SVS(message, "Value of field \"", fields, "\" does not exist on referenced table"); } } ZEPHIR_INIT_NVAR(_16); object_init_ex(_16, phalcon_mvc_model_message_ce); ZEPHIR_INIT_NVAR(_17); ZVAL_STRING(_17, "ConstraintViolation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_18, 8, message, fields, _17); zephir_check_temp_parameter(_17); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_19, 0, _16); zephir_check_call_status(); error = 1; break; } } } } if (error == 1) { if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_INIT_NVAR(_15); ZVAL_STRING(_15, "onValidationFails", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _15); zephir_check_temp_parameter(_15); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_canceloperation", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _checkForeignKeysReverseCascade) { zval *_12 = NULL; zephir_fcall_cache_entry *_6 = NULL; HashTable *_2, *_8; HashPosition _1, _7; int action, ZEPHIR_LAST_CALL_STATUS; zval *manager = NULL, *relations = NULL, *relation = NULL, *foreignKey = NULL, *resultset = NULL, *conditions = NULL, *bindParams = NULL, *referencedModel = NULL, *referencedFields = NULL, *fields = NULL, *field = NULL, *position = NULL, *value = NULL, *extraConditions = NULL, *_0, **_3, *_4 = NULL, *_5 = NULL, **_9, *_10, *_11 = NULL, *_13 = NULL, *_14 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&relations, manager, "gethasoneandhasmany", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_fast_count_int(relations TSRMLS_CC)) { zephir_is_iterable(relations, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 1723); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(relation, _3); ZEPHIR_CALL_METHOD(&foreignKey, relation, "getforeignkey", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(foreignKey)) { action = 0; if (Z_TYPE_P(foreignKey) == IS_ARRAY) { if (zephir_array_isset_string(foreignKey, SS("action"))) { ZEPHIR_OBS_NVAR(_4); zephir_array_fetch_string(&_4, foreignKey, SL("action"), PH_NOISY, "phalcon/mvc/model.zep", 1662 TSRMLS_CC); action = zephir_get_intval(_4); } } if (action == 2) { ZEPHIR_CALL_METHOD(&_5, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, manager, "load", &_6, 0, _5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(conditions); array_init(conditions); ZEPHIR_INIT_NVAR(bindParams); array_init(bindParams); if (Z_TYPE_P(fields) == IS_ARRAY) { zephir_is_iterable(fields, &_8, &_7, 0, 0, "phalcon/mvc/model.zep", 1690); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(position, _8, _7); ZEPHIR_GET_HVALUE(field, _9); ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, field, PH_SILENT_CC); zephir_array_fetch(&_10, referencedFields, position, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 1687 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSV(_11, "[", _10, "] = ?", position); zephir_array_append(&conditions, _11, PH_SEPARATE, "phalcon/mvc/model.zep", 1687); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1688); } } else { ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, fields, PH_SILENT_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, "[", referencedFields, "] = ?0"); zephir_array_append(&conditions, _11, PH_SEPARATE, "phalcon/mvc/model.zep", 1692); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1693); } ZEPHIR_OBS_NVAR(extraConditions); if (zephir_array_isset_string_fetch(&extraConditions, foreignKey, SS("conditions"), 0 TSRMLS_CC)) { zephir_array_append(&conditions, extraConditions, PH_SEPARATE, "phalcon/mvc/model.zep", 1700); } ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_13); zephir_fast_join_str(_13, SL(" AND "), conditions TSRMLS_CC); zephir_array_fast_append(_12, _13); zephir_array_update_string(&_12, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&resultset, referencedModel, "find", NULL, 0, _12); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14, resultset, "delete", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_14)) { RETURN_MM_BOOL(0); } } } } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _checkForeignKeysReverseRestrict) { zval *_12 = NULL; zephir_fcall_cache_entry *_5 = NULL, *_15 = NULL, *_16 = NULL; HashTable *_2, *_7; HashPosition _1, _6; int action, ZEPHIR_LAST_CALL_STATUS; zval *manager = NULL, *relations = NULL, *foreignKey = NULL, *relation = NULL, *relationClass = NULL, *referencedModel = NULL, *fields = NULL, *referencedFields = NULL, *conditions = NULL, *bindParams = NULL, *position = NULL, *field = NULL, *value = NULL, *extraConditions = NULL, *message = NULL, *_0, **_3, *_4 = NULL, **_8, *_9, *_10 = NULL, *_11 = NULL, *_13 = NULL, *_14 = NULL; zend_bool error; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&relations, manager, "gethasoneandhasmany", NULL, 0, this_ptr); zephir_check_call_status(); if (zephir_fast_count_int(relations TSRMLS_CC)) { error = 0; zephir_is_iterable(relations, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 1842); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(relation, _3); ZEPHIR_CALL_METHOD(&foreignKey, relation, "getforeignkey", NULL, 0); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(foreignKey)) { action = 1; if (Z_TYPE_P(foreignKey) == IS_ARRAY) { if (zephir_array_isset_string(foreignKey, SS("action"))) { ZEPHIR_OBS_NVAR(_4); zephir_array_fetch_string(&_4, foreignKey, SL("action"), PH_NOISY, "phalcon/mvc/model.zep", 1770 TSRMLS_CC); action = zephir_get_intval(_4); } } if (action == 1) { ZEPHIR_CALL_METHOD(&relationClass, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, manager, "load", &_5, 0, relationClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(conditions); array_init(conditions); ZEPHIR_INIT_NVAR(bindParams); array_init(bindParams); if (Z_TYPE_P(fields) == IS_ARRAY) { zephir_is_iterable(fields, &_7, &_6, 0, 0, "phalcon/mvc/model.zep", 1802); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(position, _7, _6); ZEPHIR_GET_HVALUE(field, _8); ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, field, PH_SILENT_CC); zephir_array_fetch(&_9, referencedFields, position, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 1798 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSV(_10, "[", _9, "] = ?", position); zephir_array_append(&conditions, _10, PH_SEPARATE, "phalcon/mvc/model.zep", 1798); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1799); } } else { ZEPHIR_OBS_NVAR(value); zephir_fetch_property_zval(&value, this_ptr, fields, PH_SILENT_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVS(_10, "[", referencedFields, "] = ?0"); zephir_array_append(&conditions, _10, PH_SEPARATE, "phalcon/mvc/model.zep", 1804); zephir_array_append(&bindParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 1805); } ZEPHIR_OBS_NVAR(extraConditions); if (zephir_array_isset_string_fetch(&extraConditions, foreignKey, SS("conditions"), 0 TSRMLS_CC)) { zephir_array_append(&conditions, extraConditions, PH_SEPARATE, "phalcon/mvc/model.zep", 1812); } ZEPHIR_INIT_NVAR(_12); zephir_create_array(_12, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_13); zephir_fast_join_str(_13, SL(" AND "), conditions TSRMLS_CC); zephir_array_fast_append(_12, _13); zephir_array_update_string(&_12, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_11, referencedModel, "count", NULL, 0, _12); zephir_check_call_status(); if (zephir_is_true(_11)) { ZEPHIR_OBS_NVAR(message); if (!(zephir_array_isset_string_fetch(&message, foreignKey, SS("message"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(message); ZEPHIR_CONCAT_SV(message, "Record is referenced by model ", relationClass); } ZEPHIR_INIT_NVAR(_13); object_init_ex(_13, phalcon_mvc_model_message_ce); ZEPHIR_INIT_NVAR(_14); ZVAL_STRING(_14, "ConstraintViolation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _13, "__construct", &_15, 8, message, fields, _14); zephir_check_temp_parameter(_14); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_16, 0, _13); zephir_check_call_status(); error = 1; break; } } } } if (error == 1) { if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_INIT_NVAR(_13); ZVAL_STRING(_13, "onValidationFails", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _13); zephir_check_temp_parameter(_13); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_canceloperation", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _preSave) { HashTable *_5; HashPosition _4; zephir_fcall_cache_entry *_2 = NULL, *_8 = NULL, *_11 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool exists, error, isNull, _9; zval *metaData, *exists_param = NULL, *identityField, *notNull = NULL, *columnMap = NULL, *dataTypeNumeric = NULL, *automaticAttributes = NULL, *defaultValues = NULL, *field = NULL, *attributeField = NULL, *value = NULL, *emptyStringValues = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_10 = NULL, *_13; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &metaData, &exists_param, &identityField); exists = zephir_get_boolval(exists_param); if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "beforeValidation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } if (!(exists)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeValidationOnCreate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeValidationOnUpdate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } } if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_checkforeignkeysrestrict", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } if (ZEPHIR_GLOBAL(orm).not_null_validations) { ZEPHIR_CALL_METHOD(¬Null, metaData, "getnotnullattributes", NULL, 0, this_ptr); zephir_check_call_status(); if (Z_TYPE_P(notNull) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&dataTypeNumeric, metaData, "getdatatypesnumeric", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } if (exists) { ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&emptyStringValues, metaData, "getemptystringattributes", NULL, 0, this_ptr); zephir_check_call_status(); error = 0; zephir_is_iterable(notNull, &_5, &_4, 0, 0, "phalcon/mvc/model.zep", 2008); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(field, _6); if (!(zephir_array_isset(automaticAttributes, field))) { isNull = 0; if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 1944 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, field); } ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { if (Z_TYPE_P(value) != IS_OBJECT) { if (!(zephir_array_isset(dataTypeNumeric, field))) { if (zephir_array_isset(emptyStringValues, field)) { if (Z_TYPE_P(value) == IS_NULL) { isNull = 1; } } else { _9 = Z_TYPE_P(value) == IS_NULL; if (!(_9)) { _9 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); } if (_9) { isNull = 1; } } } else { if (!(zephir_is_numeric(value))) { isNull = 1; } } } } else { isNull = 1; } if (isNull == 1) { if (!(exists)) { if (ZEPHIR_IS_EQUAL(field, identityField)) { continue; } if (zephir_array_isset(defaultValues, field)) { continue; } } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_message_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_VS(_7, attributeField, " is required"); ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "PresenceOf", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, 8, _7, attributeField, _10); zephir_check_temp_parameter(_10); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_errorMessages"), _1 TSRMLS_CC); error = 1; } } } if (error == 1) { if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "onValidationFails", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_12, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_canceloperation", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(0); } } } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "validation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "onValidationFails", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_12, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_MM_BOOL(0); } if (ZEPHIR_GLOBAL(orm).events) { if (!(exists)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterValidationOnCreate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterValidationOnUpdate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterValidation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeSave", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } if (0) { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (exists) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeUpdate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "beforeCreate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { RETURN_MM_BOOL(0); } } _13 = zephir_fetch_nproperty_this(this_ptr, SL("_skipped"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_13)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _postSave) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *success_param = NULL, *exists_param = NULL, *_0 = NULL; zend_bool success, exists; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &success_param, &exists_param); success = zephir_get_boolval(success_param); exists = zephir_get_boolval(exists_param); if (success == 1) { if (exists) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "afterUpdate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_1, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "afterCreate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", &_1, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } } RETURN_MM_BOOL(success); } static PHP_METHOD(Phalcon_Mvc_Model, _doLowInsert) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_9 = NULL; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zend_bool useExplicitIdentity, _6; zval *metaData, *connection, *table, *identityField, *bindSkip, *fields, *values, *bindTypes, *attributes = NULL, *bindDataTypes = NULL, *automaticAttributes = NULL, *field = NULL, *columnMap = NULL, *value = NULL, *attributeField = NULL, *success = NULL, *bindType = NULL, *defaultValue = NULL, *sequenceName = NULL, *defaultValues = NULL, *source = NULL, *schema = NULL, **_2, *_3 = NULL, *_4 = NULL, *_8 = NULL, *_10 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &metaData, &connection, &table, &identityField); ZEPHIR_INIT_VAR(bindSkip); ZVAL_LONG(bindSkip, 1024); ZEPHIR_INIT_VAR(fields); array_init(fields); ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_VAR(bindTypes); array_init(bindTypes); ZEPHIR_CALL_METHOD(&attributes, metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } zephir_is_iterable(attributes, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 2192); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(field, _2); if (!(zephir_array_isset(automaticAttributes, field))) { if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 2146 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, field); } if (!ZEPHIR_IS_EQUAL(field, identityField)) { ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { _6 = Z_TYPE_P(value) == IS_NULL; if (_6) { _6 = zephir_array_isset(defaultValues, field); } if (_6) { ZEPHIR_CALL_METHOD(&value, connection, "getdefaultvalue", &_7, 0); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", field, "' have not defined a bind data type"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 2170 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/mvc/model.zep", 2173); zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2173); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model.zep", 2173); } else { if (zephir_array_isset(defaultValues, field)) { ZEPHIR_CALL_METHOD(&_8, connection, "getdefaultvalue", &_9, 0); zephir_check_call_status(); zephir_array_append(&values, _8, PH_SEPARATE, "phalcon/mvc/model.zep", 2178); } else { zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2180); } zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/mvc/model.zep", 2183); zephir_array_append(&bindTypes, bindSkip, PH_SEPARATE, "phalcon/mvc/model.zep", 2183); } } } } if (!ZEPHIR_IS_FALSE_IDENTICAL(identityField)) { ZEPHIR_CALL_METHOD(&defaultValue, connection, "getdefaultidvalue", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, connection, "useexplicitidvalue", NULL, 0); zephir_check_call_status(); useExplicitIdentity = zephir_get_boolval(_8); if (useExplicitIdentity) { zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/mvc/model.zep", 2201); } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, identityField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Identity column '", identityField, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 2209 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, identityField); } ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { _6 = Z_TYPE_P(value) == IS_NULL; if (!(_6)) { _6 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); } if (_6) { if (useExplicitIdentity) { zephir_array_append(&values, defaultValue, PH_SEPARATE, "phalcon/mvc/model.zep", 2222); zephir_array_append(&bindTypes, bindSkip, PH_SEPARATE, "phalcon/mvc/model.zep", 2222); } } else { if (!(useExplicitIdentity)) { zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/mvc/model.zep", 2230); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, identityField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Identity column '", identityField, "' isn\\'t part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 2237 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2240); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model.zep", 2240); } } else { if (useExplicitIdentity) { zephir_array_append(&values, defaultValue, PH_SEPARATE, "phalcon/mvc/model.zep", 2244); zephir_array_append(&bindTypes, bindSkip, PH_SEPARATE, "phalcon/mvc/model.zep", 2244); } } } ZEPHIR_CALL_METHOD(&success, connection, "insert", NULL, 0, table, values, fields, bindTypes); zephir_check_call_status(); _6 = zephir_is_true(success); if (_6) { _6 = !ZEPHIR_IS_FALSE_IDENTICAL(identityField); } if (_6) { ZEPHIR_INIT_VAR(sequenceName); ZVAL_NULL(sequenceName); ZEPHIR_CALL_METHOD(&_8, connection, "supportsequences", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_8)) { if ((zephir_method_exists_ex(this_ptr, SS("getsequencename") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&sequenceName, this_ptr, "getsequencename", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(sequenceName); if (ZEPHIR_IS_EMPTY(schema)) { ZEPHIR_CONCAT_VSVS(sequenceName, source, "_", identityField, "_seq"); } else { ZEPHIR_CONCAT_VSVSVS(sequenceName, schema, ".", source, "_", identityField, "_seq"); } } } ZEPHIR_CALL_METHOD(&_10, connection, "lastinsertid", NULL, 0, sequenceName); zephir_check_call_status(); zephir_update_property_zval_zval(this_ptr, attributeField, _10 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_uniqueParams"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } RETURN_CCTOR(success); } static PHP_METHOD(Phalcon_Mvc_Model, _doLowUpdate) { zval *_15; zval *_10 = NULL, *_11 = NULL; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL; HashTable *_3, *_13; HashPosition _2, _12; int ZEPHIR_LAST_CALL_STATUS; zend_bool useDynamicUpdate, changed; zval *metaData, *connection, *table, *bindSkip, *fields, *values, *bindTypes, *manager = NULL, *bindDataTypes = NULL, *field = NULL, *automaticAttributes = NULL, *snapshotValue = NULL, *uniqueKey, *uniqueParams = NULL, *uniqueTypes, *snapshot, *nonPrimary = NULL, *columnMap = NULL, *attributeField = NULL, *value = NULL, *primaryKeys = NULL, *bindType = NULL, *_0, *_1 = NULL, **_4, *_5 = NULL, *_6 = NULL, *_9 = NULL, **_14; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &metaData, &connection, &table); ZEPHIR_INIT_VAR(bindSkip); ZVAL_LONG(bindSkip, 1024); ZEPHIR_INIT_VAR(fields); array_init(fields); ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_VAR(bindTypes); array_init(bindTypes); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&_1, manager, "isusingdynamicupdate", NULL, 0, this_ptr); zephir_check_call_status(); useDynamicUpdate = zephir_get_boolval(_1); if (useDynamicUpdate) { ZEPHIR_OBS_VAR(snapshot); zephir_read_property_this(&snapshot, this_ptr, SL("_snapshot"), PH_NOISY_CC); if (Z_TYPE_P(snapshot) != IS_ARRAY) { useDynamicUpdate = 0; } } ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&nonPrimary, metaData, "getnonprimarykeyattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } zephir_is_iterable(nonPrimary, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 2444); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(field, _4); if (!(zephir_array_isset(automaticAttributes, field))) { ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "Column '", field, "' have not defined a bind data type"); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/model.zep", 2343 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/model.zep", 2351 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, field); } ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { if (!(useDynamicUpdate)) { zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/mvc/model.zep", 2367); zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2367); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model.zep", 2368); } else { ZEPHIR_OBS_NVAR(snapshotValue); if (!(zephir_array_isset_fetch(&snapshotValue, snapshot, attributeField, 0 TSRMLS_CC))) { changed = 1; } else { if (Z_TYPE_P(value) == IS_NULL) { changed = Z_TYPE_P(snapshotValue) != IS_NULL; } else { if (Z_TYPE_P(snapshotValue) == IS_NULL) { changed = 1; } else { do { if (ZEPHIR_IS_LONG(bindType, 8)) { changed = zephir_get_boolval(snapshotValue) != zephir_get_boolval(value); break; } if (ZEPHIR_IS_LONG(bindType, 0)) { changed = zephir_get_intval(snapshotValue) != zephir_get_intval(value); break; } if (ZEPHIR_IS_LONG(bindType, 3) || ZEPHIR_IS_LONG(bindType, 7)) { ZEPHIR_CALL_FUNCTION(&_1, "floatval", &_8, 304, snapshotValue); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_9, "floatval", &_8, 304, value); zephir_check_call_status(); changed = !ZEPHIR_IS_IDENTICAL(_1, _9); break; } if (ZEPHIR_IS_LONG(bindType, 1) || ZEPHIR_IS_LONG(bindType, 2) || ZEPHIR_IS_LONG(bindType, 4) || ZEPHIR_IS_LONG(bindType, 5) || ZEPHIR_IS_LONG(bindType, 6) || ZEPHIR_IS_LONG(bindType, 2) || ZEPHIR_IS_LONG(bindType, 14)) { zephir_get_strval(_10, snapshotValue); zephir_get_strval(_11, value); changed = !ZEPHIR_IS_IDENTICAL(_10, _11); break; } changed = !ZEPHIR_IS_EQUAL(value, snapshotValue); } while(0); } } } if (changed) { zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/mvc/model.zep", 2430); zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2430); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model.zep", 2431); } } } else { zephir_array_append(&fields, field, PH_SEPARATE, "phalcon/mvc/model.zep", 2436); zephir_array_append(&values, ZEPHIR_GLOBAL(global_null), PH_SEPARATE, "phalcon/mvc/model.zep", 2436); zephir_array_append(&bindTypes, bindSkip, PH_SEPARATE, "phalcon/mvc/model.zep", 2436); } } } if (!(zephir_fast_count_int(fields TSRMLS_CC))) { RETURN_MM_BOOL(1); } ZEPHIR_OBS_VAR(uniqueKey); zephir_read_property_this(&uniqueKey, this_ptr, SL("_uniqueKey"), PH_NOISY_CC); ZEPHIR_OBS_VAR(uniqueParams); zephir_read_property_this(&uniqueParams, this_ptr, SL("_uniqueParams"), PH_NOISY_CC); ZEPHIR_OBS_VAR(uniqueTypes); zephir_read_property_this(&uniqueTypes, this_ptr, SL("_uniqueTypes"), PH_NOISY_CC); if (Z_TYPE_P(uniqueParams) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); zephir_check_call_status(); if (!(zephir_fast_count_int(primaryKeys TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A primary key must be defined in the model in order to perform the operation", "phalcon/mvc/model.zep", 2463); return; } ZEPHIR_INIT_NVAR(uniqueParams); array_init(uniqueParams); zephir_is_iterable(primaryKeys, &_13, &_12, 0, 0, "phalcon/mvc/model.zep", 2486); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HVALUE(field, _14); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/model.zep", 2474 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, field); } ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { zephir_array_append(&uniqueParams, value, PH_SEPARATE, "phalcon/mvc/model.zep", 2481); } else { zephir_array_append(&uniqueParams, ZEPHIR_GLOBAL(global_null), PH_SEPARATE, "phalcon/mvc/model.zep", 2483); } } } ZEPHIR_INIT_VAR(_15); zephir_create_array(_15, 3, 0 TSRMLS_CC); zephir_array_update_string(&_15, SL("conditions"), &uniqueKey, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_15, SL("bind"), &uniqueParams, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_15, SL("bindTypes"), &uniqueTypes, PH_COPY | PH_SEPARATE); ZEPHIR_RETURN_CALL_METHOD(connection, "update", NULL, 0, table, fields, values, _15, bindTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, _preSaveRelatedRecords) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_8 = NULL, *_13 = NULL, *_14 = NULL; HashTable *_3, *_11; HashPosition _2, _10; int ZEPHIR_LAST_CALL_STATUS; zend_bool nesting; zval *connection, *related, *className, *manager = NULL, *type = NULL, *relation = NULL, *columns = NULL, *referencedFields = NULL, *referencedModel = NULL, *message = NULL, *name = NULL, *record = NULL, *_0, *_1 = NULL, **_4, *_6 = NULL, *_9 = NULL, **_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &connection, &related); nesting = 0; ZEPHIR_INIT_VAR(_0); if (nesting) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_INIT_VAR(className); zephir_get_class(className, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _1); zephir_is_iterable(related, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 2592); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(name, _3, _2); ZEPHIR_GET_HVALUE(record, _4); ZEPHIR_CALL_METHOD(&_1, manager, "getrelationbyalias", &_5, 0, className, name); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _1); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&type, relation, "gettype", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(type, 0)) { if (Z_TYPE_P(record) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_7, 0, _6); zephir_check_call_status(); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only objects can be stored as part of belongs-to relations", "phalcon/mvc/model.zep", 2541); return; } ZEPHIR_CALL_METHOD(&columns, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(columns) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_8, 0, _6); zephir_check_call_status(); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not implemented", "phalcon/mvc/model.zep", 2550); return; } ZEPHIR_CALL_METHOD(&_1, record, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_CALL_METHOD(&_9, record, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_9, &_11, &_10, 0, 0, "phalcon/mvc/model.zep", 2579); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HVALUE(message, _12); if (Z_TYPE_P(message) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, message, "setmodel", NULL, 0, record); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_13, 0, message); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_14, 0, _6); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(&_9, record, "readattribute", NULL, 0, referencedFields); zephir_check_call_status(); zephir_update_property_zval_zval(this_ptr, columns, _9 TSRMLS_CC); } } } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, _postSaveRelatedRecords) { zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_21 = NULL, *_22 = NULL, *_23 = NULL, *_28 = NULL, *_29 = NULL; HashTable *_2, *_15, *_19, *_26; HashPosition _1, _14, _18, _25; int ZEPHIR_LAST_CALL_STATUS; zend_bool nesting, isThrough, _5; zval *connection, *related, *className, *manager = NULL, *relation = NULL, *name = NULL, *record = NULL, *message = NULL, *columns = NULL, *referencedModel = NULL, *referencedFields = NULL, *relatedRecords = NULL, *value = NULL, *recordAfter = NULL, *intermediateModel = NULL, *intermediateFields = NULL, *intermediateValue = NULL, *intermediateModelName = NULL, *intermediateReferencedFields = NULL, *_0 = NULL, **_3, *_6 = NULL, *_10 = NULL, *_11 = NULL, *_13 = NULL, **_16, *_17 = NULL, **_20, *_24 = NULL, **_27; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &connection, &related); nesting = 0; ZEPHIR_INIT_VAR(className); zephir_get_class(className, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _0); zephir_is_iterable(related, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 2780); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(name, _2, _1); ZEPHIR_GET_HVALUE(record, _3); ZEPHIR_CALL_METHOD(&_0, manager, "getrelationbyalias", &_4, 0, className, name); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _0); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_0, relation, "gettype", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_0, 0)) { continue; } _5 = Z_TYPE_P(record) != IS_OBJECT; if (_5) { _5 = Z_TYPE_P(record) != IS_ARRAY; } if (_5) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_7, 0, _6); zephir_check_call_status(); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only objects/arrays can be stored as part of has-many/has-one/has-many-to-many relations", "phalcon/mvc/model.zep", 2631); return; } ZEPHIR_CALL_METHOD(&columns, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(columns) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_8, 0, _6); zephir_check_call_status(); ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not implemented", "phalcon/mvc/model.zep", 2640); return; } if (Z_TYPE_P(record) == IS_OBJECT) { ZEPHIR_INIT_NVAR(relatedRecords); zephir_create_array(relatedRecords, 1, 0 TSRMLS_CC); zephir_array_fast_append(relatedRecords, record); } else { ZEPHIR_CPY_WRT(relatedRecords, record); } ZEPHIR_OBS_NVAR(value); if (!(zephir_fetch_property_zval(&value, this_ptr, columns, PH_SILENT_CC))) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_9, 0, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_10); object_init_ex(_10, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, "The column '", columns, "' needs to be present in the model"); ZEPHIR_CALL_METHOD(NULL, _10, "__construct", &_12, 9, _11); zephir_check_call_status(); zephir_throw_exception_debug(_10, "phalcon/mvc/model.zep", 2654 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&_13, relation, "isthrough", NULL, 0); zephir_check_call_status(); isThrough = zephir_get_boolval(_13); if (isThrough) { ZEPHIR_CALL_METHOD(&intermediateModelName, relation, "getintermediatemodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateReferencedFields, relation, "getintermediatereferencedfields", NULL, 0); zephir_check_call_status(); } zephir_is_iterable(relatedRecords, &_15, &_14, 0, 0, "phalcon/mvc/model.zep", 2769); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(recordAfter, _16); if (!(isThrough)) { ZEPHIR_CALL_METHOD(NULL, recordAfter, "writeattribute", NULL, 0, referencedFields, value); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_13, recordAfter, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_13))) { ZEPHIR_CALL_METHOD(&_17, recordAfter, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_17, &_19, &_18, 0, 0, "phalcon/mvc/model.zep", 2711); for ( ; zephir_hash_get_current_data_ex(_19, (void**) &_20, &_18) == SUCCESS ; zephir_hash_move_forward_ex(_19, &_18) ) { ZEPHIR_GET_HVALUE(message, _20); if (Z_TYPE_P(message) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, message, "setmodel", NULL, 0, record); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_21, 0, message); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_22, 0, _6); zephir_check_call_status(); RETURN_MM_BOOL(0); } if (isThrough) { ZEPHIR_INIT_NVAR(_10); ZVAL_BOOL(_10, 1); ZEPHIR_CALL_METHOD(&intermediateModel, manager, "load", &_23, 0, intermediateModelName, _10); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, intermediateModel, "writeattribute", NULL, 0, intermediateFields, value); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateValue, recordAfter, "readattribute", NULL, 0, referencedFields); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, intermediateModel, "writeattribute", NULL, 0, intermediateReferencedFields, intermediateValue); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_17, intermediateModel, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_17))) { ZEPHIR_CALL_METHOD(&_24, intermediateModel, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_24, &_26, &_25, 0, 0, "phalcon/mvc/model.zep", 2763); for ( ; zephir_hash_get_current_data_ex(_26, (void**) &_27, &_25) == SUCCESS ; zephir_hash_move_forward_ex(_26, &_25) ) { ZEPHIR_GET_HVALUE(message, _27); if (Z_TYPE_P(message) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, message, "setmodel", NULL, 0, record); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_21, 0, message); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_10); if (nesting) { ZVAL_BOOL(_10, 1); } else { ZVAL_BOOL(_10, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_28, 0, _10); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } } else { if (Z_TYPE_P(record) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_29, 0, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_10); object_init_ex(_10, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSVS(_11, "There are no defined relations for the model '", className, "' using alias '", name, "'"); ZEPHIR_CALL_METHOD(NULL, _10, "__construct", &_12, 9, _11); zephir_check_call_status(); zephir_throw_exception_debug(_10, "phalcon/mvc/model.zep", 2772 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } ZEPHIR_INIT_NVAR(_6); if (nesting) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0, _6); zephir_check_call_status(); RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model, save) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *whiteList = NULL, *metaData = NULL, *related, *schema = NULL, *writeConnection = NULL, *readConnection = NULL, *source = NULL, *table = NULL, *identityField = NULL, *exists = NULL, *success = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &whiteList); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!whiteList) { whiteList = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); _0 = Z_TYPE_P(data) == IS_ARRAY; if (_0) { _0 = zephir_fast_count_int(data TSRMLS_CC) > 0; } if (_0) { ZEPHIR_INIT_VAR(_1); ZVAL_NULL(_1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, data, _1, whiteList); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(related); zephir_read_property_this(&related, this_ptr, SL("_related"), PH_NOISY_CC); if (Z_TYPE_P(related) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "_presaverelatedrecords", NULL, 0, writeConnection, related); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_VAR(table); zephir_create_array(table, 2, 0 TSRMLS_CC); zephir_array_fast_append(table, schema); zephir_array_fast_append(table, source); } else { ZEPHIR_CPY_WRT(table, source); } ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&exists, this_ptr, "_exists", NULL, 0, metaData, readConnection, table); zephir_check_call_status(); if (zephir_is_true(exists)) { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 2); zephir_update_property_this(this_ptr, SL("_operationMade"), _3 TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 1); zephir_update_property_this(this_ptr, SL("_operationMade"), _3 TSRMLS_CC); } ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_errorMessages"), _1 TSRMLS_CC); ZEPHIR_CALL_METHOD(&identityField, metaData, "getidentityfield", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "_presave", NULL, 0, metaData, exists, identityField); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { if (Z_TYPE_P(related) == IS_ARRAY) { ZEPHIR_INIT_VAR(_4); ZVAL_BOOL(_4, 0); ZEPHIR_CALL_METHOD(NULL, writeConnection, "rollback", NULL, 0, _4); zephir_check_call_status(); } if (ZEPHIR_GLOBAL(orm).exception_on_failed_save) { ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_mvc_model_validationfailed_ce); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_errorMessages"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 305, this_ptr, _3); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/mvc/model.zep", 2885 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_MM_BOOL(0); } if (zephir_is_true(exists)) { ZEPHIR_CALL_METHOD(&success, this_ptr, "_dolowupdate", NULL, 0, metaData, writeConnection, table); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, this_ptr, "_dolowinsert", NULL, 0, metaData, writeConnection, table, identityField); zephir_check_call_status(); } if (zephir_is_true(success)) { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 0); zephir_update_property_this(this_ptr, SL("_dirtyState"), _3 TSRMLS_CC); } if (Z_TYPE_P(related) == IS_ARRAY) { if (ZEPHIR_IS_FALSE_IDENTICAL(success)) { ZEPHIR_INIT_NVAR(_1); ZVAL_BOOL(_1, 0); ZEPHIR_CALL_METHOD(NULL, writeConnection, "rollback", NULL, 0, _1); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&success, this_ptr, "_postsaverelatedrecords", NULL, 0, writeConnection, related); zephir_check_call_status(); } } if (ZEPHIR_GLOBAL(orm).events) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "_postsave", NULL, 0, success, exists); zephir_check_call_status(); ZEPHIR_CPY_WRT(success, _2); } if (ZEPHIR_IS_FALSE_IDENTICAL(success)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_canceloperation", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "afterSave", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } RETURN_CCTOR(success); } static PHP_METHOD(Phalcon_Mvc_Model, create) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *whiteList = NULL, *metaData = NULL, *_0 = NULL, *_1 = NULL, *_3, *_4, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &whiteList); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!whiteList) { whiteList = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getreadconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_exists", NULL, 0, metaData, _1); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); object_init_ex(_3, phalcon_mvc_model_message_ce); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Record cannot be created because it already exists", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); ZVAL_NULL(_5); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "InvalidCreateAttempt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 8, _4, _5, _6); zephir_check_temp_parameter(_4); zephir_check_temp_parameter(_6); zephir_check_call_status(); zephir_array_fast_append(_2, _3); zephir_update_property_this(this_ptr, SL("_errorMessages"), _2 TSRMLS_CC); RETURN_MM_BOOL(0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0, data, whiteList); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, update) { zval *_3; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL, *whiteList = NULL, *metaData = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4, *_5, *_6, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &data, &whiteList); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (!whiteList) { whiteList = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dirtyState"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getreadconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_exists", NULL, 0, metaData, _2); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); object_init_ex(_4, phalcon_mvc_model_message_ce); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Record cannot be updated because it does not exist", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_6); ZVAL_NULL(_6); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "InvalidUpdateAttempt", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 8, _5, _6, _7); zephir_check_temp_parameter(_5); zephir_check_temp_parameter(_7); zephir_check_call_status(); zephir_array_fast_append(_3, _4); zephir_update_property_this(this_ptr, SL("_errorMessages"), _3 TSRMLS_CC); RETURN_MM_BOOL(0); } } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0, data, whiteList); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, delete) { zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zval *metaData = NULL, *writeConnection = NULL, *values, *bindTypes, *primaryKeys = NULL, *bindDataTypes = NULL, *columnMap = NULL, *attributeField = NULL, *conditions, *primaryKey = NULL, *bindType = NULL, *value = NULL, *schema = NULL, *source = NULL, *table = NULL, *success = NULL, *_0, *_1, *_2 = NULL, **_5, *_6 = NULL, *_7 = NULL, *_10; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 3); zephir_update_property_this(this_ptr, SL("_operationMade"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_errorMessages"), _1 TSRMLS_CC); if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "_checkforeignkeysreverserestrict", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(values); array_init(values); ZEPHIR_INIT_VAR(bindTypes); array_init(bindTypes); ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } if (!(zephir_fast_count_int(primaryKeys TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A primary key must be defined in the model in order to perform the operation", "phalcon/mvc/model.zep", 3069); return; } zephir_is_iterable(primaryKeys, &_4, &_3, 0, 0, "phalcon/mvc/model.zep", 3110); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(primaryKey, _5); ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, primaryKey, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", primaryKey, "' have not defined a bind data type"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/mvc/model.zep", 3081 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, primaryKey, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", primaryKey, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/mvc/model.zep", 3089 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, primaryKey); } ZEPHIR_OBS_NVAR(value); if (!(zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC))) { ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cannot delete the record because the primary key attribute: '", attributeField, "' wasn't set"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/mvc/model.zep", 3099 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&values, value, PH_SEPARATE, "phalcon/mvc/model.zep", 3105); ZEPHIR_CALL_METHOD(&_2, writeConnection, "escapeidentifier", &_9, 0, primaryKey); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_VS(_7, _2, " = ?"); zephir_array_append(&conditions, _7, PH_SEPARATE, "phalcon/mvc/model.zep", 3106); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model.zep", 3107); } if (ZEPHIR_GLOBAL(orm).events) { if (0) { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "beforeDelete", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "fireeventcancel", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } else { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_skipped"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_0)) { RETURN_MM_BOOL(1); } } } ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_VAR(table); zephir_create_array(table, 2, 0 TSRMLS_CC); zephir_array_fast_append(table, schema); zephir_array_fast_append(table, source); } else { ZEPHIR_CPY_WRT(table, source); } ZEPHIR_INIT_NVAR(_6); zephir_fast_join_str(_6, SL(" AND "), conditions TSRMLS_CC); ZEPHIR_CALL_METHOD(&success, writeConnection, "delete", NULL, 0, table, _6, values, bindTypes); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { ZEPHIR_CALL_METHOD(&_2, this_ptr, "_checkforeignkeysreversecascade", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { RETURN_MM_BOOL(0); } } if (ZEPHIR_GLOBAL(orm).events) { if (zephir_is_true(success)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "afterDelete", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); } } ZEPHIR_INIT_ZVAL_NREF(_10); ZVAL_LONG(_10, 2); zephir_update_property_this(this_ptr, SL("_dirtyState"), _10 TSRMLS_CC); RETURN_CCTOR(success); } static PHP_METHOD(Phalcon_Mvc_Model, getOperationMade) { RETURN_MEMBER(this_ptr, "_operationMade"); } static PHP_METHOD(Phalcon_Mvc_Model, refresh) { zval *_5 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *metaData = NULL, *readConnection = NULL, *schema = NULL, *source = NULL, *table = NULL, *uniqueKey = NULL, *tables = NULL, *uniqueParams, *dialect = NULL, *row = NULL, *fields, *attribute = NULL, *_0, *_1 = NULL, **_4, *_6, *_7; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dirtyState"), PH_NOISY_CC); if (!ZEPHIR_IS_LONG(_0, 0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The record cannot be refreshed because it does not exist or is deleted", "phalcon/mvc/model.zep", 3185); return; } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_VAR(table); zephir_create_array(table, 2, 0 TSRMLS_CC); zephir_array_fast_append(table, schema); zephir_array_fast_append(table, source); } else { ZEPHIR_CPY_WRT(table, source); } ZEPHIR_OBS_VAR(uniqueKey); zephir_read_property_this(&uniqueKey, this_ptr, SL("_uniqueKey"), PH_NOISY_CC); if (!(zephir_is_true(uniqueKey))) { ZEPHIR_CALL_METHOD(&_1, this_ptr, "_exists", NULL, 0, metaData, readConnection, table); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The record cannot be refreshed because it does not exist or is deleted", "phalcon/mvc/model.zep", 3207); return; } ZEPHIR_OBS_NVAR(uniqueKey); zephir_read_property_this(&uniqueKey, this_ptr, SL("_uniqueKey"), PH_NOISY_CC); } ZEPHIR_OBS_VAR(uniqueParams); zephir_read_property_this(&uniqueParams, this_ptr, SL("_uniqueParams"), PH_NOISY_CC); if (Z_TYPE_P(uniqueParams) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The record cannot be refreshed because it does not exist or is deleted", "phalcon/mvc/model.zep", 3215); return; } ZEPHIR_INIT_VAR(fields); array_init(fields); ZEPHIR_CALL_METHOD(&_1, metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 3229); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(attribute, _4); ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_fast_append(_5, attribute); zephir_array_append(&fields, _5, PH_SEPARATE, "phalcon/mvc/model.zep", 3223); } ZEPHIR_CALL_METHOD(&dialect, readConnection, "getdialect", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5); zephir_create_array(_5, 3, 0 TSRMLS_CC); zephir_array_update_string(&_5, SL("columns"), &fields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, readConnection, "escapeidentifier", NULL, 0, table); zephir_check_call_status(); zephir_array_update_string(&_5, SL("tables"), &_1, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_5, SL("where"), &uniqueKey, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&tables, dialect, "select", NULL, 0, _5); zephir_check_call_status(); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueTypes"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_7); ZVAL_LONG(_7, 2); ZEPHIR_CALL_METHOD(&row, readConnection, "fetchone", NULL, 0, tables, _7, uniqueParams, _6); zephir_check_call_status(); if (Z_TYPE_P(row) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&_1, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, row, _1); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model, skipOperation) { zval *skip_param = NULL; zend_bool skip; zephir_fetch_params(0, 1, 0, &skip_param); skip = zephir_get_boolval(skip_param); if (skip) { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_skipped"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Model, readAttribute) { zval *attribute_param = NULL, *_0; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attribute_param); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } if (!(zephir_isset_property_zval(this_ptr, attribute TSRMLS_CC))) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(_0); zephir_read_property_zval(&_0, this_ptr, attribute, PH_NOISY_CC); RETURN_CCTOR(_0); } static PHP_METHOD(Phalcon_Mvc_Model, writeAttribute) { zval *attribute_param = NULL, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &attribute_param, &value); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } zephir_update_property_zval_zval(this_ptr, attribute, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, skipAttributes) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *attributes_param = NULL, *keysAttributes, *metaData = NULL, *attribute = NULL, **_2; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); attributes = attributes_param; ZEPHIR_INIT_VAR(keysAttributes); array_init(keysAttributes); zephir_is_iterable(attributes, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 3310); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(attribute, _2); zephir_array_update_zval(&keysAttributes, attribute, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, metaData, "setautomaticcreateattributes", NULL, 0, this_ptr, keysAttributes); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, metaData, "setautomaticupdateattributes", NULL, 0, this_ptr, keysAttributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnCreate) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *attributes_param = NULL, *keysAttributes, *attribute = NULL, **_2, *_3 = NULL; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); attributes = attributes_param; ZEPHIR_INIT_VAR(keysAttributes); array_init(keysAttributes); zephir_is_iterable(attributes, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 3341); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(attribute, _2); zephir_array_update_zval(&keysAttributes, attribute, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&_3, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _3, "setautomaticcreateattributes", NULL, 0, this_ptr, keysAttributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnUpdate) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *attributes_param = NULL, *keysAttributes, *attribute = NULL, **_2, *_3 = NULL; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); attributes = attributes_param; ZEPHIR_INIT_VAR(keysAttributes); array_init(keysAttributes); zephir_is_iterable(attributes, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 3370); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(attribute, _2); zephir_array_update_zval(&keysAttributes, attribute, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&_3, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _3, "setautomaticupdateattributes", NULL, 0, this_ptr, keysAttributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, allowEmptyStringValues) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *attributes_param = NULL, *keysAttributes, *attribute = NULL, **_2, *_3 = NULL; zval *attributes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attributes_param); attributes = attributes_param; ZEPHIR_INIT_VAR(keysAttributes); array_init(keysAttributes); zephir_is_iterable(attributes, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 3399); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(attribute, _2); zephir_array_update_zval(&keysAttributes, attribute, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&_3, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _3, "setemptystringattributes", NULL, 0, this_ptr, keysAttributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, hasOne) { int ZEPHIR_LAST_CALL_STATUS; zval *referenceModel = NULL; zval *fields, *referenceModel_param = NULL, *referencedFields, *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceModel_param) == IS_STRING)) { zephir_get_strval(referenceModel, referenceModel_param); } else { ZEPHIR_INIT_VAR(referenceModel); ZVAL_EMPTY_STRING(referenceModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "addhasone", NULL, 0, this_ptr, fields, referenceModel, referencedFields, options); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, belongsTo) { int ZEPHIR_LAST_CALL_STATUS; zval *referenceModel = NULL; zval *fields, *referenceModel_param = NULL, *referencedFields, *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceModel_param) == IS_STRING)) { zephir_get_strval(referenceModel, referenceModel_param); } else { ZEPHIR_INIT_VAR(referenceModel); ZVAL_EMPTY_STRING(referenceModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "addbelongsto", NULL, 0, this_ptr, fields, referenceModel, referencedFields, options); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, hasMany) { int ZEPHIR_LAST_CALL_STATUS; zval *referenceModel = NULL; zval *fields, *referenceModel_param = NULL, *referencedFields, *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceModel_param) == IS_STRING)) { zephir_get_strval(referenceModel, referenceModel_param); } else { ZEPHIR_INIT_VAR(referenceModel); ZVAL_EMPTY_STRING(referenceModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "addhasmany", NULL, 0, this_ptr, fields, referenceModel, referencedFields, options); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, hasManyToMany) { int ZEPHIR_LAST_CALL_STATUS; zval *intermediateModel = NULL, *referenceModel = NULL; zval *fields, *intermediateModel_param = NULL, *intermediateFields, *intermediateReferencedFields, *referenceModel_param = NULL, *referencedFields, *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 6, 1, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referenceModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { zephir_get_strval(intermediateModel, intermediateModel_param); } else { ZEPHIR_INIT_VAR(intermediateModel); ZVAL_EMPTY_STRING(intermediateModel); } if (unlikely(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referenceModel_param) == IS_STRING)) { zephir_get_strval(referenceModel, referenceModel_param); } else { ZEPHIR_INIT_VAR(referenceModel); ZVAL_EMPTY_STRING(referenceModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "addhasmanytomany", NULL, 0, this_ptr, fields, intermediateModel, intermediateFields, intermediateReferencedFields, referenceModel, referencedFields, options); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, addBehavior) { int ZEPHIR_LAST_CALL_STATUS; zval *behavior, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &behavior); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "addbehavior", NULL, 0, this_ptr, behavior); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, keepSnapshots) { int ZEPHIR_LAST_CALL_STATUS; zval *keepSnapshot_param = NULL, *_0, *_1; zend_bool keepSnapshot; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &keepSnapshot_param); keepSnapshot = zephir_get_boolval(keepSnapshot_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); if (keepSnapshot) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "keepsnapshots", NULL, 0, this_ptr, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, setSnapshotData) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *data_param = NULL, *columnMap = NULL, *key = NULL, *value = NULL, *snapshot, *attribute = NULL, **_2, *_3 = NULL, *_4 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &data_param, &columnMap); data = data_param; if (!columnMap) { columnMap = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_INIT_VAR(snapshot); array_init(snapshot); zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/mvc/model.zep", 3615); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(key) != IS_STRING) { continue; } ZEPHIR_OBS_NVAR(attribute); if (!(zephir_array_isset_fetch(&attribute, columnMap, key, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", key, "' doesn't make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 3596 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } if (Z_TYPE_P(attribute) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attribute); if (!(zephir_array_isset_long_fetch(&attribute, attribute, 0, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", key, "' doesn't make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model.zep", 3605 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } } zephir_array_update_zval(&snapshot, attribute, &value, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_snapshot"), snapshot TSRMLS_CC); RETURN_MM_NULL(); } zephir_update_property_this(this_ptr, SL("_snapshot"), data TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, hasSnapshotData) { zval *snapshot; snapshot = zephir_fetch_nproperty_this(this_ptr, SL("_snapshot"), PH_NOISY_CC); RETURN_BOOL(Z_TYPE_P(snapshot) == IS_ARRAY); } static PHP_METHOD(Phalcon_Mvc_Model, getSnapshotData) { RETURN_MEMBER(this_ptr, "_snapshot"); } static PHP_METHOD(Phalcon_Mvc_Model, hasChanged) { HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *fieldName = NULL, *snapshot, *metaData = NULL, *columnMap = NULL, *allAttributes = NULL, *value = NULL, *originalValue = NULL, *name = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, **_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &fieldName); if (!fieldName) { fieldName = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(snapshot); zephir_read_property_this(&snapshot, this_ptr, SL("_snapshot"), PH_NOISY_CC); if (Z_TYPE_P(snapshot) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The record doesn't have a valid data snapshot", "phalcon/mvc/model.zep", 3654); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dirtyState"), PH_NOISY_CC); if (!ZEPHIR_IS_LONG(_0, 0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Change checking cannot be performed because the object has not been persisted or is deleted", "phalcon/mvc/model.zep", 3661); return; } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); if (Z_TYPE_P(columnMap) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&allAttributes, metaData, "getdatatypes", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(allAttributes, columnMap); } if (Z_TYPE_P(fieldName) == IS_STRING) { if (Z_TYPE_P(columnMap) == IS_ARRAY) { if (!(zephir_array_isset(columnMap, fieldName))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "The field '", fieldName, "' is not part of the model"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 3693 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { if (!(zephir_array_isset(allAttributes, fieldName))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "The field '", fieldName, "' is not part of the model"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 3697 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_OBS_VAR(value); if (!(zephir_fetch_property_zval(&value, this_ptr, fieldName, PH_SILENT_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "The field '", fieldName, "' is not defined on the model"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 3705 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(originalValue); if (!(zephir_array_isset_fetch(&originalValue, snapshot, fieldName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVS(_3, "The field '", fieldName, "' was not found in the snapshot"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 3712 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_MM_BOOL(!ZEPHIR_IS_EQUAL(value, originalValue)); } ZEPHIR_INIT_NVAR(_1); zephir_is_iterable(allAttributes, &_5, &_4, 0, 0, "phalcon/mvc/model.zep", 3748); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(name, _5, _4); ZEPHIR_GET_HVALUE(_1, _6); ZEPHIR_OBS_NVAR(originalValue); if (!(zephir_array_isset_fetch(&originalValue, snapshot, name, 0 TSRMLS_CC))) { RETURN_MM_BOOL(1); } ZEPHIR_OBS_NVAR(value); if (!(zephir_fetch_property_zval(&value, this_ptr, name, PH_SILENT_CC))) { RETURN_MM_BOOL(1); } if (!ZEPHIR_IS_EQUAL(value, originalValue)) { RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model, getChangedFields) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *metaData = NULL, *changed, *name = NULL, *snapshot, *columnMap = NULL, *allAttributes = NULL, *value = NULL, *_0, *_1 = NULL, **_4, *_5; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(snapshot); zephir_read_property_this(&snapshot, this_ptr, SL("_snapshot"), PH_NOISY_CC); if (Z_TYPE_P(snapshot) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The record doesn't have a valid data snapshot", "phalcon/mvc/model.zep", 3761); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dirtyState"), PH_NOISY_CC); if (!ZEPHIR_IS_LONG(_0, 0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Change checking cannot be performed because the object has not been persisted or is deleted", "phalcon/mvc/model.zep", 3768); return; } ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); if (Z_TYPE_P(columnMap) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&allAttributes, metaData, "getdatatypes", NULL, 0, this_ptr); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(allAttributes, columnMap); } ZEPHIR_INIT_VAR(changed); array_init(changed); ZEPHIR_INIT_VAR(_1); zephir_is_iterable(allAttributes, &_3, &_2, 0, 0, "phalcon/mvc/model.zep", 3822); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(name, _3, _2); ZEPHIR_GET_HVALUE(_1, _4); if (!(zephir_array_isset(snapshot, name))) { zephir_array_append(&changed, name, PH_SEPARATE, "phalcon/mvc/model.zep", 3801); continue; } ZEPHIR_OBS_NVAR(value); if (!(zephir_fetch_property_zval(&value, this_ptr, name, PH_SILENT_CC))) { zephir_array_append(&changed, name, PH_SEPARATE, "phalcon/mvc/model.zep", 3809); continue; } zephir_array_fetch(&_5, snapshot, name, PH_NOISY | PH_READONLY, "phalcon/mvc/model.zep", 3816 TSRMLS_CC); if (!ZEPHIR_IS_EQUAL(value, _5)) { zephir_array_append(&changed, name, PH_SEPARATE, "phalcon/mvc/model.zep", 3817); continue; } } RETURN_CCTOR(changed); } static PHP_METHOD(Phalcon_Mvc_Model, useDynamicUpdate) { int ZEPHIR_LAST_CALL_STATUS; zval *dynamicUpdate_param = NULL, *_0, *_1; zend_bool dynamicUpdate; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &dynamicUpdate_param); dynamicUpdate = zephir_get_boolval(dynamicUpdate_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); if (dynamicUpdate) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(NULL, _0, "usedynamicupdate", NULL, 0, this_ptr, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, getRelated) { zval *_4, *_5; int ZEPHIR_LAST_CALL_STATUS; zval *alias_param = NULL, *arguments = NULL, *relation = NULL, *className, *manager = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3; zval *alias = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &alias_param, &arguments); zephir_get_strval(alias, alias_param); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(className); zephir_get_class(className, this_ptr, 0 TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&_1, manager, "getrelationbyalias", NULL, 0, className, alias); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _1); if (Z_TYPE_P(relation) != IS_OBJECT) { ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSVS(_3, "There is no defined relations for the model '", className, "' using alias '", alias, "'"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/mvc/model.zep", 3865 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_fast_append(_4, manager); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "getRelationRecords", 1); zephir_array_fast_append(_4, _2); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 4, 0 TSRMLS_CC); zephir_array_fast_append(_5, relation); zephir_array_fast_append(_5, ZEPHIR_GLOBAL(global_null)); zephir_array_fast_append(_5, this_ptr); zephir_array_fast_append(_5, arguments); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _4, _5); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, _getRelatedRecords) { zval *_4, *_5; int ZEPHIR_LAST_CALL_STATUS; zval *modelName_param = NULL, *method_param = NULL, *arguments, *manager = NULL, *relation = NULL, *queryMethod = NULL, *extraArgs, *_0, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL; zval *modelName = NULL, *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &modelName_param, &method_param, &arguments); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_INIT_VAR(relation); ZVAL_BOOL(relation, 0); ZEPHIR_INIT_VAR(queryMethod); ZVAL_NULL(queryMethod); if (zephir_start_with_str(method, SL("get"))) { ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, 3); ZEPHIR_INIT_VAR(_3); zephir_substr(_3, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_CALL_METHOD(&_1, manager, "getrelationbyalias", NULL, 0, modelName, _3); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _1); } if (Z_TYPE_P(relation) != IS_OBJECT) { if (zephir_start_with_str(method, SL("count"))) { ZEPHIR_INIT_NVAR(queryMethod); ZVAL_STRING(queryMethod, "count", 1); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 5); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, method, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_CALL_METHOD(&_1, manager, "getrelationbyalias", NULL, 0, modelName, _3); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _1); } } if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_OBS_VAR(extraArgs); zephir_array_isset_long_fetch(&extraArgs, arguments, 0, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_fast_append(_4, manager); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "getRelationRecords", 1); zephir_array_fast_append(_4, _3); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 4, 0 TSRMLS_CC); zephir_array_fast_append(_5, relation); zephir_array_fast_append(_5, queryMethod); zephir_array_fast_append(_5, this_ptr); zephir_array_fast_append(_5, extraArgs); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _4, _5); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model, _invokeFinder) { zval *_5, *_6; zend_class_entry *_4, *_7; int ZEPHIR_LAST_CALL_STATUS; zval *method, *arguments, *extraMethod = NULL, *type = NULL, *modelName, *value, *model, *attributes = NULL, *field = NULL, *extraMethodFirst = NULL, *metaData = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method, &arguments); ZEPHIR_INIT_VAR(extraMethod); ZVAL_NULL(extraMethod); if (zephir_start_with_str(method, SL("findFirstBy"))) { ZEPHIR_INIT_VAR(type); ZVAL_STRING(type, "findFirst", 1); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, 11); ZEPHIR_INIT_NVAR(extraMethod); zephir_substr(extraMethod, method, 11 , 0, ZEPHIR_SUBSTR_NO_LENGTH); } if (Z_TYPE_P(extraMethod) == IS_NULL) { if (zephir_start_with_str(method, SL("findBy"))) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "find", 1); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 6); ZEPHIR_INIT_NVAR(extraMethod); zephir_substr(extraMethod, method, 6 , 0, ZEPHIR_SUBSTR_NO_LENGTH); } } if (Z_TYPE_P(extraMethod) == IS_NULL) { if (zephir_start_with_str(method, SL("countBy"))) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "count", 1); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 7); ZEPHIR_INIT_NVAR(extraMethod); zephir_substr(extraMethod, method, 7 , 0, ZEPHIR_SUBSTR_NO_LENGTH); } } ZEPHIR_INIT_VAR(modelName); zephir_get_called_class(modelName TSRMLS_CC); if (!(zephir_is_true(extraMethod))) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_long_fetch(&value, arguments, 0, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "The static method '", method, "' requires one argument"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 3977 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(model); zephir_fetch_safe_class(_3, modelName); _4 = zend_fetch_class(Z_STRVAL_P(_3), Z_STRLEN_P(_3), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(model, _4); if (zephir_has_constructor(model TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, model, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&metaData, model, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&attributes, metaData, "getreversecolumnmap", NULL, 0, model); zephir_check_call_status(); if (Z_TYPE_P(attributes) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&attributes, metaData, "getdatatypes", NULL, 0, model); zephir_check_call_status(); } if (zephir_array_isset(attributes, extraMethod)) { ZEPHIR_CPY_WRT(field, extraMethod); } else { ZEPHIR_CALL_FUNCTION(&extraMethodFirst, "lcfirst", NULL, 68, extraMethod); zephir_check_call_status(); if (zephir_array_isset(attributes, extraMethodFirst)) { ZEPHIR_CPY_WRT(field, extraMethodFirst); } else { ZEPHIR_INIT_NVAR(field); zephir_uncamelize(field, extraMethod); if (!(zephir_array_isset(attributes, field))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "Cannot resolve attribute '", extraMethod, "' in the model"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 4011 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 2, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, field, " = ?0"); zephir_array_update_string(&_5, SL("conditions"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 1, 0 TSRMLS_CC); zephir_array_fast_append(_6, value); zephir_array_update_string(&_5, SL("bind"), &_6, PH_COPY | PH_SEPARATE); _7 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(_7, type, NULL, 0, _5); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, __call) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *method_param = NULL, *arguments, *modelName, *status = NULL, *records = NULL, *_1, *_2, *_3; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method_param, &arguments); zephir_get_strval(method, method_param); ZEPHIR_CALL_SELF(&records, "_invokefinder", &_0, 306, method, arguments); zephir_check_call_status(); if (Z_TYPE_P(records) != IS_NULL) { RETURN_CCTOR(records); } ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&records, this_ptr, "_getrelatedrecords", NULL, 0, modelName, method, arguments); zephir_check_call_status(); if (Z_TYPE_P(records) != IS_NULL) { RETURN_CCTOR(records); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsManager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&status, _1, "missingmethod", NULL, 0, this_ptr, method, arguments); zephir_check_call_status(); if (Z_TYPE_P(status) != IS_NULL) { RETURN_CCTOR(status); } ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSVS(_3, "The method '", method, "' doesn't exist on model '", modelName, "'"); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/mvc/model.zep", 4062 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Model, __callStatic) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *method_param = NULL, *arguments, *records = NULL, *_1; zval *method = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method_param, &arguments); zephir_get_strval(method, method_param); ZEPHIR_CALL_SELF(&records, "_invokefinder", &_0, 306, method, arguments); zephir_check_call_status(); if (Z_TYPE_P(records) == IS_NULL) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "The static method '", method, "' doesn't exist"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model.zep", 4078 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_CCTOR(records); } static PHP_METHOD(Phalcon_Mvc_Model, __set) { zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *value, *lowerProperty = NULL, *related, *modelName, *manager = NULL, *lowerKey = NULL, *relation = NULL, *referencedModel = NULL, *key = NULL, *item = NULL, *_0, **_3, *_4 = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &property_param, &value); zephir_get_strval(property, property_param); if (Z_TYPE_P(value) == IS_OBJECT) { if (zephir_instance_of_ev(value, phalcon_mvc_modelinterface_ce TSRMLS_CC)) { ZEPHIR_INIT_VAR(lowerProperty); zephir_fast_strtolower(lowerProperty, property); zephir_update_property_zval_zval(this_ptr, lowerProperty, value TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_related"), lowerProperty, value TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 1); zephir_update_property_this(this_ptr, SL("_dirtyState"), _0 TSRMLS_CC); RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_INIT_NVAR(lowerProperty); zephir_fast_strtolower(lowerProperty, property); ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(related); array_init(related); zephir_is_iterable(value, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 4134); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(item, _3); if (Z_TYPE_P(item) == IS_OBJECT) { if (zephir_instance_of_ev(item, phalcon_mvc_modelinterface_ce TSRMLS_CC)) { zephir_array_append(&related, item, PH_SEPARATE, "phalcon/mvc/model.zep", 4121); } } else { ZEPHIR_INIT_NVAR(lowerKey); zephir_fast_strtolower(lowerKey, key); zephir_update_property_zval_zval(this_ptr, lowerKey, item TSRMLS_CC); ZEPHIR_CALL_METHOD(&_4, manager, "getrelationbyalias", &_5, 0, modelName, lowerProperty); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _4); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_4, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, manager, "load", &_6, 0, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, referencedModel, "writeattribute", NULL, 0, lowerKey, item); zephir_check_call_status(); } } } if (zephir_fast_count_int(related TSRMLS_CC) > 0) { zephir_update_property_array(this_ptr, SL("_related"), lowerProperty, related TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 1); zephir_update_property_this(this_ptr, SL("_dirtyState"), _0 TSRMLS_CC); } RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } zephir_update_property_zval_zval(this_ptr, property, value TSRMLS_CC); RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, __get) { zval *_1, *_3; int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *modelName, *manager = NULL, *lowerProperty, *relation = NULL, *result, *method, *_0 = NULL, *_2 = NULL, *_4; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(lowerProperty); zephir_fast_strtolower(lowerProperty, property); ZEPHIR_CALL_METHOD(&_0, manager, "getrelationbyalias", NULL, 0, modelName, lowerProperty); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _0); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, manager); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "getRelationRecords", 1); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 4, 0 TSRMLS_CC); zephir_array_fast_append(_3, relation); zephir_array_fast_append(_3, ZEPHIR_GLOBAL(global_null)); zephir_array_fast_append(_3, this_ptr); zephir_array_fast_append(_3, ZEPHIR_GLOBAL(global_null)); ZEPHIR_INIT_VAR(result); ZEPHIR_CALL_USER_FUNC_ARRAY(result, _1, _3); zephir_check_call_status(); if (Z_TYPE_P(result) == IS_OBJECT) { zephir_update_property_zval_zval(this_ptr, lowerProperty, result TSRMLS_CC); if (zephir_instance_of_ev(result, phalcon_mvc_modelinterface_ce TSRMLS_CC)) { zephir_update_property_array(this_ptr, SL("_related"), lowerProperty, result TSRMLS_CC); } } RETURN_CCTOR(result); } ZEPHIR_INIT_NVAR(_2); zephir_camelize(_2, property); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", _2); if ((zephir_method_exists(this_ptr, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, method, NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVSV(_4, "Access to undefined property ", modelName, "::", property); ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 2, _4); zephir_check_call_status(); RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model, __isset) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *modelName, *manager = NULL, *relation = NULL, *_0 = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, this_ptr, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _0); ZEPHIR_CALL_METHOD(&_0, manager, "getrelationbyalias", NULL, 0, modelName, property); zephir_check_call_status(); ZEPHIR_CPY_WRT(relation, _0); RETURN_MM_BOOL(Z_TYPE_P(relation) == IS_OBJECT); } static PHP_METHOD(Phalcon_Mvc_Model, serialize) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 74, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, unserialize) { HashTable *_4; HashPosition _3; zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *attributes = NULL, *dependencyInjector = NULL, *manager = NULL, *key = NULL, *value = NULL, *_1 = NULL, *_2, **_5; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); if (unlikely(Z_TYPE_P(data_param) != IS_STRING && Z_TYPE_P(data_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'data' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(data_param) == IS_STRING)) { zephir_get_strval(data, data_param); } else { ZEPHIR_INIT_VAR(data); ZVAL_EMPTY_STRING(data); } ZEPHIR_CALL_FUNCTION(&attributes, "unserialize", NULL, 75, data); zephir_check_call_status(); if (Z_TYPE_P(attributes) == IS_ARRAY) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model.zep", 4258); return; } zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(manager, _1); if (Z_TYPE_P(manager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The injected service 'modelsManager' is not valid", "phalcon/mvc/model.zep", 4271); return; } zephir_update_property_this(this_ptr, SL("_modelsManager"), manager TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, manager, "initialize", NULL, 0, this_ptr); zephir_check_call_status(); zephir_is_iterable(attributes, &_4, &_3, 0, 0, "phalcon/mvc/model.zep", 4290); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(key, _4, _3); ZEPHIR_GET_HVALUE(value, _5); zephir_update_property_zval_zval(this_ptr, key, value TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, dump) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model, toArray) { zephir_fcall_cache_entry *_6 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *columns = NULL, *data, *metaData = NULL, *columnMap = NULL, *attribute = NULL, *attributeField = NULL, *value = NULL, *_0 = NULL, **_3, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &columns); if (!columns) { columns = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(data); array_init(data); ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/model.zep", 4354); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(attribute, _3); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, attribute, 0 TSRMLS_CC))) { if (!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns)) { ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "Column '", attribute, "' doesn't make part of the column map"); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_6, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/mvc/model.zep", 4332 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } else { continue; } } } else { ZEPHIR_CPY_WRT(attributeField, attribute); } if (Z_TYPE_P(columns) == IS_ARRAY) { if (!(zephir_fast_in_array(attributeField, columns TSRMLS_CC))) { continue; } } ZEPHIR_OBS_NVAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attributeField, PH_SILENT_CC)) { zephir_array_update_zval(&data, attributeField, &value, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&data, attributeField, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model, setup) { zval *options_param = NULL, *disableEvents, *columnRenaming, *notNullValidations, *exceptionOnFailedSave, *phqlLiterals, *virtualForeignKeys, *lateStateBinding, *castOnHydrate, *ignoreUnknownColumns; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_OBS_VAR(disableEvents); if (zephir_array_isset_string_fetch(&disableEvents, options, SS("events"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).events = zend_is_true(disableEvents); } ZEPHIR_OBS_VAR(virtualForeignKeys); if (zephir_array_isset_string_fetch(&virtualForeignKeys, options, SS("virtualForeignKeys"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).virtual_foreign_keys = zend_is_true(virtualForeignKeys); } ZEPHIR_OBS_VAR(columnRenaming); if (zephir_array_isset_string_fetch(&columnRenaming, options, SS("columnRenaming"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).column_renaming = zend_is_true(columnRenaming); } ZEPHIR_OBS_VAR(notNullValidations); if (zephir_array_isset_string_fetch(¬NullValidations, options, SS("notNullValidations"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).not_null_validations = zend_is_true(notNullValidations); } ZEPHIR_OBS_VAR(exceptionOnFailedSave); if (zephir_array_isset_string_fetch(&exceptionOnFailedSave, options, SS("exceptionOnFailedSave"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).exception_on_failed_save = zend_is_true(exceptionOnFailedSave); } ZEPHIR_OBS_VAR(phqlLiterals); if (zephir_array_isset_string_fetch(&phqlLiterals, options, SS("phqlLiterals"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).enable_literals = zend_is_true(phqlLiterals); } ZEPHIR_OBS_VAR(lateStateBinding); if (zephir_array_isset_string_fetch(&lateStateBinding, options, SS("lateStateBinding"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).late_state_binding = zend_is_true(lateStateBinding); } ZEPHIR_OBS_VAR(castOnHydrate); if (zephir_array_isset_string_fetch(&castOnHydrate, options, SS("castOnHydrate"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).cast_on_hydrate = zend_is_true(castOnHydrate); } ZEPHIR_OBS_VAR(ignoreUnknownColumns); if (zephir_array_isset_string_fetch(&ignoreUnknownColumns, options, SS("ignoreUnknownColumns"), 0 TSRMLS_CC)) { ZEPHIR_GLOBAL(orm).ignore_unknown_columns = zend_is_true(ignoreUnknownColumns); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model, reset) { zephir_update_property_this(this_ptr, SL("_uniqueParams"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_snapshot"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModelInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModelInterface, phalcon, mvc_modelinterface, phalcon_mvc_modelinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setTransaction); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSource); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSchema); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setWriteConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setReadConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setDirtyState); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getDirtyState); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, assign); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMap); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResult); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMapHydrate); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, find); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, findFirst); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, query); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, count); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, sum); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, maximum); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, minimum); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, average); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEvent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEventCancel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, appendMessage); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, validationHasFailed); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, save); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, create); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getOperationMade); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, refresh); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, skipOperation); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getRelated); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setSnapshotData); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, reset); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModuleDefinitionInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModuleDefinitionInterface, phalcon, mvc_moduledefinitioninterface, phalcon_mvc_moduledefinitioninterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerAutoloaders); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc, Router, phalcon, mvc_router, phalcon_mvc_router_method_entry, 0); zend_declare_property_null(phalcon_mvc_router_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_uriSource"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_namespace"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_module"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_controller"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_routes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_matchedRoute"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_matches"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_router_ce, SL("_wasMatched"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_defaultNamespace"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_defaultModule"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_defaultController"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_defaultAction"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_defaultParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_removeExtraSlashes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_ce, SL("_notFoundPaths"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_router_ce, SL("URI_SOURCE_GET_URL"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_router_ce, SL("URI_SOURCE_SERVER_REQUEST_URI"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_FIRST"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_LAST"), 1 TSRMLS_CC); zend_class_implements(phalcon_mvc_router_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_mvc_router_ce TSRMLS_CC, 1, phalcon_mvc_routerinterface_ce); zend_class_implements(phalcon_mvc_router_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Router, __construct) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *routes = NULL, *_1, *_4; zval *defaultRoutes_param = NULL, *_0 = NULL, *_2 = NULL, *_5; zend_bool defaultRoutes; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &defaultRoutes_param); if (!defaultRoutes_param) { defaultRoutes = 1; } else { if (unlikely(Z_TYPE_P(defaultRoutes_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultRoutes' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } defaultRoutes = Z_BVAL_P(defaultRoutes_param); } ZEPHIR_INIT_VAR(routes); array_init(routes); ZEPHIR_INIT_NVAR(routes); array_init(routes); if (defaultRoutes) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_router_route_ce); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); add_assoc_long_ex(_1, SS("controller"), 1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "#^/([\\w0-9\\_\\-]+)[/]{0,1}$#u", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_3, 77, _2, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_append(&routes, _0, PH_SEPARATE, "phalcon/mvc/router.zep", 120); ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_mvc_router_route_ce); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); add_assoc_long_ex(_4, SS("controller"), 1); add_assoc_long_ex(_4, SS("action"), 2); add_assoc_long_ex(_4, SS("params"), 3); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "#^/([\\w0-9\\_\\-]+)/([\\w0-9\\.\\_]+)(/.*)*$#u", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_3, 77, _5, _4); zephir_check_temp_parameter(_5); zephir_check_call_status(); zephir_array_append(&routes, _2, PH_SEPARATE, "phalcon/mvc/router.zep", 126); } ZEPHIR_INIT_NVAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); array_init(_2); zephir_update_property_this(this_ptr, SL("_defaultParams"), _2 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Router, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Router, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Router, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Mvc_Router, getRewriteUri) { zval *url = NULL, *urlParts, *realUri, *_0, *_GET, *_SERVER; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_uriSource"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_OBS_VAR(url); if (zephir_array_isset_string_fetch(&url, _GET, SS("_url"), 0 TSRMLS_CC)) { if (!(ZEPHIR_IS_EMPTY(url))) { RETURN_CCTOR(url); } } } else { ZEPHIR_OBS_NVAR(url); if (zephir_array_isset_string_fetch(&url, _SERVER, SS("REQUEST_URI"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(urlParts); zephir_fast_explode_str(urlParts, SL("?"), url, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&realUri, urlParts, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/router.zep", 188 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(realUri))) { RETURN_CTOR(realUri); } } } RETURN_MM_STRING("/", 1); } static PHP_METHOD(Phalcon_Mvc_Router, setUriSource) { zval *uriSource; zephir_fetch_params(0, 1, 0, &uriSource); zephir_update_property_this(this_ptr, SL("_uriSource"), uriSource TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router, removeExtraSlashes) { zval *remove_param = NULL; zend_bool remove; zephir_fetch_params(0, 1, 0, &remove_param); if (unlikely(Z_TYPE_P(remove_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'remove' must be a bool") TSRMLS_CC); RETURN_NULL(); } remove = Z_BVAL_P(remove_param); if (remove) { zephir_update_property_this(this_ptr, SL("_removeExtraSlashes"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_removeExtraSlashes"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router, setDefaultNamespace) { zval *namespaceName_param = NULL; zval *namespaceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &namespaceName_param); if (unlikely(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(namespaceName_param) == IS_STRING)) { zephir_get_strval(namespaceName, namespaceName_param); } else { ZEPHIR_INIT_VAR(namespaceName); ZVAL_EMPTY_STRING(namespaceName); } zephir_update_property_this(this_ptr, SL("_defaultNamespace"), namespaceName TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router, setDefaultModule) { zval *moduleName_param = NULL; zval *moduleName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &moduleName_param); if (unlikely(Z_TYPE_P(moduleName_param) != IS_STRING && Z_TYPE_P(moduleName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'moduleName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(moduleName_param) == IS_STRING)) { zephir_get_strval(moduleName, moduleName_param); } else { ZEPHIR_INIT_VAR(moduleName); ZVAL_EMPTY_STRING(moduleName); } zephir_update_property_this(this_ptr, SL("_defaultModule"), moduleName TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router, setDefaultController) { zval *controllerName_param = NULL; zval *controllerName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &controllerName_param); if (unlikely(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerName_param) == IS_STRING)) { zephir_get_strval(controllerName, controllerName_param); } else { ZEPHIR_INIT_VAR(controllerName); ZVAL_EMPTY_STRING(controllerName); } zephir_update_property_this(this_ptr, SL("_defaultController"), controllerName TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router, setDefaultAction) { zval *actionName_param = NULL; zval *actionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionName_param); if (unlikely(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(actionName_param) == IS_STRING)) { zephir_get_strval(actionName, actionName_param); } else { ZEPHIR_INIT_VAR(actionName); ZVAL_EMPTY_STRING(actionName); } zephir_update_property_this(this_ptr, SL("_defaultAction"), actionName TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router, setDefaults) { zval *defaults_param = NULL, *namespaceName, *module, *controller, *action, *params; zval *defaults = NULL; zephir_fetch_params(0, 1, 0, &defaults_param); defaults = defaults_param; if (zephir_array_isset_string_fetch(&namespaceName, defaults, SS("namespace"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultNamespace"), namespaceName TSRMLS_CC); } if (zephir_array_isset_string_fetch(&module, defaults, SS("module"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultModule"), module TSRMLS_CC); } if (zephir_array_isset_string_fetch(&controller, defaults, SS("controller"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultController"), controller TSRMLS_CC); } if (zephir_array_isset_string_fetch(&action, defaults, SS("action"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultAction"), action TSRMLS_CC); } if (zephir_array_isset_string_fetch(¶ms, defaults, SS("params"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_defaultParams"), params TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router, getDefaults) { zval *_0 = NULL; ZEPHIR_MM_GROW(); zephir_create_array(return_value, 5, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_array_update_string(&return_value, SL("namespace"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_array_update_string(&return_value, SL("module"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_array_update_string(&return_value, SL("controller"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_array_update_string(&return_value, SL("action"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_array_update_string(&return_value, SL("params"), &_0, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, handle) { zval *_13 = NULL, *_19 = NULL; zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_14 = NULL, *_20 = NULL; HashTable *_6, *_16; HashPosition _5, _15; zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params = NULL, *matches, *notFoundPaths, *vnamespace, *module, *controller, *action, *paramsStr, *strParams, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *converter = NULL, *eventsManager, *_0, _2 = zval_used_for_init, *_3 = NULL, *_4, **_7, *_8, *_9 = NULL, *_10 = NULL, **_17, *_18 = NULL, *_21, *_22, *_23, *_24; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { zephir_get_strval(uri, uri_param); } if (!(!(!uri) && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC); _1 = zephir_is_true(_0); if (_1) { _1 = !ZEPHIR_IS_STRING(realUri, "/"); } if (_1) { ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "/", 0); ZEPHIR_INIT_VAR(handledUri); zephir_fast_trim(handledUri, realUri, &_2, ZEPHIR_TRIM_RIGHT TSRMLS_CC); } else { ZEPHIR_CPY_WRT(handledUri, realUri); } ZEPHIR_INIT_VAR(request); ZVAL_NULL(request); ZEPHIR_INIT_VAR(currentHostName); ZVAL_NULL(currentHostName); ZEPHIR_INIT_VAR(routeFound); ZVAL_BOOL(routeFound, 0); ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(params); array_init(params); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "router:beforeCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _3, this_ptr); zephir_check_temp_parameter(_3); zephir_check_call_status(); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_4, &_6, &_5, 0, 1, "phalcon/mvc/router.zep", 557); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_backwards_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(route, _7); ZEPHIR_CALL_METHOD(&methods, route, "gethttpmethods", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _8); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 383); return; } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _9); } ZEPHIR_INIT_NVAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(&_9, request, "ismethod", NULL, 0, methods, _3); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_9)) { continue; } } ZEPHIR_CALL_METHOD(&hostname, route, "gethostname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(hostname) != IS_NULL) { if (Z_TYPE_P(request) == IS_NULL) { _8 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _8); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/mvc/router.zep", 410); return; } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "request", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(request, _9); } if (Z_TYPE_P(currentHostName) != IS_OBJECT) { ZEPHIR_CALL_METHOD(¤tHostName, request, "gethttphost", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(currentHostName) == IS_NULL) { continue; } if (zephir_memnstr_str(hostname, SL("("), "phalcon/mvc/router.zep", 433)) { if (!(zephir_memnstr_str(hostname, SL("#"), "phalcon/mvc/router.zep", 434))) { ZEPHIR_INIT_NVAR(regexHostName); ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#"); } else { ZEPHIR_CPY_WRT(regexHostName, hostname); } ZEPHIR_INIT_NVAR(_10); ZEPHIR_INIT_NVAR(matched); zephir_preg_match(matched, regexHostName, currentHostName, _10, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(matched); ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname)); } if (!(zephir_is_true(matched))) { continue; } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router:beforeCheckRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_11, 0, _3, this_ptr, route); zephir_check_temp_parameter(_3); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&pattern, route, "getcompiledpattern", NULL, 0); zephir_check_call_status(); if (zephir_memnstr_str(pattern, SL("^"), "phalcon/mvc/router.zep", 458)) { ZEPHIR_INIT_NVAR(routeFound); zephir_preg_match(routeFound, pattern, handledUri, matches, 0, 0 , 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri)); } if (zephir_is_true(routeFound)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router:matchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_12, 0, _3, this_ptr, route); zephir_check_temp_parameter(_3); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&beforeMatch, route, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { if (!(zephir_is_callable(beforeMatch TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/mvc/router.zep", 480); return; } ZEPHIR_INIT_NVAR(_13); zephir_create_array(_13, 3, 0 TSRMLS_CC); zephir_array_fast_append(_13, handledUri); zephir_array_fast_append(_13, route); zephir_array_fast_append(_13, this_ptr); ZEPHIR_INIT_NVAR(routeFound); ZEPHIR_CALL_USER_FUNC_ARRAY(routeFound, beforeMatch, _13); zephir_check_call_status(); } } else { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router:notMatchedRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeFound, eventsManager, "fire", &_14, 0, _3, this_ptr, route); zephir_check_temp_parameter(_3); zephir_check_call_status(); } } if (zephir_is_true(routeFound)) { ZEPHIR_CALL_METHOD(&paths, route, "getpaths", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(parts, paths); if (Z_TYPE_P(matches) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&converters, route, "getconverters", NULL, 0); zephir_check_call_status(); zephir_is_iterable(paths, &_16, &_15, 0, 0, "phalcon/mvc/router.zep", 546); for ( ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS ; zephir_hash_move_forward_ex(_16, &_15) ) { ZEPHIR_GET_HMKEY(part, _16, _15); ZEPHIR_GET_HVALUE(position, _17); ZEPHIR_OBS_NVAR(matchPosition); if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_3); ZEPHIR_INIT_NVAR(_13); zephir_create_array(_13, 1, 0 TSRMLS_CC); zephir_array_fast_append(_13, matchPosition); ZEPHIR_CALL_USER_FUNC_ARRAY(_3, converter, _13); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_3, PH_COPY | PH_SEPARATE); continue; } } zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(converters) == IS_ARRAY) { ZEPHIR_OBS_NVAR(converter); if (zephir_array_isset_fetch(&converter, converters, part, 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_18); ZEPHIR_INIT_NVAR(_19); zephir_create_array(_19, 1, 0 TSRMLS_CC); zephir_array_fast_append(_19, position); ZEPHIR_CALL_USER_FUNC_ARRAY(_18, converter, _19); zephir_check_call_status(); zephir_array_update_zval(&parts, part, &_18, PH_COPY | PH_SEPARATE); } } } } zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC); break; } } if (zephir_is_true(routeFound)) { if (1) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (0) { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_wasMatched"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } if (!(zephir_is_true(routeFound))) { ZEPHIR_OBS_VAR(notFoundPaths); zephir_read_property_this(¬FoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC); if (Z_TYPE_P(notFoundPaths) != IS_NULL) { ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", &_20, 78, notFoundPaths); zephir_check_call_status(); ZEPHIR_INIT_NVAR(routeFound); ZVAL_BOOL(routeFound, 1); } } _8 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_namespace"), _8 TSRMLS_CC); _21 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_module"), _21 TSRMLS_CC); _22 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_controller"), _22 TSRMLS_CC); _23 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_action"), _23 TSRMLS_CC); _24 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_params"), _24 TSRMLS_CC); if (zephir_is_true(routeFound)) { ZEPHIR_OBS_VAR(vnamespace); if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(vnamespace))) { zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC); } zephir_array_unset_string(&parts, SS("namespace"), PH_SEPARATE); } ZEPHIR_OBS_VAR(module); if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(module))) { zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); } zephir_array_unset_string(&parts, SS("module"), PH_SEPARATE); } ZEPHIR_OBS_VAR(controller); if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(controller))) { zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC); } zephir_array_unset_string(&parts, SS("controller"), PH_SEPARATE); } ZEPHIR_OBS_VAR(action); if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(action))) { zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); } zephir_array_unset_string(&parts, SS("action"), PH_SEPARATE); } ZEPHIR_OBS_VAR(paramsStr); if (zephir_array_isset_string_fetch(¶msStr, parts, SS("params"), 0 TSRMLS_CC)) { if (Z_TYPE_P(paramsStr) == IS_STRING) { ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "/", 0); ZEPHIR_INIT_VAR(strParams); zephir_fast_trim(strParams, paramsStr, &_2, ZEPHIR_TRIM_BOTH TSRMLS_CC); if (!ZEPHIR_IS_STRING_IDENTICAL(strParams, "")) { ZEPHIR_INIT_NVAR(params); zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC); } } zephir_array_unset_string(&parts, SS("params"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_3); zephir_fast_array_merge(_3, &(params), &(parts) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), _3 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_params"), parts TSRMLS_CC); } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router:afterCheckRoutes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _3, this_ptr); zephir_check_temp_parameter(_3); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router, add) { zval *_1; int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *httpMethods = NULL, *position = NULL, *route, *_0, *_2; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &pattern_param, &paths, &httpMethods, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!httpMethods) { httpMethods = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(route); object_init_ex(route, phalcon_mvc_router_route_ce); ZEPHIR_CALL_METHOD(NULL, route, "__construct", NULL, 77, pattern, paths, httpMethods); zephir_check_call_status(); do { if (ZEPHIR_IS_LONG(position, 1)) { zephir_update_property_array_append(this_ptr, SL("_routes"), route TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(position, 0)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1, route); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_fast_array_merge(_0, &(_1), &(_2) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), _0 TSRMLS_CC); break; } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Invalid route position", "phalcon/mvc/router.zep", 682); return; } while(0); RETURN_CCTOR(route); } static PHP_METHOD(Phalcon_Mvc_Router, addGet) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "GET", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addPost) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "POST", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addPut) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PUT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addPatch) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PATCH", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addDelete) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "DELETE", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addOptions) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "OPTIONS", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, addHead) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *position = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!position) { ZEPHIR_INIT_VAR(position); ZVAL_LONG(position, 1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HEAD", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, pattern, paths, _0, position); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router, mount) { HashTable *_1, *_4; HashPosition _0, _3; int ZEPHIR_LAST_CALL_STATUS; zval *group, *groupRoutes = NULL, *beforeMatch = NULL, *hostname = NULL, *routes, *route = NULL, **_2, **_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group); ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL, 0); zephir_check_call_status(); if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The group of routes does not contain any routes", "phalcon/mvc/router.zep", 753); return; } ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(beforeMatch) != IS_NULL) { zephir_is_iterable(groupRoutes, &_1, &_0, 0, 0, "phalcon/mvc/router.zep", 765); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(route, _2); ZEPHIR_CALL_METHOD(NULL, route, "beforematch", NULL, 0, beforeMatch); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(&hostname, group, "gethostname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(hostname) != IS_NULL) { zephir_is_iterable(groupRoutes, &_4, &_3, 0, 0, "phalcon/mvc/router.zep", 774); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(route, _5); ZEPHIR_CALL_METHOD(NULL, route, "sethostname", NULL, 0, hostname); zephir_check_call_status(); } } ZEPHIR_OBS_VAR(routes); zephir_read_property_this(&routes, this_ptr, SL("_routes"), PH_NOISY_CC); if (Z_TYPE_P(routes) == IS_ARRAY) { ZEPHIR_INIT_VAR(_6); zephir_fast_array_merge(_6, &(routes), &(groupRoutes) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), _6 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_routes"), groupRoutes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router, notFound) { zend_bool _0; zval *paths; zephir_fetch_params(0, 1, 0, &paths); _0 = Z_TYPE_P(paths) != IS_ARRAY; if (_0) { _0 = Z_TYPE_P(paths) != IS_STRING; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_router_exception_ce, "The not-found paths must be an array or string", "phalcon/mvc/router.zep", 793); return; } zephir_update_property_this(this_ptr, SL("_notFoundPaths"), paths TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router, clear) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_routes"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router, getNamespaceName) { RETURN_MEMBER(this_ptr, "_namespace"); } static PHP_METHOD(Phalcon_Mvc_Router, getModuleName) { RETURN_MEMBER(this_ptr, "_module"); } static PHP_METHOD(Phalcon_Mvc_Router, getControllerName) { RETURN_MEMBER(this_ptr, "_controller"); } static PHP_METHOD(Phalcon_Mvc_Router, getActionName) { RETURN_MEMBER(this_ptr, "_action"); } static PHP_METHOD(Phalcon_Mvc_Router, getParams) { RETURN_MEMBER(this_ptr, "_params"); } static PHP_METHOD(Phalcon_Mvc_Router, getMatchedRoute) { RETURN_MEMBER(this_ptr, "_matchedRoute"); } static PHP_METHOD(Phalcon_Mvc_Router, getMatches) { RETURN_MEMBER(this_ptr, "_matches"); } static PHP_METHOD(Phalcon_Mvc_Router, wasMatched) { RETURN_MEMBER(this_ptr, "_wasMatched"); } static PHP_METHOD(Phalcon_Mvc_Router, getRoutes) { RETURN_MEMBER(this_ptr, "_routes"); } static PHP_METHOD(Phalcon_Mvc_Router, getRouteById) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *id, *route = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/router.zep", 892); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_CALL_METHOD(&_4, route, "getrouteid", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_4, id)) { RETURN_CCTOR(route); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Router, getRouteByName) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *name_param = NULL, *route = NULL, *_0, **_3, *_4 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/router.zep", 907); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(route, _3); ZEPHIR_CALL_METHOD(&_4, route, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_4, name)) { RETURN_CCTOR(route); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Router, isExactControllerName) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_RouterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, RouterInterface, phalcon, mvc_routerinterface, phalcon_mvc_routerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultModule); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultController); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultAction); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaults); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, handle); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, add); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addGet); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPost); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPut); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPatch); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addDelete); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addOptions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addHead); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, mount); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, clear); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getModuleName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getNamespaceName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getControllerName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getActionName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getParams); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatchedRoute); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatches); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, wasMatched); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRoutes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteById); ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteByName); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc, Url, phalcon, mvc_url, phalcon_mvc_url_method_entry, 0); zend_declare_property_null(phalcon_mvc_url_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_url_ce, SL("_baseUri"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_url_ce, SL("_staticBaseUri"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_url_ce, SL("_basePath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_url_ce, SL("_router"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_url_ce TSRMLS_CC, 1, phalcon_mvc_urlinterface_ce); zend_class_implements(phalcon_mvc_url_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Url, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Url, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Url, setBaseUri) { zval *baseUri_param = NULL, *_0; zval *baseUri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &baseUri_param); if (unlikely(Z_TYPE_P(baseUri_param) != IS_STRING && Z_TYPE_P(baseUri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'baseUri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(baseUri_param) == IS_STRING)) { zephir_get_strval(baseUri, baseUri_param); } else { ZEPHIR_INIT_VAR(baseUri); ZVAL_EMPTY_STRING(baseUri); } zephir_update_property_this(this_ptr, SL("_baseUri"), baseUri TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_staticBaseUri"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { zephir_update_property_this(this_ptr, SL("_staticBaseUri"), baseUri TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Url, setStaticBaseUri) { zval *staticBaseUri_param = NULL; zval *staticBaseUri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &staticBaseUri_param); if (unlikely(Z_TYPE_P(staticBaseUri_param) != IS_STRING && Z_TYPE_P(staticBaseUri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'staticBaseUri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(staticBaseUri_param) == IS_STRING)) { zephir_get_strval(staticBaseUri, staticBaseUri_param); } else { ZEPHIR_INIT_VAR(staticBaseUri); ZVAL_EMPTY_STRING(staticBaseUri); } zephir_update_property_this(this_ptr, SL("_staticBaseUri"), staticBaseUri TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Url, getBaseUri) { zval *baseUri = NULL, *phpSelf, *uri = NULL, *_SERVER; ZEPHIR_MM_GROW(); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_OBS_VAR(baseUri); zephir_read_property_this(&baseUri, this_ptr, SL("_baseUri"), PH_NOISY_CC); if (Z_TYPE_P(baseUri) == IS_NULL) { ZEPHIR_OBS_VAR(phpSelf); if (zephir_array_isset_string_fetch(&phpSelf, _SERVER, SS("PHP_SELF"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(uri); phalcon_get_uri(uri, phpSelf); } else { ZEPHIR_INIT_NVAR(uri); ZVAL_NULL(uri); } ZEPHIR_INIT_NVAR(baseUri); if (!(zephir_is_true(uri))) { ZVAL_STRING(baseUri, "/", 1); } else { ZEPHIR_CONCAT_SVS(baseUri, "/", uri, "/"); } zephir_update_property_this(this_ptr, SL("_baseUri"), baseUri TSRMLS_CC); } RETURN_CCTOR(baseUri); } static PHP_METHOD(Phalcon_Mvc_Url, getStaticBaseUri) { int ZEPHIR_LAST_CALL_STATUS; zval *staticBaseUri; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(staticBaseUri); zephir_read_property_this(&staticBaseUri, this_ptr, SL("_staticBaseUri"), PH_NOISY_CC); if (Z_TYPE_P(staticBaseUri) != IS_NULL) { RETURN_CCTOR(staticBaseUri); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Url, setBasePath) { zval *basePath_param = NULL; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &basePath_param); if (unlikely(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(basePath_param) == IS_STRING)) { zephir_get_strval(basePath, basePath_param); } else { ZEPHIR_INIT_VAR(basePath); ZVAL_EMPTY_STRING(basePath); } zephir_update_property_this(this_ptr, SL("_basePath"), basePath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Url, getBasePath) { RETURN_MEMBER(this_ptr, "_basePath"); } static PHP_METHOD(Phalcon_Mvc_Url, get) { unsigned char _10, _12, _15; int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1, _11, _13, _14; zval *strUri = NULL, *_9 = NULL; zval *uri = NULL, *args = NULL, *local = NULL, *baseUri = NULL, *router = NULL, *dependencyInjector = NULL, *routeName, *route = NULL, *queryString = NULL, *_2, *_3 = NULL, _4 = zval_used_for_init, *_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_16; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 4, &uri, &args, &local, &baseUri); if (!uri) { ZEPHIR_CPY_WRT(uri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(uri); } if (!args) { args = ZEPHIR_GLOBAL(global_null); } if (!local) { ZEPHIR_CPY_WRT(local, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(local); } if (!baseUri) { ZEPHIR_CPY_WRT(baseUri, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(baseUri); } if (Z_TYPE_P(local) == IS_NULL) { _0 = Z_TYPE_P(uri) == IS_STRING; if (_0) { _1 = zephir_memnstr_str(uri, SL("//"), "phalcon/mvc/url.zep", 181); if (!(_1)) { _1 = zephir_memnstr_str(uri, SL(":"), "phalcon/mvc/url.zep", 181); } _0 = _1; } if (_0) { ZEPHIR_INIT_VAR(_2); ZEPHIR_INIT_VAR(_3); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "#^(//)|([a-z0-9]+://)|([a-z0-9]+:)#i", 0); zephir_preg_match(_3, &_4, uri, _2, 0, 0 , 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(local); if (zephir_is_true(_3)) { ZVAL_BOOL(local, 0); } else { ZVAL_BOOL(local, 1); } } else { ZEPHIR_INIT_NVAR(local); ZVAL_BOOL(local, 1); } } if (Z_TYPE_P(baseUri) != IS_STRING) { ZEPHIR_CALL_METHOD(&baseUri, this_ptr, "getbaseuri", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_ARRAY) { ZEPHIR_OBS_VAR(routeName); if (!(zephir_array_isset_string_fetch(&routeName, uri, SS("for"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/mvc/url.zep", 199); return; } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_router"), PH_NOISY_CC); ZEPHIR_CPY_WRT(router, _5); if (Z_TYPE_P(router) != IS_OBJECT) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _5); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the 'router' service", "phalcon/mvc/url.zep", 211); return; } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "router", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_6, dependencyInjector, "getshared", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(router, _6); zephir_update_property_this(this_ptr, SL("_router"), router TSRMLS_CC); } ZEPHIR_CALL_METHOD(&_6, router, "getroutebyname", NULL, 0, routeName); zephir_check_call_status(); ZEPHIR_CPY_WRT(route, _6); if (Z_TYPE_P(route) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_url_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Cannot obtain a route using the name '", routeName, "'"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/url.zep", 223 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_3); ZEPHIR_CALL_METHOD(&_6, route, "getpattern", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_8, route, "getreversedpaths", NULL, 0); zephir_check_call_status(); phalcon_replace_paths(_3, _6, _8, uri TSRMLS_CC); ZEPHIR_CPY_WRT(uri, _3); } if (zephir_is_true(local)) { zephir_get_strval(_9, uri); ZEPHIR_CPY_WRT(strUri, _9); _0 = ZEPHIR_IS_STRING(baseUri, "/"); if (_0) { _0 = zephir_fast_strlen_ev(strUri) > 2; } _1 = _0; if (_1) { _10 = ZEPHIR_STRING_OFFSET(strUri, 0); _1 = _10 == '/'; } _11 = _1; if (_11) { _12 = ZEPHIR_STRING_OFFSET(strUri, 1); _11 = _12 != '/'; } if (_11) { ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 1); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, strUri, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, _3); } else { _13 = ZEPHIR_IS_STRING(baseUri, "/"); if (_13) { _13 = zephir_fast_strlen_ev(strUri) == 1; } _14 = _13; if (_14) { _15 = ZEPHIR_STRING_OFFSET(strUri, 0); _14 = _15 == '/'; } if (_14) { ZEPHIR_CPY_WRT(uri, baseUri); } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, baseUri, strUri); } } } if (zephir_is_true(args)) { ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 363, args); zephir_check_call_status(); _0 = Z_TYPE_P(queryString) == IS_STRING; if (_0) { _0 = (zephir_fast_strlen_ev(queryString)) ? 1 : 0; } if (_0) { ZEPHIR_SINIT_NVAR(_4); ZVAL_STRING(&_4, "?", 0); ZEPHIR_INIT_NVAR(_3); zephir_fast_strpos(_3, uri, &_4, 0 ); if (!ZEPHIR_IS_FALSE_IDENTICAL(_3)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "&", queryString); zephir_concat_self(&uri, _7 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_16); ZEPHIR_CONCAT_SV(_16, "?", queryString); zephir_concat_self(&uri, _16 TSRMLS_CC); } } } RETVAL_ZVAL(uri, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Url, getStatic) { int ZEPHIR_LAST_CALL_STATUS; zval *uri = NULL, *_0 = NULL, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri); if (!uri) { uri = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getstaticbaseuri", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, uri, _1, _2, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Url, path) { zval *path_param = NULL, *_0; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &path_param); if (!path_param) { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } else { zephir_get_strval(path, path_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_basePath"), PH_NOISY_CC); ZEPHIR_CONCAT_VV(return_value, _0, path); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_UrlInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, UrlInterface, phalcon, mvc_urlinterface, phalcon_mvc_urlinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, setBaseUri); ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, getBaseUri); ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, setBasePath); ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, getBasePath); ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Mvc_UrlInterface, path); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, View, phalcon, mvc_view, phalcon_di_injectable_ce, phalcon_mvc_view_method_entry, 0); zend_declare_property_null(phalcon_mvc_view_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_view_ce, SL("_basePath"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_view_ce, SL("_content"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_ce, SL("_renderLevel"), 5, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_ce, SL("_currentRenderLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_disabledLevels"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_viewParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_layout"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_view_ce, SL("_layoutsDir"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_view_ce, SL("_partialsDir"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_viewsDir"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_templatesBefore"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_templatesAfter"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_ce, SL("_engines"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_registeredEngines"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_view_ce, SL("_mainView"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_controllerName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_actionName"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_pickView"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_ce, SL("_cacheLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_ce, SL("_activeRenderPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_ce, SL("_disabled"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_MAIN_LAYOUT"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_AFTER_TEMPLATE"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_LAYOUT"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_BEFORE_TEMPLATE"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_ACTION_VIEW"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_NO_RENDER"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("CACHE_MODE_NONE"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_view_ce, SL("CACHE_MODE_INVERSE"), 1 TSRMLS_CC); zend_class_implements(phalcon_mvc_view_ce TSRMLS_CC, 1, phalcon_mvc_viewinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View, getRenderLevel) { RETURN_MEMBER(this_ptr, "_renderLevel"); } static PHP_METHOD(Phalcon_Mvc_View, getCurrentRenderLevel) { RETURN_MEMBER(this_ptr, "_currentRenderLevel"); } static PHP_METHOD(Phalcon_Mvc_View, getRegisteredEngines) { RETURN_MEMBER(this_ptr, "_registeredEngines"); } static PHP_METHOD(Phalcon_Mvc_View, __construct) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_View, setViewsDir) { zval *viewsDir_param = NULL, _0, *_1; zval *viewsDir = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &viewsDir_param); zephir_get_strval(viewsDir, viewsDir_param); ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, -1); ZEPHIR_INIT_VAR(_1); zephir_substr(_1, viewsDir, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); if (!ZEPHIR_IS_STRING(_1, "/")) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VS(_2, viewsDir, "/"); ZEPHIR_CPY_WRT(viewsDir, _2); } zephir_update_property_this(this_ptr, SL("_viewsDir"), viewsDir TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getViewsDir) { RETURN_MEMBER(this_ptr, "_viewsDir"); } static PHP_METHOD(Phalcon_Mvc_View, setLayoutsDir) { zval *layoutsDir_param = NULL; zval *layoutsDir = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &layoutsDir_param); zephir_get_strval(layoutsDir, layoutsDir_param); zephir_update_property_this(this_ptr, SL("_layoutsDir"), layoutsDir TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getLayoutsDir) { RETURN_MEMBER(this_ptr, "_layoutsDir"); } static PHP_METHOD(Phalcon_Mvc_View, setPartialsDir) { zval *partialsDir_param = NULL; zval *partialsDir = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &partialsDir_param); zephir_get_strval(partialsDir, partialsDir_param); zephir_update_property_this(this_ptr, SL("_partialsDir"), partialsDir TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getPartialsDir) { RETURN_MEMBER(this_ptr, "_partialsDir"); } static PHP_METHOD(Phalcon_Mvc_View, setBasePath) { zval *basePath_param = NULL; zval *basePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &basePath_param); zephir_get_strval(basePath, basePath_param); zephir_update_property_this(this_ptr, SL("_basePath"), basePath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getBasePath) { RETURN_MEMBER(this_ptr, "_basePath"); } static PHP_METHOD(Phalcon_Mvc_View, setRenderLevel) { zval *level_param = NULL, *_0; int level; zephir_fetch_params(0, 1, 0, &level_param); level = zephir_get_intval(level_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, level); zephir_update_property_this(this_ptr, SL("_renderLevel"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, disableLevel) { zval *level; zephir_fetch_params(0, 1, 0, &level); if (Z_TYPE_P(level) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_disabledLevels"), level TSRMLS_CC); } else { zephir_update_property_array(this_ptr, SL("_disabledLevels"), level, ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, setMainView) { zval *viewPath_param = NULL; zval *viewPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &viewPath_param); zephir_get_strval(viewPath, viewPath_param); zephir_update_property_this(this_ptr, SL("_mainView"), viewPath TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getMainView) { RETURN_MEMBER(this_ptr, "_mainView"); } static PHP_METHOD(Phalcon_Mvc_View, setLayout) { zval *layout_param = NULL; zval *layout = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &layout_param); zephir_get_strval(layout, layout_param); zephir_update_property_this(this_ptr, SL("_layout"), layout TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getLayout) { RETURN_MEMBER(this_ptr, "_layout"); } static PHP_METHOD(Phalcon_Mvc_View, setTemplateBefore) { zval *_0; zval *templateBefore; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &templateBefore); if (Z_TYPE_P(templateBefore) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); zephir_array_fast_append(_0, templateBefore); zephir_update_property_this(this_ptr, SL("_templatesBefore"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_templatesBefore"), templateBefore TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateBefore) { zephir_update_property_this(this_ptr, SL("_templatesBefore"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, setTemplateAfter) { zval *_0; zval *templateAfter; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &templateAfter); if (Z_TYPE_P(templateAfter) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); zephir_array_fast_append(_0, templateAfter); zephir_update_property_this(this_ptr, SL("_templatesAfter"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_templatesAfter"), templateAfter TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateAfter) { zephir_update_property_this(this_ptr, SL("_templatesAfter"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, setParamToView) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, setVars) { zend_bool merge; zval *params_param = NULL, *merge_param = NULL, *viewParams, *_0; zval *params = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, ¶ms_param, &merge_param); params = params_param; if (!merge_param) { merge = 1; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (Z_TYPE_P(viewParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(viewParams), &(params) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_viewParams"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_viewParams"), params TSRMLS_CC); } } else { zephir_update_property_this(this_ptr, SL("_viewParams"), params TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, setVar) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getVar) { zval *key_param = NULL, *params, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } params = zephir_fetch_nproperty_this(this_ptr, SL("_viewParams"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, params, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_View, getParamsToView) { RETURN_MEMBER(this_ptr, "_viewParams"); } static PHP_METHOD(Phalcon_Mvc_View, getControllerName) { RETURN_MEMBER(this_ptr, "_controllerName"); } static PHP_METHOD(Phalcon_Mvc_View, getActionName) { RETURN_MEMBER(this_ptr, "_actionName"); } static PHP_METHOD(Phalcon_Mvc_View, getParams) { RETURN_MEMBER(this_ptr, "_params"); } static PHP_METHOD(Phalcon_Mvc_View, start) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_content"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, _loadTemplateEngines) { zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *engines = NULL, *dependencyInjector = NULL, *registeredEngines, *arguments, *engineService = NULL, *extension = NULL, *_0, *_1 = NULL, **_4, *_5 = NULL, *_6 = NULL, *_8 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(engines); zephir_read_property_this(&engines, this_ptr, SL("_engines"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(engines)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); ZEPHIR_INIT_NVAR(engines); array_init(engines); ZEPHIR_OBS_VAR(registeredEngines); zephir_read_property_this(®isteredEngines, this_ptr, SL("_registeredEngines"), PH_NOISY_CC); if (Z_TYPE_P(registeredEngines) != IS_ARRAY) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_view_engine_php_ce); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 364, this_ptr, dependencyInjector); zephir_check_call_status(); zephir_array_update_string(&engines, SL(".phtml"), &_1, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injector container is required to obtain the application services", "phalcon/mvc/view.zep", 526); return; } ZEPHIR_INIT_VAR(arguments); zephir_create_array(arguments, 2, 0 TSRMLS_CC); zephir_array_fast_append(arguments, this_ptr); zephir_array_fast_append(arguments, dependencyInjector); zephir_is_iterable(registeredEngines, &_3, &_2, 0, 0, "phalcon/mvc/view.zep", 555); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(extension, _3, _2); ZEPHIR_GET_HVALUE(engineService, _4); if (Z_TYPE_P(engineService) == IS_OBJECT) { if (zephir_instance_of_ev(engineService, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_CALL_USER_FUNC_ARRAY(_1, engineService, arguments); zephir_check_call_status(); zephir_array_update_zval(&engines, extension, &_1, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&engines, extension, &engineService, PH_COPY | PH_SEPARATE); } } else { if (Z_TYPE_P(engineService) != IS_STRING) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Invalid template engine registration for extension: ", extension); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/view.zep", 549 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&_8, dependencyInjector, "getshared", &_9, 0, engineService, arguments); zephir_check_call_status(); zephir_array_update_zval(&engines, extension, &_8, PH_COPY | PH_SEPARATE); } } } zephir_update_property_this(this_ptr, SL("_engines"), engines TSRMLS_CC); } RETURN_CCTOR(engines); } static PHP_METHOD(Phalcon_Mvc_View, _engineRender) { zephir_fcall_cache_entry *_9 = NULL, *_11 = NULL; HashTable *_6; HashPosition _5; int renderLevel, cacheLevel, ZEPHIR_LAST_CALL_STATUS; zend_bool silence, mustClean, notExists; zval *viewPath = NULL; zval *engines, *viewPath_param = NULL, *silence_param = NULL, *mustClean_param = NULL, *cache = NULL, *key = NULL, *lifetime = NULL, *viewsDir, *basePath, *viewsDirPath, *viewOptions, *cacheOptions, *cachedView = NULL, *viewParams, *eventsManager = NULL, *extension = NULL, *engine = NULL, *viewEnginePath = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, **_7, *_8 = NULL, *_10 = NULL, *_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &engines, &viewPath_param, &silence_param, &mustClean_param, &cache); zephir_get_strval(viewPath, viewPath_param); silence = zephir_get_boolval(silence_param); mustClean = zephir_get_boolval(mustClean_param); if (!cache) { cache = ZEPHIR_GLOBAL(global_null); } notExists = 1; ZEPHIR_OBS_VAR(viewsDir); zephir_read_property_this(&viewsDir, this_ptr, SL("_viewsDir"), PH_NOISY_CC); ZEPHIR_OBS_VAR(basePath); zephir_read_property_this(&basePath, this_ptr, SL("_basePath"), PH_NOISY_CC); ZEPHIR_INIT_VAR(viewsDirPath); ZEPHIR_CONCAT_VVV(viewsDirPath, basePath, viewsDir, viewPath); if (Z_TYPE_P(cache) == IS_OBJECT) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_renderLevel"), PH_NOISY_CC); renderLevel = zephir_get_intval(_0); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_cacheLevel"), PH_NOISY_CC); cacheLevel = zephir_get_intval(_1); if (renderLevel >= cacheLevel) { ZEPHIR_CALL_METHOD(&_2, cache, "isstarted", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE(_2)) { ZEPHIR_INIT_VAR(key); ZVAL_NULL(key); ZEPHIR_INIT_VAR(lifetime); ZVAL_NULL(lifetime); ZEPHIR_OBS_VAR(viewOptions); zephir_read_property_this(&viewOptions, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(viewOptions) == IS_ARRAY) { ZEPHIR_OBS_VAR(cacheOptions); if (zephir_array_isset_string_fetch(&cacheOptions, viewOptions, SS("cache"), 0 TSRMLS_CC)) { if (Z_TYPE_P(cacheOptions) == IS_ARRAY) { ZEPHIR_OBS_NVAR(key); zephir_array_isset_string_fetch(&key, cacheOptions, SS("key"), 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(lifetime); zephir_array_isset_string_fetch(&lifetime, cacheOptions, SS("lifetime"), 0 TSRMLS_CC); } } } if (Z_TYPE_P(key) == IS_NULL) { ZEPHIR_INIT_NVAR(key); zephir_md5(key, viewPath); } ZEPHIR_CALL_METHOD(&cachedView, cache, "start", NULL, 0, key, lifetime); zephir_check_call_status(); if (Z_TYPE_P(cachedView) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_content"), cachedView TSRMLS_CC); RETURN_MM_NULL(); } } ZEPHIR_CALL_METHOD(&_3, cache, "isfresh", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_3))) { RETURN_MM_NULL(); } } } ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _4); zephir_is_iterable(engines, &_6, &_5, 0, 0, "phalcon/mvc/view.zep", 673); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HMKEY(extension, _6, _5); ZEPHIR_GET_HVALUE(engine, _7); ZEPHIR_INIT_NVAR(viewEnginePath); ZEPHIR_CONCAT_VV(viewEnginePath, viewsDirPath, extension); if ((zephir_file_exists(viewEnginePath TSRMLS_CC) == SUCCESS)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_activeRenderPath"), viewEnginePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "view:beforeRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, eventsManager, "fire", &_9, 0, _8, this_ptr, viewEnginePath); zephir_check_temp_parameter(_8); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_2)) { continue; } } ZEPHIR_INIT_NVAR(_8); if (mustClean) { ZVAL_BOOL(_8, 1); } else { ZVAL_BOOL(_8, 0); } ZEPHIR_CALL_METHOD(NULL, engine, "render", NULL, 0, viewEnginePath, viewParams, _8); zephir_check_call_status(); notExists = 0; if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "view:afterRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_11, 0, _10, this_ptr); zephir_check_temp_parameter(_10); zephir_check_call_status(); } break; } } if (notExists == 1) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_activeRenderPath"), viewEnginePath TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); ZVAL_STRING(_8, "view:notFoundView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _8, this_ptr, viewEnginePath); zephir_check_temp_parameter(_8); zephir_check_call_status(); } if (!(silence)) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_VAR(_12); ZEPHIR_CONCAT_SVS(_12, "View '", viewsDirPath, "' was not found in the views directory"); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _12); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/view.zep", 684 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View, registerEngines) { zval *engines_param = NULL; zval *engines = NULL; zephir_fetch_params(0, 1, 0, &engines_param); engines = engines_param; zephir_update_property_this(this_ptr, SL("_registeredEngines"), engines TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, exists) { HashTable *_2; HashPosition _1; zend_bool exists; zval *view_param = NULL, *basePath, *viewsDir, *engines = NULL, *extension = NULL, *_0 = NULL, **_3, *_4 = NULL; zval *view = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &view_param); if (unlikely(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(view_param) == IS_STRING)) { zephir_get_strval(view, view_param); } else { ZEPHIR_INIT_VAR(view); ZVAL_EMPTY_STRING(view); } ZEPHIR_OBS_VAR(basePath); zephir_read_property_this(&basePath, this_ptr, SL("_basePath"), PH_NOISY_CC); ZEPHIR_OBS_VAR(viewsDir); zephir_read_property_this(&viewsDir, this_ptr, SL("_viewsDir"), PH_NOISY_CC); ZEPHIR_OBS_VAR(engines); zephir_read_property_this(&engines, this_ptr, SL("_registeredEngines"), PH_NOISY_CC); if (Z_TYPE_P(engines) != IS_ARRAY) { ZEPHIR_INIT_NVAR(engines); array_init(engines); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Phalcon\\Mvc\\View\\Engine\\Php", 1); zephir_array_update_string(&engines, SL(".phtml"), &_0, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_registeredEngines"), engines TSRMLS_CC); } exists = 0; ZEPHIR_INIT_NVAR(_0); zephir_is_iterable(engines, &_2, &_1, 0, 0, "phalcon/mvc/view.zep", 732); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(extension, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VVVV(_4, basePath, viewsDir, view, extension); exists = (zephir_file_exists(_4 TSRMLS_CC) == SUCCESS); if (exists) { break; } } RETURN_MM_BOOL(exists); } static PHP_METHOD(Phalcon_Mvc_View, render) { HashTable *_12, *_17; HashPosition _11, _16; zephir_fcall_cache_entry *_2 = NULL, *_10 = NULL; int renderLevel, ZEPHIR_LAST_CALL_STATUS; zend_bool silence, mustClean; zval *controllerName_param = NULL, *actionName_param = NULL, *params = NULL, *layoutsDir = NULL, *layout, *pickView, *layoutName = NULL, *engines = NULL, *renderView = NULL, *pickViewAction, *eventsManager = NULL, *disabledLevels, *templatesBefore, *templatesAfter, *templateBefore = NULL, *templateAfter = NULL, *cache = NULL, *_0, *_1 = NULL, *_4, *_5, *_6, *_7 = NULL, *_8, *_9 = NULL, **_13, *_14 = NULL, *_15 = NULL, **_18, *_19 = NULL, *_20 = NULL, *_21, *_22 = NULL, *_23 = NULL; zval *controllerName = NULL, *actionName = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms); if (unlikely(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerName_param) == IS_STRING)) { zephir_get_strval(controllerName, controllerName_param); } else { ZEPHIR_INIT_VAR(controllerName); ZVAL_EMPTY_STRING(controllerName); } if (unlikely(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(actionName_param) == IS_STRING)) { zephir_get_strval(actionName, actionName_param); } else { ZEPHIR_INIT_VAR(actionName); ZVAL_EMPTY_STRING(actionName); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _0 TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_disabled"), PH_NOISY_CC); if (!ZEPHIR_IS_FALSE(_0)) { ZEPHIR_CALL_FUNCTION(&_1, "ob_get_contents", &_2, 120); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_content"), _1 TSRMLS_CC); RETURN_MM_BOOL(0); } zephir_update_property_this(this_ptr, SL("_controllerName"), controllerName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_actionName"), actionName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); ZEPHIR_OBS_VAR(layoutsDir); zephir_read_property_this(&layoutsDir, this_ptr, SL("_layoutsDir"), PH_NOISY_CC); if (!(zephir_is_true(layoutsDir))) { ZEPHIR_INIT_NVAR(layoutsDir); ZVAL_STRING(layoutsDir, "layouts/", 1); } ZEPHIR_OBS_VAR(layout); zephir_read_property_this(&layout, this_ptr, SL("_layout"), PH_NOISY_CC); if (zephir_is_true(layout)) { ZEPHIR_CPY_WRT(layoutName, layout); } else { ZEPHIR_CPY_WRT(layoutName, controllerName); } ZEPHIR_CALL_METHOD(&engines, this_ptr, "_loadtemplateengines", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(pickView); zephir_read_property_this(&pickView, this_ptr, SL("_pickView"), PH_NOISY_CC); if (Z_TYPE_P(pickView) == IS_NULL) { ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VSV(_3, controllerName, "/", actionName); ZEPHIR_CPY_WRT(renderView, _3); } else { ZEPHIR_OBS_NVAR(renderView); zephir_array_fetch_long(&renderView, pickView, 0, PH_NOISY, "phalcon/mvc/view.zep", 805 TSRMLS_CC); ZEPHIR_OBS_VAR(pickViewAction); if (zephir_array_isset_long_fetch(&pickViewAction, pickView, 1, 0 TSRMLS_CC)) { ZEPHIR_CPY_WRT(layoutName, pickViewAction); } } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_cacheLevel"), PH_NOISY_CC); if (zephir_is_true(_4)) { ZEPHIR_CALL_METHOD(&cache, this_ptr, "getcache", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(cache); ZVAL_NULL(cache); } _5 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _5); ZEPHIR_INIT_VAR(_6); zephir_create_symbol_table(TSRMLS_C); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "view:beforeRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, 0, _7, this_ptr); zephir_check_temp_parameter(_7); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { RETURN_MM_BOOL(0); } } ZEPHIR_CALL_FUNCTION(&_1, "ob_get_contents", &_2, 120); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_content"), _1 TSRMLS_CC); mustClean = 1; silence = 1; ZEPHIR_OBS_VAR(disabledLevels); zephir_read_property_this(&disabledLevels, this_ptr, SL("_disabledLevels"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_8); zephir_read_property_this(&_8, this_ptr, SL("_renderLevel"), PH_NOISY_CC); renderLevel = zephir_get_intval(_8); if (renderLevel) { if (renderLevel >= 1) { if (!(zephir_array_isset_long(disabledLevels, 1))) { ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 1); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _5 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); if (silence) { ZVAL_BOOL(_7, 1); } else { ZVAL_BOOL(_7, 0); } ZEPHIR_INIT_VAR(_9); if (mustClean) { ZVAL_BOOL(_9, 1); } else { ZVAL_BOOL(_9, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", &_10, 0, engines, renderView, _7, _9, cache); zephir_check_call_status(); } } if (renderLevel >= 2) { if (!(zephir_array_isset_long(disabledLevels, 2))) { ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 2); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _5 TSRMLS_CC); ZEPHIR_OBS_VAR(templatesBefore); zephir_read_property_this(&templatesBefore, this_ptr, SL("_templatesBefore"), PH_NOISY_CC); if (Z_TYPE_P(templatesBefore) == IS_ARRAY) { silence = 0; zephir_is_iterable(templatesBefore, &_12, &_11, 0, 0, "phalcon/mvc/view.zep", 881); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HVALUE(templateBefore, _13); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, layoutsDir, templateBefore); ZEPHIR_INIT_NVAR(_9); if (silence) { ZVAL_BOOL(_9, 1); } else { ZVAL_BOOL(_9, 0); } ZEPHIR_INIT_NVAR(_15); if (mustClean) { ZVAL_BOOL(_15, 1); } else { ZVAL_BOOL(_15, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", &_10, 0, engines, _14, _9, _15, cache); zephir_check_call_status(); } silence = 1; } } } if (renderLevel >= 3) { if (!(zephir_array_isset_long(disabledLevels, 3))) { ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 3); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _5 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_VV(_14, layoutsDir, layoutName); ZEPHIR_INIT_NVAR(_9); if (silence) { ZVAL_BOOL(_9, 1); } else { ZVAL_BOOL(_9, 0); } ZEPHIR_INIT_NVAR(_15); if (mustClean) { ZVAL_BOOL(_15, 1); } else { ZVAL_BOOL(_15, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", &_10, 0, engines, _14, _9, _15, cache); zephir_check_call_status(); } } if (renderLevel >= 4) { if (!(zephir_array_isset_long(disabledLevels, 4))) { ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 4); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _5 TSRMLS_CC); ZEPHIR_OBS_VAR(templatesAfter); zephir_read_property_this(&templatesAfter, this_ptr, SL("_templatesAfter"), PH_NOISY_CC); if (Z_TYPE_P(templatesAfter) == IS_ARRAY) { silence = 0; zephir_is_iterable(templatesAfter, &_17, &_16, 0, 0, "phalcon/mvc/view.zep", 912); for ( ; zephir_hash_get_current_data_ex(_17, (void**) &_18, &_16) == SUCCESS ; zephir_hash_move_forward_ex(_17, &_16) ) { ZEPHIR_GET_HVALUE(templateAfter, _18); ZEPHIR_INIT_LNVAR(_19); ZEPHIR_CONCAT_VV(_19, layoutsDir, templateAfter); ZEPHIR_INIT_NVAR(_9); if (silence) { ZVAL_BOOL(_9, 1); } else { ZVAL_BOOL(_9, 0); } ZEPHIR_INIT_NVAR(_20); if (mustClean) { ZVAL_BOOL(_20, 1); } else { ZVAL_BOOL(_20, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", &_10, 0, engines, _19, _9, _20, cache); zephir_check_call_status(); } silence = 1; } } } if (renderLevel >= 5) { if (!(zephir_array_isset_long(disabledLevels, 5))) { ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 5); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _5 TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_mainView"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_9); if (silence) { ZVAL_BOOL(_9, 1); } else { ZVAL_BOOL(_9, 0); } ZEPHIR_INIT_NVAR(_15); if (mustClean) { ZVAL_BOOL(_15, 1); } else { ZVAL_BOOL(_15, 0); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", &_10, 0, engines, _5, _9, _15, cache); zephir_check_call_status(); } } ZEPHIR_INIT_ZVAL_NREF(_21); ZVAL_LONG(_21, 0); zephir_update_property_this(this_ptr, SL("_currentRenderLevel"), _21 TSRMLS_CC); if (Z_TYPE_P(cache) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_22, cache, "isstarted", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(_22)) { ZEPHIR_CALL_METHOD(&_23, cache, "isfresh", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE(_23)) { ZEPHIR_CALL_METHOD(NULL, cache, "save", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, cache, "stop", NULL, 0); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, cache, "stop", NULL, 0); zephir_check_call_status(); } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "view:afterRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _7, this_ptr); zephir_check_temp_parameter(_7); zephir_check_call_status(); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, pick) { zval *renderView, *pickView = NULL, *layout = NULL, *parts; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &renderView); if (Z_TYPE_P(renderView) == IS_ARRAY) { ZEPHIR_CPY_WRT(pickView, renderView); } else { ZEPHIR_INIT_VAR(layout); ZVAL_NULL(layout); if (zephir_memnstr_str(renderView, SL("/"), "phalcon/mvc/view.zep", 985)) { ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("/"), renderView, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_NVAR(layout); zephir_array_fetch_long(&layout, parts, 0, PH_NOISY, "phalcon/mvc/view.zep", 986 TSRMLS_CC); } ZEPHIR_INIT_NVAR(pickView); zephir_create_array(pickView, 1, 0 TSRMLS_CC); zephir_array_fast_append(pickView, renderView); if (Z_TYPE_P(layout) != IS_NULL) { zephir_array_append(&pickView, layout, PH_SEPARATE, "phalcon/mvc/view.zep", 991); } } zephir_update_property_this(this_ptr, SL("_pickView"), pickView TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getPartial) { int ZEPHIR_LAST_CALL_STATUS; zval *partialPath_param = NULL, *params = NULL; zval *partialPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); if (unlikely(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(partialPath_param) == IS_STRING)) { zephir_get_strval(partialPath, partialPath_param); } else { ZEPHIR_INIT_VAR(partialPath); ZVAL_EMPTY_STRING(partialPath); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "partial", NULL, 0, partialPath, params); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 284); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View, partial) { int ZEPHIR_LAST_CALL_STATUS; zval *partialPath_param = NULL, *params = NULL, *viewParams, *_0 = NULL, *_1 = NULL, *_2, *_3, *_4, *_5; zval *partialPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); if (unlikely(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(partialPath_param) == IS_STRING)) { zephir_get_strval(partialPath, partialPath_param); } else { ZEPHIR_INIT_VAR(partialPath); ZVAL_EMPTY_STRING(partialPath); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(params) == IS_ARRAY) { ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (Z_TYPE_P(viewParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(viewParams), &(params) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_viewParams"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_viewParams"), params TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); zephir_create_symbol_table(TSRMLS_C); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "_loadtemplateengines", NULL, 0); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_partialsDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_VV(_3, _2, partialPath); ZEPHIR_INIT_VAR(_4); ZVAL_BOOL(_4, 0); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_enginerender", NULL, 0, _1, _3, _4, _5); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_viewParams"), viewParams TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View, getRender) { zval *_1; int ZEPHIR_LAST_CALL_STATUS; zval *controllerName_param = NULL, *actionName_param = NULL, *params = NULL, *configCallback = NULL, *view, *_0; zval *controllerName = NULL, *actionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms, &configCallback); if (unlikely(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerName_param) == IS_STRING)) { zephir_get_strval(controllerName, controllerName_param); } else { ZEPHIR_INIT_VAR(controllerName); ZVAL_EMPTY_STRING(controllerName); } if (unlikely(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(actionName_param) == IS_STRING)) { zephir_get_strval(actionName, actionName_param); } else { ZEPHIR_INIT_VAR(actionName); ZVAL_EMPTY_STRING(actionName); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } if (!configCallback) { configCallback = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(view); if (zephir_clone(view, this_ptr TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, view, "reset", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, view, "setvars", NULL, 0, params); zephir_check_call_status(); } if (Z_TYPE_P(configCallback) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1, view); ZEPHIR_CALL_USER_FUNC_ARRAY(_0, configCallback, _1); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, view, "start", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, view, "render", NULL, 0, controllerName, actionName); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(view, "getcontent", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View, finish) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, _createCache) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector = NULL, *cacheService = NULL, *viewCache = NULL, *viewOptions, *cacheOptions, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injector container is required to obtain the view cache services", "phalcon/mvc/view.zep", 1165); return; } ZEPHIR_INIT_VAR(cacheService); ZVAL_STRING(cacheService, "viewCache", 1); ZEPHIR_OBS_VAR(viewOptions); zephir_read_property_this(&viewOptions, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(viewOptions) == IS_ARRAY) { ZEPHIR_OBS_VAR(cacheOptions); if (zephir_array_isset_string_fetch(&cacheOptions, viewOptions, SS("cache"), 0 TSRMLS_CC)) { if (zephir_array_isset_string(cacheOptions, SS("service"))) { ZEPHIR_OBS_NVAR(cacheService); zephir_array_fetch_string(&cacheService, cacheOptions, SL("service"), PH_NOISY, "phalcon/mvc/view.zep", 1174 TSRMLS_CC); } } } ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, 0, cacheService); zephir_check_call_status(); ZEPHIR_CPY_WRT(viewCache, _1); if (Z_TYPE_P(viewCache) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "The injected caching service is invalid", "phalcon/mvc/view.zep", 1184); return; } RETURN_CCTOR(viewCache); } static PHP_METHOD(Phalcon_Mvc_View, isCaching) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cacheLevel"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_GT_LONG(_0, 0)); } static PHP_METHOD(Phalcon_Mvc_View, getCache) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *cache = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(cache); zephir_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC); if (zephir_is_true(cache)) { if (Z_TYPE_P(cache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(&cache, this_ptr, "_createcache", &_0, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } } else { ZEPHIR_CALL_METHOD(&cache, this_ptr, "_createcache", &_0, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } RETURN_CCTOR(cache); } static PHP_METHOD(Phalcon_Mvc_View, cache) { HashTable *_1; HashPosition _0; zval *options = NULL, *viewOptions = NULL, *cacheOptions = NULL, *key = NULL, *value = NULL, *cacheLevel, **_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_true); } if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_VAR(viewOptions); zephir_read_property_this(&viewOptions, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(viewOptions) != IS_ARRAY) { ZEPHIR_INIT_NVAR(viewOptions); array_init(viewOptions); } ZEPHIR_OBS_VAR(cacheOptions); if (!(zephir_array_isset_string_fetch(&cacheOptions, viewOptions, SS("cache"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(cacheOptions); array_init(cacheOptions); } zephir_is_iterable(options, &_1, &_0, 0, 0, "phalcon/mvc/view.zep", 1252); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); zephir_array_update_zval(&cacheOptions, key, &value, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&cacheLevel, cacheOptions, SS("level"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_cacheLevel"), cacheLevel TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 5); zephir_update_property_this(this_ptr, SL("_cacheLevel"), _3 TSRMLS_CC); } zephir_array_update_string(&viewOptions, SL("cache"), &cacheOptions, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_options"), viewOptions TSRMLS_CC); } else { if (zephir_is_true(options)) { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 5); zephir_update_property_this(this_ptr, SL("_cacheLevel"), _3 TSRMLS_CC); } else { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, 0); zephir_update_property_this(this_ptr, SL("_cacheLevel"), _3 TSRMLS_CC); } } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, setContent) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); zephir_get_strval(content, content_param); zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View, getContent) { RETURN_MEMBER(this_ptr, "_content"); } static PHP_METHOD(Phalcon_Mvc_View, getActiveRenderPath) { RETURN_MEMBER(this_ptr, "_activeRenderPath"); } static PHP_METHOD(Phalcon_Mvc_View, disable) { if (1) { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, enable) { if (0) { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, reset) { zval *_0; if (0) { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_disabled"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (0) { zephir_update_property_this(this_ptr, SL("_engines"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_engines"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 5); zephir_update_property_this(this_ptr, SL("_renderLevel"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_cacheLevel"), _0 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_content"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_templatesBefore"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_templatesAfter"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View, __set) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View, __get) { zval *key_param = NULL, *value, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_viewParams"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_View, isDisabled) { RETURN_MEMBER(this_ptr, "_disabled"); } static PHP_METHOD(Phalcon_Mvc_View, __isset) { zval *key_param = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_viewParams"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, key)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewBaseInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewBaseInterface, phalcon, mvc_viewbaseinterface, phalcon_mvc_viewbaseinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setViewsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getViewsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setParamToView); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setVar); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getParamsToView); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getCache); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, cache); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setContent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getContent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, partial); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewInterface, phalcon, mvc_viewinterface, phalcon_mvc_viewinterface_method_entry); zend_class_implements(phalcon_mvc_viewinterface_ce TSRMLS_CC, 1, phalcon_mvc_viewbaseinterface_ce); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayoutsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayoutsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setPartialsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getPartialsDir); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setBasePath); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getBasePath); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setRenderLevel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setMainView); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getMainView); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayout); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayout); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateBefore); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateBefore); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateAfter); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateAfter); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getControllerName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActionName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getParams); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, start); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, registerEngines); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, render); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, pick); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, finish); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActiveRenderPath); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, disable); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, enable); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, reset); ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, isDisabled); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Application, Exception, phalcon, mvc_application_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Behavior, phalcon, mvc_collection_behavior, phalcon_mvc_collection_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_collection_behavior_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior, __construct) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior, mustTakeAction) { zval *eventName_param = NULL, *_0; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, eventName)); } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior, getOptions) { zval *eventName_param = NULL, *options, *eventOptions; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &eventName_param); if (!eventName_param) { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } else { if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } } options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!ZEPHIR_IS_STRING_IDENTICAL(eventName, "")) { if (zephir_array_isset_fetch(&eventOptions, options, eventName, 1 TSRMLS_CC)) { RETURN_CTOR(eventOptions); } RETURN_MM_NULL(); } RETURN_CTOR(options); } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior, notify) { zval *type_param = NULL, *model; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); zephir_get_strval(type, type_param); RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior, missingMethod) { zval *method = NULL; zval *model, *method_param = NULL, *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments); zephir_get_strval(method, method_param); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } RETURN_MM_NULL(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_BehaviorInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Collection, BehaviorInterface, phalcon, mvc_collection_behaviorinterface, phalcon_mvc_collection_behaviorinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_BehaviorInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_BehaviorInterface, notify); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_BehaviorInterface, missingMethod); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Document) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Document, phalcon, mvc_collection_document, phalcon_mvc_collection_document_method_entry, 0); zend_class_implements(phalcon_mvc_collection_document_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); zend_class_implements(phalcon_mvc_collection_document_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetExists) { zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } RETURN_MM_BOOL(zephir_isset_property_zval(this_ptr, index TSRMLS_CC)); } static PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetGet) { zval *index_param = NULL, *value; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, this_ptr, index, PH_SILENT_CC)) { RETURN_CCTOR(value); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The index does not exist in the row", "phalcon/mvc/collection/document.zep", 53); return; } static PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetSet) { zval *index_param = NULL, *value; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &index_param, &value); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } zephir_update_property_zval_zval(this_ptr, index, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetUnset) { zval *offset; zephir_fetch_params(0, 1, 0, &offset); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_collection_exception_ce, "The index does not exist in the row", "phalcon/mvc/collection/document.zep", 71); return; } static PHP_METHOD(Phalcon_Mvc_Collection_Document, readAttribute) { zval *attribute, *value; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attribute); ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attribute, PH_SILENT_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Collection_Document, writeAttribute) { zval *attribute_param = NULL, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &attribute_param, &value); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } zephir_update_property_zval_zval(this_ptr, attribute, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Document, toArray) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection, Exception, phalcon, mvc_collection_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Manager, phalcon, mvc_collection_manager, phalcon_mvc_collection_manager_method_entry, 0); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_initialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_lastInitialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_customEventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_connectionServices"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_implicitObjectsIds"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("_behaviors"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_collection_manager_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_mvc_collection_manager_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, setCustomEventsManager) { zval *model, *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &eventsManager); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 0 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_customEventsManager"), _0, eventsManager TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, getCustomEventsManager) { zval *model, *customEventsManager, *className, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_OBS_VAR(customEventsManager); zephir_read_property_this(&customEventsManager, this_ptr, SL("_customEventsManager"), PH_NOISY_CC); if (Z_TYPE_P(customEventsManager) == IS_ARRAY) { ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 1 TSRMLS_CC); if (zephir_array_isset(customEventsManager, className)) { zephir_array_fetch(&_0, customEventsManager, className, PH_NOISY | PH_READONLY, "phalcon/mvc/collection/manager.zep", 120 TSRMLS_CC); RETURN_CTOR(_0); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, initialize) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *className, *initialized, *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(initialized); zephir_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(initialized, className))) { if ((zephir_method_exists_ex(model, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "collectionManager:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _0, model); zephir_check_temp_parameter(_0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_initialized"), className, model TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_lastInitialized"), model TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized) { zval *modelName_param = NULL, *_0, *_1; zval *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &modelName_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelName); RETURN_MM_BOOL(zephir_array_isset(_0, _1)); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, getLastInitialized) { RETURN_MEMBER(this_ptr, "_lastInitialized"); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, setConnectionService) { zval *connectionService = NULL; zval *model, *connectionService_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 0 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_connectionServices"), _0, connectionService TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, useImplicitObjectIds) { zend_bool useImplicitObjectIds; zval *model, *useImplicitObjectIds_param = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &useImplicitObjectIds_param); useImplicitObjectIds = zephir_get_boolval(useImplicitObjectIds_param); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, useImplicitObjectIds); zephir_update_property_array(this_ptr, SL("_implicitObjectsIds"), _0, _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, isUsingImplicitObjectIds) { zval *model, *implicit, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_implicitObjectsIds"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_get_class(_1, model, 0 TSRMLS_CC); if (zephir_array_isset_fetch(&implicit, _0, _1, 1 TSRMLS_CC)) { RETURN_CTOR(implicit); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, getConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *service = NULL, *connectionService, *connection = NULL, *dependencyInjector, *entityName; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(service); ZVAL_STRING(service, "mongo", 1); ZEPHIR_OBS_VAR(connectionService); zephir_read_property_this(&connectionService, this_ptr, SL("_connectionServices"), PH_NOISY_CC); if (Z_TYPE_P(connectionService) == IS_ARRAY) { ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 0 TSRMLS_CC); if (zephir_array_isset(connectionService, entityName)) { ZEPHIR_OBS_NVAR(service); zephir_array_fetch(&service, connectionService, entityName, PH_NOISY, "phalcon/mvc/collection/manager.zep", 228 TSRMLS_CC); } } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/collection/manager.zep", 234); return; } ZEPHIR_CALL_METHOD(&connection, dependencyInjector, "getshared", NULL, 0, service); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Invalid injected connection service", "phalcon/mvc/collection/manager.zep", 242); return; } RETURN_CCTOR(connection); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, notifyEvent) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *eventName_param = NULL, *model, *behavior = NULL, *behaviors, *modelsBehaviors, *eventsManager, *status = NULL, *customEventsManager, *_0 = NULL, **_3; zval *eventName = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &eventName_param, &model); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); ZEPHIR_OBS_VAR(behaviors); zephir_read_property_this(&behaviors, this_ptr, SL("_behaviors"), PH_NOISY_CC); if (Z_TYPE_P(behaviors) == IS_ARRAY) { ZEPHIR_OBS_VAR(modelsBehaviors); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&modelsBehaviors, behaviors, _0, 0 TSRMLS_CC)) { zephir_is_iterable(modelsBehaviors, &_2, &_1, 0, 0, "phalcon/mvc/collection/manager.zep", 269); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(behavior, _3); ZEPHIR_CALL_METHOD(&status, behavior, "notify", NULL, 0, eventName, model); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_MM_BOOL(0); } } } } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "collection:", eventName); ZEPHIR_CALL_METHOD(&status, eventsManager, "fire", NULL, 0, _4, model); zephir_check_call_status(); if (!(zephir_is_true(status))) { RETURN_CCTOR(status); } } ZEPHIR_OBS_VAR(customEventsManager); zephir_read_property_this(&customEventsManager, this_ptr, SL("_customEventsManager"), PH_NOISY_CC); if (Z_TYPE_P(customEventsManager) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset(customEventsManager, _0)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, "collection:", eventName); ZEPHIR_CALL_METHOD(&status, customEventsManager, "fire", NULL, 0, _4, model); zephir_check_call_status(); if (!(zephir_is_true(status))) { RETURN_CCTOR(status); } } } RETURN_CCTOR(status); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, missingMethod) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *eventName = NULL, *_4; zval *model, *eventName_param = NULL, *data, *behaviors, *modelsBehaviors, *result = NULL, *eventsManager, *behavior = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } ZEPHIR_OBS_VAR(behaviors); zephir_read_property_this(&behaviors, this_ptr, SL("_behaviors"), PH_NOISY_CC); if (Z_TYPE_P(behaviors) == IS_ARRAY) { ZEPHIR_OBS_VAR(modelsBehaviors); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&modelsBehaviors, behaviors, _0, 0 TSRMLS_CC)) { zephir_is_iterable(modelsBehaviors, &_2, &_1, 0, 0, "phalcon/mvc/collection/manager.zep", 325); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(behavior, _3); ZEPHIR_CALL_METHOD(&result, behavior, "missingmethod", NULL, 0, model, eventName, data); zephir_check_call_status(); if (Z_TYPE_P(result) != IS_NULL) { RETURN_CCTOR(result); } } } } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "model:", eventName); ZEPHIR_RETURN_CALL_METHOD(eventsManager, "fire", NULL, 0, _4, model, data); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Collection_Manager, addBehavior) { zval *model, *behavior, *entityName, *modelsBehaviors = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &behavior); ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_OBS_VAR(modelsBehaviors); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_behaviors"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&modelsBehaviors, _0, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(modelsBehaviors); array_init(modelsBehaviors); } zephir_array_append(&modelsBehaviors, behavior, PH_SEPARATE, "phalcon/mvc/collection/manager.zep", 358); zephir_update_property_array(this_ptr, SL("_behaviors"), entityName, modelsBehaviors TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_ManagerInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Collection, ManagerInterface, phalcon, mvc_collection_managerinterface, phalcon_mvc_collection_managerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, setCustomEventsManager); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getCustomEventsManager); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, initialize); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, isInitialized); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getLastInitialized); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, setConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, useImplicitObjectIds); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, isUsingImplicitObjectIds); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, notifyEvent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, addBehavior); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_SoftDelete) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection\\Behavior, SoftDelete, phalcon, mvc_collection_behavior_softdelete, phalcon_mvc_collection_behavior_ce, phalcon_mvc_collection_behavior_softdelete_method_entry, 0); zend_class_implements(phalcon_mvc_collection_behavior_softdelete_ce TSRMLS_CC, 1, phalcon_mvc_collection_behaviorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify) { zephir_fcall_cache_entry *_7 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *value, *field, *updateModel, *message = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, **_6; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } if (ZEPHIR_IS_STRING(type, "beforeDelete")) { ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, options, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'value' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 51); return; } ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/mvc/collection/behavior/softdelete.zep", 58); return; } ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, field); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_1, value)) { ZEPHIR_INIT_VAR(updateModel); if (zephir_clone(updateModel, model TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, updateModel, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, updateModel, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_CALL_METHOD(&_3, updateModel, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_3, &_5, &_4, 0, 0, "phalcon/mvc/collection/behavior/softdelete.zep", 90); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(message, _6); ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, message); zephir_check_call_status(); } RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_Timestampable) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection\\Behavior, Timestampable, phalcon, mvc_collection_behavior_timestampable, phalcon_mvc_collection_behavior_ce, phalcon_mvc_collection_behavior_timestampable_method_entry, 0); zend_class_implements(phalcon_mvc_collection_behavior_timestampable_ce TSRMLS_CC, 1, phalcon_mvc_collection_behaviorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Collection_Behavior_Timestampable, notify) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *timestamp = NULL, *singleField = NULL, *field, *generator, *format, *_0 = NULL, **_3; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, type); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(_0)) { RETURN_MM_NULL(); } ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, type); zephir_check_call_status(); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/mvc/collection/behavior/timestampable.zep", 57); return; } ZEPHIR_INIT_VAR(timestamp); ZVAL_NULL(timestamp); ZEPHIR_OBS_VAR(format); if (zephir_array_isset_string_fetch(&format, options, SS("format"), 0 TSRMLS_CC)) { ZEPHIR_CALL_FUNCTION(×tamp, "date", NULL, 293, format); zephir_check_call_status(); } else { ZEPHIR_OBS_VAR(generator); if (zephir_array_isset_string_fetch(&generator, options, SS("generator"), 0 TSRMLS_CC)) { if (Z_TYPE_P(generator) == IS_OBJECT) { if (zephir_instance_of_ev(generator, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(timestamp); ZEPHIR_CALL_USER_FUNC(timestamp, generator); zephir_check_call_status(); } } } } if (Z_TYPE_P(timestamp) == IS_NULL) { ZEPHIR_INIT_NVAR(timestamp); zephir_time(timestamp); } if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_2, &_1, 0, 0, "phalcon/mvc/collection/behavior/timestampable.zep", 95); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(singleField, _3); ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, singleField, timestamp); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, timestamp); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Dispatcher, Exception, phalcon, mvc_dispatcher_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Collection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, Collection, phalcon, mvc_micro_collection, phalcon_mvc_micro_collection_method_entry, 0); zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("_prefix"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("_lazy"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("_handler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("_handlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_micro_collection_ce TSRMLS_CC, 1, phalcon_mvc_micro_collectioninterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, _addMap) { zval *_0; zval *method_param = NULL, *routePattern, *handler, *name; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &method_param, &routePattern, &handler, &name); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_fast_append(_0, method); zephir_array_fast_append(_0, routePattern); zephir_array_fast_append(_0, handler); zephir_array_fast_append(_0, name); zephir_update_property_array_append(this_ptr, SL("_handlers"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setPrefix) { zval *prefix_param = NULL; zval *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &prefix_param); if (unlikely(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getPrefix) { RETURN_MEMBER(this_ptr, "_prefix"); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandlers) { RETURN_MEMBER(this_ptr, "_handlers"); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setHandler) { zend_bool lazy; zval *handler, *lazy_param = NULL; zephir_fetch_params(0, 1, 1, &handler, &lazy_param); if (!lazy_param) { lazy = 0; } else { lazy = zephir_get_boolval(lazy_param); } zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); if (lazy) { zephir_update_property_this(this_ptr, SL("_lazy"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_lazy"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setLazy) { zval *lazy_param = NULL; zend_bool lazy; zephir_fetch_params(0, 1, 0, &lazy_param); if (unlikely(Z_TYPE_P(lazy_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'lazy' must be a bool") TSRMLS_CC); RETURN_NULL(); } lazy = Z_BVAL_P(lazy_param); if (lazy) { zephir_update_property_this(this_ptr, SL("_lazy"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_lazy"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, isLazy) { RETURN_MEMBER(this_ptr, "_lazy"); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandler) { RETURN_MEMBER(this_ptr, "_handler"); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, map) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_NULL(_0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, get) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "GET", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, post) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "POST", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, put) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PUT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, patch) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PATCH", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, head) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HEAD", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "DELETE", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Micro_Collection, options) { int ZEPHIR_LAST_CALL_STATUS; zval *routePattern_param = NULL, *handler, *name = NULL, *_0; zval *routePattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name); if (unlikely(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(routePattern_param) == IS_STRING)) { zephir_get_strval(routePattern, routePattern_param); } else { ZEPHIR_INIT_VAR(routePattern); ZVAL_EMPTY_STRING(routePattern); } if (!name) { name = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "OPTIONS", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_addmap", NULL, 0, _0, routePattern, handler, name); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_THIS(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_CollectionInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, CollectionInterface, phalcon, mvc_micro_collectioninterface, phalcon_mvc_micro_collectioninterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setPrefix); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getPrefix); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandlers); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setHandler); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setLazy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, isLazy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandler); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, map); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, post); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, put); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, patch); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, head); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, delete); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, options); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Micro, Exception, phalcon, mvc_micro_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_LazyLoader) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, LazyLoader, phalcon, mvc_micro_lazyloader, phalcon_mvc_micro_lazyloader_method_entry, 0); zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("_handler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("_definition"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __construct) { zval *definition_param = NULL; zval *definition = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &definition_param); if (unlikely(Z_TYPE_P(definition_param) != IS_STRING && Z_TYPE_P(definition_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'definition' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(definition_param) == IS_STRING)) { zephir_get_strval(definition, definition_param); } else { ZEPHIR_INIT_VAR(definition); ZVAL_EMPTY_STRING(definition); } zephir_update_property_this(this_ptr, SL("_definition"), definition TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __call) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *method_param = NULL, *arguments, *handler = NULL, *definition, *_0 = NULL; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method_param, &arguments); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } ZEPHIR_OBS_VAR(handler); zephir_read_property_this(&handler, this_ptr, SL("_handler"), PH_NOISY_CC); if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(handler); zephir_fetch_safe_class(_0, definition); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(handler, _1); if (zephir_has_constructor(handler TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, handler, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, handler); zephir_array_fast_append(_2, method); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _2, arguments); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_MiddlewareInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, MiddlewareInterface, phalcon, mvc_micro_middlewareinterface, phalcon_mvc_micro_middlewareinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_MiddlewareInterface, call); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Behavior, phalcon, mvc_model_behavior, phalcon_mvc_model_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_model_behavior_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Behavior, __construct) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Behavior, mustTakeAction) { zval *eventName_param = NULL, *_0; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &eventName_param); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, eventName)); } static PHP_METHOD(Phalcon_Mvc_Model_Behavior, getOptions) { zval *eventName_param = NULL, *options, *eventOptions; zval *eventName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &eventName_param); if (!eventName_param) { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } else { if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } } options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (!ZEPHIR_IS_STRING_IDENTICAL(eventName, "")) { if (zephir_array_isset_fetch(&eventOptions, options, eventName, 1 TSRMLS_CC)) { RETURN_CTOR(eventOptions); } RETURN_MM_NULL(); } RETURN_CTOR(options); } static PHP_METHOD(Phalcon_Mvc_Model_Behavior, notify) { zval *type_param = NULL, *model; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); zephir_get_strval(type, type_param); RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Behavior, missingMethod) { zval *method = NULL; zval *model, *method_param = NULL, *arguments = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments); zephir_get_strval(method, method_param); if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } RETURN_MM_NULL(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BehaviorInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BehaviorInterface, phalcon, mvc_model_behaviorinterface, phalcon_mvc_model_behaviorinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, missingMethod); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Criteria) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Criteria, phalcon, mvc_model_criteria, phalcon_mvc_model_criteria_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("_bindParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("_bindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_criteria_ce, SL("_hiddenParamNumber"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_criteria_ce TSRMLS_CC, 1, phalcon_mvc_model_criteriainterface_ce); zend_class_implements(phalcon_mvc_model_criteria_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setDI) { zval *dependencyInjector, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &dependencyInjector); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "di", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, dependencyInjector TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getDI) { zval *dependencyInjector, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&dependencyInjector, _0, SS("di"), 1 TSRMLS_CC)) { RETURN_CTORW(dependencyInjector); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setModelName) { zval *modelName_param = NULL; zval *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &modelName_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } zephir_update_property_this(this_ptr, SL("_model"), modelName TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getModelName) { RETURN_MEMBER(this_ptr, "_model"); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) { zval *bindParams_param = NULL, *_0; zval *bindParams = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &bindParams_param); bindParams = bindParams_param; ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, bindParams TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bindTypes) { zval *bindTypes_param = NULL, *_0; zval *bindTypes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &bindTypes_param); bindTypes = bindTypes_param; ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, bindTypes TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, distinct) { zval *distinct, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &distinct); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "distinct", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, distinct TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, columns) { zval *columns, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &columns); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "columns", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, columns TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) { zval *_1; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *type = NULL, *join, *mergedJoins = NULL, *currentJoins, *_0, *_2; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } if (!type) { type = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(join); zephir_create_array(join, 4, 0 TSRMLS_CC); zephir_array_fast_append(join, model); zephir_array_fast_append(join, conditions); zephir_array_fast_append(join, alias); zephir_array_fast_append(join, type); ZEPHIR_OBS_VAR(currentJoins); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tJoins, _0, SS("joins"), 0 TSRMLS_CC)) { if (Z_TYPE_P(currentJoins) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1, join); ZEPHIR_INIT_VAR(mergedJoins); zephir_fast_array_merge(mergedJoins, &(currentJoins), &(_1) TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } } else { ZEPHIR_INIT_NVAR(mergedJoins); zephir_create_array(mergedJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(mergedJoins, join); } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "joins", 1); zephir_update_property_array(this_ptr, SL("_params"), _2, mergedJoins TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin) { int ZEPHIR_LAST_CALL_STATUS; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_0; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "INNER", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, model, conditions, alias, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin) { int ZEPHIR_LAST_CALL_STATUS; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_0; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "LEFT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, model, conditions, alias, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin) { int ZEPHIR_LAST_CALL_STATUS; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_0; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "RIGHT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, model, conditions, alias, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *mergedParams = NULL, *mergedParamsTypes = NULL, *currentBindTypes, *_0, *_1, *_2 = NULL; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, conditions TSRMLS_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindParams, _1, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(currentBindParams), &(bindParams) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _2, mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(¤tBindTypes, _1, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParamsTypes); zephir_fast_array_merge(mergedParamsTypes, &(currentBindTypes), &(bindTypes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParamsTypes, bindTypes); } ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _2, mergedParamsTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, addWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "andwhere", NULL, 0, conditions, bindParams, bindTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, andWhere) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *mergedParams = NULL, *mergedParamsTypes = NULL, *currentBindTypes, *params, *currentConditions, *_0, *_1 = NULL; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); ZEPHIR_OBS_VAR(currentConditions); if (zephir_array_isset_string_fetch(¤tConditions, params, SS("conditions"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVS(_0, "(", currentConditions, ") AND (", conditions, ")"); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, _0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, conditions TSRMLS_CC); } if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); if (zephir_array_isset_string_fetch(¤tBindParams, params, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(currentBindParams), &(bindParams) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); if (zephir_array_isset_string_fetch(¤tBindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParamsTypes); zephir_fast_array_merge(mergedParamsTypes, &(currentBindTypes), &(bindTypes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParamsTypes, bindTypes); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, mergedParamsTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *mergedParams = NULL, *mergedParamsTypes = NULL, *currentBindTypes, *params, *currentConditions, *_0, *_1 = NULL; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); ZEPHIR_OBS_VAR(currentConditions); if (zephir_array_isset_string_fetch(¤tConditions, params, SS("conditions"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVS(_0, "(", currentConditions, ") OR (", conditions, ")"); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, _0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, conditions TSRMLS_CC); } if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindParams); if (zephir_array_isset_string_fetch(¤tBindParams, params, SS("bind"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(currentBindParams), &(bindParams) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bind", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBindTypes); if (zephir_array_isset_string_fetch(¤tBindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(mergedParamsTypes); zephir_fast_array_merge(mergedParamsTypes, &(currentBindTypes), &(bindTypes) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParamsTypes, bindTypes); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bindTypes", 1); zephir_update_property_array(this_ptr, SL("_params"), _1, mergedParamsTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, betweenWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *expr_param = NULL, *minimum, *maximum, *hiddenParam, *minimumKey, *nextHiddenParam, *maximumKey, *_0; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(nextHiddenParam); ZVAL_LONG(nextHiddenParam, (zephir_get_numberval(hiddenParam) + 1)); ZEPHIR_INIT_VAR(minimumKey); ZEPHIR_CONCAT_SV(minimumKey, "ACP", hiddenParam); ZEPHIR_INIT_VAR(maximumKey); ZEPHIR_CONCAT_SV(maximumKey, "ACP", nextHiddenParam); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSVSVS(_0, expr, " BETWEEN :", minimumKey, ": AND :", maximumKey, ":"); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_zval(&_1, minimumKey, &minimum, PH_COPY); zephir_array_update_zval(&_1, maximumKey, &maximum, PH_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _0, _1); zephir_check_call_status(); ZEPHIR_SEPARATE(nextHiddenParam); zephir_increment(nextHiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), nextHiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notBetweenWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *expr_param = NULL, *minimum, *maximum, *hiddenParam, *nextHiddenParam, *minimumKey, *maximumKey, *_0; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(nextHiddenParam); ZVAL_LONG(nextHiddenParam, (zephir_get_numberval(hiddenParam) + 1)); ZEPHIR_INIT_VAR(minimumKey); ZEPHIR_CONCAT_SV(minimumKey, "ACP", hiddenParam); ZEPHIR_INIT_VAR(maximumKey); ZEPHIR_CONCAT_SV(maximumKey, "ACP", nextHiddenParam); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSVSVS(_0, expr, " NOT BETWEEN :", minimumKey, ": AND :", maximumKey, ":"); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_zval(&_1, minimumKey, &minimum, PH_COPY); zephir_array_update_zval(&_1, maximumKey, &maximum, PH_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _0, _1); zephir_check_call_status(); ZEPHIR_SEPARATE(nextHiddenParam); zephir_increment(nextHiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), nextHiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, inWhere) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *values = NULL; zval *expr_param = NULL, *values_param = NULL, *hiddenParam, *bindParams, *bindKeys, *value = NULL, *key = NULL, *queryKey = NULL, **_2, *_3, *_4; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &expr_param, &values_param); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } values = values_param; ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); ZEPHIR_INIT_VAR(bindKeys); array_init(bindKeys); zephir_is_iterable(values, &_1, &_0, 0, 0, "phalcon/mvc/model/criteria.zep", 450); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_INIT_NVAR(key); ZEPHIR_CONCAT_SV(key, "ACP", hiddenParam); ZEPHIR_INIT_NVAR(queryKey); ZEPHIR_CONCAT_SVS(queryKey, ":", key, ":"); zephir_array_append(&bindKeys, queryKey, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 441); zephir_array_update_zval(&bindParams, key, &value, PH_COPY | PH_SEPARATE); ZEPHIR_SEPARATE(hiddenParam); zephir_increment(hiddenParam); } ZEPHIR_INIT_VAR(_3); zephir_fast_join_str(_3, SL(", "), bindKeys TSRMLS_CC); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_VSVS(_4, expr, " IN (", _3, ")"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _4, bindParams); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), hiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notInWhere) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *values = NULL; zval *expr_param = NULL, *values_param = NULL, *hiddenParam, *bindParams, *bindKeys, *value = NULL, *key = NULL, **_2, *_3 = NULL, *_4; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &expr_param, &values_param); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } values = values_param; ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); ZEPHIR_INIT_VAR(bindKeys); array_init(bindKeys); zephir_is_iterable(values, &_1, &_0, 0, 0, "phalcon/mvc/model/criteria.zep", 487); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_INIT_NVAR(key); ZEPHIR_CONCAT_SV(key, "ACP", hiddenParam); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVS(_3, ":", key, ":"); zephir_array_append(&bindKeys, _3, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 477); zephir_array_update_zval(&bindParams, key, &value, PH_COPY | PH_SEPARATE); ZEPHIR_SEPARATE(hiddenParam); zephir_increment(hiddenParam); } ZEPHIR_INIT_VAR(_4); zephir_fast_join_str(_4, SL(", "), bindKeys TSRMLS_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_VSVS(_3, expr, " NOT IN (", _4, ")"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _3, bindParams); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), hiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, conditions) { zval *conditions_param = NULL, *_0; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &conditions_param); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "conditions", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, conditions TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, order) { zval *orderColumns_param = NULL, *_0; zval *orderColumns = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &orderColumns_param); if (unlikely(Z_TYPE_P(orderColumns_param) != IS_STRING && Z_TYPE_P(orderColumns_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'orderColumns' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(orderColumns_param) == IS_STRING)) { zephir_get_strval(orderColumns, orderColumns_param); } else { ZEPHIR_INIT_VAR(orderColumns); ZVAL_EMPTY_STRING(orderColumns); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "order", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, orderColumns TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orderBy) { zval *orderColumns_param = NULL, *_0; zval *orderColumns = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &orderColumns_param); if (unlikely(Z_TYPE_P(orderColumns_param) != IS_STRING && Z_TYPE_P(orderColumns_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'orderColumns' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(orderColumns_param) == IS_STRING)) { zephir_get_strval(orderColumns, orderColumns_param); } else { ZEPHIR_INIT_VAR(orderColumns); ZVAL_EMPTY_STRING(orderColumns); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "order", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, orderColumns TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, groupBy) { zval *group, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "group", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, group TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, having) { zval *having, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &having); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "group", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, having TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit) { zval *_1; zval *limit, *offset = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &limit, &offset); if (!offset) { offset = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(offset) == IS_NULL) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "limit", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, limit TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL("number"), &limit, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("offset"), &offset, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "limit", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, _1 TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, forUpdate) { zval *forUpdate_param = NULL, *_0, *_1; zend_bool forUpdate; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &forUpdate_param); if (!forUpdate_param) { forUpdate = 1; } else { forUpdate = zephir_get_boolval(forUpdate_param); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "for_update", 1); ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, forUpdate); zephir_update_property_array(this_ptr, SL("_params"), _0, _1 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, sharedLock) { zval *sharedLock_param = NULL, *_0, *_1; zend_bool sharedLock; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sharedLock_param); if (!sharedLock_param) { sharedLock = 1; } else { sharedLock = zephir_get_boolval(sharedLock_param); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "shared_lock", 1); ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, sharedLock); zephir_update_property_array(this_ptr, SL("_params"), _0, _1 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, cache) { zval *cache_param = NULL, *_0; zval *cache = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &cache_param); cache = cache_param; ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "cache", 1); zephir_update_property_array(this_ptr, SL("_params"), _0, cache TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getWhere) { zval *conditions, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&conditions, _0, SS("conditions"), 1 TSRMLS_CC)) { RETURN_CTORW(conditions); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getColumns) { zval *columns, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&columns, _0, SS("columns"), 1 TSRMLS_CC)) { RETURN_CTORW(columns); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getConditions) { zval *conditions, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&conditions, _0, SS("conditions"), 1 TSRMLS_CC)) { RETURN_CTORW(conditions); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getLimit) { zval *limit, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&limit, _0, SS("limit"), 1 TSRMLS_CC)) { RETURN_CTORW(limit); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getOrder) { zval *order, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&order, _0, SS("order"), 1 TSRMLS_CC)) { RETURN_CTORW(order); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getGroupBy) { zval *group, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&group, _0, SS("group"), 1 TSRMLS_CC)) { RETURN_CTORW(group); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getHaving) { zval *having, *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); if (zephir_array_isset_string_fetch(&having, _0, SS("having"), 1 TSRMLS_CC)) { RETURN_CTORW(having); } RETURN_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getParams) { RETURN_MEMBER(this_ptr, "_params"); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput) { zend_bool _6, _7; HashTable *_4; HashPosition _3; zend_class_entry *_2; int ZEPHIR_LAST_CALL_STATUS; zval *data = NULL; zval *modelName = NULL, *operator = NULL, *_10; zval *dependencyInjector, *modelName_param = NULL, *data_param = NULL, *operator_param = NULL, *attribute = NULL, *conditions, *field = NULL, *value = NULL, *type = NULL, *metaData = NULL, *model, *dataTypes = NULL, *bind, *criteria, *columnMap = NULL, *_0 = NULL, *_1 = NULL, **_5, *_8 = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &dependencyInjector, &modelName_param, &data_param, &operator_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } data = data_param; if (!operator_param) { ZEPHIR_INIT_VAR(operator); ZVAL_STRING(operator, "AND", 1); } else { if (unlikely(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(operator_param) == IS_STRING)) { zephir_get_strval(operator, operator_param); } else { ZEPHIR_INIT_VAR(operator); ZVAL_EMPTY_STRING(operator); } } ZEPHIR_INIT_VAR(conditions); array_init(conditions); if (zephir_fast_count_int(data TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(model); zephir_fetch_safe_class(_1, modelName); _2 = zend_fetch_class(Z_STRVAL_P(_1), Z_STRLEN_P(_1), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(model, _2); if (zephir_has_constructor(model TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, model, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&dataTypes, metaData, "getdatatypes", NULL, 0, model); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, model); zephir_check_call_status(); ZEPHIR_INIT_VAR(bind); array_init(bind); zephir_is_iterable(data, &_4, &_3, 0, 0, "phalcon/mvc/model/criteria.zep", 731); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(field, _4, _3); ZEPHIR_GET_HVALUE(value, _5); _6 = Z_TYPE_P(columnMap) == IS_ARRAY; if (_6) { _6 = (zephir_fast_count_int(columnMap TSRMLS_CC)) ? 1 : 0; } if (_6) { ZEPHIR_OBS_NVAR(attribute); zephir_array_fetch(&attribute, columnMap, field, PH_NOISY, "phalcon/mvc/model/criteria.zep", 708 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(attribute, field); } ZEPHIR_OBS_NVAR(type); if (zephir_array_isset_fetch(&type, dataTypes, attribute, 0 TSRMLS_CC)) { _7 = Z_TYPE_P(value) != IS_NULL; if (_7) { _7 = !ZEPHIR_IS_STRING_IDENTICAL(value, ""); } if (_7) { if (ZEPHIR_IS_LONG(type, 2)) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "[", field, "] LIKE :", field, ":"); zephir_array_append(&conditions, _8, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 720); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVS(_9, "%", value, "%"); zephir_array_update_zval(&bind, field, &_9, PH_COPY | PH_SEPARATE); continue; } ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "[", field, "] = :", field, ":"); zephir_array_append(&conditions, _8, PH_SEPARATE, "phalcon/mvc/model/criteria.zep", 727); zephir_array_update_zval(&bind, field, &value, PH_COPY | PH_SEPARATE); } } } } ZEPHIR_INIT_VAR(criteria); object_init_ex(criteria, phalcon_mvc_model_criteria_ce); if (zephir_has_constructor(criteria TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, criteria, "__construct", NULL, 0); zephir_check_call_status(); } if (zephir_fast_count_int(conditions TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_SVS(_10, " ", operator, " "); zephir_fast_join(_0, _10, conditions TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, criteria, "where", NULL, 307, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, criteria, "bind", NULL, 308, bind); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, criteria, "setmodelname", NULL, 303, modelName); zephir_check_call_status(); RETURN_CCTOR(criteria); } static PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute) { zend_class_entry *_1; int ZEPHIR_LAST_CALL_STATUS; zval *model = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&model, this_ptr, "getmodelname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(model) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Model name must be string", "phalcon/mvc/model/criteria.zep", 755); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "getparams", NULL, 0); zephir_check_call_status(); _1 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC(_1, "find", NULL, 0, _0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_CriteriaInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, CriteriaInterface, phalcon, mvc_model_criteriainterface, phalcon_mvc_model_criteriainterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, setModelName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getModelName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bind); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bindTypes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, where); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, conditions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orderBy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, limit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, forUpdate); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, sharedLock); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, andWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, betweenWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notBetweenWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, inWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notInWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getConditions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getLimit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getOrder); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getParams); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, execute); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Exception, phalcon, mvc_model_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Manager, phalcon, mvc_model_manager, phalcon_mvc_model_manager_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_customEventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_readConnectionServices"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_writeConnectionServices"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_aliases"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasMany"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasManySingle"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasOne"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasOneSingle"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_belongsTo"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_belongsToSingle"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasManyToMany"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_hasManyToManySingle"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_initialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_sources"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_schemas"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_behaviors"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_lastInitialized"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_lastQuery"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_reusable"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_keepSnapshots"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_dynamicUpdate"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("_namespaceAliases"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_manager_ce TSRMLS_CC, 1, phalcon_mvc_model_managerinterface_ce); zend_class_implements(phalcon_mvc_model_manager_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_mvc_model_manager_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setEventsManager) { zval *eventsManager; zephir_fetch_params(0, 1, 0, &eventsManager); zephir_update_property_this(this_ptr, SL("_eventsManager"), eventsManager TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getEventsManager) { RETURN_MEMBER(this_ptr, "_eventsManager"); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setCustomEventsManager) { zval *model, *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &eventsManager); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_customEventsManager"), _0, eventsManager TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getCustomEventsManager) { zval *model, *customEventsManager, *eventsManager, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); customEventsManager = zephir_fetch_nproperty_this(this_ptr, SL("_customEventsManager"), PH_NOISY_CC); if (Z_TYPE_P(customEventsManager) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&eventsManager, customEventsManager, _0, 1 TSRMLS_CC)) { RETURN_CTOR(eventsManager); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, initialize) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *className, *eventsManager = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 1 TSRMLS_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (zephir_array_isset(_0, className)) { RETURN_MM_BOOL(0); } zephir_update_property_array(this_ptr, SL("_initialized"), className, model TSRMLS_CC); if ((zephir_method_exists_ex(model, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_lastInitialized"), model TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _1); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "modelsManager:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _2, this_ptr, model); zephir_check_temp_parameter(_2); zephir_check_call_status(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized) { zval *modelName_param = NULL, *_0, *_1; zval *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &modelName_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelName); RETURN_MM_BOOL(zephir_array_isset(_0, _1)); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastInitialized) { RETURN_MEMBER(this_ptr, "_lastInitialized"); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, load) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_3, *_6; zend_bool newInstance; zval *modelName_param = NULL, *newInstance_param = NULL, *model, *_0, *_1, *_2 = NULL, *_4, *_5 = NULL, *_7; zval *modelName = NULL, *_8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &modelName_param, &newInstance_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (!newInstance_param) { newInstance = 0; } else { newInstance = zephir_get_boolval(newInstance_param); } ZEPHIR_OBS_VAR(model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelName); if (zephir_array_isset_fetch(&model, _0, _1, 0 TSRMLS_CC)) { if (newInstance) { zephir_fetch_safe_class(_2, modelName); _3 = zend_fetch_class(Z_STRVAL_P(_2), Z_STRLEN_P(_2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _3); if (zephir_has_constructor(return_value TSRMLS_CC)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, _4, this_ptr); zephir_check_call_status(); } RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, model, "reset", NULL, 0); zephir_check_call_status(); RETURN_CCTOR(model); } if (zephir_class_exists(modelName, 1 TSRMLS_CC)) { zephir_fetch_safe_class(_5, modelName); _6 = zend_fetch_class(Z_STRVAL_P(_5), Z_STRLEN_P(_5), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _6); if (zephir_has_constructor(return_value TSRMLS_CC)) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, _4, this_ptr); zephir_check_call_status(); } RETURN_MM(); } ZEPHIR_INIT_VAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVS(_8, "Model '", modelName, "' could not be loaded"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/manager.zep", 295 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSource) { zval *source = NULL; zval *model, *source_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &source_param); if (unlikely(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(source_param) == IS_STRING)) { zephir_get_strval(source, source_param); } else { ZEPHIR_INIT_VAR(source); ZVAL_EMPTY_STRING(source); } ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_sources"), _0, source TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSource) { zval *model, *sources, *entityName, *source = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_OBS_VAR(sources); zephir_read_property_this(&sources, this_ptr, SL("_sources"), PH_NOISY_CC); if (Z_TYPE_P(sources) == IS_ARRAY) { ZEPHIR_OBS_VAR(source); if (zephir_array_isset_fetch(&source, sources, entityName, 0 TSRMLS_CC)) { RETURN_CCTOR(source); } } ZEPHIR_INIT_VAR(_0); zephir_get_class_ns(_0, model, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(source); zephir_uncamelize(source, _0); zephir_update_property_array(this_ptr, SL("_sources"), entityName, source TSRMLS_CC); RETURN_CCTOR(source); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSchema) { zval *schema = NULL; zval *model, *schema_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &schema_param); if (unlikely(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(schema_param) == IS_STRING)) { zephir_get_strval(schema, schema_param); } else { ZEPHIR_INIT_VAR(schema); ZVAL_EMPTY_STRING(schema); } ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_schemas"), _0, schema TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSchema) { zval *model, *schemas, *schema, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); schemas = zephir_fetch_nproperty_this(this_ptr, SL("_schemas"), PH_NOISY_CC); if (Z_TYPE_P(schemas) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&schema, schemas, _0, 1 TSRMLS_CC)) { RETURN_CTOR(schema); } } RETURN_MM_STRING("", 1); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setConnectionService) { zval *connectionService = NULL; zval *model, *connectionService_param = NULL, *entityName; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_readConnectionServices"), entityName, connectionService TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_writeConnectionServices"), entityName, connectionService TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setWriteConnectionService) { zval *connectionService = NULL; zval *model, *connectionService_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_writeConnectionServices"), _0, connectionService TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReadConnectionService) { zval *connectionService = NULL; zval *model, *connectionService_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionService_param); if (unlikely(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(connectionService_param) == IS_STRING)) { zephir_get_strval(connectionService, connectionService_param); } else { ZEPHIR_INIT_VAR(connectionService); ZVAL_EMPTY_STRING(connectionService); } ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_readConnectionServices"), _0, connectionService TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_readConnectionServices"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getconnection", NULL, 0, model, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_writeConnectionServices"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getconnection", NULL, 0, model, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, _getConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *connectionServices, *dependencyInjector = NULL, *service = NULL, *connection = NULL, *_0 = NULL, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionServices); ZEPHIR_INIT_VAR(service); ZVAL_NULL(service); if (Z_TYPE_P(connectionServices) == IS_ARRAY) { ZEPHIR_OBS_NVAR(service); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); zephir_array_isset_fetch(&service, connectionServices, _0, 0 TSRMLS_CC); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _1); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model/manager.zep", 409); return; } ZEPHIR_INIT_VAR(connection); if (zephir_is_true(service)) { ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, service); zephir_check_call_status(); ZEPHIR_CPY_WRT(connection, _2); } else { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "db", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CPY_WRT(connection, _2); } if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid injected connection service", "phalcon/mvc/model/manager.zep", 422); return; } RETURN_CCTOR(connection); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_readConnectionServices"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getconnectionservice", NULL, 0, model, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnectionService) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_writeConnectionServices"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getconnectionservice", NULL, 0, model, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, _getConnectionService) { zval *model, *connectionServices, *connection, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &connectionServices); if (Z_TYPE_P(connectionServices) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&connection, connectionServices, _0, 1 TSRMLS_CC)) { RETURN_CTOR(connection); } } RETURN_MM_STRING("db", 1); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *eventName_param = NULL, *model, *status = NULL, *behavior = NULL, *modelsBehaviors, *eventsManager, *customEventsManager = NULL, *behaviors, *_0 = NULL, **_3; zval *eventName = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &eventName_param, &model); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } ZEPHIR_INIT_VAR(status); ZVAL_NULL(status); ZEPHIR_OBS_VAR(behaviors); zephir_read_property_this(&behaviors, this_ptr, SL("_behaviors"), PH_NOISY_CC); if (Z_TYPE_P(behaviors) == IS_ARRAY) { ZEPHIR_OBS_VAR(modelsBehaviors); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&modelsBehaviors, behaviors, _0, 0 TSRMLS_CC)) { zephir_is_iterable(modelsBehaviors, &_2, &_1, 0, 0, "phalcon/mvc/model/manager.zep", 487); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(behavior, _3); ZEPHIR_CALL_METHOD(&status, behavior, "notify", NULL, 0, eventName, model); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_MM_BOOL(0); } } } } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "model:", eventName); ZEPHIR_CALL_METHOD(&status, eventsManager, "fire", NULL, 0, _4, model); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_CCTOR(status); } } ZEPHIR_OBS_VAR(customEventsManager); zephir_read_property_this(&customEventsManager, this_ptr, SL("_customEventsManager"), PH_NOISY_CC); if (Z_TYPE_P(customEventsManager) == IS_ARRAY) { ZEPHIR_OBS_NVAR(customEventsManager); ZEPHIR_INIT_NVAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&customEventsManager, customEventsManager, _0, 0 TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, "model:", eventName); ZEPHIR_CALL_METHOD(&status, customEventsManager, "fire", NULL, 0, _4, model); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { RETURN_MM_BOOL(0); } } } RETURN_CCTOR(status); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, missingMethod) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *eventName = NULL, *_4; zval *model, *eventName_param = NULL, *data, *behaviors, *modelsBehaviors, *result = NULL, *eventsManager, *behavior = NULL, *_0, **_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); if (unlikely(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(eventName_param) == IS_STRING)) { zephir_get_strval(eventName, eventName_param); } else { ZEPHIR_INIT_VAR(eventName); ZVAL_EMPTY_STRING(eventName); } ZEPHIR_OBS_VAR(behaviors); zephir_read_property_this(&behaviors, this_ptr, SL("_behaviors"), PH_NOISY_CC); if (Z_TYPE_P(behaviors) == IS_ARRAY) { ZEPHIR_OBS_VAR(modelsBehaviors); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&modelsBehaviors, behaviors, _0, 0 TSRMLS_CC)) { zephir_is_iterable(modelsBehaviors, &_2, &_1, 0, 0, "phalcon/mvc/model/manager.zep", 543); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(behavior, _3); ZEPHIR_CALL_METHOD(&result, behavior, "missingmethod", NULL, 0, model, eventName, data); zephir_check_call_status(); if (Z_TYPE_P(result) != IS_NULL) { RETURN_CCTOR(result); } } } } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "model:", eventName); ZEPHIR_RETURN_CALL_METHOD(eventsManager, "fire", NULL, 0, _4, model, data); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBehavior) { zval *model, *behavior, *entityName, *modelsBehaviors = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &behavior); ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_OBS_VAR(modelsBehaviors); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_behaviors"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&modelsBehaviors, _0, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(modelsBehaviors); array_init(modelsBehaviors); } zephir_array_append(&modelsBehaviors, behavior, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 576); zephir_update_property_array(this_ptr, SL("_behaviors"), entityName, modelsBehaviors TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, keepSnapshots) { zend_bool keepSnapshots; zval *model, *keepSnapshots_param = NULL, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &keepSnapshots_param); keepSnapshots = zephir_get_boolval(keepSnapshots_param); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, keepSnapshots); zephir_update_property_array(this_ptr, SL("_keepSnapshots"), _0, _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, isKeepingSnapshots) { zval *model, *keepSnapshots, *isKeeping, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); keepSnapshots = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); if (Z_TYPE_P(keepSnapshots) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&isKeeping, keepSnapshots, _0, 1 TSRMLS_CC)) { RETURN_CTOR(isKeeping); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, useDynamicUpdate) { zend_bool dynamicUpdate; zval *model, *dynamicUpdate_param = NULL, *entityName, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dynamicUpdate_param); dynamicUpdate = zephir_get_boolval(dynamicUpdate_param); ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, dynamicUpdate); zephir_update_property_array(this_ptr, SL("_dynamicUpdate"), entityName, _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, dynamicUpdate); zephir_update_property_array(this_ptr, SL("_keepSnapshots"), entityName, _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, isUsingDynamicUpdate) { zval *model, *dynamicUpdate, *isUsing, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); dynamicUpdate = zephir_fetch_nproperty_this(this_ptr, SL("_dynamicUpdate"), PH_NOISY_CC); if (Z_TYPE_P(dynamicUpdate) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&isUsing, dynamicUpdate, _0, 1 TSRMLS_CC)) { RETURN_CTOR(isUsing); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOne) { int ZEPHIR_LAST_CALL_STATUS; zval *referencedModel = NULL; zval *model, *fields, *referencedModel_param = NULL, *referencedFields, *options = NULL, *entityName, *referencedEntity, *relation, *keyRelation, *relations = NULL, *alias, *lowerAlias = NULL, *singleRelations = NULL, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referencedModel_param) == IS_STRING)) { zephir_get_strval(referencedModel, referencedModel_param); } else { ZEPHIR_INIT_VAR(referencedModel); ZVAL_EMPTY_STRING(referencedModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(referencedEntity); zephir_fast_strtolower(referencedEntity, referencedModel); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", referencedEntity); ZEPHIR_OBS_VAR(relations); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_hasOne"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&relations, _0, keyRelation, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(relations); array_init(relations); } if (Z_TYPE_P(referencedFields) == IS_ARRAY) { if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(referencedFields TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/mvc/model/manager.zep", 663); return; } } ZEPHIR_INIT_VAR(relation); object_init_ex(relation, phalcon_mvc_model_relation_ce); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 1); ZEPHIR_CALL_METHOD(NULL, relation, "__construct", NULL, 309, _1, referencedModel, fields, referencedFields, options); zephir_check_call_status(); ZEPHIR_OBS_VAR(alias); if (zephir_array_isset_string_fetch(&alias, options, SS("alias"), 0 TSRMLS_CC)) { if (Z_TYPE_P(alias) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/mvc/model/manager.zep", 683); return; } ZEPHIR_INIT_VAR(lowerAlias); zephir_fast_strtolower(lowerAlias, alias); } else { ZEPHIR_CPY_WRT(lowerAlias, referencedEntity); } zephir_array_append(&relations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 695); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSV(_2, entityName, "$", lowerAlias); zephir_update_property_array(this_ptr, SL("_aliases"), _2, relation TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_hasOne"), keyRelation, relations TSRMLS_CC); ZEPHIR_OBS_VAR(singleRelations); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_hasOneSingle"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&singleRelations, _3, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(singleRelations); array_init(singleRelations); } zephir_array_append(&singleRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 709); zephir_update_property_array(this_ptr, SL("_hasOneSingle"), entityName, singleRelations TSRMLS_CC); RETURN_CCTOR(relation); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBelongsTo) { int ZEPHIR_LAST_CALL_STATUS; zval *referencedModel = NULL; zval *model, *fields, *referencedModel_param = NULL, *referencedFields, *options = NULL, *entityName, *referencedEntity, *relation, *keyRelation, *relations = NULL, *alias, *lowerAlias = NULL, *singleRelations = NULL, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referencedModel_param) == IS_STRING)) { zephir_get_strval(referencedModel, referencedModel_param); } else { ZEPHIR_INIT_VAR(referencedModel); ZVAL_EMPTY_STRING(referencedModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(referencedEntity); zephir_fast_strtolower(referencedEntity, referencedModel); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", referencedEntity); ZEPHIR_OBS_VAR(relations); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_belongsTo"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&relations, _0, keyRelation, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(relations); array_init(relations); } if (Z_TYPE_P(referencedFields) == IS_ARRAY) { if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(referencedFields TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/mvc/model/manager.zep", 748); return; } } ZEPHIR_INIT_VAR(relation); object_init_ex(relation, phalcon_mvc_model_relation_ce); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, relation, "__construct", NULL, 309, _1, referencedModel, fields, referencedFields, options); zephir_check_call_status(); ZEPHIR_OBS_VAR(alias); if (zephir_array_isset_string_fetch(&alias, options, SS("alias"), 0 TSRMLS_CC)) { if (Z_TYPE_P(alias) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/mvc/model/manager.zep", 768); return; } ZEPHIR_INIT_VAR(lowerAlias); zephir_fast_strtolower(lowerAlias, alias); } else { ZEPHIR_CPY_WRT(lowerAlias, referencedEntity); } zephir_array_append(&relations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 780); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSV(_2, entityName, "$", lowerAlias); zephir_update_property_array(this_ptr, SL("_aliases"), _2, relation TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_belongsTo"), keyRelation, relations TSRMLS_CC); ZEPHIR_OBS_VAR(singleRelations); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_belongsToSingle"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&singleRelations, _3, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(singleRelations); array_init(singleRelations); } zephir_array_append(&singleRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 794); zephir_update_property_array(this_ptr, SL("_belongsToSingle"), entityName, singleRelations TSRMLS_CC); RETURN_CCTOR(relation); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany) { int ZEPHIR_LAST_CALL_STATUS; zval *referencedModel = NULL; zval *model, *fields, *referencedModel_param = NULL, *referencedFields, *options = NULL, *entityName, *referencedEntity, *hasMany, *relation, *keyRelation, *relations = NULL, *alias, *lowerAlias = NULL, *singleRelations = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referencedModel_param) == IS_STRING)) { zephir_get_strval(referencedModel, referencedModel_param); } else { ZEPHIR_INIT_VAR(referencedModel); ZVAL_EMPTY_STRING(referencedModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(referencedEntity); zephir_fast_strtolower(referencedEntity, referencedModel); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", referencedEntity); ZEPHIR_OBS_VAR(hasMany); zephir_read_property_this(&hasMany, this_ptr, SL("_hasMany"), PH_NOISY_CC); ZEPHIR_OBS_VAR(relations); if (!(zephir_array_isset_fetch(&relations, hasMany, keyRelation, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(relations); array_init(relations); } if (Z_TYPE_P(referencedFields) == IS_ARRAY) { if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(referencedFields TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/mvc/model/manager.zep", 833); return; } } ZEPHIR_INIT_VAR(relation); object_init_ex(relation, phalcon_mvc_model_relation_ce); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); ZEPHIR_CALL_METHOD(NULL, relation, "__construct", NULL, 309, _0, referencedModel, fields, referencedFields, options); zephir_check_call_status(); ZEPHIR_OBS_VAR(alias); if (zephir_array_isset_string_fetch(&alias, options, SS("alias"), 0 TSRMLS_CC)) { if (Z_TYPE_P(alias) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/mvc/model/manager.zep", 853); return; } ZEPHIR_INIT_VAR(lowerAlias); zephir_fast_strtolower(lowerAlias, alias); } else { ZEPHIR_CPY_WRT(lowerAlias, referencedEntity); } zephir_array_append(&relations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 865); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, entityName, "$", lowerAlias); zephir_update_property_array(this_ptr, SL("_aliases"), _1, relation TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_hasMany"), keyRelation, relations TSRMLS_CC); ZEPHIR_OBS_VAR(singleRelations); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hasManySingle"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&singleRelations, _2, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(singleRelations); array_init(singleRelations); } zephir_array_append(&singleRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 879); zephir_update_property_array(this_ptr, SL("_hasManySingle"), entityName, singleRelations TSRMLS_CC); RETURN_CCTOR(relation); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasManyToMany) { int ZEPHIR_LAST_CALL_STATUS; zval *intermediateModel = NULL, *referencedModel = NULL; zval *model, *fields, *intermediateModel_param = NULL, *intermediateFields, *intermediateReferencedFields, *referencedModel_param = NULL, *referencedFields, *options = NULL, *entityName, *referencedEntity, *hasManyToMany, *relation, *keyRelation, *relations = NULL, *alias, *lowerAlias = NULL, *singleRelations = NULL, *intermediateEntity, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options); if (unlikely(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { zephir_get_strval(intermediateModel, intermediateModel_param); } else { ZEPHIR_INIT_VAR(intermediateModel); ZVAL_EMPTY_STRING(intermediateModel); } if (unlikely(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referencedModel_param) == IS_STRING)) { zephir_get_strval(referencedModel, referencedModel_param); } else { ZEPHIR_INIT_VAR(referencedModel); ZVAL_EMPTY_STRING(referencedModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(entityName); zephir_get_class(entityName, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(intermediateEntity); zephir_fast_strtolower(intermediateEntity, intermediateModel); ZEPHIR_INIT_VAR(referencedEntity); zephir_fast_strtolower(referencedEntity, referencedModel); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", referencedEntity); ZEPHIR_OBS_VAR(hasManyToMany); zephir_read_property_this(&hasManyToMany, this_ptr, SL("_hasManyToMany"), PH_NOISY_CC); ZEPHIR_OBS_VAR(relations); if (!(zephir_array_isset_fetch(&relations, hasManyToMany, keyRelation, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(relations); array_init(relations); } if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(intermediateFields TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/mvc/model/manager.zep", 923); return; } } if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(intermediateFields TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/mvc/model/manager.zep", 932); return; } } ZEPHIR_INIT_VAR(relation); object_init_ex(relation, phalcon_mvc_model_relation_ce); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 4); ZEPHIR_CALL_METHOD(NULL, relation, "__construct", NULL, 309, _0, referencedModel, fields, referencedFields, options); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, relation, "setintermediaterelation", NULL, 310, intermediateFields, intermediateModel, intermediateReferencedFields); zephir_check_call_status(); ZEPHIR_OBS_VAR(alias); if (zephir_array_isset_string_fetch(&alias, options, SS("alias"), 0 TSRMLS_CC)) { if (Z_TYPE_P(alias) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/mvc/model/manager.zep", 957); return; } ZEPHIR_INIT_VAR(lowerAlias); zephir_fast_strtolower(lowerAlias, alias); } else { ZEPHIR_CPY_WRT(lowerAlias, referencedEntity); } zephir_array_append(&relations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 967); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, entityName, "$", lowerAlias); zephir_update_property_array(this_ptr, SL("_aliases"), _1, relation TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_hasManyToMany"), keyRelation, relations TSRMLS_CC); ZEPHIR_OBS_VAR(singleRelations); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hasManyToManySingle"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&singleRelations, _2, entityName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(singleRelations); array_init(singleRelations); } zephir_array_append(&singleRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 989); zephir_update_property_array(this_ptr, SL("_hasManyToManySingle"), entityName, singleRelations TSRMLS_CC); RETURN_CCTOR(relation); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsBelongsTo) { int ZEPHIR_LAST_CALL_STATUS; zval *modelName_param = NULL, *modelRelation_param = NULL, *entityName, *keyRelation, *_0, *_1, *_2; zval *modelName = NULL, *modelRelation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelRelation_param) == IS_STRING)) { zephir_get_strval(modelRelation, modelRelation_param); } else { ZEPHIR_INIT_VAR(modelRelation); ZVAL_EMPTY_STRING(modelRelation); } ZEPHIR_INIT_VAR(entityName); zephir_fast_strtolower(entityName, modelName); ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", _0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(_1, entityName))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, modelName); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_belongsTo"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_2, keyRelation)); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasMany) { int ZEPHIR_LAST_CALL_STATUS; zval *modelName_param = NULL, *modelRelation_param = NULL, *entityName, *keyRelation, *_0, *_1, *_2; zval *modelName = NULL, *modelRelation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelRelation_param) == IS_STRING)) { zephir_get_strval(modelRelation, modelRelation_param); } else { ZEPHIR_INIT_VAR(modelRelation); ZVAL_EMPTY_STRING(modelRelation); } ZEPHIR_INIT_VAR(entityName); zephir_fast_strtolower(entityName, modelName); ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", _0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(_1, entityName))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, modelName); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hasMany"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_2, keyRelation)); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOne) { int ZEPHIR_LAST_CALL_STATUS; zval *modelName_param = NULL, *modelRelation_param = NULL, *entityName, *keyRelation, *_0, *_1, *_2; zval *modelName = NULL, *modelRelation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelRelation_param) == IS_STRING)) { zephir_get_strval(modelRelation, modelRelation_param); } else { ZEPHIR_INIT_VAR(modelRelation); ZVAL_EMPTY_STRING(modelRelation); } ZEPHIR_INIT_VAR(entityName); zephir_fast_strtolower(entityName, modelName); ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", _0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(_1, entityName))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, modelName); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hasOne"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_2, keyRelation)); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasManyToMany) { int ZEPHIR_LAST_CALL_STATUS; zval *modelName_param = NULL, *modelRelation_param = NULL, *entityName, *keyRelation, *_0, *_1, *_2; zval *modelName = NULL, *modelRelation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelRelation_param) == IS_STRING)) { zephir_get_strval(modelRelation, modelRelation_param); } else { ZEPHIR_INIT_VAR(modelRelation); ZVAL_EMPTY_STRING(modelRelation); } ZEPHIR_INIT_VAR(entityName); zephir_fast_strtolower(entityName, modelName); ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, entityName, "$", _0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_array_isset(_1, entityName))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, modelName); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hasManyToMany"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_2, keyRelation)); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationByAlias) { zval *modelName_param = NULL, *alias_param = NULL, *aliases, *relation, *_0; zval *modelName = NULL, *alias = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &alias_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(alias_param) == IS_STRING)) { zephir_get_strval(alias, alias_param); } else { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } aliases = zephir_fetch_nproperty_this(this_ptr, SL("_aliases"), PH_NOISY_CC); if (Z_TYPE_P(aliases) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_VSV(_1, modelName, "$", alias); zephir_fast_strtolower(_0, _1); if (zephir_array_isset_fetch(&relation, aliases, _0, 1 TSRMLS_CC)) { RETURN_CTOR(relation); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, _mergeFindParameters) { HashTable *_3, *_8; HashPosition _2, _7; zend_bool _0, _5, _10; zval *findParamsOne, *findParamsTwo, *key = NULL, *value = NULL, *findParams = NULL, *_1 = NULL, **_4, *_6, **_9, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &findParamsOne, &findParamsTwo); _0 = Z_TYPE_P(findParamsOne) == IS_STRING; if (_0) { _0 = Z_TYPE_P(findParamsTwo) == IS_STRING; } if (_0) { zephir_create_array(return_value, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVSV(_1, "(", findParamsOne, ") AND ", findParamsTwo); zephir_array_fast_append(return_value, _1); RETURN_MM(); } ZEPHIR_INIT_VAR(findParams); array_init(findParams); if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { zephir_is_iterable(findParamsOne, &_3, &_2, 0, 0, "phalcon/mvc/model/manager.zep", 1137); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(key, _3, _2); ZEPHIR_GET_HVALUE(value, _4); _5 = ZEPHIR_IS_LONG_IDENTICAL(key, 0); if (!(_5)) { _5 = ZEPHIR_IS_STRING_IDENTICAL(key, "conditions"); } if (_5) { if (!(zephir_array_isset_long(findParams, 0))) { zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { zephir_array_fetch_long(&_6, findParams, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1130 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSV(_1, "(", _6, ") AND ", value); zephir_array_update_long(&findParams, 0, &_1, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } continue; } zephir_array_update_zval(&findParams, key, &value, PH_COPY | PH_SEPARATE); } } else { if (Z_TYPE_P(findParamsOne) == IS_STRING) { ZEPHIR_INIT_NVAR(findParams); zephir_create_array(findParams, 1, 0 TSRMLS_CC); zephir_array_update_string(&findParams, SL("conditions"), &findParamsOne, PH_COPY | PH_SEPARATE); } } if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { zephir_is_iterable(findParamsTwo, &_8, &_7, 0, 0, "phalcon/mvc/model/manager.zep", 1171); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HMKEY(key, _8, _7); ZEPHIR_GET_HVALUE(value, _9); _5 = ZEPHIR_IS_LONG_IDENTICAL(key, 0); if (!(_5)) { _5 = ZEPHIR_IS_STRING_IDENTICAL(key, "conditions"); } if (_5) { if (!(zephir_array_isset_long(findParams, 0))) { zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { zephir_array_fetch_long(&_6, findParams, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1151 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSV(_1, "(", _6, ") AND ", value); zephir_array_update_long(&findParams, 0, &_1, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } continue; } _10 = ZEPHIR_IS_STRING_IDENTICAL(key, "bind"); if (!(_10)) { _10 = ZEPHIR_IS_STRING_IDENTICAL(key, "bindTypes"); } if (_10) { if (!(zephir_array_isset(findParams, key))) { if (Z_TYPE_P(value) == IS_ARRAY) { zephir_array_update_zval(&findParams, key, &value, PH_COPY | PH_SEPARATE); } } else { if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_11); zephir_array_fetch(&_6, findParams, key, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1163 TSRMLS_CC); zephir_fast_array_merge(_11, &(_6), &(value) TSRMLS_CC); zephir_array_update_zval(&findParams, key, &_11, PH_COPY | PH_SEPARATE); } } continue; } zephir_array_update_zval(&findParams, key, &value, PH_COPY | PH_SEPARATE); } } else { if (Z_TYPE_P(findParamsTwo) == IS_STRING) { if (!(zephir_array_isset_long(findParams, 0))) { zephir_array_update_long(&findParams, 0, &findParamsTwo, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { zephir_array_fetch_long(&_6, findParams, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1176 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSV(_1, "(", _6, ") AND ", findParamsTwo); zephir_array_update_long(&findParams, 0, &_1, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } } } RETURN_CCTOR(findParams); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationRecords) { zval *_16; HashTable *_9; HashPosition _8; zephir_fcall_cache_entry *_3 = NULL, *_13 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool reusable, _15; zval *method = NULL; zval *relation, *method_param = NULL, *record, *parameters = NULL, *placeholders, *referencedModel = NULL, *intermediateModel = NULL, *intermediateFields = NULL, *joinConditions, *fields = NULL, *builder = NULL, *extraParameters = NULL, *conditions = NULL, *refPosition = NULL, *field = NULL, *referencedFields = NULL, *findParams = NULL, *findArguments = NULL, *retrieveMethod = NULL, *uniqueKey, *records = NULL, *arguments, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, **_10, *_11, *_12 = NULL, *_14 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &relation, &method_param, &record, ¶meters); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(placeholders); array_init(placeholders); ZEPHIR_CALL_METHOD(&extraParameters, relation, "getparams", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, relation, "isthrough", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_CALL_METHOD(&intermediateModel, relation, "getintermediatemodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(fields) != IS_ARRAY) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVSVS(_1, "[", intermediateModel, "].[", intermediateFields, "] = :APR0:"); zephir_array_append(&conditions, _1, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1227); ZEPHIR_CALL_METHOD(&_2, record, "readattribute", NULL, 0, fields); zephir_check_call_status(); zephir_array_update_string(&placeholders, SL("APR0"), &_2, PH_COPY | PH_SEPARATE); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/mvc/model/manager.zep", 1230); return; } ZEPHIR_INIT_VAR(joinConditions); array_init(joinConditions); ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatereferencedfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(intermediateFields) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&_2, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVSVSVS(_1, "[", intermediateModel, "].[", intermediateFields, "] = [", referencedModel, "].[", _2, "]"); zephir_array_append(&joinConditions, _1, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1240); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/mvc/model/manager.zep", 1242); return; } ZEPHIR_CALL_METHOD(&_2, this_ptr, "_mergefindparameters", &_3, 311, extraParameters, parameters); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&builder, this_ptr, "createbuilder", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, builder, "from", NULL, 0, referencedModel); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); zephir_fast_join_str(_4, SL(" AND "), joinConditions TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, builder, "innerjoin", NULL, 0, intermediateModel, _4); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); zephir_fast_join_str(_5, SL(" AND "), conditions TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, builder, "andwhere", NULL, 0, _5, placeholders); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, builder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(_6, "execute", NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_NVAR(conditions); array_init(conditions); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(fields) != IS_ARRAY) { ZEPHIR_CALL_METHOD(&_6, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "[", _6, "] = :APR0:"); zephir_array_append(&conditions, _1, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1269); ZEPHIR_CALL_METHOD(&_7, record, "readattribute", NULL, 0, fields); zephir_check_call_status(); zephir_array_update_string(&placeholders, SL("APR0"), &_7, PH_COPY | PH_SEPARATE); } else { ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_6, &_9, &_8, 0, 0, "phalcon/mvc/model/manager.zep", 1281); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(refPosition, _9, _8); ZEPHIR_GET_HVALUE(field, _10); zephir_array_fetch(&_11, referencedFields, refPosition, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1278 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SVSVS(_12, "[", _11, "] = :APR", refPosition, ":"); zephir_array_append(&conditions, _12, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1278); ZEPHIR_CALL_METHOD(&_7, record, "readattribute", &_13, 0, field); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_SV(_14, "APR", refPosition); zephir_array_update_zval(&placeholders, _14, &_7, PH_COPY | PH_SEPARATE); } } ZEPHIR_INIT_VAR(findParams); zephir_create_array(findParams, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_4); zephir_fast_join_str(_4, SL(" AND "), conditions TSRMLS_CC); zephir_array_fast_append(findParams, _4); zephir_array_update_string(&findParams, SL("bind"), &placeholders, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_2, record, "getdi", NULL, 0); zephir_check_call_status(); zephir_array_update_string(&findParams, SL("di"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&findArguments, this_ptr, "_mergefindparameters", &_3, 311, findParams, parameters); zephir_check_call_status(); if (Z_TYPE_P(extraParameters) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&findParams, this_ptr, "_mergefindparameters", &_3, 311, findArguments, extraParameters); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(findParams, findArguments); } if (ZEPHIR_IS_STRING_IDENTICAL(method, "")) { ZEPHIR_CALL_METHOD(&_2, relation, "gettype", NULL, 0); zephir_check_call_status(); do { if (ZEPHIR_IS_LONG(_2, 0) || ZEPHIR_IS_LONG(_2, 1)) { ZEPHIR_INIT_VAR(retrieveMethod); ZVAL_STRING(retrieveMethod, "findFirst", 1); break; } if (ZEPHIR_IS_LONG(_2, 2)) { ZEPHIR_INIT_NVAR(retrieveMethod); ZVAL_STRING(retrieveMethod, "find", 1); break; } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/mvc/model/manager.zep", 1317); return; } while(0); } else { ZEPHIR_CPY_WRT(retrieveMethod, method); } ZEPHIR_INIT_VAR(arguments); zephir_create_array(arguments, 1, 0 TSRMLS_CC); zephir_array_fast_append(arguments, findParams); ZEPHIR_CALL_METHOD(&_2, relation, "isreusable", NULL, 0); zephir_check_call_status(); reusable = zephir_get_boolval(_2); if (reusable) { ZEPHIR_INIT_VAR(uniqueKey); zephir_unique_key(uniqueKey, referencedModel, arguments TSRMLS_CC); ZEPHIR_CALL_METHOD(&records, this_ptr, "getreusablerecords", NULL, 0, referencedModel, uniqueKey); zephir_check_call_status(); _15 = Z_TYPE_P(records) == IS_ARRAY; if (!(_15)) { _15 = Z_TYPE_P(records) == IS_OBJECT; } if (_15) { RETURN_CCTOR(records); } } ZEPHIR_INIT_VAR(_16); zephir_create_array(_16, 2, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "load", NULL, 0, referencedModel); zephir_check_call_status(); zephir_array_fast_append(_16, _2); zephir_array_fast_append(_16, retrieveMethod); ZEPHIR_INIT_NVAR(records); ZEPHIR_CALL_USER_FUNC_ARRAY(records, _16, arguments); zephir_check_call_status(); if (reusable) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreusablerecords", NULL, 0, referencedModel, uniqueKey, records); zephir_check_call_status(); } RETURN_CCTOR(records); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReusableRecords) { zval *modelName_param = NULL, *key_param = NULL, *records, *_0; zval *modelName = NULL, *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &modelName_param, &key_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_reusable"), PH_NOISY_CC); if (zephir_array_isset_fetch(&records, _0, key, 1 TSRMLS_CC)) { RETURN_CTOR(records); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReusableRecords) { zval *modelName_param = NULL, *key_param = NULL, *records; zval *modelName = NULL, *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &modelName_param, &key_param, &records); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_reusable"), key, records TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, clearReusableObjects) { zephir_update_property_this(this_ptr, SL("_reusable"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsToRecords) { int ZEPHIR_LAST_CALL_STATUS; zval *method_param = NULL, *modelName_param = NULL, *modelRelation, *record, *parameters = NULL, *belongsTo, *keyRelation, *relations, *_0, *_1, *_2; zval *method = NULL, *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &method_param, &modelName_param, &modelRelation, &record, ¶meters); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(belongsTo); zephir_read_property_this(&belongsTo, this_ptr, SL("_hasMany"), PH_NOISY_CC); if (Z_TYPE_P(belongsTo) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelName); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, _0, "$", _1); if (!(zephir_array_isset(belongsTo, keyRelation))) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(relations); zephir_array_fetch(&relations, belongsTo, keyRelation, PH_NOISY, "phalcon/mvc/model/manager.zep", 1404 TSRMLS_CC); zephir_array_fetch_long(&_2, relations, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1405 TSRMLS_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, _2, method, record, parameters); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyRecords) { int ZEPHIR_LAST_CALL_STATUS; zval *method_param = NULL, *modelName_param = NULL, *modelRelation, *record, *parameters = NULL, *hasMany, *keyRelation, *relations, *_0, *_1, *_2; zval *method = NULL, *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &method_param, &modelName_param, &modelRelation, &record, ¶meters); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(hasMany); zephir_read_property_this(&hasMany, this_ptr, SL("_hasMany"), PH_NOISY_CC); if (Z_TYPE_P(hasMany) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelName); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, _0, "$", _1); if (!(zephir_array_isset(hasMany, keyRelation))) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(relations); zephir_array_fetch(&relations, hasMany, keyRelation, PH_NOISY, "phalcon/mvc/model/manager.zep", 1434 TSRMLS_CC); zephir_array_fetch_long(&_2, relations, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1435 TSRMLS_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, _2, method, record, parameters); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneRecords) { int ZEPHIR_LAST_CALL_STATUS; zval *method_param = NULL, *modelName_param = NULL, *modelRelation, *record, *parameters = NULL, *hasOne, *keyRelation, *relations, *_0, *_1, *_2; zval *method = NULL, *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &method_param, &modelName_param, &modelRelation, &record, ¶meters); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(hasOne); zephir_read_property_this(&hasOne, this_ptr, SL("_hasOne"), PH_NOISY_CC); if (Z_TYPE_P(hasOne) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, modelName); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, modelRelation); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, _0, "$", _1); if (!(zephir_array_isset(hasOne, keyRelation))) { RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(relations); zephir_array_fetch(&relations, hasOne, keyRelation, PH_NOISY, "phalcon/mvc/model/manager.zep", 1464 TSRMLS_CC); zephir_array_fetch_long(&_2, relations, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/manager.zep", 1465 TSRMLS_CC); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, _2, method, record, parameters); zephir_check_call_status(); RETURN_MM(); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsTo) { zval *model, *belongsToSingle, *relations, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); belongsToSingle = zephir_fetch_nproperty_this(this_ptr, SL("_belongsToSingle"), PH_NOISY_CC); if (Z_TYPE_P(belongsToSingle) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&relations, belongsToSingle, _0, 1 TSRMLS_CC)) { RETURN_CTOR(relations); } } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasMany) { zval *model, *hasManySingle, *relations, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); hasManySingle = zephir_fetch_nproperty_this(this_ptr, SL("_hasManySingle"), PH_NOISY_CC); if (Z_TYPE_P(hasManySingle) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&relations, hasManySingle, _0, 1 TSRMLS_CC)) { RETURN_CTOR(relations); } } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOne) { zval *model, *hasOneSingle, *relations, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); hasOneSingle = zephir_fetch_nproperty_this(this_ptr, SL("_hasOneSingle"), PH_NOISY_CC); if (Z_TYPE_P(hasOneSingle) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&relations, hasOneSingle, _0, 1 TSRMLS_CC)) { RETURN_CTOR(relations); } } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyToMany) { zval *model, *hasManyToManySingle, *relations, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); hasManyToManySingle = zephir_fetch_nproperty_this(this_ptr, SL("_hasManyToManySingle"), PH_NOISY_CC); if (Z_TYPE_P(hasManyToManySingle) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); if (zephir_array_isset_fetch(&relations, hasManyToManySingle, _0, 1 TSRMLS_CC)) { RETURN_CTOR(relations); } } array_init(return_value); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneAndHasMany) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0 = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethasone", NULL, 0, model); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "gethasmany", NULL, 0, model); zephir_check_call_status(); zephir_fast_array_merge(return_value, &(_0), &(_1) TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelations) { HashTable *_1, *_4, *_7; HashPosition _0, _3, _6; zval *modelName_param = NULL, *entityName, *allRelations, *relations = NULL, *belongsTo, *relation = NULL, *hasOne, *hasMany, **_2, **_5, **_8; zval *modelName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &modelName_param); if (unlikely(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(modelName_param) == IS_STRING)) { zephir_get_strval(modelName, modelName_param); } else { ZEPHIR_INIT_VAR(modelName); ZVAL_EMPTY_STRING(modelName); } ZEPHIR_INIT_VAR(entityName); zephir_fast_strtolower(entityName, modelName); ZEPHIR_INIT_VAR(allRelations); array_init(allRelations); belongsTo = zephir_fetch_nproperty_this(this_ptr, SL("_belongsToSingle"), PH_NOISY_CC); if (Z_TYPE_P(belongsTo) == IS_ARRAY) { ZEPHIR_OBS_VAR(relations); if (zephir_array_isset_fetch(&relations, belongsTo, entityName, 0 TSRMLS_CC)) { zephir_is_iterable(relations, &_1, &_0, 0, 0, "phalcon/mvc/model/manager.zep", 1564); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(relation, _2); zephir_array_append(&allRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1562); } } } hasMany = zephir_fetch_nproperty_this(this_ptr, SL("_hasManySingle"), PH_NOISY_CC); if (Z_TYPE_P(hasMany) == IS_ARRAY) { ZEPHIR_OBS_NVAR(relations); if (zephir_array_isset_fetch(&relations, hasMany, entityName, 0 TSRMLS_CC)) { zephir_is_iterable(relations, &_4, &_3, 0, 0, "phalcon/mvc/model/manager.zep", 1576); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(relation, _5); zephir_array_append(&allRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1574); } } } hasOne = zephir_fetch_nproperty_this(this_ptr, SL("_hasOneSingle"), PH_NOISY_CC); if (Z_TYPE_P(hasOne) == IS_ARRAY) { ZEPHIR_OBS_NVAR(relations); if (zephir_array_isset_fetch(&relations, hasOne, entityName, 0 TSRMLS_CC)) { zephir_is_iterable(relations, &_7, &_6, 0, 0, "phalcon/mvc/model/manager.zep", 1588); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(relation, _8); zephir_array_append(&allRelations, relation, PH_SEPARATE, "phalcon/mvc/model/manager.zep", 1586); } } } RETURN_CCTOR(allRelations); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationsBetween) { zval *first_param = NULL, *second_param = NULL, *keyRelation, *belongsTo, *hasMany, *hasOne, *relations = NULL, *_0, *_1; zval *first = NULL, *second = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &first_param, &second_param); if (unlikely(Z_TYPE_P(first_param) != IS_STRING && Z_TYPE_P(first_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'first' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(first_param) == IS_STRING)) { zephir_get_strval(first, first_param); } else { ZEPHIR_INIT_VAR(first); ZVAL_EMPTY_STRING(first); } if (unlikely(Z_TYPE_P(second_param) != IS_STRING && Z_TYPE_P(second_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'second' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(second_param) == IS_STRING)) { zephir_get_strval(second, second_param); } else { ZEPHIR_INIT_VAR(second); ZVAL_EMPTY_STRING(second); } ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, first); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, second); ZEPHIR_INIT_VAR(keyRelation); ZEPHIR_CONCAT_VSV(keyRelation, _0, "$", _1); belongsTo = zephir_fetch_nproperty_this(this_ptr, SL("_belongsTo"), PH_NOISY_CC); if (Z_TYPE_P(belongsTo) == IS_ARRAY) { ZEPHIR_OBS_VAR(relations); if (zephir_array_isset_fetch(&relations, belongsTo, keyRelation, 0 TSRMLS_CC)) { RETURN_CCTOR(relations); } } hasMany = zephir_fetch_nproperty_this(this_ptr, SL("_hasMany"), PH_NOISY_CC); if (Z_TYPE_P(hasMany) == IS_ARRAY) { ZEPHIR_OBS_NVAR(relations); if (zephir_array_isset_fetch(&relations, hasMany, keyRelation, 0 TSRMLS_CC)) { RETURN_CCTOR(relations); } } hasOne = zephir_fetch_nproperty_this(this_ptr, SL("_hasOne"), PH_NOISY_CC); if (Z_TYPE_P(hasOne) == IS_ARRAY) { ZEPHIR_OBS_NVAR(relations); if (zephir_array_isset_fetch(&relations, hasOne, keyRelation, 0 TSRMLS_CC)) { RETURN_CCTOR(relations); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, createQuery) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *phql_param = NULL, *dependencyInjector, *query = NULL, *_0 = NULL, *_2; zval *phql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &phql_param); if (unlikely(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(phql_param) == IS_STRING)) { zephir_get_strval(phql, phql_param); } else { ZEPHIR_INIT_VAR(phql); ZVAL_EMPTY_STRING(phql); } ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection object is required to access ORM services", "phalcon/mvc/model/manager.zep", 1645); return; } ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, phql); zephir_array_fast_append(_1, dependencyInjector); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "Phalcon\\Mvc\\Model\\Query", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "get", NULL, 0, _2, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CPY_WRT(query, _0); zephir_update_property_this(this_ptr, SL("_lastQuery"), query TSRMLS_CC); RETURN_CCTOR(query); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, executeQuery) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *phql_param = NULL, *placeholders = NULL, *types = NULL, *dependencyInjector = NULL, *query = NULL, *_0, *_1 = NULL, *_3; zval *phql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &phql_param, &placeholders, &types); if (unlikely(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(phql_param) == IS_STRING)) { zephir_get_strval(phql, phql_param); } else { ZEPHIR_INIT_VAR(phql); ZVAL_EMPTY_STRING(phql); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } if (!types) { types = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection object is required to access ORM services", "phalcon/mvc/model/manager.zep", 1665); return; } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, phql); zephir_array_fast_append(_2, dependencyInjector); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Phalcon\\Mvc\\Model\\Query", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "get", NULL, 0, _3, _2); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CPY_WRT(query, _1); zephir_update_property_this(this_ptr, SL("_lastQuery"), query TSRMLS_CC); if (Z_TYPE_P(placeholders) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, query, "setbindparams", NULL, 0, placeholders); zephir_check_call_status(); } if (Z_TYPE_P(types) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, query, "setbindtypes", NULL, 0, types); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(query, "execute", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, createBuilder) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *params = NULL, *dependencyInjector = NULL, *_0, *_1 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶ms); if (!params) { params = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection object is required to access ORM services", "phalcon/mvc/model/manager.zep", 1697); return; } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, params); zephir_array_fast_append(_2, dependencyInjector); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Phalcon\\Mvc\\Model\\Query\\Builder", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "get", NULL, 0, _3, _2); zephir_check_temp_parameter(_3); zephir_check_call_status(); RETURN_CCTOR(_1); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastQuery) { RETURN_MEMBER(this_ptr, "_lastQuery"); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, registerNamespaceAlias) { zval *alias_param = NULL, *namespaceName_param = NULL; zval *alias = NULL, *namespaceName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &alias_param, &namespaceName_param); zephir_get_strval(alias, alias_param); zephir_get_strval(namespaceName, namespaceName_param); zephir_update_property_array(this_ptr, SL("_namespaceAliases"), alias, namespaceName TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getNamespaceAlias) { int ZEPHIR_LAST_CALL_STATUS; zval *alias_param = NULL, *namespaceName, *_0, *_1; zval *alias = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &alias_param); if (unlikely(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(alias_param) == IS_STRING)) { zephir_get_strval(alias, alias_param); } else { ZEPHIR_INIT_VAR(alias); ZVAL_EMPTY_STRING(alias); } ZEPHIR_OBS_VAR(namespaceName); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_namespaceAliases"), PH_NOISY_CC); if (zephir_array_isset_fetch(&namespaceName, _0, alias, 0 TSRMLS_CC)) { RETURN_CCTOR(namespaceName); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Namespace alias '", alias, "' is not registered"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/manager.zep", 1732 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Model_Manager, getNamespaceAliases) { RETURN_MEMBER(this_ptr, "_namespaceAliases"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ManagerInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ManagerInterface, phalcon, mvc_model_managerinterface, phalcon_mvc_model_managerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, initialize); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSource); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSource); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSchema); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSchema); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setReadConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setWriteConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnectionService); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isInitialized); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastInitialized); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, load); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOne); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBelongsTo); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasMany); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, existsBelongsTo); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, existsHasMany); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, existsHasOne); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsToRecords); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyRecords); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneRecords); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsTo); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasMany); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOne); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneAndHasMany); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelations); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationsBetween); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createQuery); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, executeQuery); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createBuilder); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBehavior); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, notifyEvent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, missingMethod); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastQuery); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationByAlias); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Message) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Message, phalcon, mvc_model_message, phalcon_mvc_model_message_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_message_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_message_ce, SL("_message"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_message_ce, SL("_field"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_message_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_message_ce TSRMLS_CC, 1, phalcon_mvc_model_messageinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Message, __construct) { zval *message_param = NULL, *field = NULL, *type = NULL, *model = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &message_param, &field, &type, &model); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!field) { field = ZEPHIR_GLOBAL(global_null); } if (!type) { type = ZEPHIR_GLOBAL(global_null); } if (!model) { model = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_field"), field TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); if (Z_TYPE_P(model) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Message, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Message, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Mvc_Model_Message, setMessage) { zval *message_param = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Message, getMessage) { RETURN_MEMBER(this_ptr, "_message"); } static PHP_METHOD(Phalcon_Mvc_Model_Message, setField) { zval *field; zephir_fetch_params(0, 1, 0, &field); zephir_update_property_this(this_ptr, SL("_field"), field TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Message, getField) { RETURN_MEMBER(this_ptr, "_field"); } static PHP_METHOD(Phalcon_Mvc_Model_Message, setModel) { zval *model; zephir_fetch_params(0, 1, 0, &model); zephir_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Message, getModel) { RETURN_MEMBER(this_ptr, "_model"); } static PHP_METHOD(Phalcon_Mvc_Model_Message, __toString) { RETURN_MEMBER(this_ptr, "_message"); } static PHP_METHOD(Phalcon_Mvc_Model_Message, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *_0, *_1, *_2; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); message = message_param; object_init_ex(return_value, phalcon_mvc_model_message_ce); zephir_array_fetch_string(&_0, message, SL("_message"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/message.zep", 161 TSRMLS_CC); zephir_array_fetch_string(&_1, message, SL("_field"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/message.zep", 161 TSRMLS_CC); zephir_array_fetch_string(&_2, message, SL("_type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/message.zep", 161 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 8, _0, _1, _2); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MessageInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MessageInterface, phalcon, mvc_model_messageinterface, phalcon_mvc_model_messageinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setType); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setMessage); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getMessage); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, setField); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, getField); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __toString); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MessageInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, MetaData, phalcon, mvc_model_metadata, phalcon_mvc_model_metadata_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("_strategy"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("_metaData"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("_columnMap"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_ATTRIBUTES"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_PRIMARY_KEY"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NON_PRIMARY_KEY"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NOT_NULL"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_NUMERIC"), 5 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_AT"), 6 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_IN"), 7 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_IDENTITY_COLUMN"), 8 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_BIND"), 9 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_INSERT"), 10 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_UPDATE"), 11 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DEFAULT_VALUES"), 12 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_EMPTY_STRING_VALUES"), 13 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_COLUMN_MAP"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_REVERSE_COLUMN_MAP"), 1 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, _initialize) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *model, *key, *table, *schema, *strategy = NULL, *className, *metaData, *data = NULL, *modelMetadata = NULL, *modelColumnMap = NULL, *dependencyInjector = NULL, *keyName, *prefixKey = NULL, *_0, *_1, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); ZEPHIR_INIT_VAR(strategy); ZVAL_NULL(strategy); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); if (Z_TYPE_P(key) != IS_NULL) { ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(metaData, key))) { ZEPHIR_INIT_VAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "meta-", key); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_metaData"), key, data TSRMLS_CC); } else { if ((zephir_method_exists_ex(model, SS("metadata") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(modelMetadata) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "Invalid meta-data for model ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata.zep", 119 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&modelMetadata, strategy, "getmetadata", NULL, 0, model, dependencyInjector); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_metaData"), key, modelMetadata TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelMetadata); zephir_check_call_status(); } } } if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_fast_strtolower(keyName, className); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (zephir_array_isset(_3, keyName)) { RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(prefixKey); ZEPHIR_CONCAT_SV(prefixKey, "map-", keyName); ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, prefixKey); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_NULL) { zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, data TSRMLS_CC); RETURN_MM_NULL(); } if (Z_TYPE_P(strategy) != IS_OBJECT) { ZEPHIR_OBS_NVAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", &_2, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&modelColumnMap, strategy, "getcolumnmaps", NULL, 0, model, dependencyInjector); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_columnMap"), keyName, modelColumnMap TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, prefixKey, modelColumnMap); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setStrategy) { zval *strategy; zephir_fetch_params(0, 1, 0, &strategy); zephir_update_property_this(this_ptr, SL("_strategy"), strategy TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getStrategy) { int ZEPHIR_LAST_CALL_STATUS; zval *strategy = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(strategy); zephir_read_property_this(&strategy, this_ptr, SL("_strategy"), PH_NOISY_CC); if (Z_TYPE_P(strategy) == IS_NULL) { ZEPHIR_INIT_NVAR(strategy); object_init_ex(strategy, phalcon_mvc_model_metadata_strategy_introspection_ce); if (zephir_has_constructor(strategy TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, strategy, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_strategy"), strategy TSRMLS_CC); } RETURN_CCTOR(strategy); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaData) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *source = NULL, *schema = NULL, *key, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(key); ZEPHIR_CONCAT_VSVV(key, _0, "-", schema, source); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(_1, key))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, key, source, schema); zephir_check_call_status(); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); zephir_array_fetch(&_3, _2, key, PH_NOISY | PH_READONLY, "phalcon/mvc/model/metadata.zep", 249 TSRMLS_CC); RETURN_CTOR(_3); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) { int index, ZEPHIR_LAST_CALL_STATUS; zval *model, *index_param = NULL, *source = NULL, *schema = NULL, *key, *metaData, *_0, *_1, *_2, *_3, *_4, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &index_param); index = zephir_get_intval(index_param); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(key); ZEPHIR_CONCAT_VSVV(key, _0, "-", schema, source); ZEPHIR_OBS_VAR(metaData); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); zephir_array_fetch(&_2, _1, key, PH_READONLY, "phalcon/mvc/model/metadata.zep", 271 TSRMLS_CC); if (zephir_array_isset_long_fetch(&metaData, _2, index, 0 TSRMLS_CC)) { RETURN_CCTOR(metaData); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, key, source, schema); zephir_check_call_status(); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); zephir_array_fetch(&_4, _3, key, PH_NOISY | PH_READONLY, "phalcon/mvc/model/metadata.zep", 276 TSRMLS_CC); zephir_array_fetch_long(&_5, _4, index, PH_NOISY | PH_READONLY, "phalcon/mvc/model/metadata.zep", 276 TSRMLS_CC); RETURN_CTOR(_5); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex) { zend_bool _0, _1; int index, ZEPHIR_LAST_CALL_STATUS; zval *model, *index_param = NULL, *data, *metaData, *source = NULL, *schema = NULL, *key, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &model, &index_param, &data); index = zephir_get_intval(index_param); _0 = Z_TYPE_P(data) != IS_ARRAY; if (_0) { _0 = Z_TYPE_P(data) != IS_STRING; } _1 = _0; if (_1) { _1 = Z_TYPE_P(data) != IS_BOOL; } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid data for index", "phalcon/mvc/model/metadata.zep", 291); return; } ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_get_class(_2, model, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(key); ZEPHIR_CONCAT_VSVV(key, _2, "-", schema, source); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); if (!(zephir_array_isset(_3, key))) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, key, source, schema); zephir_check_call_status(); } ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); zephir_array_update_multi(&metaData, &data TSRMLS_CC, SL("zl"), 2, key, index); zephir_update_property_this(this_ptr, SL("_metaData"), metaData TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *keyName, *data = NULL, *_0, *_1, *_2, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_get_class(keyName, model, 1 TSRMLS_CC); ZEPHIR_OBS_VAR(data); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&data, _0, keyName, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); ZVAL_NULL(_3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, _1, _2, _3); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(data); zephir_array_fetch(&data, _4, keyName, PH_NOISY, "phalcon/mvc/model/metadata.zep", 329 TSRMLS_CC); } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) { int index, ZEPHIR_LAST_CALL_STATUS; zval *model, *index_param = NULL, *keyName, *columnMapModel = NULL, *map, *_0, *_1, *_2, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &index_param); index = zephir_get_intval(index_param); if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(keyName); zephir_get_class(keyName, model, 1 TSRMLS_CC); ZEPHIR_OBS_VAR(columnMapModel); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&columnMapModel, _0, keyName, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); ZVAL_NULL(_1); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); ZVAL_NULL(_3); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, _1, _2, _3); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(columnMapModel); zephir_array_fetch(&columnMapModel, _4, keyName, PH_NOISY, "phalcon/mvc/model/metadata.zep", 354 TSRMLS_CC); } zephir_array_isset_long_fetch(&map, columnMapModel, index, 1 TSRMLS_CC); RETURN_CTOR(map); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 374); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getPrimaryKeyAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 391); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNonPrimaryKeyAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 2); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 408); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNotNullAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 3); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 425); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 4); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 442); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypesNumeric) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 5); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 459); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getIdentityField) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 8); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getBindTypes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 9); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 491); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticCreateAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 10); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 508); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticUpdateAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 11); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 525); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticCreateAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *attributes = NULL; zval *model, *attributes_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &attributes_param); zephir_get_arrval(attributes, attributes_param); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 10); ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 12, model, _0, attributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticUpdateAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *attributes = NULL; zval *model, *attributes_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &attributes_param); zephir_get_arrval(attributes, attributes_param); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 11); ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 12, model, _0, attributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setEmptyStringAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *attributes = NULL; zval *model, *attributes_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &attributes_param); zephir_get_arrval(attributes, attributes_param); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 13); ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 12, model, _0, attributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getEmptyStringAttributes) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 13); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 578); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDefaultValues) { int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 12); ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 11, model, _0); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 595); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMap) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 13, model, _0); zephir_check_call_status(); _1 = Z_TYPE_P(data) != IS_NULL; if (_1) { _1 = Z_TYPE_P(data) != IS_ARRAY; } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 613); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getReverseColumnMap) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zval *model, *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &model); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 13, model, _0); zephir_check_call_status(); _1 = Z_TYPE_P(data) != IS_NULL; if (_1) { _1 = Z_TYPE_P(data) != IS_ARRAY; } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/mvc/model/metadata.zep", 631); return; } RETURN_CCTOR(data); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, hasAttribute) { int ZEPHIR_LAST_CALL_STATUS; zval *attribute = NULL; zval *model, *attribute_param = NULL, *columnMap = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &attribute_param); zephir_get_strval(attribute, attribute_param); ZEPHIR_CALL_METHOD(&columnMap, this_ptr, "getreversecolumnmap", NULL, 0, model); zephir_check_call_status(); if (Z_TYPE_P(columnMap) == IS_ARRAY) { RETURN_MM_BOOL(zephir_array_isset(columnMap, attribute)); } else { ZEPHIR_CALL_METHOD(&_0, this_ptr, "readmetadata", NULL, 14, model); zephir_check_call_status(); zephir_array_fetch_long(&_1, _0, 4, PH_READONLY, "phalcon/mvc/model/metadata.zep", 651 TSRMLS_CC); RETURN_MM_BOOL(zephir_array_isset(_1, attribute)); } } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY_CC); RETURN_BOOL(zephir_fast_count_int(_0 TSRMLS_CC) == 0); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData, reset) { zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_metaData"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_columnMap"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaDataInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MetaDataInterface, phalcon, mvc_model_metadatainterface, phalcon_mvc_model_metadatainterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setStrategy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getStrategy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaData); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaDataIndex); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, writeMetaDataIndex); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMap); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMapIndex); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getPrimaryKeyAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNonPrimaryKeyAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNotNullAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypesNumeric); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getIdentityField); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getBindTypes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticCreateAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticUpdateAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticCreateAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticUpdateAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setEmptyStringAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getEmptyStringAttributes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDefaultValues); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getColumnMap); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getReverseColumnMap); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, hasAttribute); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, isEmpty); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, reset); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, read); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, write); #ifdef HAVE_CONFIG_H #endif static void phalcon_orm_destroy_cache(TSRMLS_D) { zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; if (phalcon_globals_ptr->orm.parser_cache != NULL) { zend_hash_destroy(phalcon_globals_ptr->orm.parser_cache); FREE_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); phalcon_globals_ptr->orm.parser_cache = NULL; } if (phalcon_globals_ptr->orm.ast_cache != NULL) { zend_hash_destroy(phalcon_globals_ptr->orm.ast_cache); FREE_HASHTABLE(phalcon_globals_ptr->orm.ast_cache); phalcon_globals_ptr->orm.ast_cache = NULL; } } static void phalcon_orm_singlequotes(zval *return_value, zval *str TSRMLS_DC) { int i; smart_str escaped_str = {0}; char *marker; if (Z_TYPE_P(str) != IS_STRING) { RETURN_ZVAL(str, 1, 0); } marker = Z_STRVAL_P(str); for (i = 0; i < Z_STRLEN_P(str); i++) { if ((*marker) == '\0') { break; } if ((*marker) == '\'') { if (i > 0) { if (*(marker - 1) != '\\') { smart_str_appendc(&escaped_str, '\''); } } else { smart_str_appendc(&escaped_str, '\''); } } smart_str_appendc(&escaped_str, (*marker)); marker++; } smart_str_0(&escaped_str); if (escaped_str.len) { RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); } smart_str_free(&escaped_str); RETURN_EMPTY_STRING(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Query, phalcon, mvc_model_query, phalcon_mvc_model_query_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_manager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_metaData"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_phql"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_ast"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_intermediate"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_models"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_sqlAliases"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_sqlAliasesModels"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_sqlModelsAliases"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_sqlAliasesModelsInstances"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_sqlColumnAliases"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_modelsInstances"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_cacheOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_uniqueRow"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_bindParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_bindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_enableImplicitJoins"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_ce, SL("_irPhqlCache"), ZEND_ACC_STATIC|ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_SELECT"), 309 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_INSERT"), 306 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_UPDATE"), 300 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_DELETE"), 303 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_query_ce TSRMLS_CC, 1, phalcon_mvc_model_queryinterface_ce); zend_class_implements(phalcon_mvc_model_query_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Query, __construct) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *phql = NULL, *dependencyInjector = NULL, *options = NULL, *enableImplicitJoins; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &phql, &dependencyInjector, &options); if (!phql) { phql = ZEPHIR_GLOBAL(global_null); } if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(phql) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_phql"), phql TSRMLS_CC); } if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, dependencyInjector); zephir_check_call_status(); } _0 = Z_TYPE_P(options) == IS_ARRAY; if (_0) { ZEPHIR_OBS_VAR(enableImplicitJoins); _0 = zephir_array_isset_string_fetch(&enableImplicitJoins, options, SS("enable_implicit_joins"), 0 TSRMLS_CC); } if (_0) { if (ZEPHIR_IS_TRUE(enableImplicitJoins)) { zephir_update_property_this(this_ptr, SL("_enableImplicitJoins"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_enableImplicitJoins"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (ZEPHIR_GLOBAL(orm).enable_implicit_joins) { zephir_update_property_this(this_ptr, SL("_enableImplicitJoins"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_enableImplicitJoins"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setDI) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector, *manager = NULL, *metaData = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &dependencyInjector); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "modelsManager", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&manager, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(manager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsManager' is invalid", "phalcon/mvc/model/query.zep", 147); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(metaData) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsMetaData' is invalid", "phalcon/mvc/model/query.zep", 152); return; } zephir_update_property_this(this_ptr, SL("_manager"), manager TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_metaData"), metaData TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setUniqueRow) { zval *uniqueRow_param = NULL; zend_bool uniqueRow; zephir_fetch_params(0, 1, 0, &uniqueRow_param); uniqueRow = zephir_get_boolval(uniqueRow_param); if (uniqueRow) { zephir_update_property_this(this_ptr, SL("_uniqueRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_uniqueRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getUniqueRow) { RETURN_MEMBER(this_ptr, "_uniqueRow"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getQualified) { zephir_fcall_cache_entry *_7 = NULL; HashTable *_4; HashPosition _3; int number, ZEPHIR_LAST_CALL_STATUS; zval *expr_param = NULL, *columnName, *sqlColumnAliases, *metaData, *sqlAliases, *source = NULL, *sqlAliasesModelsInstances, *realColumnName = NULL, *columnDomain, *model = NULL, *models, *columnMap = NULL, *hasModel = NULL, *className, *_0 = NULL, *_1, *_2 = NULL, **_5, *_6 = NULL, *_8; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_OBS_VAR(columnName); zephir_array_fetch_string(&columnName, expr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 196 TSRMLS_CC); ZEPHIR_OBS_VAR(sqlColumnAliases); zephir_read_property_this(&sqlColumnAliases, this_ptr, SL("_sqlColumnAliases"), PH_NOISY_CC); if (zephir_array_isset(sqlColumnAliases, columnName)) { zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("qualified"), 1); zephir_array_update_string(&return_value, SL("name"), &columnName, PH_COPY | PH_SEPARATE); RETURN_MM(); } ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnDomain); if (zephir_array_isset_string_fetch(&columnDomain, expr, SS("domain"), 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(sqlAliases); zephir_read_property_this(&sqlAliases, this_ptr, SL("_sqlAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(source); if (!(zephir_array_isset_fetch(&source, sqlAliases, columnDomain, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVSV(_2, "Unknown model or alias '", columnDomain, "' (11), when preparing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 222 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_OBS_VAR(sqlAliasesModelsInstances); zephir_read_property_this(&sqlAliasesModelsInstances, this_ptr, SL("_sqlAliasesModelsInstances"), PH_NOISY_CC); ZEPHIR_OBS_VAR(model); if (!(zephir_array_isset_fetch(&model, sqlAliasesModelsInstances, columnDomain, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSV(_2, "There is no model related to model or alias '", columnDomain, "', when executing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 239 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, model); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_VAR(realColumnName); if (!(zephir_array_isset_fetch(&realColumnName, columnMap, columnName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSVSV(_2, "Column '", columnName, "' doesn't belong to the model or alias '", columnDomain, "', when executing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 249 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(realColumnName, columnName); } } else { number = 0; ZEPHIR_INIT_VAR(hasModel); ZVAL_BOOL(hasModel, 0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); zephir_is_iterable(_1, &_4, &_3, 0, 0, "phalcon/mvc/model/query.zep", 279); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(model, _5); ZEPHIR_CALL_METHOD(&_6, metaData, "hasattribute", &_7, 0, model, columnName); zephir_check_call_status(); if (zephir_is_true(_6)) { number++; if (number > 1) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _8 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSV(_2, "The column '", columnName, "' is ambiguous, when preparing: ", _8); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 270 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CPY_WRT(hasModel, model); } } if (ZEPHIR_IS_FALSE_IDENTICAL(hasModel)) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSV(_2, "Column '", columnName, "' doesn't belong to any of the selected models (1), when preparing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 280 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(models); zephir_read_property_this(&models, this_ptr, SL("_models"), PH_NOISY_CC); if (Z_TYPE_P(models) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The models list was not loaded correctly", "phalcon/mvc/model/query.zep", 288); return; } ZEPHIR_INIT_VAR(className); zephir_get_class(className, hasModel, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(source); if (!(zephir_array_isset_fetch(&source, models, className, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSV(_2, "Can't obtain model's source from models list: '", className, "', when preparing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 296 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, hasModel); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(realColumnName); if (!(zephir_array_isset_fetch(&realColumnName, columnMap, columnName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSV(_2, "Column '", columnName, "' doesn't belong to any of the selected models (3), when preparing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 313 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(realColumnName, columnName); } } zephir_create_array(return_value, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("qualified"), 1); zephir_array_update_string(&return_value, SL("domain"), &source, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("name"), &realColumnName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("balias"), &columnName, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getCallArgument) { int ZEPHIR_LAST_CALL_STATUS; zval *argument_param = NULL, *_0; zval *argument = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &argument_param); argument = argument_param; zephir_array_fetch_string(&_0, argument, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 336 TSRMLS_CC); if (ZEPHIR_IS_LONG(_0, 352)) { zephir_create_array(return_value, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("all"), 1); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getexpression", NULL, 317, argument); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getCaseExpression) { zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *expr_param = NULL, *whenClauses, *whenExpr = NULL, *_0, **_3, *_5 = NULL, *_6, *_8; zval *expr = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_INIT_VAR(whenClauses); array_init(whenClauses); zephir_array_fetch_string(&_0, expr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 350 TSRMLS_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/model/query.zep", 365); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(whenExpr, _3); if (zephir_array_isset_string(whenExpr, SS("right"))) { ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_4, SS("type"), SL("when"), 1); zephir_array_fetch_string(&_6, whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 354 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, this_ptr, "_getexpression", &_7, 317, _6); zephir_check_call_status(); zephir_array_update_string(&_4, SL("expr"), &_5, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_8, whenExpr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 355 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, this_ptr, "_getexpression", &_7, 317, _8); zephir_check_call_status(); zephir_array_update_string(&_4, SL("then"), &_5, PH_COPY | PH_SEPARATE); zephir_array_append(&whenClauses, _4, PH_SEPARATE, "phalcon/mvc/model/query.zep", 356); } else { ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(_4, SS("type"), SL("else"), 1); zephir_array_fetch_string(&_6, whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 360 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, this_ptr, "_getexpression", &_7, 317, _6); zephir_check_call_status(); zephir_array_update_string(&_4, SL("expr"), &_5, PH_COPY | PH_SEPARATE); zephir_array_append(&whenClauses, _4, PH_SEPARATE, "phalcon/mvc/model/query.zep", 361); } } zephir_create_array(return_value, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("case"), 1); zephir_array_fetch_string(&_6, expr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 367 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_5, this_ptr, "_getexpression", &_7, 317, _6); zephir_check_call_status(); zephir_array_update_string(&return_value, SL("expr"), &_5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("when-clauses"), &whenClauses, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getFunctionCall) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_1; HashPosition _0; int distinct, ZEPHIR_LAST_CALL_STATUS; zval *expr_param = NULL, *arguments, *argument = NULL, *functionArgs, **_2, *_3 = NULL, *_5 = NULL, *_6; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_OBS_VAR(arguments); if (zephir_array_isset_string_fetch(&arguments, expr, SS("arguments"), 0 TSRMLS_CC)) { if (zephir_array_isset_string(expr, SS("distinct"))) { distinct = 1; } else { distinct = 0; } ZEPHIR_INIT_VAR(functionArgs); if (zephir_array_isset_long(arguments, 0)) { array_init(functionArgs); zephir_is_iterable(arguments, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 393); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(argument, _2); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getcallargument", &_4, 318, argument); zephir_check_call_status(); zephir_array_append(&functionArgs, _3, PH_SEPARATE, "phalcon/mvc/model/query.zep", 391); } } else { zephir_create_array(functionArgs, 1, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getcallargument", &_4, 318, arguments); zephir_check_call_status(); zephir_array_fast_append(functionArgs, _3); } if (distinct) { zephir_create_array(return_value, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("functionCall"), 1); ZEPHIR_OBS_VAR(_5); zephir_array_fetch_string(&_5, expr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 401 TSRMLS_CC); zephir_array_update_string(&return_value, SL("name"), &_5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, distinct); zephir_array_update_string(&return_value, SL("distinct"), &_6, PH_COPY | PH_SEPARATE); RETURN_MM(); } else { zephir_create_array(return_value, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("functionCall"), 1); ZEPHIR_OBS_NVAR(_5); zephir_array_fetch_string(&_5, expr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 408 TSRMLS_CC); zephir_array_update_string(&return_value, SL("name"), &_5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); RETURN_MM(); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("functionCall"), 1); ZEPHIR_OBS_NVAR(_5); zephir_array_fetch_string(&_5, expr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 417 TSRMLS_CC); zephir_array_update_string(&return_value, SL("name"), &_5, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getExpression) { HashTable *_14; HashPosition _13; zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool quoting, tempNotQuoting; zval *expr, *quoting_param = NULL, *exprType, *exprLeft, *exprRight, *left = NULL, *right = NULL, *listItems, *exprListItem = NULL, *exprReturn = NULL, *value = NULL, *escapedValue = NULL, *exprValue = NULL, *valueParts, *name, *bindType, *bind, *_0 = NULL, *_3 = NULL, *_4, _5, _6, *_7 = NULL, *_8 = NULL, *_9, *_10 = NULL, *_11, *_12 = NULL, **_15; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &expr, "ing_param); if (!quoting_param) { quoting = 1; } else { quoting = zephir_get_boolval(quoting_param); } ZEPHIR_INIT_VAR(left); ZVAL_NULL(left); ZEPHIR_INIT_VAR(right); ZVAL_NULL(right); ZEPHIR_OBS_VAR(exprType); if (zephir_array_isset_string_fetch(&exprType, expr, SS("type"), 0 TSRMLS_CC)) { tempNotQuoting = 1; if (!ZEPHIR_IS_LONG(exprType, 409)) { ZEPHIR_OBS_VAR(exprLeft); if (zephir_array_isset_string_fetch(&exprLeft, expr, SS("left"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0); if (tempNotQuoting) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&left, this_ptr, "_getexpression", &_1, 317, exprLeft, _0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(exprRight); if (zephir_array_isset_string_fetch(&exprRight, expr, SS("right"), 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_0); if (tempNotQuoting) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&right, this_ptr, "_getexpression", &_1, 317, exprRight, _0); zephir_check_call_status(); } } do { if (ZEPHIR_IS_LONG(exprType, '<')) { ZEPHIR_INIT_VAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("<"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '=')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("="), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '>')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL(">"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 270)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("<>"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 271)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("<="), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 272)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL(">="), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 266)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("AND"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 267)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("OR"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 355)) { ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "_getqualified", &_2, 319, expr); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(exprType, '+')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("+"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '-')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("-"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '*')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("*"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '/')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("/"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '%')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("%"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '&')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("&"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '|')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("|"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 356) || ZEPHIR_IS_LONG(exprType, 407)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("parentheses"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 367)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("-"), 1); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 258) || ZEPHIR_IS_LONG(exprType, 259) || ZEPHIR_IS_LONG(exprType, 414)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); ZEPHIR_OBS_VAR(_3); zephir_array_fetch_string(&_3, expr, SL("value"), PH_NOISY, "phalcon/mvc/model/query.zep", 535 TSRMLS_CC); zephir_array_update_string(&exprReturn, SL("value"), &_3, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 333)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); add_assoc_stringl_ex(exprReturn, SS("value"), SL("TRUE"), 1); break; } if (ZEPHIR_IS_LONG(exprType, 334)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); add_assoc_stringl_ex(exprReturn, SS("value"), SL("FALSE"), 1); break; } if (ZEPHIR_IS_LONG(exprType, 260)) { ZEPHIR_OBS_VAR(value); zephir_array_fetch_string(&value, expr, SL("value"), PH_NOISY, "phalcon/mvc/model/query.zep", 547 TSRMLS_CC); if (quoting == 1) { if (zephir_memnstr_str(value, SL("'"), "phalcon/mvc/model/query.zep", 552)) { ZEPHIR_INIT_VAR(escapedValue); phalcon_orm_singlequotes(escapedValue, value TSRMLS_CC); } else { ZEPHIR_CPY_WRT(escapedValue, value); } ZEPHIR_INIT_VAR(exprValue); ZEPHIR_CONCAT_SVS(exprValue, "'", escapedValue, "'"); } else { ZEPHIR_CPY_WRT(exprValue, value); } ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); zephir_array_update_string(&exprReturn, SL("value"), &exprValue, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 273)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_NVAR(_0); zephir_array_fetch_string(&_4, expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 565 TSRMLS_CC); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "?", 0); ZEPHIR_SINIT_VAR(_6); ZVAL_STRING(&_6, ":", 0); zephir_fast_str_replace(&_0, &_5, &_6, _4 TSRMLS_CC); zephir_array_update_string(&exprReturn, SL("value"), &_0, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 274)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); zephir_array_fetch_string(&_4, expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 569 TSRMLS_CC); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, ":", _4); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 277)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch_string(&value, expr, SL("value"), PH_NOISY, "phalcon/mvc/model/query.zep", 573 TSRMLS_CC); if (zephir_memnstr_str(value, SL(":"), "phalcon/mvc/model/query.zep", 574)) { ZEPHIR_INIT_VAR(valueParts); zephir_fast_explode_str(valueParts, SL(":"), value, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(name); zephir_array_fetch_long(&name, valueParts, 0, PH_NOISY, "phalcon/mvc/model/query.zep", 577 TSRMLS_CC); ZEPHIR_OBS_VAR(bindType); zephir_array_fetch_long(&bindType, valueParts, 1, PH_NOISY, "phalcon/mvc/model/query.zep", 578 TSRMLS_CC); do { if (ZEPHIR_IS_STRING(bindType, "str")) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 2); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _0 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "int")) { ZEPHIR_INIT_VAR(_8); ZVAL_LONG(_8, 1); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _8 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "double")) { ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 32); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _8 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "bool")) { ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 5); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _8 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "blob")) { ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 3); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _8 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "null")) { ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, 0); zephir_update_property_array(this_ptr, SL("_bindTypes"), name, _8 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(bindType, "array") || ZEPHIR_IS_STRING(bindType, "array-str") || ZEPHIR_IS_STRING(bindType, "array-int")) { ZEPHIR_OBS_VAR(bind); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&bind, _9, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "Bind value is required for array type placeholder: ", name); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/query.zep", 617 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(bind) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_SV(_10, "Bind type requires an array in placeholder: ", name); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/query.zep", 621 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_fast_count_int(bind TSRMLS_CC) < 1) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SV(_10, "At least one value must be bound in placeholder: ", name); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/query.zep", 625 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SV(_10, ":", name); zephir_array_update_string(&exprReturn, SL("value"), &_10, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("rawValue"), &name, PH_COPY | PH_SEPARATE); add_assoc_long_ex(exprReturn, SS("times"), zephir_fast_count_int(bind TSRMLS_CC)); break; } ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SV(_10, "Unknown bind type: ", bindType); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/query.zep", 637 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); } else { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("placeholder"), 1); ZEPHIR_INIT_VAR(_11); ZEPHIR_CONCAT_SV(_11, ":", value); zephir_array_update_string(&exprReturn, SL("value"), &_11, PH_COPY | PH_SEPARATE); } break; } if (ZEPHIR_IS_LONG(exprType, 322)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); add_assoc_stringl_ex(exprReturn, SS("value"), SL("NULL"), 1); break; } if (ZEPHIR_IS_LONG(exprType, 268)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("LIKE"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 351)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("NOT LIKE"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 275)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("ILIKE"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 357)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("NOT ILIKE"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, '!')) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("NOT "), 1); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 365)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL(" IS NULL"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 366)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL(" IS NOT NULL"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 315)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("IN"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 323)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("NOT IN"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 408)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("EXISTS"), 1); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 330)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("unary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("DISTINCT "), 1); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 331)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("BETWEEN"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 276)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(exprReturn, SS("op"), SL("AGAINST"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 332)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("cast"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 335)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("convert"), 1); zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 358)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("literal"), 1); ZEPHIR_OBS_NVAR(_3); zephir_array_fetch_string(&_3, expr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 710 TSRMLS_CC); zephir_array_update_string(&exprReturn, SL("value"), &_3, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_LONG(exprType, 350)) { ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "_getfunctioncall", NULL, 320, expr); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(exprType, 409)) { ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "_getcaseexpression", NULL, 321, expr); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(exprType, 309)) { ZEPHIR_INIT_NVAR(exprReturn); zephir_create_array(exprReturn, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(exprReturn, SS("type"), SL("select"), 1); ZEPHIR_INIT_NVAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(&_12, this_ptr, "_prepareselect", NULL, 322, expr, _0); zephir_check_call_status(); zephir_array_update_string(&exprReturn, SL("value"), &_12, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "Unknown expression type ", exprType); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 726 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); RETURN_CCTOR(exprReturn); } if (zephir_array_isset_string(expr, SS("domain"))) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_getqualified", &_2, 319, expr); zephir_check_call_status(); RETURN_MM(); } if (zephir_array_isset_long(expr, 0)) { ZEPHIR_INIT_VAR(listItems); array_init(listItems); zephir_is_iterable(expr, &_14, &_13, 0, 0, "phalcon/mvc/model/query.zep", 747); for ( ; zephir_hash_get_current_data_ex(_14, (void**) &_15, &_13) == SUCCESS ; zephir_hash_move_forward_ex(_14, &_13) ) { ZEPHIR_GET_HVALUE(exprListItem, _15); ZEPHIR_CALL_METHOD(&_12, this_ptr, "_getexpression", &_1, 317, exprListItem); zephir_check_call_status(); zephir_array_append(&listItems, _12, PH_SEPARATE, "phalcon/mvc/model/query.zep", 745); } zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("type"), SL("list"), 1); zephir_array_fast_append(return_value, listItems); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown expression", "phalcon/mvc/model/query.zep", 750); return; } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getSelectColumn) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_5 = NULL; HashTable *_2; HashPosition _1; zval *column_param = NULL, *sqlColumns, *columnType, *sqlAliases, *modelName = NULL, *source = NULL, *columnDomain, *sqlColumnAlias = NULL, *preparedAlias = NULL, *sqlExprColumn = NULL, *sqlAliasesModels, *sqlColumn = NULL, *columnData, *balias, *eager, *_0, **_3, *_4 = NULL, *_6, *_7 = NULL, *_8 = NULL, *_9; zval *column = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &column_param); column = column_param; ZEPHIR_OBS_VAR(columnType); if (!(zephir_array_isset_string_fetch(&columnType, column, SS("type"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 764); return; } ZEPHIR_INIT_VAR(sqlColumns); array_init(sqlColumns); ZEPHIR_OBS_VAR(eager); zephir_array_isset_string_fetch(&eager, column, SS("eager"), 0 TSRMLS_CC); if (ZEPHIR_IS_LONG(columnType, 352)) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_models"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/model/query.zep", 794); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(modelName, _2, _1); ZEPHIR_GET_HVALUE(source, _3); ZEPHIR_INIT_NVAR(sqlColumn); zephir_create_array(sqlColumn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(sqlColumn, SS("type"), SL("object"), 1); zephir_array_update_string(&sqlColumn, SL("model"), &modelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlColumn, SL("column"), &source, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_4, "lcfirst", &_5, 68, modelName); zephir_check_call_status(); zephir_array_update_string(&sqlColumn, SL("balias"), &_4, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(eager) != IS_NULL) { zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_6, column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 789 TSRMLS_CC); zephir_array_update_string(&sqlColumn, SL("eagerType"), &_6, PH_COPY | PH_SEPARATE); } zephir_array_append(&sqlColumns, sqlColumn, PH_SEPARATE, "phalcon/mvc/model/query.zep", 792); } RETURN_CCTOR(sqlColumns); } if (!(zephir_array_isset_string(column, SS("column")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 798); return; } if (ZEPHIR_IS_LONG(columnType, 353)) { ZEPHIR_OBS_VAR(sqlAliases); zephir_read_property_this(&sqlAliases, this_ptr, SL("_sqlAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnDomain); zephir_array_fetch_string(&columnDomain, column, SL("column"), PH_NOISY, "phalcon/mvc/model/query.zep", 811 TSRMLS_CC); ZEPHIR_OBS_VAR(source); if (!(zephir_array_isset_fetch(&source, sqlAliases, columnDomain, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVSV(_8, "Unknown model or alias '", columnDomain, "' (2), when preparing: ", _0); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/query.zep", 814 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CPY_WRT(sqlColumnAlias, source); ZEPHIR_OBS_VAR(preparedAlias); zephir_array_isset_string_fetch(&preparedAlias, column, SS("balias"), 0 TSRMLS_CC); ZEPHIR_OBS_VAR(sqlAliasesModels); zephir_read_property_this(&sqlAliasesModels, this_ptr, SL("_sqlAliasesModels"), PH_NOISY_CC); ZEPHIR_OBS_VAR(modelName); zephir_array_fetch(&modelName, sqlAliasesModels, columnDomain, PH_NOISY, "phalcon/mvc/model/query.zep", 828 TSRMLS_CC); if (Z_TYPE_P(preparedAlias) != IS_STRING) { if (ZEPHIR_IS_EQUAL(columnDomain, modelName)) { ZEPHIR_CALL_FUNCTION(&preparedAlias, "lcfirst", &_5, 68, modelName); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(preparedAlias, columnDomain); } } ZEPHIR_INIT_NVAR(sqlColumn); zephir_create_array(sqlColumn, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(sqlColumn, SS("type"), SL("object"), 1); zephir_array_update_string(&sqlColumn, SL("model"), &modelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlColumn, SL("column"), &sqlColumnAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlColumn, SL("balias"), &preparedAlias, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(eager) != IS_NULL) { zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_6, column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 854 TSRMLS_CC); zephir_array_update_string(&sqlColumn, SL("eagerType"), &_6, PH_COPY | PH_SEPARATE); } zephir_array_append(&sqlColumns, sqlColumn, PH_SEPARATE, "phalcon/mvc/model/query.zep", 857); RETURN_CCTOR(sqlColumns); } if (ZEPHIR_IS_LONG(columnType, 354)) { ZEPHIR_INIT_NVAR(sqlColumn); zephir_create_array(sqlColumn, 1, 0 TSRMLS_CC); add_assoc_stringl_ex(sqlColumn, SS("type"), SL("scalar"), 1); ZEPHIR_OBS_VAR(columnData); zephir_array_fetch_string(&columnData, column, SL("column"), PH_NOISY, "phalcon/mvc/model/query.zep", 871 TSRMLS_CC); ZEPHIR_CALL_METHOD(&sqlExprColumn, this_ptr, "_getexpression", NULL, 317, columnData); zephir_check_call_status(); ZEPHIR_OBS_VAR(balias); if (zephir_array_isset_string_fetch(&balias, sqlExprColumn, SS("balias"), 0 TSRMLS_CC)) { zephir_array_update_string(&sqlColumn, SL("balias"), &balias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &balias, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(eager) != IS_NULL) { zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); zephir_array_fetch_string(&_9, column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 884 TSRMLS_CC); zephir_array_update_string(&sqlColumn, SL("eagerType"), &_9, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&sqlColumn, SL("column"), &sqlExprColumn, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlColumns, sqlColumn, PH_SEPARATE, "phalcon/mvc/model/query.zep", 888); RETURN_CCTOR(sqlColumns); } ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SV(_8, "Unknown type of column ", columnType); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/query.zep", 893 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getTable) { int ZEPHIR_LAST_CALL_STATUS; zval *manager, *qualifiedName, *modelName, *model = NULL, *source = NULL, *schema = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &manager, &qualifiedName); ZEPHIR_OBS_VAR(modelName); if (!(zephir_array_isset_string_fetch(&modelName, qualifiedName, SS("name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 908); return; } ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, modelName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, schema); zephir_array_fast_append(return_value, source); RETURN_MM(); } RETURN_CCTOR(source); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getJoin) { int ZEPHIR_LAST_CALL_STATUS; zval *manager, *join, *qualified, *modelName, *realModelName = NULL, *nsAlias, *source = NULL, *model = NULL, *schema = NULL, *_0, *_1 = NULL, *_2, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &manager, &join); ZEPHIR_OBS_VAR(qualified); if (zephir_array_isset_string_fetch(&qualified, join, SS("qualified"), 0 TSRMLS_CC)) { zephir_array_fetch_string(&_0, qualified, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 932 TSRMLS_CC); if (ZEPHIR_IS_LONG(_0, 355)) { ZEPHIR_OBS_VAR(modelName); zephir_array_fetch_string(&modelName, qualified, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 934 TSRMLS_CC); if (zephir_memnstr_str(modelName, SL(":"), "phalcon/mvc/model/query.zep", 936)) { ZEPHIR_INIT_VAR(nsAlias); zephir_fast_explode_str(nsAlias, SL(":"), modelName, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_2, nsAlias, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 938 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_1, manager, "getnamespacealias", NULL, 0, _2); zephir_check_call_status(); zephir_array_fetch_long(&_3, nsAlias, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 938 TSRMLS_CC); ZEPHIR_INIT_VAR(realModelName); ZEPHIR_CONCAT_VSV(realModelName, _1, "\\", _3); } else { ZEPHIR_CPY_WRT(realModelName, modelName); } ZEPHIR_INIT_VAR(_4); ZVAL_BOOL(_4, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, realModelName, _4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); zephir_create_array(return_value, 4, 0 TSRMLS_CC); zephir_array_update_string(&return_value, SL("schema"), &schema, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("source"), &source, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("modelName"), &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("model"), &model, PH_COPY | PH_SEPARATE); RETURN_MM(); } } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 956); return; } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getJoinType) { int ZEPHIR_LAST_CALL_STATUS; zval *join, *type, *_0, *_1, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &join); ZEPHIR_OBS_VAR(type); if (!(zephir_array_isset_string_fetch(&type, join, SS("type"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 970); return; } do { if (ZEPHIR_IS_LONG(type, 360)) { RETURN_MM_STRING("INNER", 1); } if (ZEPHIR_IS_LONG(type, 361)) { RETURN_MM_STRING("LEFT", 1); } if (ZEPHIR_IS_LONG(type, 362)) { RETURN_MM_STRING("RIGHT", 1); } if (ZEPHIR_IS_LONG(type, 363)) { RETURN_MM_STRING("CROSS", 1); } if (ZEPHIR_IS_LONG(type, 364)) { RETURN_MM_STRING("FULL OUTER", 1); } } while(0); ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVSV(_2, "Unknown join type ", type, ", when preparing: ", _1); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/query.zep", 991 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getSingleJoin) { HashTable *_6; HashPosition _5; zephir_fcall_cache_entry *_3 = NULL, *_11 = NULL; zval *_0 = NULL, *_2 = NULL, *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *joinType_param = NULL, *joinSource, *modelAlias, *joinAlias, *relation, *fields = NULL, *referencedFields = NULL, *sqlJoinConditions = NULL, *sqlJoinPartialConditions, *position = NULL, *field = NULL, *referencedField = NULL, *_1 = NULL, **_7, *_8 = NULL, *_9, *_10 = NULL; zval *joinType = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias, &joinAlias, &relation); if (unlikely(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(joinType_param) == IS_STRING)) { zephir_get_strval(joinType, joinType_param); } else { ZEPHIR_INIT_VAR(joinType); ZVAL_EMPTY_STRING(joinType); } ZEPHIR_INIT_VAR(sqlJoinConditions); ZVAL_NULL(sqlJoinConditions); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(fields) != IS_ARRAY) { ZEPHIR_INIT_NVAR(sqlJoinConditions); zephir_create_array(sqlJoinConditions, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(_0, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(_0, SS("op"), SL("="), 1); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 3, 0 TSRMLS_CC); add_assoc_long_ex(_2, SS("type"), 355); zephir_array_update_string(&_2, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_2, SL("name"), &fields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getqualified", &_3, 319, _2); zephir_check_call_status(); zephir_array_update_string(&_0, SL("left"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_4, SS("type"), SL("qualified"), 1); zephir_array_update_string(&_4, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getqualified", &_3, 319, _4); zephir_check_call_status(); zephir_array_update_string(&_0, SL("right"), &_1, PH_COPY | PH_SEPARATE); zephir_array_fast_append(sqlJoinConditions, _0); } else { ZEPHIR_INIT_VAR(sqlJoinPartialConditions); array_init(sqlJoinPartialConditions); zephir_is_iterable(fields, &_6, &_5, 0, 0, "phalcon/mvc/model/query.zep", 1079); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HMKEY(position, _6, _5); ZEPHIR_GET_HVALUE(field, _7); ZEPHIR_OBS_NVAR(referencedField); if (!(zephir_array_isset_fetch(&referencedField, referencedFields, position, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_8); object_init_ex(_8, phalcon_mvc_model_exception_ce); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSVSV(_10, "The number of fields must be equal to the number of referenced fields in join ", modelAlias, "-", joinAlias, ", when preparing: ", _9); ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_11, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_8, "phalcon/mvc/model/query.zep", 1055 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(_0, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(_0, SS("op"), SL("="), 1); ZEPHIR_INIT_NVAR(_2); zephir_create_array(_2, 3, 0 TSRMLS_CC); add_assoc_long_ex(_2, SS("type"), 355); zephir_array_update_string(&_2, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_2, SL("name"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getqualified", &_3, 319, _2); zephir_check_call_status(); zephir_array_update_string(&_0, SL("left"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_4, SS("type"), SL("qualified"), 1); zephir_array_update_string(&_4, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_1, this_ptr, "_getqualified", &_3, 319, _4); zephir_check_call_status(); zephir_array_update_string(&_0, SL("right"), &_1, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlJoinPartialConditions, _0, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1076); } } zephir_create_array(return_value, 3, 0 TSRMLS_CC); zephir_array_update_string(&return_value, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("conditions"), &sqlJoinConditions, PH_COPY | PH_SEPARATE); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getMultiJoin) { zval *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12, *_13, *_14, *_15; zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL; HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *joinType, *joinSource, *modelAlias, *joinAlias, *relation, *sqlJoins = NULL, *fields = NULL, *referencedFields = NULL, *intermediateModelName = NULL, *intermediateModel = NULL, *intermediateSource = NULL, *intermediateSchema = NULL, *intermediateFields = NULL, *intermediateReferencedFields = NULL, *referencedModelName = NULL, *manager, *field = NULL, *position = NULL, *intermediateField = NULL, *sqlEqualsJoinCondition = NULL, **_2, *_3 = NULL, *_4, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); ZEPHIR_INIT_VAR(sqlJoins); array_init(sqlJoins); ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateModelName, relation, "getintermediatemodel", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&intermediateModel, manager, "load", NULL, 0, intermediateModelName); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateSource, intermediateModel, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateSchema, intermediateModel, "getschema", NULL, 0); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_sqlAliases"), intermediateModelName, intermediateSource TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_sqlAliasesModelsInstances"), intermediateModelName, intermediateModel TSRMLS_CC); ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&intermediateReferencedFields, relation, "getintermediatereferencedfields", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&referencedModelName, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(fields) == IS_ARRAY) { zephir_is_iterable(fields, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 1204); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(field, _1, _0); ZEPHIR_GET_HVALUE(position, _2); if (!(zephir_array_isset(referencedFields, position))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_model_exception_ce); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVSV(_5, "The number of fields must be equal to the number of referenced fields in join ", modelAlias, "-", joinAlias, ", when preparing: ", _4); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_6, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/model/query.zep", 1175 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(intermediateField); zephir_array_fetch(&intermediateField, intermediateFields, position, PH_NOISY, "phalcon/mvc/model/query.zep", 1181 TSRMLS_CC); ZEPHIR_INIT_NVAR(sqlEqualsJoinCondition); zephir_create_array(sqlEqualsJoinCondition, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(sqlEqualsJoinCondition, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(sqlEqualsJoinCondition, SS("op"), SL("="), 1); ZEPHIR_INIT_NVAR(_8); zephir_create_array(_8, 3, 0 TSRMLS_CC); add_assoc_long_ex(_8, SS("type"), 355); zephir_array_update_string(&_8, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_8, SL("name"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _8); zephir_check_call_status(); zephir_array_update_string(&sqlEqualsJoinCondition, SL("left"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_10, SS("type"), SL("qualified"), 1); zephir_array_update_string(&_10, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_10, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _10); zephir_check_call_status(); zephir_array_update_string(&sqlEqualsJoinCondition, SL("right"), &_7, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_NVAR(sqlJoins); zephir_create_array(sqlJoins, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); zephir_create_array(_8, 3, 0 TSRMLS_CC); zephir_array_update_string(&_8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_8, SL("source"), &intermediateSource, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(_11, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(_11, SS("op"), SL("="), 1); ZEPHIR_INIT_VAR(_12); zephir_create_array(_12, 3, 0 TSRMLS_CC); add_assoc_long_ex(_12, SS("type"), 355); zephir_array_update_string(&_12, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_12, SL("name"), &fields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _12); zephir_check_call_status(); zephir_array_update_string(&_11, SL("left"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_13); zephir_create_array(_13, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_13, SS("type"), SL("qualified"), 1); zephir_array_update_string(&_13, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_13, SL("name"), &intermediateFields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _13); zephir_check_call_status(); zephir_array_update_string(&_11, SL("right"), &_7, PH_COPY | PH_SEPARATE); zephir_array_fast_append(_10, _11); zephir_array_update_string(&_8, SL("conditions"), &_10, PH_COPY | PH_SEPARATE); zephir_array_fast_append(sqlJoins, _8); ZEPHIR_INIT_NVAR(_8); zephir_create_array(_8, 3, 0 TSRMLS_CC); zephir_array_update_string(&_8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_8, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_10); zephir_create_array(_10, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); zephir_create_array(_11, 4, 0 TSRMLS_CC); add_assoc_stringl_ex(_11, SS("type"), SL("binary-op"), 1); add_assoc_stringl_ex(_11, SS("op"), SL("="), 1); ZEPHIR_INIT_VAR(_14); zephir_create_array(_14, 3, 0 TSRMLS_CC); add_assoc_long_ex(_14, SS("type"), 355); zephir_array_update_string(&_14, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_14, SL("name"), &intermediateReferencedFields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _14); zephir_check_call_status(); zephir_array_update_string(&_11, SL("left"), &_7, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_15); zephir_create_array(_15, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_15, SS("type"), SL("qualified"), 1); zephir_array_update_string(&_15, SL("domain"), &referencedModelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_15, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_7, this_ptr, "_getqualified", &_9, 319, _15); zephir_check_call_status(); zephir_array_update_string(&_11, SL("right"), &_7, PH_COPY | PH_SEPARATE); zephir_array_fast_append(_10, _11); zephir_array_update_string(&_8, SL("conditions"), &_10, PH_COPY | PH_SEPARATE); zephir_array_fast_append(sqlJoins, _8); } RETURN_CCTOR(sqlJoins); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getJoins) { zval *_17 = NULL, *_18 = NULL, *_40 = NULL; zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL, *_13 = NULL, *_31 = NULL, *_32 = NULL, *_35 = NULL, *_36 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_10, *_15, *_20, *_26, *_29, *_38; HashPosition _0, _9, _14, _19, _25, _28, _37; zval *select, *models, *sqlAliases, *sqlAliasesModels, *sqlModelsAliases, *sqlAliasesModelsInstances, *modelsInstances, *fromModels = NULL, *sqlJoins, *joinModels, *joinSources, *joinTypes, *joinPreCondition, *joinPrepared, *manager, *selectJoins = NULL, *joinItem = NULL, *joins, *joinData = NULL, *schema = NULL, *source = NULL, *model = NULL, *realModelName = NULL, *completeSource = NULL, *joinType = NULL, *aliasExpr = NULL, *alias = NULL, *joinAliasName = NULL, *joinExpr = NULL, *fromModelName = NULL, *joinAlias = NULL, *joinModel = NULL, *joinSource = NULL, *preCondition = NULL, *modelNameAlias = NULL, *relation = NULL, *relations = NULL, *modelAlias = NULL, *sqlJoin = NULL, *sqlJoinItem = NULL, *selectTables = NULL, *tables, *tableItem = NULL, **_2, *_5 = NULL, *_6, *_7 = NULL, **_11, *_12 = NULL, **_16, **_21, *_22, *_23 = NULL, *_24 = NULL, **_27, **_30, *_33 = NULL, *_34, **_39; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &select); ZEPHIR_OBS_VAR(models); zephir_read_property_this(&models, this_ptr, SL("_models"), PH_NOISY_CC); ZEPHIR_OBS_VAR(sqlAliases); zephir_read_property_this(&sqlAliases, this_ptr, SL("_sqlAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(sqlAliasesModels); zephir_read_property_this(&sqlAliasesModels, this_ptr, SL("_sqlAliasesModels"), PH_NOISY_CC); ZEPHIR_OBS_VAR(sqlModelsAliases); zephir_read_property_this(&sqlModelsAliases, this_ptr, SL("_sqlModelsAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(sqlAliasesModelsInstances); zephir_read_property_this(&sqlAliasesModelsInstances, this_ptr, SL("_sqlAliasesModelsInstances"), PH_NOISY_CC); ZEPHIR_OBS_VAR(modelsInstances); zephir_read_property_this(&modelsInstances, this_ptr, SL("_modelsInstances"), PH_NOISY_CC); ZEPHIR_CPY_WRT(fromModels, models); ZEPHIR_INIT_VAR(sqlJoins); array_init(sqlJoins); ZEPHIR_INIT_VAR(joinModels); array_init(joinModels); ZEPHIR_INIT_VAR(joinSources); array_init(joinSources); ZEPHIR_INIT_VAR(joinTypes); array_init(joinTypes); ZEPHIR_INIT_VAR(joinPreCondition); array_init(joinPreCondition); ZEPHIR_INIT_VAR(joinPrepared); array_init(joinPrepared); ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tables); zephir_array_fetch_string(&tables, select, SL("tables"), PH_NOISY, "phalcon/mvc/model/query.zep", 1295 TSRMLS_CC); if (!(zephir_array_isset_long(tables, 0))) { ZEPHIR_INIT_VAR(selectTables); zephir_create_array(selectTables, 1, 0 TSRMLS_CC); zephir_array_fast_append(selectTables, tables); } else { ZEPHIR_CPY_WRT(selectTables, tables); } ZEPHIR_OBS_VAR(joins); zephir_array_fetch_string(&joins, select, SL("joins"), PH_NOISY, "phalcon/mvc/model/query.zep", 1302 TSRMLS_CC); if (!(zephir_array_isset_long(joins, 0))) { ZEPHIR_INIT_VAR(selectJoins); zephir_create_array(selectJoins, 1, 0 TSRMLS_CC); zephir_array_fast_append(selectJoins, joins); } else { ZEPHIR_CPY_WRT(selectJoins, joins); } zephir_is_iterable(selectJoins, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 1451); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(joinItem, _2); ZEPHIR_CALL_METHOD(&joinData, this_ptr, "_getjoin", &_3, 323, manager, joinItem); zephir_check_call_status(); ZEPHIR_OBS_NVAR(source); zephir_array_fetch_string(&source, joinData, SL("source"), PH_NOISY, "phalcon/mvc/model/query.zep", 1315 TSRMLS_CC); ZEPHIR_OBS_NVAR(schema); zephir_array_fetch_string(&schema, joinData, SL("schema"), PH_NOISY, "phalcon/mvc/model/query.zep", 1316 TSRMLS_CC); ZEPHIR_OBS_NVAR(model); zephir_array_fetch_string(&model, joinData, SL("model"), PH_NOISY, "phalcon/mvc/model/query.zep", 1317 TSRMLS_CC); ZEPHIR_OBS_NVAR(realModelName); zephir_array_fetch_string(&realModelName, joinData, SL("modelName"), PH_NOISY, "phalcon/mvc/model/query.zep", 1318 TSRMLS_CC); ZEPHIR_INIT_NVAR(completeSource); zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, schema); ZEPHIR_CALL_METHOD(&joinType, this_ptr, "_getjointype", &_4, 324, joinItem); zephir_check_call_status(); ZEPHIR_OBS_NVAR(aliasExpr); if (zephir_array_isset_string_fetch(&aliasExpr, joinItem, SS("alias"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(alias); zephir_array_fetch_string(&alias, aliasExpr, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 1331 TSRMLS_CC); if (zephir_array_isset(joinModels, alias)) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_model_exception_ce); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSV(_7, "Cannot use '", alias, "' as join alias because it was already used, when preparing: ", _6); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/model/query.zep", 1337 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&completeSource, alias, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1343); zephir_array_update_zval(&joinTypes, alias, &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliases, alias, &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinModels, alias, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlModelsAliases, realModelName, &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModels, alias, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, alias, &model, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&models, realModelName, &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinSources, alias, &completeSource, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinPrepared, alias, &joinItem, PH_COPY | PH_SEPARATE); } else { if (zephir_array_isset(joinModels, realModelName)) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_mvc_model_exception_ce); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSV(_7, "Cannot use '", realModelName, "' as join alias because it was already used, when preparing: ", _6); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/mvc/model/query.zep", 1396 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_update_zval(&joinTypes, realModelName, &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliases, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinModels, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlModelsAliases, realModelName, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModels, realModelName, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&models, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinSources, realModelName, &completeSource, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&joinPrepared, realModelName, &joinItem, PH_COPY | PH_SEPARATE); } zephir_array_update_zval(&modelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), sqlAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModels"), sqlAliasesModels TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlModelsAliases"), sqlModelsAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), sqlAliasesModelsInstances TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), modelsInstances TSRMLS_CC); zephir_is_iterable(joinPrepared, &_10, &_9, 0, 0, "phalcon/mvc/model/query.zep", 1471); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HMKEY(joinAliasName, _10, _9); ZEPHIR_GET_HVALUE(joinItem, _11); ZEPHIR_OBS_NVAR(joinExpr); if (zephir_array_isset_string_fetch(&joinExpr, joinItem, SS("conditions"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_12, this_ptr, "_getexpression", &_13, 317, joinExpr); zephir_check_call_status(); zephir_array_update_zval(&joinPreCondition, joinAliasName, &_12, PH_COPY | PH_SEPARATE); } } _6 = zephir_fetch_nproperty_this(this_ptr, SL("_enableImplicitJoins"), PH_NOISY_CC); if (!(zephir_is_true(_6))) { ZEPHIR_INIT_NVAR(_5); zephir_is_iterable(joinPrepared, &_15, &_14, 0, 0, "phalcon/mvc/model/query.zep", 1482); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HMKEY(joinAliasName, _15, _14); ZEPHIR_GET_HVALUE(_5, _16); ZEPHIR_OBS_NVAR(joinType); zephir_array_fetch(&joinType, joinTypes, joinAliasName, PH_NOISY, "phalcon/mvc/model/query.zep", 1473 TSRMLS_CC); ZEPHIR_OBS_NVAR(joinSource); zephir_array_fetch(&joinSource, joinSources, joinAliasName, PH_NOISY, "phalcon/mvc/model/query.zep", 1474 TSRMLS_CC); ZEPHIR_OBS_NVAR(preCondition); zephir_array_fetch(&preCondition, joinPreCondition, joinAliasName, PH_NOISY, "phalcon/mvc/model/query.zep", 1475 TSRMLS_CC); ZEPHIR_INIT_NVAR(_17); zephir_create_array(_17, 3, 0 TSRMLS_CC); zephir_array_update_string(&_17, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_17, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_18); zephir_create_array(_18, 1, 0 TSRMLS_CC); zephir_array_fast_append(_18, preCondition); zephir_array_update_string(&_17, SL("conditions"), &_18, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlJoins, _17, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1480); } RETURN_CCTOR(sqlJoins); } ZEPHIR_INIT_NVAR(fromModels); array_init(fromModels); zephir_is_iterable(selectTables, &_20, &_19, 0, 0, "phalcon/mvc/model/query.zep", 1496); for ( ; zephir_hash_get_current_data_ex(_20, (void**) &_21, &_19) == SUCCESS ; zephir_hash_move_forward_ex(_20, &_19) ) { ZEPHIR_GET_HVALUE(tableItem, _21); zephir_array_fetch_string(&_22, tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 1490 TSRMLS_CC); ZEPHIR_OBS_NVAR(_23); zephir_array_fetch_string(&_23, _22, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 1490 TSRMLS_CC); zephir_array_update_zval(&fromModels, _23, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(_24); zephir_is_iterable(fromModels, &_26, &_25, 0, 0, "phalcon/mvc/model/query.zep", 1602); for ( ; zephir_hash_get_current_data_ex(_26, (void**) &_27, &_25) == SUCCESS ; zephir_hash_move_forward_ex(_26, &_25) ) { ZEPHIR_GET_HMKEY(fromModelName, _26, _25); ZEPHIR_GET_HVALUE(_24, _27); zephir_is_iterable(joinModels, &_29, &_28, 0, 0, "phalcon/mvc/model/query.zep", 1600); for ( ; zephir_hash_get_current_data_ex(_29, (void**) &_30, &_28) == SUCCESS ; zephir_hash_move_forward_ex(_29, &_28) ) { ZEPHIR_GET_HMKEY(joinAlias, _29, _28); ZEPHIR_GET_HVALUE(joinModel, _30); ZEPHIR_OBS_NVAR(joinSource); zephir_array_fetch(&joinSource, joinSources, joinAlias, PH_NOISY, "phalcon/mvc/model/query.zep", 1503 TSRMLS_CC); ZEPHIR_OBS_NVAR(joinType); zephir_array_fetch(&joinType, joinTypes, joinAlias, PH_NOISY, "phalcon/mvc/model/query.zep", 1508 TSRMLS_CC); ZEPHIR_OBS_NVAR(preCondition); if (!(zephir_array_isset_fetch(&preCondition, joinPreCondition, joinAlias, 0 TSRMLS_CC))) { ZEPHIR_OBS_NVAR(modelNameAlias); zephir_array_fetch(&modelNameAlias, sqlAliasesModels, joinAlias, PH_NOISY, "phalcon/mvc/model/query.zep", 1518 TSRMLS_CC); ZEPHIR_CALL_METHOD(&relation, manager, "getrelationbyalias", &_31, 0, fromModelName, modelNameAlias); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(relation)) { ZEPHIR_CALL_METHOD(&relations, manager, "getrelationsbetween", &_32, 0, fromModelName, modelNameAlias); zephir_check_call_status(); if (Z_TYPE_P(relations) == IS_ARRAY) { if (zephir_fast_count_int(relations TSRMLS_CC) != 1) { ZEPHIR_INIT_NVAR(_33); object_init_ex(_33, phalcon_mvc_model_exception_ce); _34 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVSV(_7, "There is more than one relation between models '", fromModelName, "' and '", joinModel, "', the join must be done using an alias, when preparing: ", _34); ZEPHIR_CALL_METHOD(NULL, _33, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_33, "phalcon/mvc/model/query.zep", 1536 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(relation); zephir_array_fetch_long(&relation, relations, 0, PH_NOISY, "phalcon/mvc/model/query.zep", 1542 TSRMLS_CC); } } if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_OBS_NVAR(modelAlias); zephir_array_fetch(&modelAlias, sqlModelsAliases, fromModelName, PH_NOISY, "phalcon/mvc/model/query.zep", 1554 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_12, relation, "isthrough", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_12))) { ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "_getsinglejoin", &_35, 325, joinType, joinSource, modelAlias, joinAlias, relation); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "_getmultijoin", &_36, 326, joinType, joinSource, modelAlias, joinAlias, relation); zephir_check_call_status(); } if (zephir_array_isset_long(sqlJoin, 0)) { zephir_is_iterable(sqlJoin, &_38, &_37, 0, 0, "phalcon/mvc/model/query.zep", 1572); for ( ; zephir_hash_get_current_data_ex(_38, (void**) &_39, &_37) == SUCCESS ; zephir_hash_move_forward_ex(_38, &_37) ) { ZEPHIR_GET_HVALUE(sqlJoinItem, _39); zephir_array_append(&sqlJoins, sqlJoinItem, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1570); } } else { zephir_array_append(&sqlJoins, sqlJoin, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1573); } } else { ZEPHIR_INIT_NVAR(_17); zephir_create_array(_17, 3, 0 TSRMLS_CC); zephir_array_update_string(&_17, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_17, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_33); array_init(_33); zephir_array_update_string(&_17, SL("conditions"), &_33, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlJoins, _17, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1585); } } else { ZEPHIR_INIT_NVAR(_18); zephir_create_array(_18, 3, 0 TSRMLS_CC); zephir_array_update_string(&_18, SL("type"), &joinType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_18, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_40); zephir_create_array(_40, 1, 0 TSRMLS_CC); zephir_array_fast_append(_40, preCondition); zephir_array_update_string(&_18, SL("conditions"), &_40, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlJoins, _18, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1597); } } } RETURN_CCTOR(sqlJoins); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getOrderClause) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *order, *orderColumns = NULL, *orderParts, *orderItem = NULL, *orderPartExpr = NULL, *orderSort, *orderPartSort = NULL, **_2, *_3, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &order); if (!(zephir_array_isset_long(order, 0))) { ZEPHIR_INIT_VAR(orderColumns); zephir_create_array(orderColumns, 1, 0 TSRMLS_CC); zephir_array_fast_append(orderColumns, order); } else { ZEPHIR_CPY_WRT(orderColumns, order); } ZEPHIR_INIT_VAR(orderParts); array_init(orderParts); zephir_is_iterable(orderColumns, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 1643); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(orderItem, _2); zephir_array_fetch_string(&_3, orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 1625 TSRMLS_CC); ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "_getexpression", &_4, 317, _3); zephir_check_call_status(); if (zephir_array_isset_string_fetch(&orderSort, orderItem, SS("sort"), 1 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(orderPartSort); if (ZEPHIR_IS_LONG(orderSort, 327)) { zephir_create_array(orderPartSort, 2, 0 TSRMLS_CC); zephir_array_fast_append(orderPartSort, orderPartExpr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "ASC", 1); zephir_array_fast_append(orderPartSort, _5); } else { zephir_create_array(orderPartSort, 2, 0 TSRMLS_CC); zephir_array_fast_append(orderPartSort, orderPartExpr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "DESC", 1); zephir_array_fast_append(orderPartSort, _5); } } else { ZEPHIR_INIT_NVAR(orderPartSort); zephir_create_array(orderPartSort, 1, 0 TSRMLS_CC); zephir_array_fast_append(orderPartSort, orderPartExpr); } zephir_array_append(&orderParts, orderPartSort, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1640); } RETURN_CCTOR(orderParts); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getGroupClause) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *group_param = NULL, *groupItem = NULL, *groupParts, **_2, *_3 = NULL; zval *group = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group_param); group = group_param; ZEPHIR_INIT_VAR(groupParts); if (zephir_array_isset_long(group, 0)) { array_init(groupParts); zephir_is_iterable(group, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 1661); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(groupItem, _2); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getexpression", &_4, 317, groupItem); zephir_check_call_status(); zephir_array_append(&groupParts, _3, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1659); } } else { zephir_create_array(groupParts, 1, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getexpression", &_4, 317, group); zephir_check_call_status(); zephir_array_fast_append(groupParts, _3); } RETURN_CCTOR(groupParts); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getLimitClause) { zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *limitClause_param = NULL, *number, *offset, *_0 = NULL; zval *limitClause = NULL, *limit = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &limitClause_param); limitClause = limitClause_param; ZEPHIR_INIT_VAR(limit); array_init(limit); ZEPHIR_INIT_NVAR(limit); array_init(limit); ZEPHIR_OBS_VAR(number); if (zephir_array_isset_string_fetch(&number, limitClause, SS("number"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getexpression", &_1, 317, number); zephir_check_call_status(); zephir_array_update_string(&limit, SL("number"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(offset); if (zephir_array_isset_string_fetch(&offset, limitClause, SS("offset"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getexpression", &_1, 317, offset); zephir_check_call_status(); zephir_array_update_string(&limit, SL("offset"), &_0, PH_COPY | PH_SEPARATE); } RETURN_CTOR(limit); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareSelect) { zval *_19 = NULL, *_20 = NULL, *_21 = NULL; zval *_16 = NULL; zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL, *_11 = NULL, *_17 = NULL, *_18 = NULL, *_32 = NULL, *_36 = NULL, *_40 = NULL; HashTable *_1, *_13, *_34, *_38; HashPosition _0, _12, _33, _37; int position, number, ZEPHIR_LAST_CALL_STATUS; zval *ast = NULL, *merge = NULL, *sqlModels, *sqlTables, *sqlAliases, *sqlColumns, *select = NULL, *tables, *columns, *sqlAliasesModels, *sqlModelsAliases, *sqlAliasesModelsInstances, *models, *modelsInstances, *selectedModels = NULL, *manager, *metaData, *selectedModel = NULL, *qualifiedName = NULL, *modelName = NULL, *nsAlias = NULL, *realModelName = NULL, *model = NULL, *schema = NULL, *source = NULL, *completeSource = NULL, *alias = NULL, *joins, *sqlJoins = NULL, *selectColumns = NULL, *sqlColumnAliases, *column = NULL, *sqlColumn = NULL, *sqlSelect, *distinct, *having, *where, *groupBy, *order, *limit, *tempModels, *tempModelsInstances, *tempSqlAliases, *tempSqlModelsAliases, *tempSqlAliasesModelsInstances, *tempSqlAliasesModels, *with = NULL, *withs = NULL, *withItem = NULL, *automaticJoins, *relation = NULL, *joinAlias = NULL, *relationModel = NULL, *bestAlias = NULL, *eagerType = NULL, **_2, *_3 = NULL, *_4, *_6, *_7 = NULL, *_9, *_10 = NULL, **_14, _15 = zval_used_for_init, *_22, *_23, *_24, *_25, *_26, *_27, *_28, *_29, *_30, *_31, **_35, **_39, *_41 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &ast, &merge); if (!ast) { ZEPHIR_CPY_WRT(ast, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(ast); } if (!merge) { ZEPHIR_CPY_WRT(merge, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(merge); } if (ZEPHIR_IS_EMPTY(ast)) { ZEPHIR_OBS_NVAR(ast); zephir_read_property_this(&ast, this_ptr, SL("_ast"), PH_NOISY_CC); } if (Z_TYPE_P(merge) == IS_NULL) { ZEPHIR_INIT_NVAR(merge); ZVAL_BOOL(merge, 0); } ZEPHIR_OBS_VAR(select); if (!(zephir_array_isset_string_fetch(&select, ast, SS("select"), 0 TSRMLS_CC))) { ZEPHIR_CPY_WRT(select, ast); } ZEPHIR_OBS_VAR(tables); if (!(zephir_array_isset_string_fetch(&tables, select, SS("tables"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 1716); return; } ZEPHIR_OBS_VAR(columns); if (!(zephir_array_isset_string_fetch(&columns, select, SS("columns"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/mvc/model/query.zep", 1720); return; } ZEPHIR_INIT_VAR(sqlModels); array_init(sqlModels); ZEPHIR_INIT_VAR(sqlTables); array_init(sqlTables); ZEPHIR_INIT_VAR(sqlColumns); array_init(sqlColumns); ZEPHIR_INIT_VAR(sqlAliases); array_init(sqlAliases); ZEPHIR_INIT_VAR(sqlAliasesModels); array_init(sqlAliasesModels); ZEPHIR_INIT_VAR(sqlModelsAliases); array_init(sqlModelsAliases); ZEPHIR_INIT_VAR(sqlAliasesModelsInstances); array_init(sqlAliasesModelsInstances); ZEPHIR_INIT_VAR(models); array_init(models); ZEPHIR_INIT_VAR(modelsInstances); array_init(modelsInstances); if (!(zephir_array_isset_long(tables, 0))) { ZEPHIR_INIT_VAR(selectedModels); zephir_create_array(selectedModels, 1, 0 TSRMLS_CC); zephir_array_fast_append(selectedModels, tables); } else { ZEPHIR_CPY_WRT(selectedModels, tables); } if (!(zephir_array_isset_long(columns, 0))) { ZEPHIR_INIT_VAR(selectColumns); zephir_create_array(selectColumns, 1, 0 TSRMLS_CC); zephir_array_fast_append(selectColumns, columns); } else { ZEPHIR_CPY_WRT(selectColumns, columns); } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); if (Z_TYPE_P(manager) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A models-manager is required to execute the query", "phalcon/mvc/model/query.zep", 1782); return; } if (Z_TYPE_P(metaData) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A meta-data is required to execute the query", "phalcon/mvc/model/query.zep", 1786); return; } number = 0; ZEPHIR_INIT_VAR(automaticJoins); array_init(automaticJoins); zephir_is_iterable(selectedModels, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 1913); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(selectedModel, _2); ZEPHIR_OBS_NVAR(qualifiedName); zephir_array_fetch_string(&qualifiedName, selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/mvc/model/query.zep", 1795 TSRMLS_CC); ZEPHIR_OBS_NVAR(modelName); zephir_array_fetch_string(&modelName, qualifiedName, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 1796 TSRMLS_CC); if (zephir_memnstr_str(modelName, SL(":"), "phalcon/mvc/model/query.zep", 1799)) { ZEPHIR_INIT_NVAR(nsAlias); zephir_fast_explode_str(nsAlias, SL(":"), modelName, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_4, nsAlias, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 1801 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, manager, "getnamespacealias", &_5, 0, _4); zephir_check_call_status(); zephir_array_fetch_long(&_6, nsAlias, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 1801 TSRMLS_CC); ZEPHIR_INIT_NVAR(realModelName); ZEPHIR_CONCAT_VSV(realModelName, _3, "\\", _6); } else { ZEPHIR_CPY_WRT(realModelName, modelName); } ZEPHIR_INIT_NVAR(_7); ZVAL_BOOL(_7, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", &_8, 0, realModelName, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_NVAR(completeSource); zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, schema); } else { ZEPHIR_CPY_WRT(completeSource, source); } ZEPHIR_OBS_NVAR(alias); if (zephir_array_isset_string_fetch(&alias, selectedModel, SS("alias"), 0 TSRMLS_CC)) { if (zephir_array_isset(sqlAliases, alias)) { ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSV(_10, "Alias '", alias, "' is used more than once, when preparing: ", _9); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_11, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/query.zep", 1825 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_update_zval(&sqlAliases, alias, &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModels, alias, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlModelsAliases, realModelName, &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, alias, &model, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(completeSource) == IS_ARRAY) { zephir_array_append(&completeSource, alias, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1837); } else { ZEPHIR_INIT_NVAR(completeSource); zephir_create_array(completeSource, 3, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, ZEPHIR_GLOBAL(global_null)); zephir_array_fast_append(completeSource, alias); } zephir_array_update_zval(&models, realModelName, &alias, PH_COPY | PH_SEPARATE); } else { ZEPHIR_CPY_WRT(alias, source); zephir_array_update_zval(&sqlAliases, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModels, realModelName, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlModelsAliases, realModelName, &realModelName, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&models, realModelName, &source, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_NVAR(with); if (zephir_array_isset_string_fetch(&with, selectedModel, SS("with"), 0 TSRMLS_CC)) { if (!(zephir_array_isset_long(with, 0))) { ZEPHIR_INIT_NVAR(withs); zephir_create_array(withs, 1, 0 TSRMLS_CC); zephir_array_fast_append(withs, with); } else { ZEPHIR_CPY_WRT(withs, with); } zephir_is_iterable(withs, &_13, &_12, 0, 0, "phalcon/mvc/model/query.zep", 1905); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HVALUE(withItem, _14); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, number); ZEPHIR_INIT_LNVAR(_16); ZEPHIR_CONCAT_SV(_16, "AA", &_15); ZEPHIR_CPY_WRT(joinAlias, _16); ZEPHIR_OBS_NVAR(relationModel); zephir_array_fetch_string(&relationModel, withItem, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 1865 TSRMLS_CC); ZEPHIR_CALL_METHOD(&relation, manager, "getrelationbyalias", &_17, 0, realModelName, relationModel); zephir_check_call_status(); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "alias", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&bestAlias, relation, "getoption", NULL, 0, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&relationModel, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&eagerType, relation, "gettype", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&relation, manager, "getrelationsbetween", &_18, 0, realModelName, relationModel); zephir_check_call_status(); if (Z_TYPE_P(relation) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_7); ZVAL_STRING(_7, "alias", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&bestAlias, relation, "getoption", NULL, 0, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&relationModel, relation, "getreferencedmodel", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&eagerType, relation, "gettype", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSVSV(_10, "Can't find a relationship between '", realModelName, "' and '", relationModel, "' when preparing: ", _9); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_11, 9, _10); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/query.zep", 1879 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } ZEPHIR_INIT_NVAR(_19); zephir_create_array(_19, 5, 0 TSRMLS_CC); add_assoc_long_ex(_19, SS("type"), 353); zephir_array_update_string(&_19, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_19, SL("eager"), &alias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_19, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_19, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); zephir_array_append(&selectColumns, _19, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1889); ZEPHIR_INIT_NVAR(_20); zephir_create_array(_20, 3, 0 TSRMLS_CC); add_assoc_long_ex(_20, SS("type"), 360); ZEPHIR_INIT_NVAR(_21); zephir_create_array(_21, 2, 0 TSRMLS_CC); add_assoc_long_ex(_21, SS("type"), 355); zephir_array_update_string(&_21, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_20, SL("qualified"), &_21, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_21); zephir_create_array(_21, 2, 0 TSRMLS_CC); add_assoc_long_ex(_21, SS("type"), 355); zephir_array_update_string(&_21, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_20, SL("alias"), &_21, PH_COPY | PH_SEPARATE); zephir_array_append(&automaticJoins, _20, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1901); number++; } } zephir_array_append(&sqlModels, realModelName, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1907); zephir_array_append(&sqlTables, completeSource, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1908); zephir_array_update_zval(&modelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); } if (!(zephir_is_true(merge))) { zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), modelsInstances TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), sqlAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModels"), sqlAliasesModels TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlModelsAliases"), sqlModelsAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), sqlAliasesModelsInstances TSRMLS_CC); } else { ZEPHIR_OBS_VAR(tempModels); zephir_read_property_this(&tempModels, this_ptr, SL("_models"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tempModelsInstances); zephir_read_property_this(&tempModelsInstances, this_ptr, SL("_modelsInstances"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tempSqlAliases); zephir_read_property_this(&tempSqlAliases, this_ptr, SL("_sqlAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tempSqlAliasesModels); zephir_read_property_this(&tempSqlAliasesModels, this_ptr, SL("_sqlAliasesModels"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tempSqlModelsAliases); zephir_read_property_this(&tempSqlModelsAliases, this_ptr, SL("_sqlModelsAliases"), PH_NOISY_CC); ZEPHIR_OBS_VAR(tempSqlAliasesModelsInstances); zephir_read_property_this(&tempSqlAliasesModelsInstances, this_ptr, SL("_sqlAliasesModelsInstances"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_7); _9 = zephir_fetch_nproperty_this(this_ptr, SL("_models"), PH_NOISY_CC); zephir_fast_array_merge(_7, &(_9), &(models) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_models"), _7 TSRMLS_CC); ZEPHIR_INIT_VAR(_22); _23 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); zephir_fast_array_merge(_22, &(_23), &(modelsInstances) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), _22 TSRMLS_CC); ZEPHIR_INIT_VAR(_24); _25 = zephir_fetch_nproperty_this(this_ptr, SL("_sqlAliases"), PH_NOISY_CC); zephir_fast_array_merge(_24, &(_25), &(sqlAliases) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), _24 TSRMLS_CC); ZEPHIR_INIT_VAR(_26); _27 = zephir_fetch_nproperty_this(this_ptr, SL("_sqlAliasesModels"), PH_NOISY_CC); zephir_fast_array_merge(_26, &(_27), &(sqlAliasesModels) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModels"), _26 TSRMLS_CC); ZEPHIR_INIT_VAR(_28); _29 = zephir_fetch_nproperty_this(this_ptr, SL("_sqlModelsAliases"), PH_NOISY_CC); zephir_fast_array_merge(_28, &(_29), &(sqlModelsAliases) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlModelsAliases"), _28 TSRMLS_CC); ZEPHIR_INIT_VAR(_30); _31 = zephir_fetch_nproperty_this(this_ptr, SL("_sqlAliasesModelsInstances"), PH_NOISY_CC); zephir_fast_array_merge(_30, &(_31), &(sqlAliasesModelsInstances) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), _30 TSRMLS_CC); } ZEPHIR_OBS_VAR(joins); zephir_array_isset_string_fetch(&joins, select, SS("joins"), 0 TSRMLS_CC); if (zephir_fast_count_int(joins TSRMLS_CC)) { if (zephir_fast_count_int(automaticJoins TSRMLS_CC)) { if (zephir_array_isset_long(joins, 0)) { ZEPHIR_INIT_NVAR(_7); zephir_fast_array_merge(_7, &(joins), &(automaticJoins) TSRMLS_CC); zephir_array_update_string(&select, SL("joins"), &_7, PH_COPY | PH_SEPARATE); } else { zephir_array_append(&automaticJoins, joins, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1945); zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); } } ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "_getjoins", &_32, 327, select); zephir_check_call_status(); } else { if (zephir_fast_count_int(automaticJoins TSRMLS_CC)) { zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "_getjoins", &_32, 327, select); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(sqlJoins); array_init(sqlJoins); } } position = 0; ZEPHIR_INIT_VAR(sqlColumnAliases); array_init(sqlColumnAliases); zephir_is_iterable(selectColumns, &_34, &_33, 0, 0, "phalcon/mvc/model/query.zep", 1998); for ( ; zephir_hash_get_current_data_ex(_34, (void**) &_35, &_33) == SUCCESS ; zephir_hash_move_forward_ex(_34, &_33) ) { ZEPHIR_GET_HVALUE(column, _35); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getselectcolumn", &_36, 328, column); zephir_check_call_status(); zephir_is_iterable(_3, &_38, &_37, 0, 0, "phalcon/mvc/model/query.zep", 1997); for ( ; zephir_hash_get_current_data_ex(_38, (void**) &_39, &_37) == SUCCESS ; zephir_hash_move_forward_ex(_38, &_37) ) { ZEPHIR_GET_HVALUE(sqlColumn, _39); ZEPHIR_OBS_NVAR(alias); if (zephir_array_isset_string_fetch(&alias, column, SS("alias"), 0 TSRMLS_CC)) { zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlColumns, alias, &sqlColumn, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlColumnAliases, alias, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } else { ZEPHIR_OBS_NVAR(alias); if (zephir_array_isset_string_fetch(&alias, sqlColumn, SS("balias"), 0 TSRMLS_CC)) { zephir_array_update_zval(&sqlColumns, alias, &sqlColumn, PH_COPY | PH_SEPARATE); } else { zephir_array_fetch_string(&_4, sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 1987 TSRMLS_CC); if (ZEPHIR_IS_STRING(_4, "scalar")) { ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, position); ZEPHIR_INIT_LNVAR(_16); ZEPHIR_CONCAT_SV(_16, "_", &_15); zephir_array_update_zval(&sqlColumns, _16, &sqlColumn, PH_COPY | PH_SEPARATE); } else { zephir_array_append(&sqlColumns, sqlColumn, PH_SEPARATE, "phalcon/mvc/model/query.zep", 1990); } } } position++; } } zephir_update_property_this(this_ptr, SL("_sqlColumnAliases"), sqlColumnAliases TSRMLS_CC); ZEPHIR_INIT_VAR(sqlSelect); zephir_create_array(sqlSelect, 3, 0 TSRMLS_CC); zephir_array_update_string(&sqlSelect, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlSelect, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlSelect, SL("columns"), &sqlColumns, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(distinct); if (zephir_array_isset_string_fetch(&distinct, select, SS("distinct"), 0 TSRMLS_CC)) { zephir_array_update_string(&sqlSelect, SL("distinct"), &distinct, PH_COPY | PH_SEPARATE); } if (zephir_fast_count_int(sqlJoins TSRMLS_CC)) { zephir_array_update_string(&sqlSelect, SL("joins"), &sqlJoins, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(where); if (zephir_array_isset_string_fetch(&where, ast, SS("where"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getexpression", &_40, 317, where); zephir_check_call_status(); zephir_array_update_string(&sqlSelect, SL("where"), &_3, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(groupBy); if (zephir_array_isset_string_fetch(&groupBy, ast, SS("groupBy"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_41, this_ptr, "_getgroupclause", NULL, 329, groupBy); zephir_check_call_status(); zephir_array_update_string(&sqlSelect, SL("group"), &_41, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(having); if (zephir_array_isset_string_fetch(&having, ast, SS("having"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_41, this_ptr, "_getexpression", &_40, 317, having); zephir_check_call_status(); zephir_array_update_string(&sqlSelect, SL("having"), &_41, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(order); if (zephir_array_isset_string_fetch(&order, ast, SS("orderBy"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_41, this_ptr, "_getorderclause", NULL, 330, order); zephir_check_call_status(); zephir_array_update_string(&sqlSelect, SL("order"), &_41, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_string_fetch(&limit, ast, SS("limit"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_41, this_ptr, "_getlimitclause", NULL, 331, limit); zephir_check_call_status(); zephir_array_update_string(&sqlSelect, SL("limit"), &_41, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string(ast, SS("forUpdate"))) { zephir_array_update_string(&sqlSelect, SL("forUpdate"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } if (zephir_is_true(merge)) { zephir_update_property_this(this_ptr, SL("_models"), tempModels TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), tempModelsInstances TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), tempSqlAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModels"), tempSqlAliasesModels TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlModelsAliases"), tempSqlModelsAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), tempSqlAliasesModelsInstances TSRMLS_CC); } RETURN_CCTOR(sqlSelect); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareInsert) { zephir_fcall_cache_entry *_9 = NULL, *_13 = NULL, *_17 = NULL; zval *_7 = NULL; HashTable *_5, *_11; HashPosition _4, _10; int ZEPHIR_LAST_CALL_STATUS; zend_bool notQuoting; zval *ast, *qualifiedName, *nsAlias, *manager, *modelName, *model = NULL, *source = NULL, *schema = NULL, *exprValues, *exprValue = NULL, *sqlInsert, *metaData, *fields, *sqlFields, *field = NULL, *name = NULL, *realModelName = NULL, *_0 = NULL, *_1, *_2, *_3 = NULL, **_6, *_8 = NULL, **_12, *_14 = NULL, *_15, *_16 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(ast); zephir_read_property_this(&ast, this_ptr, SL("_ast"), PH_NOISY_CC); if (!(zephir_array_isset_string(ast, SS("qualifiedName")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/mvc/model/query.zep", 2070); return; } if (!(zephir_array_isset_string(ast, SS("values")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/mvc/model/query.zep", 2074); return; } ZEPHIR_OBS_VAR(qualifiedName); zephir_array_fetch_string(&qualifiedName, ast, SL("qualifiedName"), PH_NOISY, "phalcon/mvc/model/query.zep", 2077 TSRMLS_CC); if (!(zephir_array_isset_string(qualifiedName, SS("name")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/mvc/model/query.zep", 2081); return; } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_OBS_VAR(modelName); zephir_array_fetch_string(&modelName, qualifiedName, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 2085 TSRMLS_CC); if (zephir_memnstr_str(modelName, SL(":"), "phalcon/mvc/model/query.zep", 2088)) { ZEPHIR_INIT_VAR(nsAlias); zephir_fast_explode_str(nsAlias, SL(":"), modelName, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_1, nsAlias, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2090 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, manager, "getnamespacealias", NULL, 0, _1); zephir_check_call_status(); zephir_array_fetch_long(&_2, nsAlias, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2090 TSRMLS_CC); ZEPHIR_INIT_VAR(realModelName); ZEPHIR_CONCAT_VSV(realModelName, _0, "\\", _2); } else { ZEPHIR_CPY_WRT(realModelName, modelName); } ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, realModelName, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); if (zephir_is_true(schema)) { ZEPHIR_INIT_NVAR(source); zephir_create_array(source, 2, 0 TSRMLS_CC); zephir_array_fast_append(source, schema); zephir_array_fast_append(source, source); } notQuoting = 0; ZEPHIR_INIT_VAR(exprValues); array_init(exprValues); zephir_array_fetch_string(&_1, ast, SL("values"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2106 TSRMLS_CC); zephir_is_iterable(_1, &_5, &_4, 0, 0, "phalcon/mvc/model/query.zep", 2115); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(exprValue, _6); ZEPHIR_INIT_NVAR(_7); zephir_create_array(_7, 2, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_8); zephir_array_fetch_string(&_8, exprValue, SL("type"), PH_NOISY, "phalcon/mvc/model/query.zep", 2110 TSRMLS_CC); zephir_array_update_string(&_7, SL("type"), &_8, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); if (notQuoting) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "_getexpression", &_9, 317, exprValue, _3); zephir_check_call_status(); zephir_array_update_string(&_7, SL("value"), &_0, PH_COPY | PH_SEPARATE); zephir_array_append(&exprValues, _7, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2112); } ZEPHIR_INIT_VAR(sqlInsert); zephir_create_array(sqlInsert, 2, 0 TSRMLS_CC); zephir_array_update_string(&sqlInsert, SL("model"), &modelName, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlInsert, SL("table"), &source, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); ZEPHIR_OBS_VAR(fields); if (zephir_array_isset_string_fetch(&fields, ast, SS("fields"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(sqlFields); array_init(sqlFields); zephir_is_iterable(fields, &_11, &_10, 0, 0, "phalcon/mvc/model/query.zep", 2137); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HVALUE(field, _12); ZEPHIR_OBS_NVAR(name); zephir_array_fetch_string(&name, field, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 2126 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, metaData, "hasattribute", &_13, 0, model, name); zephir_check_call_status(); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_NVAR(_14); object_init_ex(_14, phalcon_mvc_model_exception_ce); _15 = zephir_fetch_nproperty_this(this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_LNVAR(_16); ZEPHIR_CONCAT_SVSVSV(_16, "The model '", modelName, "' doesn't have the attribute '", name, "', when preparing: ", _15); ZEPHIR_CALL_METHOD(NULL, _14, "__construct", &_17, 9, _16); zephir_check_call_status(); zephir_throw_exception_debug(_14, "phalcon/mvc/model/query.zep", 2130 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_array_append(&sqlFields, name, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2134); } zephir_array_update_string(&sqlInsert, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&sqlInsert, SL("values"), &exprValues, PH_COPY | PH_SEPARATE); RETURN_CCTOR(sqlInsert); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareUpdate) { zval *_13 = NULL; zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_10; HashPosition _0, _9; zend_bool notQuoting; zval *ast, *update, *tables, *values, *modelsInstances, *models, *sqlTables, *sqlAliases, *sqlAliasesModelsInstances, *updateTables = NULL, *nsAlias = NULL, *realModelName = NULL, *completeSource = NULL, *sqlModels, *manager, *table = NULL, *qualifiedName = NULL, *modelName = NULL, *model = NULL, *source = NULL, *schema = NULL, *alias = NULL, *sqlFields, *sqlValues, *updateValues = NULL, *updateValue = NULL, *exprColumn = NULL, *sqlUpdate, *where, *limit, **_2, *_3 = NULL, *_4, *_6, *_7 = NULL, **_11, *_14 = NULL, *_15 = NULL, *_16 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(ast); zephir_read_property_this(&ast, this_ptr, SL("_ast"), PH_NOISY_CC); ZEPHIR_OBS_VAR(update); if (!(zephir_array_isset_string_fetch(&update, ast, SS("update"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/mvc/model/query.zep", 2161); return; } ZEPHIR_OBS_VAR(tables); if (!(zephir_array_isset_string_fetch(&tables, update, SS("tables"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/mvc/model/query.zep", 2165); return; } ZEPHIR_OBS_VAR(values); if (!(zephir_array_isset_string_fetch(&values, update, SS("values"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/mvc/model/query.zep", 2169); return; } ZEPHIR_INIT_VAR(models); array_init(models); ZEPHIR_INIT_VAR(modelsInstances); array_init(modelsInstances); ZEPHIR_INIT_VAR(sqlTables); array_init(sqlTables); ZEPHIR_INIT_VAR(sqlModels); array_init(sqlModels); ZEPHIR_INIT_VAR(sqlAliases); array_init(sqlAliases); ZEPHIR_INIT_VAR(sqlAliasesModelsInstances); array_init(sqlAliasesModelsInstances); if (!(zephir_array_isset_long(tables, 0))) { ZEPHIR_INIT_VAR(updateTables); zephir_create_array(updateTables, 1, 0 TSRMLS_CC); zephir_array_fast_append(updateTables, tables); } else { ZEPHIR_CPY_WRT(updateTables, tables); } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); zephir_is_iterable(updateTables, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 2244); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(table, _2); ZEPHIR_OBS_NVAR(qualifiedName); zephir_array_fetch_string(&qualifiedName, table, SL("qualifiedName"), PH_NOISY, "phalcon/mvc/model/query.zep", 2192 TSRMLS_CC); ZEPHIR_OBS_NVAR(modelName); zephir_array_fetch_string(&modelName, qualifiedName, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 2193 TSRMLS_CC); if (zephir_memnstr_str(modelName, SL(":"), "phalcon/mvc/model/query.zep", 2198)) { ZEPHIR_INIT_NVAR(nsAlias); zephir_fast_explode_str(nsAlias, SL(":"), modelName, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_4, nsAlias, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2200 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, manager, "getnamespacealias", &_5, 0, _4); zephir_check_call_status(); zephir_array_fetch_long(&_6, nsAlias, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2200 TSRMLS_CC); ZEPHIR_INIT_NVAR(realModelName); ZEPHIR_CONCAT_VSV(realModelName, _3, "\\", _6); } else { ZEPHIR_CPY_WRT(realModelName, modelName); } ZEPHIR_INIT_NVAR(_7); ZVAL_BOOL(_7, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", &_8, 0, realModelName, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(completeSource); if (zephir_is_true(schema)) { zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, schema); } else { zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, ZEPHIR_GLOBAL(global_null)); } ZEPHIR_OBS_NVAR(alias); if (zephir_array_isset_string_fetch(&alias, table, SS("alias"), 0 TSRMLS_CC)) { zephir_array_update_zval(&sqlAliases, alias, &alias, PH_COPY | PH_SEPARATE); zephir_array_append(&completeSource, alias, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2226); zephir_array_append(&sqlTables, completeSource, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2227); zephir_array_update_zval(&sqlAliasesModelsInstances, alias, &model, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&models, alias, &realModelName, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&sqlAliases, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlTables, source, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2233); zephir_array_update_zval(&models, realModelName, &source, PH_COPY | PH_SEPARATE); } zephir_array_append(&sqlModels, realModelName, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2237); zephir_array_update_zval(&modelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), modelsInstances TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), sqlAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), sqlAliasesModelsInstances TSRMLS_CC); ZEPHIR_INIT_VAR(sqlFields); array_init(sqlFields); ZEPHIR_INIT_VAR(sqlValues); array_init(sqlValues); if (!(zephir_array_isset_long(values, 0))) { ZEPHIR_INIT_VAR(updateValues); zephir_create_array(updateValues, 1, 0 TSRMLS_CC); zephir_array_fast_append(updateValues, values); } else { ZEPHIR_CPY_WRT(updateValues, values); } notQuoting = 0; zephir_is_iterable(updateValues, &_10, &_9, 0, 0, "phalcon/mvc/model/query.zep", 2268); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HVALUE(updateValue, _11); zephir_array_fetch_string(&_4, updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2260 TSRMLS_CC); ZEPHIR_INIT_NVAR(_7); if (notQuoting) { ZVAL_BOOL(_7, 1); } else { ZVAL_BOOL(_7, 0); } ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getexpression", &_12, 317, _4, _7); zephir_check_call_status(); zephir_array_append(&sqlFields, _3, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2260); ZEPHIR_OBS_NVAR(exprColumn); zephir_array_fetch_string(&exprColumn, updateValue, SL("expr"), PH_NOISY, "phalcon/mvc/model/query.zep", 2261 TSRMLS_CC); ZEPHIR_INIT_NVAR(_13); zephir_create_array(_13, 2, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_14); zephir_array_fetch_string(&_14, exprColumn, SL("type"), PH_NOISY, "phalcon/mvc/model/query.zep", 2263 TSRMLS_CC); zephir_array_update_string(&_13, SL("type"), &_14, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_16); if (notQuoting) { ZVAL_BOOL(_16, 1); } else { ZVAL_BOOL(_16, 0); } ZEPHIR_CALL_METHOD(&_15, this_ptr, "_getexpression", &_12, 317, exprColumn, _16); zephir_check_call_status(); zephir_array_update_string(&_13, SL("value"), &_15, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlValues, _13, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2265); } ZEPHIR_INIT_VAR(sqlUpdate); zephir_create_array(sqlUpdate, 4, 0 TSRMLS_CC); zephir_array_update_string(&sqlUpdate, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlUpdate, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlUpdate, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlUpdate, SL("values"), &sqlValues, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(where); if (zephir_array_isset_string_fetch(&where, ast, SS("where"), 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_7); ZVAL_BOOL(_7, 1); ZEPHIR_CALL_METHOD(&_15, this_ptr, "_getexpression", &_12, 317, where, _7); zephir_check_call_status(); zephir_array_update_string(&sqlUpdate, SL("where"), &_15, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_string_fetch(&limit, ast, SS("limit"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_15, this_ptr, "_getlimitclause", NULL, 331, limit); zephir_check_call_status(); zephir_array_update_string(&sqlUpdate, SL("limit"), &_15, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(sqlUpdate); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareDelete) { zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *ast, *delete, *tables, *models, *modelsInstances, *sqlTables, *sqlModels, *sqlAliases, *sqlAliasesModelsInstances, *deleteTables = NULL, *manager, *table = NULL, *qualifiedName = NULL, *modelName = NULL, *nsAlias = NULL, *realModelName = NULL, *model = NULL, *source = NULL, *schema = NULL, *completeSource = NULL, *alias = NULL, *sqlDelete, *where, *limit, **_2, *_3 = NULL, *_4, *_6, *_7 = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(ast); zephir_read_property_this(&ast, this_ptr, SL("_ast"), PH_NOISY_CC); ZEPHIR_OBS_VAR(delete); if (!(zephir_array_isset_string_fetch(&delete, ast, SS("delete"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/mvc/model/query.zep", 2300); return; } ZEPHIR_OBS_VAR(tables); if (!(zephir_array_isset_string_fetch(&tables, delete, SS("tables"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/mvc/model/query.zep", 2304); return; } ZEPHIR_INIT_VAR(models); array_init(models); ZEPHIR_INIT_VAR(modelsInstances); array_init(modelsInstances); ZEPHIR_INIT_VAR(sqlTables); array_init(sqlTables); ZEPHIR_INIT_VAR(sqlModels); array_init(sqlModels); ZEPHIR_INIT_VAR(sqlAliases); array_init(sqlAliases); ZEPHIR_INIT_VAR(sqlAliasesModelsInstances); array_init(sqlAliasesModelsInstances); if (!(zephir_array_isset_long(tables, 0))) { ZEPHIR_INIT_VAR(deleteTables); zephir_create_array(deleteTables, 1, 0 TSRMLS_CC); zephir_array_fast_append(deleteTables, tables); } else { ZEPHIR_CPY_WRT(deleteTables, tables); } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); zephir_is_iterable(deleteTables, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 2374); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(table, _2); ZEPHIR_OBS_NVAR(qualifiedName); zephir_array_fetch_string(&qualifiedName, table, SL("qualifiedName"), PH_NOISY, "phalcon/mvc/model/query.zep", 2328 TSRMLS_CC); ZEPHIR_OBS_NVAR(modelName); zephir_array_fetch_string(&modelName, qualifiedName, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 2329 TSRMLS_CC); if (zephir_memnstr_str(modelName, SL(":"), "phalcon/mvc/model/query.zep", 2334)) { ZEPHIR_INIT_NVAR(nsAlias); zephir_fast_explode_str(nsAlias, SL(":"), modelName, LONG_MAX TSRMLS_CC); zephir_array_fetch_long(&_4, nsAlias, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2336 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, manager, "getnamespacealias", &_5, 0, _4); zephir_check_call_status(); zephir_array_fetch_long(&_6, nsAlias, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2336 TSRMLS_CC); ZEPHIR_INIT_NVAR(realModelName); ZEPHIR_CONCAT_VSV(realModelName, _3, "\\", _6); } else { ZEPHIR_CPY_WRT(realModelName, modelName); } ZEPHIR_INIT_NVAR(_7); ZVAL_BOOL(_7, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", &_8, 0, realModelName, _7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&source, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(completeSource); if (zephir_is_true(schema)) { zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, schema); } else { zephir_create_array(completeSource, 2, 0 TSRMLS_CC); zephir_array_fast_append(completeSource, source); zephir_array_fast_append(completeSource, ZEPHIR_GLOBAL(global_null)); } ZEPHIR_OBS_NVAR(alias); if (zephir_array_isset_string_fetch(&alias, table, SS("alias"), 0 TSRMLS_CC)) { zephir_array_update_zval(&sqlAliases, alias, &alias, PH_COPY | PH_SEPARATE); zephir_array_append(&completeSource, alias, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2356); zephir_array_append(&sqlTables, completeSource, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2357); zephir_array_update_zval(&sqlAliasesModelsInstances, alias, &model, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&models, alias, &realModelName, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&sqlAliases, realModelName, &source, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&sqlAliasesModelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); zephir_array_append(&sqlTables, source, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2363); zephir_array_update_zval(&models, realModelName, &source, PH_COPY | PH_SEPARATE); } zephir_array_append(&sqlModels, realModelName, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2367); zephir_array_update_zval(&modelsInstances, realModelName, &model, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_modelsInstances"), modelsInstances TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliases"), sqlAliases TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_sqlAliasesModelsInstances"), sqlAliasesModelsInstances TSRMLS_CC); ZEPHIR_INIT_VAR(sqlDelete); array_init(sqlDelete); zephir_array_update_string(&sqlDelete, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); zephir_array_update_string(&sqlDelete, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(where); if (zephir_array_isset_string_fetch(&where, ast, SS("where"), 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_7); ZVAL_BOOL(_7, 1); ZEPHIR_CALL_METHOD(&_3, this_ptr, "_getexpression", NULL, 317, where, _7); zephir_check_call_status(); zephir_array_update_string(&sqlDelete, SL("where"), &_3, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_string_fetch(&limit, ast, SS("limit"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_9, this_ptr, "_getlimitclause", NULL, 331, limit); zephir_check_call_status(); zephir_array_update_string(&sqlDelete, SL("limit"), &_9, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(sqlDelete); } static PHP_METHOD(Phalcon_Mvc_Model_Query, parse) { int ZEPHIR_LAST_CALL_STATUS; zval *intermediate, *phql, *ast, *irPhql = NULL, *uniqueId = NULL, *type, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(intermediate); zephir_read_property_this(&intermediate, this_ptr, SL("_intermediate"), PH_NOISY_CC); if (Z_TYPE_P(intermediate) == IS_ARRAY) { RETURN_CCTOR(intermediate); } ZEPHIR_OBS_VAR(phql); zephir_read_property_this(&phql, this_ptr, SL("_phql"), PH_NOISY_CC); ZEPHIR_INIT_VAR(ast); ZEPHIR_LAST_CALL_STATUS = phql_parse_phql(ast, phql TSRMLS_CC); zephir_check_call_status(); ZEPHIR_INIT_VAR(irPhql); ZVAL_NULL(irPhql); ZEPHIR_INIT_VAR(uniqueId); ZVAL_NULL(uniqueId); if (Z_TYPE_P(ast) == IS_ARRAY) { ZEPHIR_OBS_NVAR(uniqueId); if (zephir_array_isset_string_fetch(&uniqueId, ast, SS("id"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(irPhql); _0 = zephir_fetch_static_property_ce(phalcon_mvc_model_query_ce, SL("_irPhqlCache") TSRMLS_CC); if (zephir_array_isset_fetch(&irPhql, _0, uniqueId, 0 TSRMLS_CC)) { if (Z_TYPE_P(irPhql) == IS_ARRAY) { zephir_array_fetch_string(&_1, ast, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2425 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_type"), _1 TSRMLS_CC); RETURN_CCTOR(irPhql); } } } ZEPHIR_OBS_VAR(type); if (zephir_array_isset_string_fetch(&type, ast, SS("type"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ast"), ast TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); do { if (ZEPHIR_IS_LONG(type, 309)) { ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareselect", NULL, 322); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 306)) { ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareinsert", NULL, 332); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 300)) { ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareupdate", NULL, 333); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 303)) { ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_preparedelete", NULL, 334); zephir_check_call_status(); break; } ZEPHIR_INIT_VAR(_2); object_init_ex(_2, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "Unknown statement ", type, ", when preparing: ", phql); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/mvc/model/query.zep", 2458 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); } } if (Z_TYPE_P(irPhql) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted AST", "phalcon/mvc/model/query.zep", 2464); return; } if (Z_TYPE_P(uniqueId) == IS_LONG) { zephir_update_static_property_array_multi_ce(phalcon_mvc_model_query_ce, SL("_irPhqlCache"), &irPhql TSRMLS_CC, SL("z"), 1, uniqueId); } zephir_update_property_this(this_ptr, SL("_intermediate"), irPhql TSRMLS_CC); RETURN_CCTOR(irPhql); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getCache) { RETURN_MEMBER(this_ptr, "_cache"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _executeSelect) { zval *_20 = NULL; zephir_fcall_cache_entry *_5 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_22 = NULL; HashTable *_1, *_8, *_12, *_18, *_24, *_28, *_31, *_34, *_38; HashPosition _0, _7, _11, _17, _23, _27, _30, _33, _37; int numberObjects, ZEPHIR_LAST_CALL_STATUS; zend_bool simulate, haveObjects, haveScalars, isComplex, isSimpleStd, isKeepingSnapshots, _26; zval *intermediate, *bindParams, *bindTypes, *simulate_param = NULL, *manager, *modelName = NULL, *models, *model = NULL, *connection = NULL, *connectionTypes, *columns, *column = NULL, *selectColumns, *simpleColumnMap = NULL, *metaData, *aliasCopy = NULL, *sqlColumn = NULL, *attributes = NULL, *instance = NULL, *columnMap = NULL, *attribute = NULL, *columnAlias = NULL, *sqlAlias = NULL, *dialect = NULL, *sqlSelect = NULL, *bindCounts, *processed = NULL, *wildcard = NULL, *value = NULL, *processedTypes = NULL, *typeWildcard = NULL, *result = NULL, *resultData = NULL, *cache, *resultObject = NULL, *columns1 = NULL, *typesColumnMap = NULL, *wildcardValue = NULL, **_2, *_3, *_4 = NULL, *_6 = NULL, **_9, *_10, **_13, **_19, *_21 = NULL, **_25, **_29, **_32, **_35, *_36 = NULL, **_39, *_40 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &intermediate, &bindParams, &bindTypes, &simulate_param); ZEPHIR_SEPARATE_PARAM(intermediate); if (!simulate_param) { simulate = 0; } else { simulate = zephir_get_boolval(simulate_param); } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_INIT_VAR(connectionTypes); array_init(connectionTypes); ZEPHIR_OBS_VAR(models); zephir_array_fetch_string(&models, intermediate, SL("models"), PH_NOISY, "phalcon/mvc/model/query.zep", 2507 TSRMLS_CC); zephir_is_iterable(models, &_1, &_0, 0, 0, "phalcon/mvc/model/query.zep", 2535); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(modelName, _2); ZEPHIR_OBS_NVAR(model); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&model, _3, modelName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_4); ZVAL_BOOL(_4, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", &_5, 0, modelName, _4); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_modelsInstances"), modelName, model TSRMLS_CC); } if ((zephir_method_exists_ex(model, SS("selectreadconnection") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&connection, model, "selectreadconnection", NULL, 0, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "'selectReadConnection' didn't return a valid connection", "phalcon/mvc/model/query.zep", 2522); return; } } else { ZEPHIR_CALL_METHOD(&connection, model, "getreadconnection", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_6, connection, "gettype", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&connectionTypes, _6, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); if (zephir_fast_count_int(connectionTypes TSRMLS_CC) == 2) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/mvc/model/query.zep", 2531); return; } } ZEPHIR_OBS_VAR(columns); zephir_array_fetch_string(&columns, intermediate, SL("columns"), PH_NOISY, "phalcon/mvc/model/query.zep", 2535 TSRMLS_CC); haveObjects = 0; haveScalars = 0; isComplex = 0; numberObjects = 0; ZEPHIR_CPY_WRT(columns1, columns); zephir_is_iterable(columns, &_8, &_7, 0, 0, "phalcon/mvc/model/query.zep", 2562); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(column, _9); if (Z_TYPE_P(column) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/mvc/model/query.zep", 2548); return; } zephir_array_fetch_string(&_10, column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2551 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "scalar")) { if (!(zephir_array_isset_string(column, SS("balias")))) { isComplex = 1; } haveScalars = 1; } else { haveObjects = 1; numberObjects++; } } if (isComplex == 0) { if (haveObjects == 1) { if (haveScalars == 1) { isComplex = 1; } else { if (numberObjects == 1) { isSimpleStd = 0; } else { isComplex = 1; } } } else { isSimpleStd = 1; } } ZEPHIR_INIT_VAR(instance); ZVAL_NULL(instance); ZEPHIR_INIT_VAR(selectColumns); array_init(selectColumns); ZEPHIR_INIT_VAR(simpleColumnMap); array_init(simpleColumnMap); ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); zephir_is_iterable(columns, &_12, &_11, 0, 0, "phalcon/mvc/model/query.zep", 2661); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HMKEY(aliasCopy, _12, _11); ZEPHIR_GET_HVALUE(column, _13); ZEPHIR_OBS_NVAR(sqlColumn); zephir_array_fetch_string(&sqlColumn, column, SL("column"), PH_NOISY, "phalcon/mvc/model/query.zep", 2586 TSRMLS_CC); zephir_array_fetch_string(&_10, column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2589 TSRMLS_CC); if (ZEPHIR_IS_STRING(_10, "object")) { ZEPHIR_OBS_NVAR(modelName); zephir_array_fetch_string(&modelName, column, SL("model"), PH_NOISY, "phalcon/mvc/model/query.zep", 2591 TSRMLS_CC); ZEPHIR_OBS_NVAR(instance); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&instance, _3, modelName, 0 TSRMLS_CC))) { ZEPHIR_CALL_METHOD(&instance, manager, "load", &_14, 0, modelName); zephir_check_call_status(); zephir_update_property_array(this_ptr, SL("_modelsInstances"), modelName, instance TSRMLS_CC); } ZEPHIR_CALL_METHOD(&attributes, metaData, "getattributes", &_15, 0, instance); zephir_check_call_status(); if (isComplex == 1) { if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", &_16, 0, instance); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } zephir_is_iterable(attributes, &_18, &_17, 0, 0, "phalcon/mvc/model/query.zep", 2617); for ( ; zephir_hash_get_current_data_ex(_18, (void**) &_19, &_17) == SUCCESS ; zephir_hash_move_forward_ex(_18, &_17) ) { ZEPHIR_GET_HVALUE(attribute, _19); ZEPHIR_INIT_NVAR(_20); zephir_create_array(_20, 3, 0 TSRMLS_CC); zephir_array_fast_append(_20, attribute); zephir_array_fast_append(_20, sqlColumn); ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_SVSV(_21, "_", sqlColumn, "_", attribute); zephir_array_fast_append(_20, _21); zephir_array_append(&selectColumns, _20, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2613); } zephir_array_update_multi(&columns1, &instance TSRMLS_CC, SL("zs"), 3, aliasCopy, SL("instance")); zephir_array_update_multi(&columns1, &attributes TSRMLS_CC, SL("zs"), 3, aliasCopy, SL("attributes")); zephir_array_update_multi(&columns1, &columnMap TSRMLS_CC, SL("zs"), 3, aliasCopy, SL("columnMap")); ZEPHIR_CALL_METHOD(&_6, manager, "iskeepingsnapshots", &_22, 0, instance); zephir_check_call_status(); isKeepingSnapshots = zephir_get_boolval(_6); if (isKeepingSnapshots) { ZEPHIR_INIT_NVAR(_4); ZVAL_BOOL(_4, isKeepingSnapshots); zephir_array_update_multi(&columns1, &_4 TSRMLS_CC, SL("zs"), 3, aliasCopy, SL("keepSnapshots")); } } else { zephir_is_iterable(attributes, &_24, &_23, 0, 0, "phalcon/mvc/model/query.zep", 2635); for ( ; zephir_hash_get_current_data_ex(_24, (void**) &_25, &_23) == SUCCESS ; zephir_hash_move_forward_ex(_24, &_23) ) { ZEPHIR_GET_HVALUE(attribute, _25); ZEPHIR_INIT_NVAR(_20); zephir_create_array(_20, 2, 0 TSRMLS_CC); zephir_array_fast_append(_20, attribute); zephir_array_fast_append(_20, sqlColumn); zephir_array_append(&selectColumns, _20, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2633); } } } else { ZEPHIR_INIT_NVAR(columnAlias); if (Z_TYPE_P(aliasCopy) == IS_LONG) { zephir_create_array(columnAlias, 2, 0 TSRMLS_CC); zephir_array_fast_append(columnAlias, sqlColumn); zephir_array_fast_append(columnAlias, ZEPHIR_GLOBAL(global_null)); } else { zephir_create_array(columnAlias, 3, 0 TSRMLS_CC); zephir_array_fast_append(columnAlias, sqlColumn); zephir_array_fast_append(columnAlias, ZEPHIR_GLOBAL(global_null)); zephir_array_fast_append(columnAlias, aliasCopy); } zephir_array_append(&selectColumns, columnAlias, PH_SEPARATE, "phalcon/mvc/model/query.zep", 2646); } _26 = isComplex == 0; if (_26) { _26 = isSimpleStd == 1; } if (_26) { ZEPHIR_OBS_NVAR(sqlAlias); if (zephir_array_isset_string_fetch(&sqlAlias, column, SS("sqlAlias"), 0 TSRMLS_CC)) { zephir_array_update_zval(&simpleColumnMap, sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&simpleColumnMap, aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); } } } ZEPHIR_INIT_VAR(bindCounts); array_init(bindCounts); zephir_array_update_string(&intermediate, SL("columns"), &selectColumns, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(processed); array_init(processed); zephir_is_iterable(bindParams, &_28, &_27, 0, 0, "phalcon/mvc/model/query.zep", 2682); for ( ; zephir_hash_get_current_data_ex(_28, (void**) &_29, &_27) == SUCCESS ; zephir_hash_move_forward_ex(_28, &_27) ) { ZEPHIR_GET_HMKEY(wildcard, _28, _27); ZEPHIR_GET_HVALUE(value, _29); if (Z_TYPE_P(wildcard) == IS_LONG) { ZEPHIR_INIT_NVAR(wildcardValue); ZEPHIR_CONCAT_SV(wildcardValue, ":", wildcard); } else { ZEPHIR_CPY_WRT(wildcardValue, wildcard); } zephir_array_update_zval(&processed, wildcardValue, &value, PH_COPY | PH_SEPARATE); if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, zephir_fast_count_int(value TSRMLS_CC)); zephir_array_update_zval(&bindCounts, wildcardValue, &_4, PH_COPY | PH_SEPARATE); } } } else { ZEPHIR_CPY_WRT(processed, bindParams); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_INIT_VAR(processedTypes); array_init(processedTypes); zephir_is_iterable(bindTypes, &_31, &_30, 0, 0, "phalcon/mvc/model/query.zep", 2698); for ( ; zephir_hash_get_current_data_ex(_31, (void**) &_32, &_30) == SUCCESS ; zephir_hash_move_forward_ex(_31, &_30) ) { ZEPHIR_GET_HMKEY(typeWildcard, _31, _30); ZEPHIR_GET_HVALUE(value, _32); if (Z_TYPE_P(typeWildcard) == IS_LONG) { ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_SV(_21, ":", typeWildcard); zephir_array_update_zval(&processedTypes, _21, &value, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(&processedTypes, typeWildcard, &value, PH_COPY | PH_SEPARATE); } } } else { ZEPHIR_CPY_WRT(processedTypes, bindTypes); } if (zephir_fast_count_int(bindCounts TSRMLS_CC)) { zephir_array_update_string(&intermediate, SL("bindCounts"), &bindCounts, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&dialect, connection, "getdialect", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&sqlSelect, dialect, "select", NULL, 0, intermediate); zephir_check_call_status(); if (simulate) { zephir_create_array(return_value, 3, 0 TSRMLS_CC); zephir_array_update_string(&return_value, SL("sql"), &sqlSelect, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("bind"), &processed, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("bindTypes"), &processedTypes, PH_COPY | PH_SEPARATE); RETURN_MM(); } ZEPHIR_CALL_METHOD(&result, connection, "query", NULL, 0, sqlSelect, processed, processedTypes); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_6, result, "numrows", NULL, 0, result); zephir_check_call_status(); if (zephir_is_true(_6)) { ZEPHIR_CPY_WRT(resultData, result); } else { ZEPHIR_INIT_NVAR(resultData); ZVAL_BOOL(resultData, 0); } ZEPHIR_OBS_VAR(cache); zephir_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC); if (isComplex == 0) { if (isSimpleStd == 1) { ZEPHIR_INIT_VAR(resultObject); object_init_ex(resultObject, phalcon_mvc_model_row_ce); if (zephir_has_constructor(resultObject TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, resultObject, "__construct", NULL, 0); zephir_check_call_status(); } isKeepingSnapshots = 0; } else { if (Z_TYPE_P(instance) == IS_OBJECT) { ZEPHIR_CPY_WRT(resultObject, instance); } else { ZEPHIR_CPY_WRT(resultObject, model); } if (!(ZEPHIR_GLOBAL(orm).cast_on_hydrate)) { ZEPHIR_CALL_METHOD(&simpleColumnMap, metaData, "getcolumnmap", NULL, 0, model); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, model); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&typesColumnMap, metaData, "getdatatypes", NULL, 0, model); zephir_check_call_status(); ZEPHIR_INIT_NVAR(simpleColumnMap); if (Z_TYPE_P(columnMap) == IS_NULL) { array_init(simpleColumnMap); ZEPHIR_CALL_METHOD(&_6, metaData, "getattributes", NULL, 0, model); zephir_check_call_status(); zephir_is_iterable(_6, &_34, &_33, 0, 0, "phalcon/mvc/model/query.zep", 2781); for ( ; zephir_hash_get_current_data_ex(_34, (void**) &_35, &_33) == SUCCESS ; zephir_hash_move_forward_ex(_34, &_33) ) { ZEPHIR_GET_HVALUE(attribute, _35); ZEPHIR_INIT_NVAR(_20); zephir_create_array(_20, 2, 0 TSRMLS_CC); zephir_array_fast_append(_20, attribute); ZEPHIR_OBS_NVAR(_36); zephir_array_fetch(&_36, typesColumnMap, attribute, PH_NOISY, "phalcon/mvc/model/query.zep", 2779 TSRMLS_CC); zephir_array_fast_append(_20, _36); zephir_array_update_zval(&simpleColumnMap, attribute, &_20, PH_COPY | PH_SEPARATE); } } else { array_init(simpleColumnMap); zephir_is_iterable(columnMap, &_38, &_37, 0, 0, "phalcon/mvc/model/query.zep", 2786); for ( ; zephir_hash_get_current_data_ex(_38, (void**) &_39, &_37) == SUCCESS ; zephir_hash_move_forward_ex(_38, &_37) ) { ZEPHIR_GET_HMKEY(column, _38, _37); ZEPHIR_GET_HVALUE(attribute, _39); ZEPHIR_INIT_NVAR(_20); zephir_create_array(_20, 2, 0 TSRMLS_CC); zephir_array_fast_append(_20, attribute); ZEPHIR_OBS_NVAR(_36); zephir_array_fetch(&_36, typesColumnMap, column, PH_NOISY, "phalcon/mvc/model/query.zep", 2784 TSRMLS_CC); zephir_array_fast_append(_20, _36); zephir_array_update_zval(&simpleColumnMap, column, &_20, PH_COPY | PH_SEPARATE); } } } ZEPHIR_CALL_METHOD(&_40, manager, "iskeepingsnapshots", NULL, 0, model); zephir_check_call_status(); isKeepingSnapshots = zephir_get_boolval(_40); } object_init_ex(return_value, phalcon_mvc_model_resultset_simple_ce); ZEPHIR_INIT_NVAR(_4); if (isKeepingSnapshots) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 335, simpleColumnMap, resultObject, resultData, cache, _4); zephir_check_call_status(); RETURN_MM(); } object_init_ex(return_value, phalcon_mvc_model_resultset_complex_ce); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 336, columns1, resultData, cache); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _executeInsert) { zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zend_bool automaticFields; zval *intermediate, *bindParams, *bindTypes, *modelName, *manager, *connection = NULL, *metaData, *attributes = NULL, *fields = NULL, *columnMap = NULL, *dialect = NULL, *insertValues, *number = NULL, *value = NULL, *model = NULL, *values, *exprValue = NULL, *insertValue = NULL, *wildcard = NULL, *fieldName = NULL, *attributeName = NULL, *insertModel, *_0, *_1 = NULL, **_4, *_5, *_7 = NULL, _9 = zval_used_for_init, _10 = zval_used_for_init, *_11 = NULL, *_15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &intermediate, &bindParams, &bindTypes); ZEPHIR_OBS_VAR(modelName); zephir_array_fetch_string(&modelName, intermediate, SL("model"), PH_NOISY, "phalcon/mvc/model/query.zep", 2823 TSRMLS_CC); ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_OBS_VAR(model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&model, _0, modelName, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, 1); ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, modelName, _1); zephir_check_call_status(); } if ((zephir_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't return a valid connection", "phalcon/mvc/model/query.zep", 2836); return; } } else { ZEPHIR_CALL_METHOD(&connection, model, "getwriteconnection", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(metaData); zephir_read_property_this(&metaData, this_ptr, SL("_metaData"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&attributes, metaData, "getattributes", NULL, 0, model); zephir_check_call_status(); automaticFields = 0; ZEPHIR_OBS_VAR(fields); if (!(zephir_array_isset_string_fetch(&fields, intermediate, SS("fields"), 0 TSRMLS_CC))) { automaticFields = 1; ZEPHIR_CPY_WRT(fields, attributes); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, model); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } } ZEPHIR_OBS_VAR(values); zephir_array_fetch_string(&values, intermediate, SL("values"), PH_NOISY, "phalcon/mvc/model/query.zep", 2859 TSRMLS_CC); if (zephir_fast_count_int(fields TSRMLS_CC) != zephir_fast_count_int(values TSRMLS_CC)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The column count does not match the values count", "phalcon/mvc/model/query.zep", 2865); return; } ZEPHIR_CALL_METHOD(&dialect, connection, "getdialect", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(insertValues); array_init(insertValues); zephir_is_iterable(values, &_3, &_2, 0, 0, "phalcon/mvc/model/query.zep", 2933); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(number, _3, _2); ZEPHIR_GET_HVALUE(value, _4); ZEPHIR_OBS_NVAR(exprValue); zephir_array_fetch_string(&exprValue, value, SL("value"), PH_NOISY, "phalcon/mvc/model/query.zep", 2876 TSRMLS_CC); zephir_array_fetch_string(&_5, value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 2877 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_5, 260) || ZEPHIR_IS_LONG(_5, 258) || ZEPHIR_IS_LONG(_5, 259)) { ZEPHIR_CALL_METHOD(&insertValue, dialect, "getsqlexpression", &_6, 0, exprValue); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(_5, 322)) { ZEPHIR_INIT_NVAR(insertValue); ZVAL_NULL(insertValue); break; } if (ZEPHIR_IS_LONG(_5, 273) || ZEPHIR_IS_LONG(_5, 274) || ZEPHIR_IS_LONG(_5, 277)) { if (Z_TYPE_P(bindParams) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Bound parameter cannot be replaced because placeholders is not an array", "phalcon/mvc/model/query.zep", 2894); return; } ZEPHIR_CALL_METHOD(&_7, dialect, "getsqlexpression", &_8, 0, exprValue); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_9); ZVAL_STRING(&_9, ":", 0); ZEPHIR_SINIT_NVAR(_10); ZVAL_STRING(&_10, "", 0); ZEPHIR_INIT_NVAR(wildcard); zephir_fast_str_replace(&wildcard, &_9, &_10, _7 TSRMLS_CC); ZEPHIR_OBS_NVAR(insertValue); if (!(zephir_array_isset_fetch(&insertValue, bindParams, wildcard, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, "Bound parameter '", wildcard, "' cannot be replaced because it isn't in the placeholders list"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_12, 9, _11); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/query.zep", 2899 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } break; } ZEPHIR_INIT_NVAR(insertValue); object_init_ex(insertValue, phalcon_db_rawvalue_ce); ZEPHIR_CALL_METHOD(&_7, dialect, "getsqlexpression", &_13, 0, exprValue); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, insertValue, "__construct", &_14, 17, _7); zephir_check_call_status(); break; } while(0); ZEPHIR_OBS_NVAR(fieldName); zephir_array_fetch(&fieldName, fields, number, PH_NOISY, "phalcon/mvc/model/query.zep", 2909 TSRMLS_CC); if (automaticFields == 1) { if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeName); if (!(zephir_array_isset_fetch(&attributeName, columnMap, fieldName, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVS(_11, "Column '", fieldName, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_12, 9, _11); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/query.zep", 2917 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeName, fieldName); } } else { ZEPHIR_CPY_WRT(attributeName, fieldName); } zephir_array_update_zval(&insertValues, attributeName, &insertValue, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&_7, manager, "load", NULL, 0, modelName); zephir_check_call_status(); ZEPHIR_INIT_VAR(insertModel); if (zephir_clone(insertModel, _7 TSRMLS_CC) == FAILURE) { RETURN_MM(); } object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_CALL_METHOD(&_15, insertModel, "create", NULL, 0, insertValues); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 337, _15, insertModel); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _executeUpdate) { zend_object_iterator *_17; zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_18 = NULL; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *intermediate, *bindParams, *bindTypes, *models, *modelName, *model = NULL, *connection = NULL, *dialect = NULL, *fields, *values, *updateValues, *fieldName = NULL, *value = NULL, *selectBindParams = NULL, *selectBindTypes = NULL, *number = NULL, *field = NULL, *records = NULL, *exprValue = NULL, *updateValue = NULL, *wildcard = NULL, *record = NULL, *_0, *_1, **_4, *_5, *_7 = NULL, _9 = zval_used_for_init, _10 = zval_used_for_init, *_11 = NULL, *_12 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &intermediate, &bindParams, &bindTypes); ZEPHIR_OBS_VAR(models); zephir_array_fetch_string(&models, intermediate, SL("models"), PH_NOISY, "phalcon/mvc/model/query.zep", 2957 TSRMLS_CC); if (zephir_array_isset_long(models, 1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Updating several models at the same time is still not supported", "phalcon/mvc/model/query.zep", 2960); return; } ZEPHIR_OBS_VAR(modelName); zephir_array_fetch_long(&modelName, models, 0, PH_NOISY, "phalcon/mvc/model/query.zep", 2963 TSRMLS_CC); ZEPHIR_OBS_VAR(model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&model, _0, modelName, 0 TSRMLS_CC))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&model, _1, "load", NULL, 0, modelName); zephir_check_call_status(); } if ((zephir_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't return a valid connection", "phalcon/mvc/model/query.zep", 2975); return; } } else { ZEPHIR_CALL_METHOD(&connection, model, "getwriteconnection", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&dialect, connection, "getdialect", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(fields); zephir_array_fetch_string(&fields, intermediate, SL("fields"), PH_NOISY, "phalcon/mvc/model/query.zep", 2983 TSRMLS_CC); ZEPHIR_OBS_VAR(values); zephir_array_fetch_string(&values, intermediate, SL("values"), PH_NOISY, "phalcon/mvc/model/query.zep", 2984 TSRMLS_CC); ZEPHIR_INIT_VAR(updateValues); array_init(updateValues); ZEPHIR_CPY_WRT(selectBindParams, bindParams); ZEPHIR_CPY_WRT(selectBindTypes, bindTypes); zephir_is_iterable(fields, &_3, &_2, 0, 0, "phalcon/mvc/model/query.zep", 3051); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(number, _3, _2); ZEPHIR_GET_HVALUE(field, _4); ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, values, number, PH_NOISY, "phalcon/mvc/model/query.zep", 2999 TSRMLS_CC); ZEPHIR_OBS_NVAR(exprValue); zephir_array_fetch_string(&exprValue, value, SL("value"), PH_NOISY, "phalcon/mvc/model/query.zep", 3000 TSRMLS_CC); if (zephir_array_isset_string(field, SS("balias"))) { ZEPHIR_OBS_NVAR(fieldName); zephir_array_fetch_string(&fieldName, field, SL("balias"), PH_NOISY, "phalcon/mvc/model/query.zep", 3003 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(fieldName); zephir_array_fetch_string(&fieldName, field, SL("name"), PH_NOISY, "phalcon/mvc/model/query.zep", 3005 TSRMLS_CC); } zephir_array_fetch_string(&_5, value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/query.zep", 3008 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_5, 260) || ZEPHIR_IS_LONG(_5, 258) || ZEPHIR_IS_LONG(_5, 259)) { ZEPHIR_CALL_METHOD(&updateValue, dialect, "getsqlexpression", &_6, 0, exprValue); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(_5, 322)) { ZEPHIR_INIT_NVAR(updateValue); ZVAL_NULL(updateValue); break; } if (ZEPHIR_IS_LONG(_5, 273) || ZEPHIR_IS_LONG(_5, 274) || ZEPHIR_IS_LONG(_5, 277)) { if (Z_TYPE_P(bindParams) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Bound parameter cannot be replaced because placeholders is not an array", "phalcon/mvc/model/query.zep", 3025); return; } ZEPHIR_CALL_METHOD(&_7, dialect, "getsqlexpression", &_8, 0, exprValue); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_9); ZVAL_STRING(&_9, ":", 0); ZEPHIR_SINIT_NVAR(_10); ZVAL_STRING(&_10, "", 0); ZEPHIR_INIT_NVAR(wildcard); zephir_fast_str_replace(&wildcard, &_9, &_10, _7 TSRMLS_CC); ZEPHIR_OBS_NVAR(updateValue); if (zephir_array_isset_fetch(&updateValue, bindParams, wildcard, 0 TSRMLS_CC)) { zephir_array_unset(&selectBindParams, wildcard, PH_SEPARATE); zephir_array_unset(&selectBindTypes, wildcard, PH_SEPARATE); } else { ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SVS(_12, "Bound parameter '", wildcard, "' cannot be replaced because it's not in the placeholders list"); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_13, 9, _12); zephir_check_call_status(); zephir_throw_exception_debug(_11, "phalcon/mvc/model/query.zep", 3033 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } break; } if (ZEPHIR_IS_LONG(_5, 277)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/mvc/model/query.zep", 3038); return; } ZEPHIR_INIT_NVAR(updateValue); object_init_ex(updateValue, phalcon_db_rawvalue_ce); ZEPHIR_CALL_METHOD(&_7, dialect, "getsqlexpression", &_14, 0, exprValue); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, updateValue, "__construct", &_15, 17, _7); zephir_check_call_status(); break; } while(0); zephir_array_update_zval(&updateValues, fieldName, &updateValue, PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&records, this_ptr, "_getrelatedrecords", NULL, 338, model, intermediate, selectBindParams, selectBindTypes); zephir_check_call_status(); if (!(zephir_fast_count_int(records TSRMLS_CC))) { object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_NVAR(_11); ZVAL_BOOL(_11, 1); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_16, 337, _11); zephir_check_call_status(); RETURN_MM(); } if ((zephir_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't return a valid connection", "phalcon/mvc/model/query.zep", 3063); return; } } else { ZEPHIR_CALL_METHOD(&connection, model, "getwriteconnection", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); _17 = zephir_get_iterator(records TSRMLS_CC); _17->funcs->rewind(_17 TSRMLS_CC); for (;_17->funcs->valid(_17 TSRMLS_CC) == SUCCESS && !EG(exception); _17->funcs->move_forward(_17 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _17->funcs->get_current_data(_17, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(&_7, record, "update", NULL, 0, updateValues); zephir_check_call_status(); if (!(zephir_is_true(_7))) { ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_18, 0); zephir_check_call_status(); object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_NVAR(_11); ZVAL_BOOL(_11, 0); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_16, 337, _11, record); zephir_check_call_status(); RETURN_MM(); } } _17->funcs->dtor(_17 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_NVAR(_11); ZVAL_BOOL(_11, 1); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_16, 337, _11); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _executeDelete) { zend_object_iterator *_4; zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *intermediate, *bindParams, *bindTypes, *models, *modelName, *model = NULL, *records = NULL, *connection = NULL, *record = NULL, *_0, *_1, *_2 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &intermediate, &bindParams, &bindTypes); ZEPHIR_OBS_VAR(models); zephir_array_fetch_string(&models, intermediate, SL("models"), PH_NOISY, "phalcon/mvc/model/query.zep", 3110 TSRMLS_CC); if (zephir_array_isset_long(models, 1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Delete from several models at the same time is still not supported", "phalcon/mvc/model/query.zep", 3113); return; } ZEPHIR_OBS_VAR(modelName); zephir_array_fetch_long(&modelName, models, 0, PH_NOISY, "phalcon/mvc/model/query.zep", 3116 TSRMLS_CC); ZEPHIR_OBS_VAR(model); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_modelsInstances"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&model, _0, modelName, 0 TSRMLS_CC))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_manager"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&model, _1, "load", NULL, 0, modelName); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&records, this_ptr, "_getrelatedrecords", NULL, 338, model, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (!(zephir_fast_count_int(records TSRMLS_CC))) { object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_3, 337, _2); zephir_check_call_status(); RETURN_MM(); } if ((zephir_method_exists_ex(model, SS("selectwriteconnection") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, intermediate, bindParams, bindTypes); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "'selectWriteConnection' didn't return a valid connection", "phalcon/mvc/model/query.zep", 3140); return; } } else { ZEPHIR_CALL_METHOD(&connection, model, "getwriteconnection", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); _4 = zephir_get_iterator(records TSRMLS_CC); _4->funcs->rewind(_4 TSRMLS_CC); for (;_4->funcs->valid(_4 TSRMLS_CC) == SUCCESS && !EG(exception); _4->funcs->move_forward(_4 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _4->funcs->get_current_data(_4, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(&_5, record, "delete", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_5))) { ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_6, 0); zephir_check_call_status(); object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_NVAR(_2); ZVAL_BOOL(_2, 0); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_3, 337, _2, record); zephir_check_call_status(); RETURN_MM(); } } _4->funcs->dtor(_4 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); object_init_ex(return_value, phalcon_mvc_model_query_status_ce); ZEPHIR_INIT_NVAR(_2); ZVAL_BOOL(_2, 1); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_3, 337, _2); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, _getRelatedRecords) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; zval *model, *intermediate, *bindParams, *bindTypes, *selectIr, *whereConditions, *limitConditions, *query, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &model, &intermediate, &bindParams, &bindTypes); ZEPHIR_INIT_VAR(selectIr); zephir_create_array(selectIr, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); add_assoc_stringl_ex(_1, SS("type"), SL("object"), 1); ZEPHIR_INIT_VAR(_2); zephir_get_class(_2, model, 0 TSRMLS_CC); zephir_array_update_string(&_1, SL("model"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_3, model, "getsource", NULL, 0); zephir_check_call_status(); zephir_array_update_string(&_1, SL("column"), &_3, PH_COPY | PH_SEPARATE); zephir_array_fast_append(_0, _1); zephir_array_update_string(&selectIr, SL("columns"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(_4); zephir_array_fetch_string(&_4, intermediate, SL("models"), PH_NOISY, "phalcon/mvc/model/query.zep", 3201 TSRMLS_CC); zephir_array_update_string(&selectIr, SL("models"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_4); zephir_array_fetch_string(&_4, intermediate, SL("tables"), PH_NOISY, "phalcon/mvc/model/query.zep", 3203 TSRMLS_CC); zephir_array_update_string(&selectIr, SL("tables"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_VAR(whereConditions); if (zephir_array_isset_string_fetch(&whereConditions, intermediate, SS("where"), 0 TSRMLS_CC)) { zephir_array_update_string(&selectIr, SL("where"), &whereConditions, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(limitConditions); if (zephir_array_isset_string_fetch(&limitConditions, intermediate, SS("limit"), 0 TSRMLS_CC)) { zephir_array_update_string(&selectIr, SL("limit"), &limitConditions, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_VAR(query); object_init_ex(query, phalcon_mvc_model_query_ce); ZEPHIR_CALL_METHOD(NULL, query, "__construct", NULL, 339); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, query, "setdi", NULL, 340, _5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 309); ZEPHIR_CALL_METHOD(NULL, query, "settype", NULL, 341, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, query, "setintermediate", NULL, 342, selectIr); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(query, "execute", NULL, 343, bindParams, bindTypes); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, execute) { zend_bool _2, _3; int ZEPHIR_LAST_CALL_STATUS; zval *bindParams = NULL, *bindTypes = NULL, *uniqueRow, *cacheOptions, *key, *cacheService = NULL, *cache = NULL, *result = NULL, *preparedResult = NULL, *defaultBindParams, *mergedParams = NULL, *defaultBindTypes, *mergedTypes = NULL, *type, *lifetime = NULL, *intermediate = NULL, *_0, *_1 = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &bindParams, &bindTypes); if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(uniqueRow); zephir_read_property_this(&uniqueRow, this_ptr, SL("_uniqueRow"), PH_NOISY_CC); ZEPHIR_OBS_VAR(cacheOptions); zephir_read_property_this(&cacheOptions, this_ptr, SL("_cacheOptions"), PH_NOISY_CC); if (Z_TYPE_P(cacheOptions) != IS_NULL) { if (Z_TYPE_P(cacheOptions) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid caching options", "phalcon/mvc/model/query.zep", 3249); return; } ZEPHIR_OBS_VAR(key); if (!(zephir_array_isset_string_fetch(&key, cacheOptions, SS("key"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A cache key must be provided to identify the cached resultset in the cache backend", "phalcon/mvc/model/query.zep", 3256); return; } ZEPHIR_OBS_VAR(lifetime); if (!(zephir_array_isset_string_fetch(&lifetime, cacheOptions, SS("lifetime"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(lifetime); ZVAL_LONG(lifetime, 3600); } ZEPHIR_OBS_VAR(cacheService); if (!(zephir_array_isset_string_fetch(&cacheService, cacheOptions, SS("service"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(cacheService); ZVAL_STRING(cacheService, "modelsCache", 1); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&cache, _0, "getshared", NULL, 0, cacheService); zephir_check_call_status(); if (Z_TYPE_P(cache) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cache service must be an object", "phalcon/mvc/model/query.zep", 3275); return; } ZEPHIR_CALL_METHOD(&result, cache, "get", NULL, 0, key, lifetime); zephir_check_call_status(); if (Z_TYPE_P(result) != IS_NULL) { if (Z_TYPE_P(result) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cache didn't return a valid resultset", "phalcon/mvc/model/query.zep", 3282); return; } ZEPHIR_INIT_VAR(_1); ZVAL_BOOL(_1, 0); ZEPHIR_CALL_METHOD(NULL, result, "setisfresh", NULL, 0, _1); zephir_check_call_status(); if (zephir_is_true(uniqueRow)) { ZEPHIR_CALL_METHOD(&preparedResult, result, "getfirst", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(preparedResult, result); } RETURN_CCTOR(preparedResult); } zephir_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(defaultBindParams); zephir_read_property_this(&defaultBindParams, this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(defaultBindParams) == IS_ARRAY) { if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_add_function(mergedParams, defaultBindParams, bindParams); } else { ZEPHIR_CPY_WRT(mergedParams, defaultBindParams); } } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } ZEPHIR_OBS_VAR(defaultBindTypes); zephir_read_property_this(&defaultBindTypes, this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(defaultBindTypes) == IS_ARRAY) { if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedTypes); zephir_add_function(mergedTypes, defaultBindTypes, bindTypes); } else { ZEPHIR_CPY_WRT(mergedTypes, defaultBindTypes); } } else { ZEPHIR_CPY_WRT(mergedTypes, bindTypes); } _2 = Z_TYPE_P(mergedParams) != IS_NULL; if (_2) { _2 = Z_TYPE_P(mergedParams) != IS_ARRAY; } if (_2) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Bound parameters must be an array", "phalcon/mvc/model/query.zep", 3336); return; } _3 = Z_TYPE_P(mergedTypes) != IS_NULL; if (_3) { _3 = Z_TYPE_P(mergedTypes) != IS_ARRAY; } if (_3) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Bound parameter types must be an array", "phalcon/mvc/model/query.zep", 3340); return; } ZEPHIR_OBS_VAR(type); zephir_read_property_this(&type, this_ptr, SL("_type"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(type, 309)) { ZEPHIR_CALL_METHOD(&result, this_ptr, "_executeselect", NULL, 344, intermediate, mergedParams, mergedTypes); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 306)) { ZEPHIR_CALL_METHOD(&result, this_ptr, "_executeinsert", NULL, 345, intermediate, mergedParams, mergedTypes); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 300)) { ZEPHIR_CALL_METHOD(&result, this_ptr, "_executeupdate", NULL, 346, intermediate, mergedParams, mergedTypes); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 303)) { ZEPHIR_CALL_METHOD(&result, this_ptr, "_executedelete", NULL, 347, intermediate, mergedParams, mergedTypes); zephir_check_call_status(); break; } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "Unknown statement ", type); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/query.zep", 3363 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); if (Z_TYPE_P(cacheOptions) != IS_NULL) { if (!ZEPHIR_IS_LONG(type, 309)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only PHQL statements that return resultsets can be cached", "phalcon/mvc/model/query.zep", 3375); return; } ZEPHIR_CALL_METHOD(NULL, cache, "save", NULL, 0, key, result, lifetime); zephir_check_call_status(); } if (zephir_is_true(uniqueRow)) { ZEPHIR_CALL_METHOD(&preparedResult, result, "getfirst", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(preparedResult, result); } RETURN_CCTOR(preparedResult); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleResult) { int ZEPHIR_LAST_CALL_STATUS; zval *bindParams = NULL, *bindTypes = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &bindParams, &bindTypes); if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueRow"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, bindParams, bindTypes); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "execute", NULL, 343, bindParams, bindTypes); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(_1, "getfirst", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setType) { zval *type_param = NULL, *_0; int type; zephir_fetch_params(0, 1, 0, &type_param); type = zephir_get_intval(type_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, type); zephir_update_property_this(this_ptr, SL("_type"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindParams) { zend_bool merge; zval *bindParams_param = NULL, *merge_param = NULL, *currentBindParams, *_0; zval *bindParams = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); bindParams = bindParams_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { currentBindParams = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_add_function(_0, currentBindParams, bindParams); zephir_update_property_this(this_ptr, SL("_bindParams"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_bindParams"), bindParams TSRMLS_CC); } } else { zephir_update_property_this(this_ptr, SL("_bindParams"), bindParams TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindParams) { RETURN_MEMBER(this_ptr, "_bindParams"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindTypes) { zend_bool merge; zval *bindTypes_param = NULL, *merge_param = NULL, *currentBindTypes, *_0; zval *bindTypes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); bindTypes = bindTypes_param; if (!merge_param) { merge = 0; } else { merge = zephir_get_boolval(merge_param); } if (merge) { currentBindTypes = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(currentBindTypes) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_add_function(_0, currentBindTypes, bindTypes); zephir_update_property_this(this_ptr, SL("_bindTypes"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_bindTypes"), bindTypes TSRMLS_CC); } } else { zephir_update_property_this(this_ptr, SL("_bindTypes"), bindTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindTypes) { RETURN_MEMBER(this_ptr, "_bindTypes"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, setIntermediate) { zval *intermediate_param = NULL; zval *intermediate = NULL; zephir_fetch_params(0, 1, 0, &intermediate_param); intermediate = intermediate_param; zephir_update_property_this(this_ptr, SL("_intermediate"), intermediate TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getIntermediate) { RETURN_MEMBER(this_ptr, "_intermediate"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, cache) { zval *cacheOptions; zephir_fetch_params(0, 1, 0, &cacheOptions); zephir_update_property_this(this_ptr, SL("_cacheOptions"), cacheOptions TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getCacheOptions) { RETURN_MEMBER(this_ptr, "_cacheOptions"); } static PHP_METHOD(Phalcon_Mvc_Model_Query, getSql) { int ZEPHIR_LAST_CALL_STATUS; zval *intermediate = NULL, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); zephir_check_call_status(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(_0, 309)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, 1); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_executeselect", NULL, 344, intermediate, _1, _2, _3); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "This type of statement generates multiple SQL statements", "phalcon/mvc/model/query.zep", 3545); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_QueryInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, QueryInterface, phalcon, mvc_model_queryinterface, phalcon_mvc_model_queryinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, parse); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, cache); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getCacheOptions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setUniqueRow); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getUniqueRow); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, execute); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Relation) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Relation, phalcon, mvc_model_relation, phalcon_mvc_model_relation_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_referencedModel"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_fields"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_referencedFields"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_intermediateModel"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_intermediateFields"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_intermediateReferencedFields"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("BELONGS_TO"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE_THROUGH"), 3 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY_THROUGH"), 4 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("NO_ACTION"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_RESTRICT"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_CASCADE"), 2 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_relation_ce TSRMLS_CC, 1, phalcon_mvc_model_relationinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Relation, __construct) { zval *referencedModel = NULL; zval *type, *referencedModel_param = NULL, *fields, *referencedFields, *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 1, &type, &referencedModel_param, &fields, &referencedFields, &options); if (unlikely(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(referencedModel_param) == IS_STRING)) { zephir_get_strval(referencedModel, referencedModel_param); } else { ZEPHIR_INIT_VAR(referencedModel); ZVAL_EMPTY_STRING(referencedModel); } if (!options) { options = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_referencedModel"), referencedModel TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_fields"), fields TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_referencedFields"), referencedFields TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, setIntermediateRelation) { zval *intermediateModel = NULL; zval *intermediateFields, *intermediateModel_param = NULL, *intermediateReferencedFields; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &intermediateFields, &intermediateModel_param, &intermediateReferencedFields); if (unlikely(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { zephir_get_strval(intermediateModel, intermediateModel_param); } else { ZEPHIR_INIT_VAR(intermediateModel); ZVAL_EMPTY_STRING(intermediateModel); } zephir_update_property_this(this_ptr, SL("_intermediateFields"), intermediateFields TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_intermediateModel"), intermediateModel TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_intermediateReferencedFields"), intermediateReferencedFields TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedModel) { RETURN_MEMBER(this_ptr, "_referencedModel"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getFields) { RETURN_MEMBER(this_ptr, "_fields"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedFields) { RETURN_MEMBER(this_ptr, "_referencedFields"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOption) { zval *name_param = NULL, *option, *_0; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (zephir_array_isset_fetch(&option, _0, name, 1 TSRMLS_CC)) { RETURN_CTOR(option); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, isForeignKey) { zval *options; options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string(options, SS("foreignKey"))) { RETURN_BOOL(1); } } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getForeignKey) { zval *options, *foreignKey; options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&foreignKey, options, SS("foreignKey"), 1 TSRMLS_CC)) { if (zephir_is_true(foreignKey)) { RETURN_CTORW(foreignKey); } } } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getParams) { zval *options, *params; options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(¶ms, options, SS("params"), 1 TSRMLS_CC)) { if (zephir_is_true(params)) { RETURN_CTORW(params); } } } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, isThrough) { zend_bool _0; zval *type; type = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC); _0 = ZEPHIR_IS_LONG(type, 3); if (!(_0)) { _0 = ZEPHIR_IS_LONG(type, 4); } RETURN_BOOL(_0); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, isReusable) { zval *options, *reusable; options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&reusable, options, SS("reusable"), 1 TSRMLS_CC)) { RETURN_CTORW(reusable); } } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateFields) { RETURN_MEMBER(this_ptr, "_intermediateFields"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateModel) { RETURN_MEMBER(this_ptr, "_intermediateModel"); } static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateReferencedFields) { RETURN_MEMBER(this_ptr, "_intermediateReferencedFields"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_RelationInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, RelationInterface, phalcon, mvc_model_relationinterface, phalcon_mvc_model_relationinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, setIntermediateRelation); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isReusable); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedModel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getFields); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedFields); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOptions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getForeignKey); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isThrough); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateFields); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateModel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateReferencedFields); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultInterface, phalcon, mvc_model_resultinterface, phalcon_mvc_model_resultinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultInterface, setDirtyState); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Resultset, phalcon, mvc_model_resultset, phalcon_mvc_model_resultset_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_bool(phalcon_mvc_model_resultset_ce, SL("_result"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_resultset_ce, SL("_isFresh"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("_pointer"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_count"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_activeRow"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_rows"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_row"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("_errorMessages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("_hydrateMode"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_FULL"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_PARTIAL"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_RECORDS"), 0 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_OBJECTS"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_ARRAYS"), 1 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, phalcon_mvc_model_resultsetinterface_ce); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, zend_ce_iterator); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, spl_ce_SeekableIterator); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_mvc_model_resultset_ce TSRMLS_CC, 1, zend_ce_serializable); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *result, *cache = NULL, *rowCount = NULL, *rows = NULL, *_0, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &result, &cache); if (!cache) { cache = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(result) != IS_OBJECT) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_count"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_rows"), _1 TSRMLS_CC); RETURN_MM_NULL(); } zephir_update_property_this(this_ptr, SL("_result"), result TSRMLS_CC); if (Z_TYPE_P(cache) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 2); ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&rowCount, result, "numrows", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_count"), rowCount TSRMLS_CC); if (ZEPHIR_IS_LONG(rowCount, 0)) { ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_rows"), _1 TSRMLS_CC); RETURN_MM_NULL(); } if (ZEPHIR_LE_LONG(rowCount, 32)) { ZEPHIR_CALL_METHOD(&rows, result, "fetchall", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(rows) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_rows"), rows TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_rows"), _1 TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, next) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, (zephir_get_numberval(_0) + 1)); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 73, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, valid) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_LT(_0, _1)); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, key) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC); if (ZEPHIR_GE(_0, _1)) { RETURN_NULL(); } RETURN_MEMBER(this_ptr, "_pointer"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, rewind) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 73, _0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, seek) { zephir_fcall_cache_entry *_9 = NULL; zend_bool _1, _6; zval *position_param = NULL, *result, *row, *_0, *_2, *_3, *_4, *_5, *_7 = NULL, *_8; int position, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &position_param); position = zephir_get_intval(position_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); _1 = !ZEPHIR_IS_LONG(_0, position); if (!(_1)) { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_row"), PH_NOISY_CC); _1 = Z_TYPE_P(_2) == IS_NULL; } if (_1) { ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(_3) == IS_ARRAY) { ZEPHIR_OBS_VAR(row); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_rows"), PH_NOISY_CC); if (zephir_array_isset_long_fetch(&row, _4, position, 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_row"), row TSRMLS_CC); } ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, position); zephir_update_property_this(this_ptr, SL("_pointer"), _5 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_row"), PH_NOISY_CC); _6 = Z_TYPE_P(_4) == IS_NULL; if (_6) { _5 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); _6 = ZEPHIR_IS_LONG_IDENTICAL(_5, 0); } if (_6) { ZEPHIR_CALL_METHOD(&_7, result, "fetch", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_row"), _7 TSRMLS_CC); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); if (ZEPHIR_GT_LONG(_4, position)) { ZEPHIR_INIT_VAR(_8); ZVAL_LONG(_8, position); ZEPHIR_CALL_METHOD(NULL, result, "dataseek", NULL, 0, _8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, result, "fetch", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_row"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, position); zephir_update_property_this(this_ptr, SL("_pointer"), _5 TSRMLS_CC); } while (1) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_pointer"), PH_NOISY_CC); if (!(ZEPHIR_LT_LONG(_4, position))) { break; } ZEPHIR_CALL_METHOD(&_7, result, "fetch", &_9, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_row"), _7 TSRMLS_CC); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_pointer") TSRMLS_CC)); } ZEPHIR_INIT_ZVAL_NREF(_4); ZVAL_LONG(_4, position); zephir_update_property_this(this_ptr, SL("_pointer"), _4 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, count) { RETURN_MEMBER(this_ptr, "_count"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists) { zval *index_param = NULL, *_0; int index; zephir_fetch_params(0, 1, 0, &index_param); index = zephir_get_intval(index_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_GT_LONG(_0, index)); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet) { zval *index_param = NULL, *_0, *_1; int index, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } index = Z_LVAL_P(index_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC); if (ZEPHIR_GT_LONG(_0, index)) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, index); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 73, _1); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor", "phalcon/mvc/model/resultset.zep", 285); return; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetSet) { zval *index, *value; zephir_fetch_params(0, 2, 0, &index, &value); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/mvc/model/resultset.zep", 296); return; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetUnset) { zval *offset_param = NULL; int offset; zephir_fetch_params(0, 1, 0, &offset_param); offset = zephir_get_intval(offset_param); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/mvc/model/resultset.zep", 304); return; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getType) { zval *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(_1) == IS_ARRAY) { ZVAL_LONG(_0, 0); } else { ZVAL_LONG(_0, 1); } RETURN_CCTOR(_0); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getFirst) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_count"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(_0, 0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 73, _1); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast) { int ZEPHIR_LAST_CALL_STATUS; zval *count, *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(count); zephir_read_property_this(&count, this_ptr, SL("_count"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(count, 0)) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, (zephir_get_numberval(count) - 1)); ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 73, _0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setIsFresh) { zval *isFresh_param = NULL; zend_bool isFresh; zephir_fetch_params(0, 1, 0, &isFresh_param); isFresh = zephir_get_boolval(isFresh_param); if (isFresh) { zephir_update_property_this(this_ptr, SL("_isFresh"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_isFresh"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh) { RETURN_MEMBER(this_ptr, "_isFresh"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setHydrateMode) { zval *hydrateMode_param = NULL, *_0; int hydrateMode; zephir_fetch_params(0, 1, 0, &hydrateMode_param); hydrateMode = zephir_get_intval(hydrateMode_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, hydrateMode); zephir_update_property_this(this_ptr, SL("_hydrateMode"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getHydrateMode) { RETURN_MEMBER(this_ptr, "_hydrateMode"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getCache) { RETURN_MEMBER(this_ptr, "_cache"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getMessages) { RETURN_MEMBER(this_ptr, "_errorMessages"); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) { zval *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_0; zend_bool transaction; zval *data, *conditionCallback = NULL, *record = NULL, *connection = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &data, &conditionCallback); if (!conditionCallback) { conditionCallback = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(connection); ZVAL_NULL(connection); transaction = 0; _0 = zephir_get_iterator(this_ptr TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } if (transaction == 0) { if (!((zephir_method_exists_ex(record, SS("getwriteconnection") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/mvc/model/resultset.zep", 414); return; } ZEPHIR_CALL_METHOD(&connection, record, "getwriteconnection", NULL, 0); zephir_check_call_status(); transaction = 1; ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_NVAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_fast_append(_2, record); ZEPHIR_CALL_USER_FUNC_ARRAY(_1, conditionCallback, _2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { continue; } } ZEPHIR_CALL_METHOD(&_3, record, "save", NULL, 0, data); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_CALL_METHOD(&_4, record, "getmessages", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_errorMessages"), _4 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "rollback", NULL, 0); zephir_check_call_status(); transaction = 0; break; } } _0->funcs->dtor(_0 TSRMLS_CC); if (transaction == 1) { ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, delete) { zval *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_0; zend_bool transaction; zval *conditionCallback = NULL, *record = NULL, *connection = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &conditionCallback); if (!conditionCallback) { conditionCallback = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(connection); ZVAL_NULL(connection); transaction = 0; _0 = zephir_get_iterator(this_ptr TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } if (transaction == 0) { if (!((zephir_method_exists_ex(record, SS("getwriteconnection") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/mvc/model/resultset.zep", 477); return; } ZEPHIR_CALL_METHOD(&connection, record, "getwriteconnection", NULL, 0); zephir_check_call_status(); transaction = 1; ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_NVAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_fast_append(_2, record); ZEPHIR_CALL_USER_FUNC_ARRAY(_1, conditionCallback, _2); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { continue; } } ZEPHIR_CALL_METHOD(&_3, record, "delete", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_CALL_METHOD(&_4, record, "getmessages", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_errorMessages"), _4 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, connection, "rollback", NULL, 0); zephir_check_call_status(); transaction = 0; break; } } _0->funcs->dtor(_0 TSRMLS_CC); if (transaction == 1) { ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset, filter) { zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_0; zval *filter, *records, *record = NULL, *parameters, *processedRecord = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &filter); ZEPHIR_INIT_VAR(records); array_init(records); ZEPHIR_INIT_VAR(parameters); array_init(parameters); _0 = zephir_get_iterator(this_ptr TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(record, (*ZEPHIR_TMP_ITERATOR_PTR)); } zephir_array_update_long(¶meters, 0, &record, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_NVAR(processedRecord); ZEPHIR_CALL_USER_FUNC_ARRAY(processedRecord, filter, parameters); zephir_check_call_status(); _1 = Z_TYPE_P(processedRecord) != IS_OBJECT; if (_1) { _1 = Z_TYPE_P(processedRecord) != IS_ARRAY; } if (_1) { continue; } zephir_array_append(&records, processedRecord, PH_SEPARATE, "phalcon/mvc/model/resultset.zep", 556); } _0->funcs->dtor(_0 TSRMLS_CC); RETURN_CCTOR(records); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultsetInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultsetInterface, phalcon, mvc_model_resultsetinterface, phalcon_mvc_model_resultsetinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getFirst); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getLast); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setIsFresh); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, isFresh); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getCache); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, toArray); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Row) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Row, phalcon, mvc_model_row, phalcon_mvc_model_row_method_entry, 0); zend_class_implements(phalcon_mvc_model_row_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); zend_class_implements(phalcon_mvc_model_row_ce TSRMLS_CC, 1, phalcon_mvc_model_resultinterface_ce); zend_class_implements(phalcon_mvc_model_row_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Row, setDirtyState) { zval *dirtyState_param = NULL; int dirtyState; zephir_fetch_params(0, 1, 0, &dirtyState_param); dirtyState = zephir_get_intval(dirtyState_param); RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetExists) { zval *index; zephir_fetch_params(0, 1, 0, &index); RETURN_BOOL(zephir_isset_property_zval(this_ptr, index TSRMLS_CC)); } static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetGet) { zval *index, *value; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, this_ptr, index, PH_SILENT_CC)) { RETURN_CCTOR(value); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the row", "phalcon/mvc/model/row.zep", 67); return; } static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetSet) { zval *index, *value; zephir_fetch_params(0, 2, 0, &index, &value); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/mvc/model/row.zep", 78); return; } static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset) { zval *offset_param = NULL; int offset; zephir_fetch_params(0, 1, 0, &offset_param); offset = zephir_get_intval(offset_param); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/mvc/model/row.zep", 88); return; } static PHP_METHOD(Phalcon_Mvc_Model_Row, readAttribute) { zval *attribute, *value; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &attribute); ZEPHIR_OBS_VAR(value); if (zephir_fetch_property_zval(&value, this_ptr, attribute, PH_SILENT_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_Row, writeAttribute) { zval *attribute_param = NULL, *value; zval *attribute = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &attribute_param, &value); if (unlikely(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(attribute_param) == IS_STRING)) { zephir_get_strval(attribute, attribute_param); } else { ZEPHIR_INIT_VAR(attribute); ZVAL_EMPTY_STRING(attribute); } zephir_update_property_zval_zval(this_ptr, attribute, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Row, toArray) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 24, this_ptr); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Transaction, phalcon, mvc_model_transaction, phalcon_mvc_model_transaction_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("_connection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("_activeTransaction"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("_isNewTransaction"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("_rollbackOnAbort"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("_manager"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("_rollbackRecord"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_transaction_ce TSRMLS_CC, 1, phalcon_mvc_model_transactioninterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, __construct) { int ZEPHIR_LAST_CALL_STATUS; zend_bool autoBegin; zval *dependencyInjector, *autoBegin_param = NULL, *service = NULL, *connection = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &dependencyInjector, &autoBegin_param, &service); if (!autoBegin_param) { autoBegin = 0; } else { autoBegin = zephir_get_boolval(autoBegin_param); } if (!service) { service = ZEPHIR_GLOBAL(global_null); } if (zephir_is_true(service)) { ZEPHIR_CALL_METHOD(&connection, dependencyInjector, "get", NULL, 0, service); zephir_check_call_status(); } else { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "db", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&connection, dependencyInjector, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_connection"), connection TSRMLS_CC); if (autoBegin) { ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setTransactionManager) { zval *manager; zephir_fetch_params(0, 1, 0, &manager); zephir_update_property_this(this_ptr, SL("_manager"), manager TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, begin) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "begin", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, commit) { zval *_1, *_3; int ZEPHIR_LAST_CALL_STATUS; zval *manager, *_0, *_2, *_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); if (Z_TYPE_P(manager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, manager); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "notifyCommit", 1); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_fast_append(_3, this_ptr); ZEPHIR_CALL_USER_FUNC_ARRAY(_0, _1, _3); zephir_check_call_status(); } _4 = zephir_fetch_nproperty_this(this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_4, "commit", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback) { zval *_1, *_3; int ZEPHIR_LAST_CALL_STATUS; zval *rollbackMessage = NULL, *rollbackRecord = NULL, *manager, *connection, *_0 = NULL, *_2, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &rollbackMessage, &rollbackRecord); if (!rollbackMessage) { ZEPHIR_CPY_WRT(rollbackMessage, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(rollbackMessage); } if (!rollbackRecord) { rollbackRecord = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(manager); zephir_read_property_this(&manager, this_ptr, SL("_manager"), PH_NOISY_CC); if (Z_TYPE_P(manager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, manager); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "notifyRollback", 1); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_fast_append(_3, this_ptr); ZEPHIR_CALL_USER_FUNC_ARRAY(_0, _1, _3); zephir_check_call_status(); } ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_4, connection, "rollback", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_4)) { if (!(zephir_is_true(rollbackMessage))) { ZEPHIR_INIT_NVAR(rollbackMessage); ZVAL_STRING(rollbackMessage, "Transaction aborted", 1); } if (Z_TYPE_P(rollbackRecord) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_rollbackRecord"), rollbackRecord TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_transaction_failed_ce); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_rollbackRecord"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 354, rollbackMessage, _5); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/transaction.zep", 160 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getConnection) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rollbackOnAbort"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_FUNCTION(&_1, "connection_aborted", NULL, 355); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "The request was aborted", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); } } RETURN_MM_MEMBER(this_ptr, "_connection"); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setIsNewTransaction) { zval *isNew_param = NULL; zend_bool isNew; zephir_fetch_params(0, 1, 0, &isNew_param); isNew = zephir_get_boolval(isNew_param); if (isNew) { zephir_update_property_this(this_ptr, SL("_isNewTransaction"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_isNewTransaction"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackOnAbort) { zval *rollbackOnAbort_param = NULL; zend_bool rollbackOnAbort; zephir_fetch_params(0, 1, 0, &rollbackOnAbort_param); rollbackOnAbort = zephir_get_boolval(rollbackOnAbort_param); if (rollbackOnAbort) { zephir_update_property_this(this_ptr, SL("_rollbackOnAbort"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_rollbackOnAbort"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isManaged) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_manager"), PH_NOISY_CC); RETURN_BOOL(!zephir_is_true(_0)); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getMessages) { RETURN_MEMBER(this_ptr, "_messages"); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isValid) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_connection"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "isundertransaction", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackedRecord) { zval *record; zephir_fetch_params(0, 1, 0, &record); zephir_update_property_this(this_ptr, SL("_rollbackRecord"), record TSRMLS_CC); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_TransactionInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, TransactionInterface, phalcon, mvc_model_transactioninterface, phalcon_mvc_model_transactioninterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setTransactionManager); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, begin); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, commit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, rollback); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getConnection); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setIsNewTransaction); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackOnAbort); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isManaged); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isValid); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackedRecord); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ValidationFailed) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, ValidationFailed, phalcon, mvc_model_validationfailed, phalcon_mvc_model_exception_ce, phalcon_mvc_model_validationfailed_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *validationMessages = NULL; zval *model, *validationMessages_param = NULL, *messageStr = NULL, *message; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &validationMessages_param); validationMessages = validationMessages_param; if (zephir_fast_count_int(validationMessages TSRMLS_CC) > 0) { ZEPHIR_OBS_VAR(message); zephir_array_fetch_long(&message, validationMessages, 0, PH_NOISY, "phalcon/mvc/model/validationfailed.zep", 51 TSRMLS_CC); ZEPHIR_CALL_METHOD(&messageStr, message, "getmessage", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(messageStr); ZVAL_STRING(messageStr, "Validation failed", 1); } zephir_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_messages"), validationMessages TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_validationfailed_ce, this_ptr, "__construct", NULL, 0, messageStr); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getModel) { RETURN_MEMBER(this_ptr, "_model"); } static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getMessages) { RETURN_MEMBER(this_ptr, "_messages"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Validator, phalcon, mvc_model_validator, phalcon_mvc_model_validator_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_model_validator_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_validator_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); phalcon_mvc_model_validator_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator; return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator, __construct) { zval *options_param = NULL; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Validator, appendMessage) { int ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *field = NULL, *type = NULL, *_0 = NULL, _1, _2; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &message_param, &field, &type); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!field) { field = ZEPHIR_GLOBAL(global_null); } if (!type) { ZEPHIR_CPY_WRT(type, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(type); } if (!(zephir_is_true(type))) { ZEPHIR_INIT_VAR(_0); zephir_get_class(_0, this_ptr, 0 TSRMLS_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "Validator", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); ZEPHIR_INIT_NVAR(type); zephir_fast_str_replace(&type, &_1, &_2, _0 TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_message_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 8, message, field, type); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_messages"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Validator, getMessages) { RETURN_MEMBER(this_ptr, "_messages"); } static PHP_METHOD(Phalcon_Mvc_Model_Validator, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Mvc_Model_Validator, getOption) { zval *option_param = NULL, *defaultValue = NULL, *options, *value; zval *option = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &option_param, &defaultValue); if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(option_param) == IS_STRING)) { zephir_get_strval(option, option_param); } else { ZEPHIR_INIT_VAR(option); ZVAL_EMPTY_STRING(option); } if (!defaultValue) { ZEPHIR_INIT_VAR(defaultValue); ZVAL_STRING(defaultValue, "", 1); } options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, options, option, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Validator, isSetOption) { zval *option_param = NULL, *_0; zval *option = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &option_param); if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(option_param) == IS_STRING)) { zephir_get_strval(option, option_param); } else { ZEPHIR_INIT_VAR(option); ZVAL_EMPTY_STRING(option); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, option)); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ValidatorInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ValidatorInterface, phalcon, mvc_model_validatorinterface, phalcon_mvc_model_validatorinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ValidatorInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ValidatorInterface, validate); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_SoftDelete) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, SoftDelete, phalcon, mvc_model_behavior_softdelete, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_softdelete_method_entry, 0); zend_class_implements(phalcon_mvc_model_behavior_softdelete_ce TSRMLS_CC, 1, phalcon_mvc_model_behaviorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Behavior_SoftDelete, notify) { zephir_fcall_cache_entry *_7 = NULL; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *value, *field, *updateModel, *message = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, **_6; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } if (ZEPHIR_IS_STRING(type, "beforeDelete")) { ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, options, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'value' is required", "phalcon/mvc/model/behavior/softdelete.zep", 51); return; } ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/mvc/model/behavior/softdelete.zep", 58); return; } ZEPHIR_INIT_VAR(_0); ZVAL_BOOL(_0, 1); ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, field); zephir_check_call_status(); if (!ZEPHIR_IS_EQUAL(_1, value)) { ZEPHIR_INIT_VAR(updateModel); if (zephir_clone(updateModel, model TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(NULL, updateModel, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, updateModel, "save", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_2))) { ZEPHIR_CALL_METHOD(&_3, updateModel, "getmessages", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_3, &_5, &_4, 0, 0, "phalcon/mvc/model/behavior/softdelete.zep", 90); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(message, _6); ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, message); zephir_check_call_status(); } RETURN_MM_BOOL(0); } ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_Timestampable) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, Timestampable, phalcon, mvc_model_behavior_timestampable, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_timestampable_method_entry, 0); zend_class_implements(phalcon_mvc_model_behavior_timestampable_ce TSRMLS_CC, 1, phalcon_mvc_model_behaviorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, notify) { zephir_fcall_cache_entry *_4 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *timestamp = NULL, *singleField = NULL, *field, *generator, *format, *_0 = NULL, **_3; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, type); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(_0)) { RETURN_MM_NULL(); } ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, type); zephir_check_call_status(); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/mvc/model/behavior/timestampable.zep", 57); return; } ZEPHIR_INIT_VAR(timestamp); ZVAL_NULL(timestamp); ZEPHIR_OBS_VAR(format); if (zephir_array_isset_string_fetch(&format, options, SS("format"), 0 TSRMLS_CC)) { ZEPHIR_CALL_FUNCTION(×tamp, "date", NULL, 293, format); zephir_check_call_status(); } else { ZEPHIR_OBS_VAR(generator); if (zephir_array_isset_string_fetch(&generator, options, SS("generator"), 0 TSRMLS_CC)) { if (Z_TYPE_P(generator) == IS_OBJECT) { if (zephir_instance_of_ev(generator, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(timestamp); ZEPHIR_CALL_USER_FUNC(timestamp, generator); zephir_check_call_status(); } } } } if (Z_TYPE_P(timestamp) == IS_NULL) { ZEPHIR_INIT_NVAR(timestamp); zephir_time(timestamp); } if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_2, &_1, 0, 0, "phalcon/mvc/model/behavior/timestampable.zep", 95); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(singleField, _3); ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, singleField, timestamp); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, timestamp); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Apc) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Apc, phalcon, mvc_model_metadata_apc, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_apc_method_entry, 0); zend_declare_property_string(phalcon_mvc_model_metadata_apc_ce, SL("_prefix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_metadata_apc_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_apc_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Apc, __construct) { zval *options = NULL, *prefix, *ttl, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_metaData"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Apc, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data = NULL, *_0, *_1; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVV(_1, "$PMM$", _0, key); ZEPHIR_CALL_FUNCTION(&data, "apc_fetch", NULL, 82, _1); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_ARRAY) { RETURN_CCTOR(data); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Apc, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0, *_1, *_2; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVV(_1, "$PMM$", _0, key); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_ttl"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "apc_store", NULL, 83, _1, data, _2); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Files) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Files, phalcon, mvc_model_metadata_files, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_files_method_entry, 0); zend_declare_property_string(phalcon_mvc_model_metadata_files_ce, SL("_metaDataDir"), "./", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_files_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, __construct) { zval *options = NULL, *metaDataDir, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&metaDataDir, options, SS("metaDataDir"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_metaDataDir"), metaDataDir TSRMLS_CC); } } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_metaData"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read) { zval *key_param = NULL, *path, *_0, *_1, _2, *_3 = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "_", 0); zephir_prepare_virtual_path(_1, key, &_2 TSRMLS_CC); ZEPHIR_INIT_VAR(path); ZEPHIR_CONCAT_VVS(path, _0, _1, ".php"); if ((zephir_file_exists(path TSRMLS_CC) == SUCCESS)) { ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_3); if (zephir_require_zval_ret(&_3, path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } RETURN_CCTOR(_3); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, write) { zval *key_param = NULL, *data, *path, *_0, *_1, _2, *_3, *_4 = NULL, *_5; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "_", 0); zephir_prepare_virtual_path(_1, key, &_2 TSRMLS_CC); ZEPHIR_INIT_VAR(path); ZEPHIR_CONCAT_VVS(path, _0, _1, ".php"); ZEPHIR_INIT_VAR(_3); ZEPHIR_INIT_VAR(_4); ZEPHIR_INIT_NVAR(_4); zephir_var_export_ex(_4, &data TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVS(_5, "<?php return ", _4, "; "); zephir_file_put_contents(_3, path, _5 TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Meta-Data directory cannot be written", "phalcon/mvc/model/metadata/files.zep", 86); return; } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Libmemcached) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Libmemcached, phalcon, mvc_model_metadata_libmemcached, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_libmemcached_method_entry, 0); zend_declare_property_long(phalcon_mvc_model_metadata_libmemcached_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_libmemcached_ce, SL("_memcache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_libmemcached_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *options = NULL, *ttl, *_0 = NULL, *_1, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("servers")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "No servers given in options", "phalcon/mvc/model/metadata/libmemcached.zep", 71); return; } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "_PHCM_MM", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_cache_backend_libmemcached_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_ttl"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 313, _1, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_memcache"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); array_init(_4); zephir_update_property_this(this_ptr, SL("_metaData"), _4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&data, _0, "get", NULL, 0, key); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_ARRAY) { RETURN_CCTOR(data); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, key, data); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, reset) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *meta, *key = NULL, *realKey = NULL, *_0 = NULL, **_3, *_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(meta); zephir_read_property_this(&meta, this_ptr, SL("_metaData"), PH_NOISY_CC); if (Z_TYPE_P(meta) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(meta, &_2, &_1, 0, 0, "phalcon/mvc/model/metadata/libmemcached.zep", 128); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_INIT_NVAR(realKey); ZEPHIR_CONCAT_SV(realKey, "meta-", key); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _4, "delete", NULL, 0, realKey); zephir_check_call_status(); } } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_libmemcached_ce, this_ptr, "reset", &_5, 314); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Memcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Memcache, phalcon, mvc_model_metadata_memcache, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_memcache_method_entry, 0); zend_declare_property_long(phalcon_mvc_model_metadata_memcache_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_memcache_ce, SL("_memcache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_memcache_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memcache, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *options = NULL, *ttl, *_0 = NULL, *_1, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 11211); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_string(&options, SL("persistent"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "_PHCM_MM", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_cache_backend_memcache_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_ttl"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 315, _1, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_memcache"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); array_init(_4); zephir_update_property_this(this_ptr, SL("_metaData"), _4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memcache, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&data, _0, "get", NULL, 0, key); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_ARRAY) { RETURN_CCTOR(data); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memcache, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, key, data); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memcache, reset) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *meta, *key = NULL, *realKey = NULL, *_0 = NULL, **_3, *_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(meta); zephir_read_property_this(&meta, this_ptr, SL("_metaData"), PH_NOISY_CC); if (Z_TYPE_P(meta) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(meta, &_2, &_1, 0, 0, "phalcon/mvc/model/metadata/memcache.zep", 131); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_INIT_NVAR(realKey); ZEPHIR_CONCAT_SV(realKey, "meta-", key); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _4, "delete", NULL, 0, realKey); zephir_check_call_status(); } } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_memcache_ce, this_ptr, "reset", &_5, 314); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Memory) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Memory, phalcon, mvc_model_metadata_memory, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_memory_method_entry, 0); zend_class_implements(phalcon_mvc_model_metadata_memory_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, __construct) { zval *options = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_metaData"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, read) { zval *key_param = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, write) { zval *key_param = NULL, *data; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } RETURN_MM_NULL(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Redis) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Redis, phalcon, mvc_model_metadata_redis, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_redis_method_entry, 0); zend_declare_property_long(phalcon_mvc_model_metadata_redis_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_metadata_redis_ce, SL("_redis"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_redis_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *options = NULL, *ttl, *_0 = NULL, *_1, *_3, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { ZEPHIR_CPY_WRT(options, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(options); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_NVAR(options); array_init(options); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 6379); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_string(&options, SL("persistent"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("statsKey")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "_PHCM_MM", 1); zephir_array_update_string(&options, SL("statsKey"), &_0, PH_COPY | PH_SEPARATE); } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_cache_backend_redis_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_ttl"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 316, _1, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_redis"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); array_init(_4); zephir_update_property_this(this_ptr, SL("_metaData"), _4 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&data, _0, "get", NULL, 0, key); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_ARRAY) { RETURN_CCTOR(data); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, key, data); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, reset) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *meta, *key = NULL, *realKey = NULL, *_0 = NULL, **_3, *_4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(meta); zephir_read_property_this(&meta, this_ptr, SL("_metaData"), PH_NOISY_CC); if (Z_TYPE_P(meta) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(meta, &_2, &_1, 0, 0, "phalcon/mvc/model/metadata/redis.zep", 131); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_INIT_NVAR(realKey); ZEPHIR_CONCAT_SV(realKey, "meta-", key); _4 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _4, "delete", NULL, 0, realKey); zephir_check_call_status(); } } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_redis_ce, this_ptr, "reset", &_5, 314); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Session) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Session, phalcon, mvc_model_metadata_session, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_session_method_entry, 0); zend_declare_property_string(phalcon_mvc_model_metadata_session_ce, SL("_prefix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_session_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, __construct) { zval *options = NULL, *prefix; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } } } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, read) { zval *key_param = NULL, *metaData, *_SESSION, *_0, *_1, *_2; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "$PMM$", _1); zephir_array_fetch(&_0, _SESSION, _2, PH_READONLY, "phalcon/mvc/model/metadata/session.zep", 70 TSRMLS_CC); if (zephir_array_isset_fetch(&metaData, _0, key, 1 TSRMLS_CC)) { RETURN_CTOR(metaData); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, write) { zval *key_param = NULL, *data, *_SESSION, *_0, *_1; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "$PMM$", _0); zephir_array_update_multi(&_SESSION, &data TSRMLS_CC, SL("zz"), 2, _1, key); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_StrategyInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\MetaData, StrategyInterface, phalcon, mvc_model_metadata_strategyinterface, phalcon_mvc_model_metadata_strategyinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaData_StrategyInterface, getMetaData); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaData_StrategyInterface, getColumnMaps); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Xcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Xcache, phalcon, mvc_model_metadata_xcache, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_xcache_method_entry, 0); zend_declare_property_string(phalcon_mvc_model_metadata_xcache_ce, SL("_prefix"), "", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_metadata_xcache_ce, SL("_ttl"), 172800, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_metadata_xcache_ce TSRMLS_CC, 1, phalcon_mvc_model_metadatainterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, __construct) { zval *options = NULL, *prefix, *ttl, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } if (zephir_array_isset_string_fetch(&ttl, options, SS("lifetime"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_metaData"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, read) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data = NULL, *_0, *_1; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVV(_1, "$PMM$", _0, key); ZEPHIR_CALL_FUNCTION(&data, "xcache_get", NULL, 84, _1); zephir_check_call_status(); if (Z_TYPE_P(data) == IS_ARRAY) { RETURN_CCTOR(data); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, write) { int ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *data, *_0, *_1, *_2; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &data); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVV(_1, "$PMM$", _0, key); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_ttl"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(NULL, "xcache_set", NULL, 85, _1, data, _2); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Strategy_Annotations) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\MetaData\\Strategy, Annotations, phalcon, mvc_model_metadata_strategy_annotations, phalcon_mvc_model_metadata_strategy_annotations_method_entry, 0); zend_class_implements(phalcon_mvc_model_metadata_strategy_annotations_ce TSRMLS_CC, 1, phalcon_mvc_model_metadata_strategyinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getMetaData) { zend_bool _11; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *model, *dependencyInjector, *annotations = NULL, *className, *reflection = NULL, *propertiesAnnotations = NULL, *property = NULL, *propAnnotations = NULL, *columnAnnotation = NULL, *columnName = NULL, *feature = NULL, *fieldTypes, *fieldBindTypes, *numericTyped, *primaryKeys, *nonPrimaryKeys, *identityField = NULL, *notNull, *attributes, *automaticDefault, *defaultValues, *defaultValue = NULL, *emptyStringValues, *_0 = NULL, *_1 = NULL, **_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_12 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dependencyInjector); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid", "phalcon/mvc/model/metadata/strategy/annotations.zep", 42); return; } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotations, dependencyInjector, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&reflection, annotations, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(reflection) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "No annotations were found in class ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 51 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&propertiesAnnotations, reflection, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); if (!(zephir_fast_count_int(propertiesAnnotations TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "No properties with annotations were found in class ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 60 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(attributes); array_init(attributes); ZEPHIR_INIT_VAR(primaryKeys); array_init(primaryKeys); ZEPHIR_INIT_VAR(nonPrimaryKeys); array_init(nonPrimaryKeys); ZEPHIR_INIT_VAR(numericTyped); array_init(numericTyped); ZEPHIR_INIT_VAR(notNull); array_init(notNull); ZEPHIR_INIT_VAR(fieldTypes); array_init(fieldTypes); ZEPHIR_INIT_VAR(fieldBindTypes); array_init(fieldBindTypes); ZEPHIR_INIT_VAR(automaticDefault); array_init(automaticDefault); ZEPHIR_INIT_VAR(identityField); ZVAL_BOOL(identityField, 0); ZEPHIR_INIT_VAR(defaultValues); array_init(defaultValues); ZEPHIR_INIT_VAR(emptyStringValues); array_init(emptyStringValues); zephir_is_iterable(propertiesAnnotations, &_3, &_2, 0, 0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 184); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(property, _3, _2); ZEPHIR_GET_HVALUE(propAnnotations, _4); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, propAnnotations, "has", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (!(zephir_is_true(_5))) { continue; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&columnAnnotation, propAnnotations, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&columnName, columnAnnotation, "getnamedparameter", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(columnName)) { ZEPHIR_CPY_WRT(columnName, property); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "type", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&feature, columnAnnotation, "getnamedparameter", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); do { if (ZEPHIR_IS_STRING(feature, "integer")) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_zval(&fieldTypes, property, &_0, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 1); zephir_array_update_zval(&fieldBindTypes, columnName, &_6, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, columnName, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(feature, "decimal")) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 3); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 32); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, columnName, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(feature, "boolean")) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 8); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 5); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(feature, "date")) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 1); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(feature, "datetime")) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 4); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(feature, "text")) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 6); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 2); zephir_array_update_zval(&fieldTypes, columnName, &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_7); ZVAL_LONG(_7, 2); zephir_array_update_zval(&fieldBindTypes, columnName, &_7, PH_COPY | PH_SEPARATE); } while(0); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "Primary", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_8, propAnnotations, "has", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (zephir_is_true(_8)) { zephir_array_append(&primaryKeys, columnName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/annotations.zep", 151); } else { zephir_array_append(&nonPrimaryKeys, columnName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/annotations.zep", 153); } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "Identity", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, propAnnotations, "has", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_CPY_WRT(identityField, columnName); } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "nullable", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_10, columnAnnotation, "getnamedparameter", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (!(zephir_is_true(_10))) { zephir_array_append(¬Null, columnName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/annotations.zep", 167); } ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "default", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&defaultValue, columnAnnotation, "getnamedparameter", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); _11 = Z_TYPE_P(defaultValue) != IS_NULL; if (!(_11)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "nullable", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_12, columnAnnotation, "getnamedparameter", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); _11 = zephir_is_true(_12); } if (_11) { zephir_array_update_zval(&defaultValues, columnName, &defaultValue, PH_COPY | PH_SEPARATE); } zephir_array_append(&attributes, columnName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/annotations.zep", 178); } zephir_create_array(return_value, 12, 0 TSRMLS_CC); zephir_array_update_long(&return_value, 0, &attributes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 1, &primaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 2, &nonPrimaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 3, ¬Null, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 4, &fieldTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 5, &numericTyped, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 8, &identityField, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 9, &fieldBindTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 10, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 11, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 12, &defaultValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 13, &emptyStringValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getColumnMaps) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *model, *dependencyInjector, *annotations = NULL, *className, *reflection = NULL, *propertiesAnnotations = NULL, *property = NULL, *propAnnotations = NULL, *columnAnnotation = NULL, *columnName = NULL, *orderedColumnMap = NULL, *reversedColumnMap = NULL, *_0 = NULL, *_1 = NULL, **_4, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dependencyInjector); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid", "phalcon/mvc/model/metadata/strategy/annotations.zep", 210); return; } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotations, dependencyInjector, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(className); zephir_get_class(className, model, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&reflection, annotations, "get", NULL, 0, className); zephir_check_call_status(); if (Z_TYPE_P(reflection) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "No annotations were found in class ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 217 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&propertiesAnnotations, reflection, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); if (!(zephir_fast_count_int(propertiesAnnotations TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SV(_1, "No properties with annotations were found in class ", className); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 225 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(orderedColumnMap); ZVAL_NULL(orderedColumnMap); ZEPHIR_INIT_VAR(reversedColumnMap); ZVAL_NULL(reversedColumnMap); zephir_is_iterable(propertiesAnnotations, &_3, &_2, 0, 0, "phalcon/mvc/model/metadata/strategy/annotations.zep", 262); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(property, _3, _2); ZEPHIR_GET_HVALUE(propAnnotations, _4); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_5, propAnnotations, "has", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (!(zephir_is_true(_5))) { continue; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&columnAnnotation, propAnnotations, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "column", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&columnName, columnAnnotation, "getnamedparameter", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (!(ZEPHIR_IS_EMPTY(columnName))) { if (Z_TYPE_P(orderedColumnMap) != IS_ARRAY) { ZEPHIR_INIT_NVAR(orderedColumnMap); array_init(orderedColumnMap); ZEPHIR_INIT_NVAR(reversedColumnMap); array_init(reversedColumnMap); } zephir_array_update_zval(&orderedColumnMap, columnName, &property, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&reversedColumnMap, property, &columnName, PH_COPY | PH_SEPARATE); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, orderedColumnMap); zephir_array_fast_append(return_value, reversedColumnMap); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Strategy_Introspection) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\MetaData\\Strategy, Introspection, phalcon, mvc_model_metadata_strategy_introspection, phalcon_mvc_model_metadata_strategy_introspection_method_entry, 0); zend_class_implements(phalcon_mvc_model_metadata_strategy_introspection_ce TSRMLS_CC, 1, phalcon_mvc_model_metadata_strategyinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData) { zend_bool _13; HashTable *_5; HashPosition _4; int ZEPHIR_LAST_CALL_STATUS; zval *model, *dependencyInjector, *schema = NULL, *table = NULL, *readConnection = NULL, *columns = NULL, *attributes, *primaryKeys, *nonPrimaryKeys, *completeTable = NULL, *numericTyped, *notNull, *fieldTypes, *automaticDefault, *identityField = NULL, *fieldBindTypes, *defaultValues, *column = NULL, *fieldName = NULL, *defaultValue = NULL, *emptyStringValues, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dependencyInjector); ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&table, model, "getsource", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&readConnection, model, "getreadconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_0, readConnection, "tableexists", NULL, 0, table, schema); zephir_check_call_status(); if (!(zephir_is_true(_0))) { if (zephir_is_true(schema)) { ZEPHIR_INIT_VAR(completeTable); ZEPHIR_CONCAT_VSV(completeTable, schema, "'.'", table); } else { ZEPHIR_CPY_WRT(completeTable, table); } ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_2); zephir_get_class(_2, model, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "Table '", completeTable, "' doesn't exist in database when dumping meta-data for ", _2); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/metadata/strategy/introspection.zep", 66 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&columns, readConnection, "describecolumns", NULL, 0, table, schema); zephir_check_call_status(); if (!(zephir_fast_count_int(columns TSRMLS_CC))) { if (zephir_is_true(schema)) { ZEPHIR_INIT_NVAR(completeTable); ZEPHIR_CONCAT_VSV(completeTable, schema, "'.'", table); } else { ZEPHIR_CPY_WRT(completeTable, table); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_NVAR(_2); zephir_get_class(_2, model, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVSV(_3, "Cannot obtain table columns for the mapped source '", completeTable, "' used in model ", _2); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/metadata/strategy/introspection.zep", 84 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(attributes); array_init(attributes); ZEPHIR_INIT_VAR(primaryKeys); array_init(primaryKeys); ZEPHIR_INIT_VAR(nonPrimaryKeys); array_init(nonPrimaryKeys); ZEPHIR_INIT_VAR(numericTyped); array_init(numericTyped); ZEPHIR_INIT_VAR(notNull); array_init(notNull); ZEPHIR_INIT_VAR(fieldTypes); array_init(fieldTypes); ZEPHIR_INIT_VAR(fieldBindTypes); array_init(fieldBindTypes); ZEPHIR_INIT_VAR(automaticDefault); array_init(automaticDefault); ZEPHIR_INIT_VAR(identityField); ZVAL_BOOL(identityField, 0); ZEPHIR_INIT_VAR(defaultValues); array_init(defaultValues); ZEPHIR_INIT_VAR(emptyStringValues); array_init(emptyStringValues); zephir_is_iterable(columns, &_5, &_4, 0, 0, "phalcon/mvc/model/metadata/strategy/introspection.zep", 161); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HVALUE(column, _6); ZEPHIR_CALL_METHOD(&fieldName, column, "getname", NULL, 0); zephir_check_call_status(); zephir_array_append(&attributes, fieldName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/introspection.zep", 105); ZEPHIR_CALL_METHOD(&_7, column, "isprimary", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_7)) { zephir_array_append(&primaryKeys, fieldName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/introspection.zep", 111); } else { zephir_array_append(&nonPrimaryKeys, fieldName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/introspection.zep", 113); } ZEPHIR_CALL_METHOD(&_8, column, "isnumeric", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_8)) { zephir_array_update_zval(&numericTyped, fieldName, &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); } ZEPHIR_CALL_METHOD(&_9, column, "isnotnull", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_9)) { zephir_array_append(¬Null, fieldName, PH_SEPARATE, "phalcon/mvc/model/metadata/strategy/introspection.zep", 127); } ZEPHIR_CALL_METHOD(&_10, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_10)) { ZEPHIR_CPY_WRT(identityField, fieldName); } ZEPHIR_CALL_METHOD(&_11, column, "gettype", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&fieldTypes, fieldName, &_11, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&_12, column, "getbindtype", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&fieldBindTypes, fieldName, &_12, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(&defaultValue, column, "getdefault", NULL, 0); zephir_check_call_status(); _13 = Z_TYPE_P(defaultValue) != IS_NULL; if (!(_13)) { ZEPHIR_CALL_METHOD(&_14, column, "isnotnull", NULL, 0); zephir_check_call_status(); _13 = ZEPHIR_IS_FALSE_IDENTICAL(_14); } if (_13) { ZEPHIR_CALL_METHOD(&_15, column, "isautoincrement", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_15))) { zephir_array_update_zval(&defaultValues, fieldName, &defaultValue, PH_COPY | PH_SEPARATE); } } } zephir_create_array(return_value, 12, 0 TSRMLS_CC); zephir_array_update_long(&return_value, 0, &attributes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 1, &primaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 2, &nonPrimaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 3, ¬Null, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 4, &fieldTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 5, &numericTyped, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 8, &identityField, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 9, &fieldBindTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 10, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 11, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 12, &defaultValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(&return_value, 13, &emptyStringValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getColumnMaps) { HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zval *model, *dependencyInjector, *orderedColumnMap = NULL, *userColumnMap = NULL, *reversedColumnMap = NULL, *name = NULL, *userName = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &dependencyInjector); ZEPHIR_INIT_VAR(orderedColumnMap); ZVAL_NULL(orderedColumnMap); ZEPHIR_INIT_VAR(reversedColumnMap); ZVAL_NULL(reversedColumnMap); if ((zephir_method_exists_ex(model, SS("columnmap") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&userColumnMap, model, "columnmap", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(userColumnMap) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "columnMap() not returned an array", "phalcon/mvc/model/metadata/strategy/introspection.zep", 194); return; } ZEPHIR_INIT_NVAR(reversedColumnMap); array_init(reversedColumnMap); ZEPHIR_CPY_WRT(orderedColumnMap, userColumnMap); zephir_is_iterable(userColumnMap, &_1, &_0, 0, 0, "phalcon/mvc/model/metadata/strategy/introspection.zep", 201); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(name, _1, _0); ZEPHIR_GET_HVALUE(userName, _2); zephir_array_update_zval(&reversedColumnMap, userName, &name, PH_COPY | PH_SEPARATE); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, orderedColumnMap); zephir_array_fast_append(return_value, reversedColumnMap); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Builder) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Builder, phalcon, mvc_model_query_builder, phalcon_mvc_model_query_builder_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_columns"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_models"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_joins"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_with"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_conditions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_group"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_having"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_order"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_limit"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_offset"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_forUpdate"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_sharedLock"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_bindParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_bindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("_distinct"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_query_builder_ce, SL("_hiddenParamNumber"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_query_builder_ce TSRMLS_CC, 1, phalcon_mvc_model_query_builderinterface_ce); zend_class_implements(phalcon_mvc_model_query_builder_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct) { zend_bool _5; HashTable *_1; HashPosition _0; zval *params = NULL, *dependencyInjector = NULL, *conditions = NULL, *columns, *groupClause, *havingClause, *limitClause, *forUpdate, *sharedLock, *orderClause, *offsetClause, *joinsClause, *singleConditionArray = NULL, *limit, *offset, *fromClause, *mergedConditions, *mergedParams = NULL, *mergedTypes = NULL, *singleCondition = NULL, *singleParams = NULL, *singleTypes = NULL, *with, *distinct, *bind, *bindTypes, **_2, *_3 = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶ms, &dependencyInjector); if (!params) { params = ZEPHIR_GLOBAL(global_null); } if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(params) == IS_ARRAY) { ZEPHIR_OBS_VAR(conditions); if (zephir_array_isset_long_fetch(&conditions, params, 0, 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(conditions); if (zephir_array_isset_string_fetch(&conditions, params, SS("conditions"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC); } } if (Z_TYPE_P(conditions) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedConditions); array_init(mergedConditions); ZEPHIR_INIT_VAR(mergedParams); array_init(mergedParams); ZEPHIR_INIT_VAR(mergedTypes); array_init(mergedTypes); zephir_is_iterable(conditions, &_1, &_0, 0, 0, "phalcon/mvc/model/query/builder.zep", 146); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(singleConditionArray, _2); if (Z_TYPE_P(singleConditionArray) == IS_ARRAY) { ZEPHIR_OBS_NVAR(singleCondition); zephir_array_isset_long_fetch(&singleCondition, singleConditionArray, 0, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(singleParams); zephir_array_isset_long_fetch(&singleParams, singleConditionArray, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(singleTypes); zephir_array_isset_long_fetch(&singleTypes, singleConditionArray, 2, 0 TSRMLS_CC); if (Z_TYPE_P(singleCondition) == IS_STRING) { zephir_array_append(&mergedConditions, singleCondition, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 133); } if (Z_TYPE_P(singleParams) == IS_ARRAY) { ZEPHIR_INIT_LNVAR(_3); zephir_add_function(_3, mergedParams, singleParams); ZEPHIR_CPY_WRT(mergedParams, _3); } if (Z_TYPE_P(singleTypes) == IS_ARRAY) { ZEPHIR_INIT_LNVAR(_3); zephir_add_function(_3, mergedTypes, singleTypes); ZEPHIR_CPY_WRT(mergedTypes, _3); } } } ZEPHIR_INIT_VAR(_4); zephir_fast_join_str(_4, SL(" AND "), mergedConditions TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_conditions"), _4 TSRMLS_CC); if (Z_TYPE_P(mergedParams) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_bindParams"), mergedParams TSRMLS_CC); } if (Z_TYPE_P(mergedTypes) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_bindTypes"), mergedTypes TSRMLS_CC); } } ZEPHIR_OBS_VAR(bind); if (zephir_array_isset_string_fetch(&bind, params, SS("bind"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_bindParams"), bind TSRMLS_CC); } ZEPHIR_OBS_VAR(bindTypes); if (zephir_array_isset_string_fetch(&bindTypes, params, SS("bindTypes"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_bindTypes"), bindTypes TSRMLS_CC); } ZEPHIR_OBS_VAR(distinct); if (zephir_array_isset_string_fetch(&distinct, params, SS("distinct"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_distinct"), distinct TSRMLS_CC); } ZEPHIR_OBS_VAR(fromClause); if (zephir_array_isset_string_fetch(&fromClause, params, SS("models"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_models"), fromClause TSRMLS_CC); } ZEPHIR_OBS_VAR(columns); if (zephir_array_isset_string_fetch(&columns, params, SS("columns"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_columns"), columns TSRMLS_CC); } ZEPHIR_OBS_VAR(joinsClause); if (zephir_array_isset_string_fetch(&joinsClause, params, SS("joins"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_joins"), joinsClause TSRMLS_CC); } ZEPHIR_OBS_VAR(with); if (zephir_array_isset_string_fetch(&with, params, SS("with"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_with"), with TSRMLS_CC); } ZEPHIR_OBS_VAR(groupClause); if (zephir_array_isset_string_fetch(&groupClause, params, SS("group"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_group"), groupClause TSRMLS_CC); } ZEPHIR_OBS_VAR(havingClause); if (zephir_array_isset_string_fetch(&havingClause, params, SS("having"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_having"), havingClause TSRMLS_CC); } ZEPHIR_OBS_VAR(orderClause); if (zephir_array_isset_string_fetch(&orderClause, params, SS("order"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_order"), orderClause TSRMLS_CC); } ZEPHIR_OBS_VAR(limitClause); if (zephir_array_isset_string_fetch(&limitClause, params, SS("limit"), 0 TSRMLS_CC)) { if (Z_TYPE_P(limitClause) == IS_ARRAY) { ZEPHIR_OBS_VAR(limit); if (zephir_array_isset_long_fetch(&limit, limitClause, 0, 0 TSRMLS_CC)) { if (Z_TYPE_P(limit) == IS_LONG) { zephir_update_property_this(this_ptr, SL("_limit"), limit TSRMLS_CC); } ZEPHIR_OBS_VAR(offset); if (zephir_array_isset_long_fetch(&offset, limitClause, 1, 0 TSRMLS_CC)) { if (Z_TYPE_P(offset) == IS_LONG) { zephir_update_property_this(this_ptr, SL("_offset"), offset TSRMLS_CC); } } } else { zephir_update_property_this(this_ptr, SL("_limit"), limitClause TSRMLS_CC); } } else { zephir_update_property_this(this_ptr, SL("_limit"), limitClause TSRMLS_CC); } } if (zephir_array_isset_string_fetch(&offsetClause, params, SS("offset"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_offset"), offsetClause TSRMLS_CC); } if (zephir_array_isset_string_fetch(&forUpdate, params, SS("for_update"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_forUpdate"), forUpdate TSRMLS_CC); } if (zephir_array_isset_string_fetch(&sharedLock, params, SS("shared_lock"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_sharedLock"), sharedLock TSRMLS_CC); } } else { _5 = Z_TYPE_P(params) == IS_STRING; if (_5) { _5 = !ZEPHIR_IS_STRING_IDENTICAL(params, ""); } if (_5) { zephir_update_property_this(this_ptr, SL("_conditions"), params TSRMLS_CC); } } if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, distinct) { zval *distinct; zephir_fetch_params(0, 1, 0, &distinct); zephir_update_property_this(this_ptr, SL("_distinct"), distinct TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDistinct) { RETURN_MEMBER(this_ptr, "_distinct"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, columns) { zval *columns; zephir_fetch_params(0, 1, 0, &columns); zephir_update_property_this(this_ptr, SL("_columns"), columns TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getColumns) { RETURN_MEMBER(this_ptr, "_columns"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, from) { zval *models; zephir_fetch_params(0, 1, 0, &models); zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, addFrom) { zval *model, *alias = NULL, *with = NULL, *models = NULL, *currentModel = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model, &alias, &with); if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } if (!with) { with = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(models); zephir_read_property_this(&models, this_ptr, SL("_models"), PH_NOISY_CC); if (Z_TYPE_P(models) != IS_ARRAY) { if (Z_TYPE_P(models) != IS_NULL) { ZEPHIR_CPY_WRT(currentModel, models); ZEPHIR_INIT_NVAR(models); zephir_create_array(models, 1, 0 TSRMLS_CC); zephir_array_fast_append(models, currentModel); } else { ZEPHIR_INIT_NVAR(models); array_init(models); } } if (Z_TYPE_P(alias) == IS_STRING) { zephir_array_update_zval(&models, alias, &model, PH_COPY | PH_SEPARATE); } else { zephir_array_append(&models, model, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 395); } zephir_update_property_this(this_ptr, SL("_models"), models TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getFrom) { RETURN_MEMBER(this_ptr, "_models"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, join) { zval *_0; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *type = NULL; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } if (!type) { type = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_fast_append(_0, model); zephir_array_fast_append(_0, conditions); zephir_array_fast_append(_0, alias); zephir_array_fast_append(_0, type); zephir_update_property_array_append(this_ptr, SL("_joins"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, innerJoin) { zval *_0; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_1; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_fast_append(_0, model); zephir_array_fast_append(_0, conditions); zephir_array_fast_append(_0, alias); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "INNER", 1); zephir_array_fast_append(_0, _1); zephir_update_property_array_append(this_ptr, SL("_joins"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, leftJoin) { zval *_0; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_1; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_fast_append(_0, model); zephir_array_fast_append(_0, conditions); zephir_array_fast_append(_0, alias); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "LEFT", 1); zephir_array_fast_append(_0, _1); zephir_update_property_array_append(this_ptr, SL("_joins"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, rightJoin) { zval *_0; zval *model_param = NULL, *conditions = NULL, *alias = NULL, *_1; zval *model = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); if (unlikely(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(model_param) == IS_STRING)) { zephir_get_strval(model, model_param); } else { ZEPHIR_INIT_VAR(model); ZVAL_EMPTY_STRING(model); } if (!conditions) { conditions = ZEPHIR_GLOBAL(global_null); } if (!alias) { alias = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_fast_append(_0, model); zephir_array_fast_append(_0, conditions); zephir_array_fast_append(_0, alias); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "RIGHT", 1); zephir_array_fast_append(_0, _1); zephir_update_property_array_append(this_ptr, SL("_joins"), _0 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where) { zval *conditions, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *currentBindTypes, *mergedParams = NULL, *mergedTypes = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions, &bindParams, &bindTypes); if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { currentBindParams = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_add_function(mergedParams, currentBindParams, bindParams); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } zephir_update_property_this(this_ptr, SL("_bindParams"), mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { currentBindTypes = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedTypes); zephir_add_function(mergedTypes, currentBindTypes, bindTypes); } else { ZEPHIR_CPY_WRT(mergedTypes, bindTypes); } zephir_update_property_this(this_ptr, SL("_bindTypes"), mergedTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andWhere) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *currentBindTypes, *mergedParams = NULL, *mergedTypes = NULL, *currentConditions, *newConditions = NULL; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } currentConditions = zephir_fetch_nproperty_this(this_ptr, SL("_conditions"), PH_NOISY_CC); if (zephir_is_true(currentConditions)) { ZEPHIR_INIT_VAR(newConditions); ZEPHIR_CONCAT_SVSVS(newConditions, "(", currentConditions, ") AND (", conditions, ")"); } else { ZEPHIR_CPY_WRT(newConditions, conditions); } zephir_update_property_this(this_ptr, SL("_conditions"), newConditions TSRMLS_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { currentBindParams = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_add_function(mergedParams, currentBindParams, bindParams); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } zephir_update_property_this(this_ptr, SL("_bindParams"), mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { currentBindTypes = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedTypes); zephir_add_function(mergedTypes, currentBindTypes, bindTypes); } else { ZEPHIR_CPY_WRT(mergedTypes, bindTypes); } zephir_update_property_this(this_ptr, SL("_bindTypes"), mergedTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orWhere) { zval *conditions_param = NULL, *bindParams = NULL, *bindTypes = NULL, *currentBindParams, *currentBindTypes, *mergedParams = NULL, *mergedTypes = NULL, *currentConditions, *_0; zval *conditions = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); if (unlikely(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(conditions_param) == IS_STRING)) { zephir_get_strval(conditions, conditions_param); } else { ZEPHIR_INIT_VAR(conditions); ZVAL_EMPTY_STRING(conditions); } if (!bindParams) { bindParams = ZEPHIR_GLOBAL(global_null); } if (!bindTypes) { bindTypes = ZEPHIR_GLOBAL(global_null); } currentConditions = zephir_fetch_nproperty_this(this_ptr, SL("_conditions"), PH_NOISY_CC); if (zephir_is_true(currentConditions)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVS(_0, "(", currentConditions, ") OR (", conditions, ")"); zephir_update_property_this(this_ptr, SL("_conditions"), _0 TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_conditions"), conditions TSRMLS_CC); } if (Z_TYPE_P(bindParams) == IS_ARRAY) { currentBindParams = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_add_function(mergedParams, currentBindParams, bindParams); } else { ZEPHIR_CPY_WRT(mergedParams, bindParams); } zephir_update_property_this(this_ptr, SL("_bindParams"), mergedParams TSRMLS_CC); } if (Z_TYPE_P(bindTypes) == IS_ARRAY) { currentBindTypes = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(currentBindParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedTypes); zephir_add_function(mergedTypes, currentBindTypes, bindTypes); } else { ZEPHIR_CPY_WRT(mergedTypes, bindTypes); } zephir_update_property_this(this_ptr, SL("_bindTypes"), mergedTypes TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *expr_param = NULL, *minimum, *maximum, *hiddenParam, *nextHiddenParam, *minimumKey, *maximumKey, *_0; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(nextHiddenParam); ZVAL_LONG(nextHiddenParam, (zephir_get_numberval(hiddenParam) + 1)); ZEPHIR_INIT_VAR(minimumKey); ZEPHIR_CONCAT_SV(minimumKey, "AP", hiddenParam); ZEPHIR_INIT_VAR(maximumKey); ZEPHIR_CONCAT_SV(maximumKey, "AP", nextHiddenParam); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSVSVS(_0, expr, " BETWEEN :", minimumKey, ": AND :", maximumKey, ":"); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_zval(&_1, minimumKey, &minimum, PH_COPY); zephir_array_update_zval(&_1, maximumKey, &maximum, PH_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _0, _1); zephir_check_call_status(); ZEPHIR_SEPARATE(nextHiddenParam); zephir_increment(nextHiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), nextHiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenWhere) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zval *expr_param = NULL, *minimum, *maximum, *hiddenParam, *nextHiddenParam, *minimumKey, *maximumKey, *_0; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } ZEPHIR_OBS_VAR(hiddenParam); zephir_read_property_this(&hiddenParam, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); ZEPHIR_INIT_VAR(nextHiddenParam); ZVAL_LONG(nextHiddenParam, (zephir_get_numberval(hiddenParam) + 1)); ZEPHIR_INIT_VAR(minimumKey); ZEPHIR_CONCAT_SV(minimumKey, "AP", hiddenParam); ZEPHIR_INIT_VAR(maximumKey); ZEPHIR_CONCAT_SV(maximumKey, "AP", nextHiddenParam); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSVSVS(_0, expr, " NOT BETWEEN :", minimumKey, ": AND :", maximumKey, ":"); ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_update_zval(&_1, minimumKey, &minimum, PH_COPY); zephir_array_update_zval(&_1, maximumKey, &maximum, PH_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, _0, _1); zephir_check_call_status(); ZEPHIR_SEPARATE(nextHiddenParam); zephir_increment(nextHiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), nextHiddenParam TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inWhere) { HashTable *_4; HashPosition _3; zephir_fcall_cache_entry *_1 = NULL; int hiddenParam, ZEPHIR_LAST_CALL_STATUS; zval *values = NULL; zval *expr_param = NULL, *values_param = NULL, *key = NULL, *queryKey = NULL, *value = NULL, *bindKeys, *bindParams, *_2, **_5, _6 = zval_used_for_init, *_7, *_8, *_9; zval *expr = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &expr_param, &values_param); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } values = values_param; if (!(zephir_fast_count_int(values TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, expr, " != ", expr); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", &_1, 0, _0); zephir_check_call_status(); RETURN_THIS(); } ZEPHIR_OBS_VAR(_2); zephir_read_property_this(&_2, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); hiddenParam = zephir_get_intval(_2); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); ZEPHIR_INIT_VAR(bindKeys); array_init(bindKeys); zephir_is_iterable(values, &_4, &_3, 0, 0, "phalcon/mvc/model/query/builder.zep", 776); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(value, _5); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, hiddenParam); ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SV(_0, "AP", &_6); ZEPHIR_CPY_WRT(key, _0); ZEPHIR_INIT_NVAR(queryKey); ZEPHIR_CONCAT_SVS(queryKey, ":", key, ":"); zephir_array_append(&bindKeys, queryKey, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 767); zephir_array_update_zval(&bindParams, key, &value, PH_COPY | PH_SEPARATE); hiddenParam++; } ZEPHIR_INIT_VAR(_7); zephir_fast_join_str(_7, SL(", "), bindKeys TSRMLS_CC); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_VSVS(_8, expr, " IN (", _7, ")"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", &_1, 0, _8, bindParams); zephir_check_call_status(); ZEPHIR_INIT_ZVAL_NREF(_9); ZVAL_LONG(_9, hiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), _9 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInWhere) { HashTable *_4; HashPosition _3; zephir_fcall_cache_entry *_1 = NULL; int hiddenParam, ZEPHIR_LAST_CALL_STATUS; zval *values = NULL; zval *expr_param = NULL, *values_param = NULL, *key = NULL, *queryKey = NULL, *value = NULL, *bindKeys, *bindParams, *_2, **_5, _6 = zval_used_for_init, *_7, *_8, *_9; zval *expr = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &expr_param, &values_param); if (unlikely(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(expr_param) == IS_STRING)) { zephir_get_strval(expr, expr_param); } else { ZEPHIR_INIT_VAR(expr); ZVAL_EMPTY_STRING(expr); } values = values_param; if (!(zephir_fast_count_int(values TSRMLS_CC))) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, expr, " != ", expr); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", &_1, 0, _0); zephir_check_call_status(); RETURN_THIS(); } ZEPHIR_OBS_VAR(_2); zephir_read_property_this(&_2, this_ptr, SL("_hiddenParamNumber"), PH_NOISY_CC); hiddenParam = zephir_get_intval(_2); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); ZEPHIR_INIT_VAR(bindKeys); array_init(bindKeys); zephir_is_iterable(values, &_4, &_3, 0, 0, "phalcon/mvc/model/query/builder.zep", 819); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(value, _5); ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, hiddenParam); ZEPHIR_INIT_LNVAR(_0); ZEPHIR_CONCAT_SV(_0, "AP", &_6); ZEPHIR_CPY_WRT(key, _0); ZEPHIR_INIT_NVAR(queryKey); ZEPHIR_CONCAT_SVS(queryKey, ":", key, ":"); zephir_array_append(&bindKeys, queryKey, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 810); zephir_array_update_zval(&bindParams, key, &value, PH_COPY | PH_SEPARATE); hiddenParam++; } ZEPHIR_INIT_VAR(_7); zephir_fast_join_str(_7, SL(", "), bindKeys TSRMLS_CC); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_VSVS(_8, expr, " NOT IN (", _7, ")"); ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", &_1, 0, _8, bindParams); zephir_check_call_status(); ZEPHIR_INIT_ZVAL_NREF(_9); ZVAL_LONG(_9, hiddenParam); zephir_update_property_this(this_ptr, SL("_hiddenParamNumber"), _9 TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getWhere) { RETURN_MEMBER(this_ptr, "_conditions"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orderBy) { zval *orderBy; zephir_fetch_params(0, 1, 0, &orderBy); zephir_update_property_this(this_ptr, SL("_order"), orderBy TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOrderBy) { RETURN_MEMBER(this_ptr, "_order"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, having) { zval *having_param = NULL; zval *having = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &having_param); if (unlikely(Z_TYPE_P(having_param) != IS_STRING && Z_TYPE_P(having_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'having' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(having_param) == IS_STRING)) { zephir_get_strval(having, having_param); } else { ZEPHIR_INIT_VAR(having); ZVAL_EMPTY_STRING(having); } zephir_update_property_this(this_ptr, SL("_having"), having TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, forUpdate) { zval *forUpdate_param = NULL; zend_bool forUpdate; zephir_fetch_params(0, 1, 0, &forUpdate_param); forUpdate = zephir_get_boolval(forUpdate_param); if (forUpdate) { zephir_update_property_this(this_ptr, SL("_forUpdate"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_forUpdate"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getHaving) { RETURN_MEMBER(this_ptr, "_having"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, limit) { zval *limit_param = NULL, *offset_param = NULL, *_0; int limit, offset; zephir_fetch_params(0, 0, 2, &limit_param, &offset_param); if (!limit_param) { limit = 0; } else { limit = zephir_get_intval(limit_param); } if (!offset_param) { offset = 0; } else { offset = zephir_get_intval(offset_param); } ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, limit); zephir_update_property_this(this_ptr, SL("_limit"), _0 TSRMLS_CC); if (offset) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, offset); zephir_update_property_this(this_ptr, SL("_offset"), _0 TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getLimit) { RETURN_MEMBER(this_ptr, "_limit"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, offset) { zval *offset_param = NULL, *_0; int offset; zephir_fetch_params(0, 1, 0, &offset_param); offset = zephir_get_intval(offset_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, offset); zephir_update_property_this(this_ptr, SL("_offset"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOffset) { RETURN_MEMBER(this_ptr, "_offset"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, groupBy) { zval *group; zephir_fetch_params(0, 1, 0, &group); zephir_update_property_this(this_ptr, SL("_group"), group TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getGroupBy) { RETURN_MEMBER(this_ptr, "_group"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql) { HashTable *_7, *_10, *_13, *_18, *_23, *_29; HashPosition _6, _9, _12, _17, _22, _28; zend_class_entry *_3; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL, *_32 = NULL; zend_bool noPrimary, _5; zval *dependencyInjector = NULL, *models, *conditions = NULL, *model = NULL, *metaData = NULL, *modelInstance, *primaryKeys = NULL, *firstPrimaryKey, *columnMap = NULL, *modelAlias = NULL, *attributeField = NULL, *phql = NULL, *column = NULL, *columns, *selectedColumns = NULL, *selectedColumn = NULL, *selectedModel = NULL, *selectedModels, *columnAlias = NULL, *modelColumnAlias = NULL, *joins, *join = NULL, *joinModel = NULL, *joinConditions = NULL, *joinAlias = NULL, *joinType = NULL, *group = NULL, *groupItems = NULL, *groupItem = NULL, *having, *order, *orderItems, *orderItem = NULL, *limit, *number = NULL, *offset = NULL, *forUpdate, *distinct, *_1 = NULL, *_2 = NULL, *_4 = NULL, **_8, **_11, **_14, *_15 = NULL, *_16 = NULL, **_19, *_20 = NULL, *_21 = NULL, **_24, *_25 = NULL, _26 = zval_used_for_init, _27, **_30, *_31 = NULL, *_33, *_34, *_35, *_36; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } ZEPHIR_OBS_VAR(models); zephir_read_property_this(&models, this_ptr, SL("_models"), PH_NOISY_CC); if (Z_TYPE_P(models) == IS_ARRAY) { if (!(zephir_fast_count_int(models TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/mvc/model/query/builder.zep", 1000); return; } } else { if (!(zephir_is_true(models))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/mvc/model/query/builder.zep", 1004); return; } } ZEPHIR_OBS_VAR(conditions); zephir_read_property_this(&conditions, this_ptr, SL("_conditions"), PH_NOISY_CC); if (zephir_is_numeric(conditions)) { if (Z_TYPE_P(models) == IS_ARRAY) { if (zephir_fast_count_int(models TSRMLS_CC) > 1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot build the query. Invalid condition", "phalcon/mvc/model/query/builder.zep", 1017); return; } ZEPHIR_OBS_VAR(model); zephir_array_fetch_long(&model, models, 0, PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1019 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(model, models); } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(modelInstance); zephir_fetch_safe_class(_2, model); _3 = zend_fetch_class(Z_STRVAL_P(_2), Z_STRLEN_P(_2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(modelInstance, _3); if (zephir_has_constructor(modelInstance TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, modelInstance, "__construct", NULL, 0, dependencyInjector); zephir_check_call_status(); } noPrimary = 1; ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, modelInstance); zephir_check_call_status(); if (zephir_fast_count_int(primaryKeys TSRMLS_CC)) { ZEPHIR_OBS_VAR(firstPrimaryKey); if (zephir_array_isset_long_fetch(&firstPrimaryKey, primaryKeys, 0, 0 TSRMLS_CC)) { if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, modelInstance); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_VAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, firstPrimaryKey, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", firstPrimaryKey, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/model/query/builder.zep", 1047 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, firstPrimaryKey); } ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVSVSV(_4, "[", model, "].[", attributeField, "] = ", conditions); ZEPHIR_CPY_WRT(conditions, _4); noPrimary = 0; } } if (noPrimary == 1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Source related to this model does not have a primary key defined", "phalcon/mvc/model/query/builder.zep", 1062); return; } } ZEPHIR_OBS_VAR(distinct); zephir_read_property_this(&distinct, this_ptr, SL("_distinct"), PH_NOISY_CC); _5 = Z_TYPE_P(distinct) != IS_NULL; if (_5) { _5 = Z_TYPE_P(distinct) == IS_BOOL; } if (_5) { ZEPHIR_INIT_VAR(phql); if (zephir_is_true(distinct)) { ZVAL_STRING(phql, "SELECT DISTINCT ", 1); } else { ZVAL_STRING(phql, "SELECT ALL ", 1); } } else { ZEPHIR_INIT_NVAR(phql); ZVAL_STRING(phql, "SELECT ", 1); } ZEPHIR_OBS_VAR(columns); zephir_read_property_this(&columns, this_ptr, SL("_columns"), PH_NOISY_CC); if (Z_TYPE_P(columns) != IS_NULL) { if (Z_TYPE_P(columns) == IS_ARRAY) { ZEPHIR_INIT_VAR(selectedColumns); array_init(selectedColumns); zephir_is_iterable(columns, &_7, &_6, 0, 0, "phalcon/mvc/model/query/builder.zep", 1098); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HMKEY(columnAlias, _7, _6); ZEPHIR_GET_HVALUE(column, _8); if (Z_TYPE_P(columnAlias) == IS_LONG) { zephir_array_append(&selectedColumns, column, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1088); } else { if (zephir_memnstr_str(columnAlias, SL("["), "phalcon/mvc/model/query/builder.zep", 1090)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VSV(_4, column, " AS ", columnAlias); zephir_array_append(&selectedColumns, _4, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1091); } else { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VSVS(_4, column, " AS [", columnAlias, "]"); zephir_array_append(&selectedColumns, _4, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1093); } } } ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), selectedColumns TSRMLS_CC); zephir_concat_self(&phql, _1 TSRMLS_CC); } else { zephir_concat_self(&phql, columns TSRMLS_CC); } } else { if (Z_TYPE_P(models) == IS_ARRAY) { ZEPHIR_INIT_NVAR(selectedColumns); array_init(selectedColumns); zephir_is_iterable(models, &_10, &_9, 0, 0, "phalcon/mvc/model/query/builder.zep", 1121); for ( ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS ; zephir_hash_move_forward_ex(_10, &_9) ) { ZEPHIR_GET_HMKEY(modelColumnAlias, _10, _9); ZEPHIR_GET_HVALUE(model, _11); ZEPHIR_INIT_NVAR(selectedColumn); if (Z_TYPE_P(modelColumnAlias) == IS_LONG) { ZEPHIR_CONCAT_SVS(selectedColumn, "[", model, "].*"); } else { ZEPHIR_CONCAT_SVS(selectedColumn, "[", modelColumnAlias, "].*"); } zephir_array_append(&selectedColumns, selectedColumn, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1118); } ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), selectedColumns TSRMLS_CC); zephir_concat_self(&phql, _1 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "[", models, "].*"); zephir_concat_self(&phql, _4 TSRMLS_CC); } } if (Z_TYPE_P(models) == IS_ARRAY) { ZEPHIR_INIT_VAR(selectedModels); array_init(selectedModels); zephir_is_iterable(models, &_13, &_12, 0, 0, "phalcon/mvc/model/query/builder.zep", 1152); for ( ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HMKEY(modelAlias, _13, _12); ZEPHIR_GET_HVALUE(model, _14); if (Z_TYPE_P(modelAlias) == IS_STRING) { ZEPHIR_INIT_NVAR(selectedModel); if (zephir_memnstr_str(model, SL("["), "phalcon/mvc/model/query/builder.zep", 1136)) { ZEPHIR_CONCAT_VSVS(selectedModel, model, " AS [", modelAlias, "]"); } else { ZEPHIR_CONCAT_SVSVS(selectedModel, "[", model, "] AS [", modelAlias, "]"); } } else { if (zephir_memnstr_str(model, SL("["), "phalcon/mvc/model/query/builder.zep", 1142)) { ZEPHIR_CPY_WRT(selectedModel, model); } else { ZEPHIR_INIT_NVAR(selectedModel); ZEPHIR_CONCAT_SVS(selectedModel, "[", model, "]"); } } zephir_array_append(&selectedModels, selectedModel, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1149); } ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), selectedModels TSRMLS_CC); ZEPHIR_INIT_VAR(_15); ZEPHIR_CONCAT_SV(_15, " FROM ", _1); zephir_concat_self(&phql, _15 TSRMLS_CC); } else { if (zephir_memnstr_str(models, SL("["), "phalcon/mvc/model/query/builder.zep", 1156)) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SVS(_15, " FROM ", models, ""); zephir_concat_self(&phql, _15 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_16); ZEPHIR_CONCAT_SVS(_16, " FROM [", models, "]"); zephir_concat_self(&phql, _16 TSRMLS_CC); } } ZEPHIR_OBS_VAR(joins); zephir_read_property_this(&joins, this_ptr, SL("_joins"), PH_NOISY_CC); if (Z_TYPE_P(joins) == IS_ARRAY) { zephir_is_iterable(joins, &_18, &_17, 0, 0, "phalcon/mvc/model/query/builder.zep", 1222); for ( ; zephir_hash_get_current_data_ex(_18, (void**) &_19, &_17) == SUCCESS ; zephir_hash_move_forward_ex(_18, &_17) ) { ZEPHIR_GET_HVALUE(join, _19); ZEPHIR_OBS_NVAR(joinModel); zephir_array_fetch_long(&joinModel, join, 0, PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1174 TSRMLS_CC); ZEPHIR_OBS_NVAR(joinConditions); zephir_array_fetch_long(&joinConditions, join, 1, PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1179 TSRMLS_CC); ZEPHIR_OBS_NVAR(joinAlias); zephir_array_fetch_long(&joinAlias, join, 2, PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1184 TSRMLS_CC); ZEPHIR_OBS_NVAR(joinType); zephir_array_fetch_long(&joinType, join, 3, PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1189 TSRMLS_CC); if (zephir_is_true(joinType)) { if (zephir_memnstr_str(joinModel, SL("["), "phalcon/mvc/model/query/builder.zep", 1195)) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SVSV(_15, " ", joinType, " JOIN ", joinModel); zephir_concat_self(&phql, _15 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_16); ZEPHIR_CONCAT_SVSVS(_16, " ", joinType, " JOIN [", joinModel, "]"); zephir_concat_self(&phql, _16 TSRMLS_CC); } } else { if (zephir_memnstr_str(joinModel, SL("["), "phalcon/mvc/model/query/builder.zep", 1201)) { ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_SVS(_20, " JOIN ", joinModel, ""); zephir_concat_self(&phql, _20 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_SVS(_20, " JOIN [", joinModel, "]"); zephir_concat_self(&phql, _20 TSRMLS_CC); } } if (zephir_is_true(joinAlias)) { ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_SVS(_20, " AS [", joinAlias, "]"); zephir_concat_self(&phql, _20 TSRMLS_CC); } if (zephir_is_true(joinConditions)) { ZEPHIR_INIT_LNVAR(_21); ZEPHIR_CONCAT_SV(_21, " ON ", joinConditions); zephir_concat_self(&phql, _21 TSRMLS_CC); } } } if (Z_TYPE_P(conditions) == IS_STRING) { if (!(ZEPHIR_IS_EMPTY(conditions))) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SV(_15, " WHERE ", conditions); zephir_concat_self(&phql, _15 TSRMLS_CC); } } ZEPHIR_OBS_VAR(group); zephir_read_property_this(&group, this_ptr, SL("_group"), PH_NOISY_CC); if (Z_TYPE_P(group) != IS_NULL) { if (Z_TYPE_P(group) == IS_ARRAY) { ZEPHIR_INIT_VAR(groupItems); array_init(groupItems); zephir_is_iterable(group, &_23, &_22, 0, 0, "phalcon/mvc/model/query/builder.zep", 1249); for ( ; zephir_hash_get_current_data_ex(_23, (void**) &_24, &_22) == SUCCESS ; zephir_hash_move_forward_ex(_23, &_22) ) { ZEPHIR_GET_HVALUE(groupItem, _24); if (zephir_is_numeric(groupItem)) { zephir_array_append(&groupItems, groupItem, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1240); } else { if (zephir_memnstr_str(groupItem, SL("."), "phalcon/mvc/model/query/builder.zep", 1242)) { zephir_array_append(&groupItems, groupItem, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1243); } else { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "[", groupItem, "]"); zephir_array_append(&groupItems, _4, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1245); } } } ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), groupItems TSRMLS_CC); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, " GROUP BY ", _1); zephir_concat_self(&phql, _4 TSRMLS_CC); } else { if (zephir_is_numeric(group)) { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SV(_15, " GROUP BY ", group); zephir_concat_self(&phql, _15 TSRMLS_CC); } else { if (zephir_memnstr_str(group, SL("."), "phalcon/mvc/model/query/builder.zep", 1254)) { ZEPHIR_INIT_LNVAR(_16); ZEPHIR_CONCAT_SV(_16, " GROUP BY ", group); zephir_concat_self(&phql, _16 TSRMLS_CC); } else { if (zephir_memnstr_str(group, SL(","), "phalcon/mvc/model/query/builder.zep", 1257)) { ZEPHIR_INIT_VAR(_25); ZEPHIR_SINIT_VAR(_26); ZVAL_STRING(&_26, " ", 0); ZEPHIR_SINIT_VAR(_27); ZVAL_STRING(&_27, "", 0); zephir_fast_str_replace(&_25, &_26, &_27, group TSRMLS_CC); ZEPHIR_CPY_WRT(group, _25); ZEPHIR_INIT_NVAR(groupItems); zephir_fast_explode_str(groupItems, SL(","), group, LONG_MAX TSRMLS_CC); ZEPHIR_INIT_NVAR(_25); zephir_fast_join_str(_25, SL("], ["), groupItems TSRMLS_CC); ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_SVS(_20, " GROUP BY [", _25, "]"); zephir_concat_self(&phql, _20 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, " GROUP BY [", group, "]"); zephir_concat_self(&phql, _4 TSRMLS_CC); } } } } } ZEPHIR_OBS_VAR(having); zephir_read_property_this(&having, this_ptr, SL("_having"), PH_NOISY_CC); if (Z_TYPE_P(having) != IS_NULL) { if (!(ZEPHIR_IS_EMPTY(having))) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, " HAVING ", having); zephir_concat_self(&phql, _4 TSRMLS_CC); } } ZEPHIR_OBS_VAR(order); zephir_read_property_this(&order, this_ptr, SL("_order"), PH_NOISY_CC); if (Z_TYPE_P(order) != IS_NULL) { if (Z_TYPE_P(order) == IS_ARRAY) { ZEPHIR_INIT_VAR(orderItems); array_init(orderItems); zephir_is_iterable(order, &_29, &_28, 0, 0, "phalcon/mvc/model/query/builder.zep", 1294); for ( ; zephir_hash_get_current_data_ex(_29, (void**) &_30, &_28) == SUCCESS ; zephir_hash_move_forward_ex(_29, &_28) ) { ZEPHIR_GET_HVALUE(orderItem, _30); if (zephir_is_numeric(orderItem)) { zephir_array_append(&orderItems, orderItem, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1285); } else { if (zephir_memnstr_str(orderItem, SL("."), "phalcon/mvc/model/query/builder.zep", 1287)) { zephir_array_append(&orderItems, orderItem, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1288); } else { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "[", orderItem, "]"); zephir_array_append(&orderItems, _4, PH_SEPARATE, "phalcon/mvc/model/query/builder.zep", 1290); } } } ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), orderItems TSRMLS_CC); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, " ORDER BY ", _1); zephir_concat_self(&phql, _4 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_15); ZEPHIR_CONCAT_SV(_15, " ORDER BY ", order); zephir_concat_self(&phql, _15 TSRMLS_CC); } } ZEPHIR_OBS_VAR(limit); zephir_read_property_this(&limit, this_ptr, SL("_limit"), PH_NOISY_CC); if (Z_TYPE_P(limit) != IS_NULL) { ZEPHIR_INIT_VAR(number); ZVAL_NULL(number); if (Z_TYPE_P(limit) == IS_ARRAY) { ZEPHIR_OBS_NVAR(number); zephir_array_fetch_string(&number, limit, SL("number"), PH_NOISY, "phalcon/mvc/model/query/builder.zep", 1309 TSRMLS_CC); ZEPHIR_OBS_VAR(offset); if (zephir_array_isset_string_fetch(&offset, limit, SS("offset"), 0 TSRMLS_CC)) { if (!(zephir_is_numeric(offset))) { ZEPHIR_INIT_NVAR(offset); ZVAL_LONG(offset, 0); } } } else { if (zephir_is_numeric(limit)) { ZEPHIR_CPY_WRT(number, limit); ZEPHIR_OBS_NVAR(offset); zephir_read_property_this(&offset, this_ptr, SL("_offset"), PH_NOISY_CC); if (Z_TYPE_P(offset) != IS_NULL) { if (!(zephir_is_numeric(offset))) { ZEPHIR_INIT_NVAR(offset); ZVAL_LONG(offset, 0); } } } } if (zephir_is_numeric(number)) { zephir_concat_self_str(&phql, SL(" LIMIT :APL0:") TSRMLS_CC); ZEPHIR_SINIT_NVAR(_26); ZVAL_LONG(&_26, 10); ZEPHIR_CALL_FUNCTION(&_31, "intval", &_32, 26, number, &_26); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "APL0", 1); zephir_update_property_array(this_ptr, SL("_bindParams"), _1, _31 TSRMLS_CC); ZEPHIR_INIT_NVAR(_25); ZVAL_STRING(_25, "APL0", 1); ZEPHIR_INIT_VAR(_33); ZVAL_LONG(_33, 1); zephir_update_property_array(this_ptr, SL("_bindTypes"), _25, _33 TSRMLS_CC); if (zephir_is_numeric(offset)) { zephir_concat_self_str(&phql, SL(" OFFSET :APL1:") TSRMLS_CC); ZEPHIR_SINIT_NVAR(_26); ZVAL_LONG(&_26, 10); ZEPHIR_CALL_FUNCTION(&_31, "intval", &_32, 26, offset, &_26); zephir_check_call_status(); ZEPHIR_INIT_VAR(_34); ZVAL_STRING(_34, "APL1", 1); zephir_update_property_array(this_ptr, SL("_bindParams"), _34, _31 TSRMLS_CC); ZEPHIR_INIT_VAR(_35); ZVAL_STRING(_35, "APL1", 1); ZEPHIR_INIT_VAR(_36); ZVAL_LONG(_36, 1); zephir_update_property_array(this_ptr, SL("_bindTypes"), _35, _36 TSRMLS_CC); } } } forUpdate = zephir_fetch_nproperty_this(this_ptr, SL("_forUpdate"), PH_NOISY_CC); if (Z_TYPE_P(forUpdate) == IS_BOOL) { if (zephir_is_true(forUpdate)) { zephir_concat_self_str(&phql, SL(" FOR UPDATE") TSRMLS_CC); } } RETURN_CCTOR(phql); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getQuery) { int ZEPHIR_LAST_CALL_STATUS; zval *query, *bindParams, *bindTypes, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(query); object_init_ex(query, phalcon_mvc_model_query_ce); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getphql", NULL, 348); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, query, "__construct", NULL, 339, _0, _1); zephir_check_call_status(); ZEPHIR_OBS_VAR(bindParams); zephir_read_property_this(&bindParams, this_ptr, SL("_bindParams"), PH_NOISY_CC); if (Z_TYPE_P(bindParams) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, query, "setbindparams", NULL, 349, bindParams); zephir_check_call_status(); } ZEPHIR_OBS_VAR(bindTypes); zephir_read_property_this(&bindTypes, this_ptr, SL("_bindTypes"), PH_NOISY_CC); if (Z_TYPE_P(bindTypes) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, query, "setbindtypes", NULL, 350, bindTypes); zephir_check_call_status(); } RETURN_CCTOR(query); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_BuilderInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, BuilderInterface, phalcon, mvc_model_query_builderinterface, phalcon_mvc_model_query_builderinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, columns); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getColumns); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, from); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, addFrom); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getFrom); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, join); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, innerJoin); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, leftJoin); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, rightJoin); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, where); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, andWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, betweenWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notBetweenWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, inWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notInWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getWhere); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orderBy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOrderBy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, having); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getHaving); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, limit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getLimit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, groupBy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getGroupBy); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getPhql); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getQuery); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Lang) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Lang, phalcon, mvc_model_query_lang, phalcon_mvc_model_query_lang_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Query_Lang, parsePHQL) { int ZEPHIR_LAST_CALL_STATUS; zval *phql_param = NULL; zval *phql = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &phql_param); if (unlikely(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(phql_param) == IS_STRING)) { zephir_get_strval(phql, phql_param); } else { ZEPHIR_INIT_VAR(phql); ZVAL_EMPTY_STRING(phql); } ZEPHIR_LAST_CALL_STATUS = phql_parse_phql(return_value, phql TSRMLS_CC); zephir_check_call_status(); RETURN_MM(); } /* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> // 39 "parser.lemon" #ifdef HAVE_CONFIG_H #endif static zval *phql_ret_literal_zval(int type, phql_parser_token *T) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_long(ret, "type", type); if (T) { add_assoc_stringl(ret, "value", T->token, T->token_len, 0); efree(T); } return ret; } static zval *phql_ret_placeholder_zval(int type, phql_parser_token *T) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_long(ret, "type", type); add_assoc_stringl(ret, "value", T->token, T->token_len, 0); efree(T); return ret; } static zval *phql_ret_qualified_name(phql_parser_token *A, phql_parser_token *B, phql_parser_token *C) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 4); add_assoc_long(ret, "type", PHQL_T_QUALIFIED); if (A != NULL) { add_assoc_stringl(ret, "ns-alias", A->token, A->token_len, 0); efree(A); } if (B != NULL) { add_assoc_stringl(ret, "domain", B->token, B->token_len, 0); efree(B); } add_assoc_stringl(ret, "name", C->token, C->token_len, 0); efree(C); return ret; } static zval *phql_ret_raw_qualified_name(phql_parser_token *A, phql_parser_token *B) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHQL_T_RAW_QUALIFIED); if (B != NULL) { add_assoc_stringl(ret, "domain", A->token, A->token_len, 0); add_assoc_stringl(ret, "name", B->token, B->token_len, 0); efree(B); } else { add_assoc_stringl(ret, "name", A->token, A->token_len, 0); } efree(A); return ret; } static zval *phql_ret_select_statement(zval *S, zval *W, zval *O, zval *G, zval *H, zval *L, zval *F) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHQL_T_SELECT); add_assoc_zval(ret, "select", S); if (W != NULL) { add_assoc_zval(ret, "where", W); } if (O != NULL) { add_assoc_zval(ret, "orderBy", O); } if (G != NULL) { add_assoc_zval(ret, "groupBy", G); } if (H != NULL) { add_assoc_zval(ret, "having", H); } if (L != NULL) { add_assoc_zval(ret, "limit", L); } if (F != NULL) { add_assoc_zval(ret, "forUpdate", F); } return ret; } static zval *phql_ret_select_clause(zval *distinct, zval *columns, zval *tables, zval *join_list) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); if (distinct) { add_assoc_zval(ret, "distinct", distinct); } add_assoc_zval(ret, "columns", columns); add_assoc_zval(ret, "tables", tables); if (join_list) { add_assoc_zval(ret, "joins", join_list); } return ret; } static zval *phql_ret_distinct_all(int distinct) { zval *ret; MAKE_STD_ZVAL(ret); ZVAL_LONG(ret, distinct); return ret; } static zval *phql_ret_distinct(void) { zval *ret; MAKE_STD_ZVAL(ret); ZVAL_TRUE(ret); return ret; } static zval *phql_ret_order_item(zval *column, int sort){ zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_zval(ret, "column", column); if (sort != 0 ) { add_assoc_long(ret, "sort", sort); } return ret; } static zval *phql_ret_limit_clause(zval *L, zval *O) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_zval(ret, "number", L); if (O != NULL) { add_assoc_zval(ret, "offset", O); } return ret; } static zval *phql_ret_for_update_clause() { zval *ret; MAKE_STD_ZVAL(ret); ZVAL_BOOL(ret, 1); return ret; } static zval *phql_ret_insert_statement(zval *Q, zval *F, zval *V) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHQL_T_INSERT); add_assoc_zval(ret, "qualifiedName", Q); if (F != NULL) { add_assoc_zval(ret, "fields", F); } add_assoc_zval(ret, "values", V); return ret; } static zval *phql_ret_update_statement(zval *U, zval *W, zval *L) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHQL_T_UPDATE); add_assoc_zval(ret, "update", U); if (W != NULL) { add_assoc_zval(ret, "where", W); } if (L != NULL) { add_assoc_zval(ret, "limit", L); } return ret; } static zval *phql_ret_update_clause(zval *tables, zval *values) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_zval(ret, "tables", tables); add_assoc_zval(ret, "values", values); return ret; } static zval *phql_ret_update_item(zval *column, zval *expr) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 2); add_assoc_zval(ret, "column", column); add_assoc_zval(ret, "expr", expr); return ret; } static zval *phql_ret_delete_statement(zval *D, zval *W, zval *L) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHQL_T_DELETE); add_assoc_zval(ret, "delete", D); if (W != NULL) { add_assoc_zval(ret, "where", W); } if (L != NULL) { add_assoc_zval(ret, "limit", L); } return ret; } static zval *phql_ret_delete_clause(zval *tables) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 1); add_assoc_zval(ret, "tables", tables); return ret; } static zval *phql_ret_zval_list(zval *list_left, zval *right_list) { zval *ret; HashPosition pos; HashTable *list; MAKE_STD_ZVAL(ret); array_init(ret); list = Z_ARRVAL_P(list_left); if (zend_hash_index_exists(list, 0)) { zend_hash_internal_pointer_reset_ex(list, &pos); for (;; zend_hash_move_forward_ex(list, &pos)) { zval ** item; if (zend_hash_get_current_data_ex(list, (void**)&item, &pos) == FAILURE) { break; } Z_ADDREF_PP(item); add_next_index_zval(ret, *item); } zval_ptr_dtor(&list_left); } else { add_next_index_zval(ret, list_left); } if (right_list) { add_next_index_zval(ret, right_list); } return ret; } static zval *phql_ret_column_item(int type, zval *column, phql_parser_token *identifier_column, phql_parser_token *alias) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", type); if (column) { add_assoc_zval(ret, "column", column); } if (identifier_column) { add_assoc_stringl(ret, "column", identifier_column->token, identifier_column->token_len, 0); efree(identifier_column); } if (alias) { add_assoc_stringl(ret, "alias", alias->token, alias->token_len, 0); efree(alias); } return ret; } static zval *phql_ret_assoc_name(zval *qualified_name, phql_parser_token *alias, zval *with) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_zval(ret, "qualifiedName", qualified_name); if (alias) { add_assoc_stringl(ret, "alias", alias->token, alias->token_len, 0); efree(alias); } if (with) { add_assoc_zval(ret, "with", with); } return ret; } static zval *phql_ret_join_type(int type) { zval *ret; MAKE_STD_ZVAL(ret); ZVAL_LONG(ret, type); return ret; } static zval *phql_ret_join_item(zval *type, zval *qualified, zval *alias, zval *conditions) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_zval(ret, "type", type); if (qualified) { add_assoc_zval(ret, "qualified", qualified); } if (alias) { add_assoc_zval(ret, "alias", alias); } if (conditions) { add_assoc_zval(ret, "conditions", conditions); } return ret; } static zval *phql_ret_expr(int type, zval *left, zval *right) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", type); if (left) { add_assoc_zval(ret, "left", left); } if (right) { add_assoc_zval(ret, "right", right); } return ret; } static zval *phql_ret_func_call(phql_parser_token *name, zval *arguments, zval *distinct) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHQL_T_FCALL); add_assoc_stringl(ret, "name", name->token, name->token_len, 0); efree(name); if (arguments) { add_assoc_zval(ret, "arguments", arguments); } if (distinct) { add_assoc_zval(ret, "distinct", distinct); } return ret; } // 460 "parser.c" /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ /* Make sure the INTERFACE macro is defined. */ #ifndef INTERFACE # define INTERFACE 1 #endif /* The next thing included is series of defines which control ** various aspects of the generated parser. ** PPCODETYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 terminals ** and nonterminals. "int" is used otherwise. ** PPNOCODE is a number of type PPCODETYPE which corresponds ** to no legal terminal or nonterminal number. This ** number is used to fill in empty slots of the hash ** table. ** PPFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the ** original value of the token will not parse. ** PPACTIONTYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. ** phql_TOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** PPMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of ** which is phql_TOKENTYPE. The entry in the union ** for base tokens is called "pp0". ** PPSTACKDEPTH is the maximum depth of the parser's stack. ** phql_ARG_SDECL A static variable declaration for the %extra_argument ** phql_ARG_PDECL A parameter declaration for the %extra_argument ** phql_ARG_STORE Code to store %extra_argument into pppParser ** phql_ARG_FETCH Code to extract %extra_argument from pppParser ** PPNSTATE the combined number of states. ** PPNRULE the number of rules in the grammar ** PPERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define PPCODETYPE unsigned char #define PPNOCODE 134 #define PPACTIONTYPE unsigned short int #define phql_TOKENTYPE phql_parser_token* typedef union { phql_TOKENTYPE pp0; zval* pp162; int pp267; } PPMINORTYPE; #define PPSTACKDEPTH 100 #define phql_ARG_SDECL phql_parser_status *status; #define phql_ARG_PDECL ,phql_parser_status *status #define phql_ARG_FETCH phql_parser_status *status = pppParser->status #define phql_ARG_STORE pppParser->status = status #define PPNSTATE 293 #define PPNRULE 161 #define PPERRORSYMBOL 79 #define PPERRSYMDT pp267 #define PP_NO_ACTION (PPNSTATE+PPNRULE+2) #define PP_ACCEPT_ACTION (PPNSTATE+PPNRULE+1) #define PP_ERROR_ACTION (PPNSTATE+PPNRULE) /* Next are that tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N < PPNSTATE Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** PPNSTATE <= N < PPNSTATE+PPNRULE Reduce by rule N-PPNSTATE. ** ** N == PPNSTATE+PPNRULE A syntax error has occurred. ** ** N == PPNSTATE+PPNRULE+1 The parser accepts its input. ** ** N == PPNSTATE+PPNRULE+2 No such action. Denotes unused ** slots in the pp_action[] table. ** ** The action table is constructed as a single large table named pp_action[]. ** Given state S and lookahead X, the action is computed as ** ** pp_action[ pp_shift_ofst[S] + X ] ** ** If the index value pp_shift_ofst[S]+X is out of range or if the value ** pp_lookahead[pp_shift_ofst[S]+X] is not equal to X or if pp_shift_ofst[S] ** is equal to PP_SHIFT_USE_DFLT, it means that the action is not in the table ** and that pp_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the pp_reduce_ofst[] array is used in place of ** the pp_shift_ofst[] array and PP_REDUCE_USE_DFLT is used in place of ** PP_SHIFT_USE_DFLT. ** ** The following are the tables generated in this section: ** ** pp_action[] A single table containing all actions. ** pp_lookahead[] A table containing the lookahead for each entry in ** pp_action. Used to detect hash collisions. ** pp_shift_ofst[] For each state, the offset into pp_action for ** shifting terminals. ** pp_reduce_ofst[] For each state, the offset into pp_action for ** shifting non-terminals after a reduce. ** pp_default[] Default action for each state. */ static PPACTIONTYPE pp_action[] = { /* 0 */ 120, 126, 55, 57, 59, 61, 63, 65, 45, 47, /* 10 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, /* 20 */ 122, 74, 69, 120, 126, 55, 57, 59, 61, 63, /* 30 */ 65, 45, 47, 67, 72, 49, 51, 53, 41, 39, /* 40 */ 43, 37, 34, 122, 74, 69, 37, 34, 122, 74, /* 50 */ 69, 166, 220, 92, 218, 45, 47, 67, 72, 49, /* 60 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, /* 70 */ 154, 429, 186, 91, 120, 126, 55, 57, 59, 61, /* 80 */ 63, 65, 45, 47, 67, 72, 49, 51, 53, 41, /* 90 */ 39, 43, 37, 34, 122, 74, 69, 120, 126, 55, /* 100 */ 57, 59, 61, 63, 65, 45, 47, 67, 72, 49, /* 110 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, /* 120 */ 19, 20, 21, 22, 23, 227, 32, 33, 67, 72, /* 130 */ 49, 51, 53, 41, 39, 43, 37, 34, 122, 74, /* 140 */ 69, 130, 238, 120, 126, 55, 57, 59, 61, 63, /* 150 */ 65, 45, 47, 67, 72, 49, 51, 53, 41, 39, /* 160 */ 43, 37, 34, 122, 74, 69, 41, 39, 43, 37, /* 170 */ 34, 122, 74, 69, 140, 8, 120, 126, 55, 57, /* 180 */ 59, 61, 63, 65, 45, 47, 67, 72, 49, 51, /* 190 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 120, /* 200 */ 126, 55, 57, 59, 61, 63, 65, 45, 47, 67, /* 210 */ 72, 49, 51, 53, 41, 39, 43, 37, 34, 122, /* 220 */ 74, 69, 120, 126, 55, 57, 59, 61, 63, 65, /* 230 */ 45, 47, 67, 72, 49, 51, 53, 41, 39, 43, /* 240 */ 37, 34, 122, 74, 69, 168, 109, 156, 35, 95, /* 250 */ 99, 169, 171, 26, 76, 151, 188, 81, 159, 160, /* 260 */ 82, 111, 209, 113, 114, 17, 146, 285, 192, 208, /* 270 */ 194, 196, 128, 200, 204, 222, 223, 455, 1, 2, /* 280 */ 3, 4, 5, 6, 199, 173, 284, 197, 174, 175, /* 290 */ 181, 182, 183, 133, 137, 143, 76, 149, 158, 24, /* 300 */ 212, 217, 178, 176, 177, 179, 180, 168, 135, 271, /* 310 */ 35, 249, 6, 169, 171, 287, 276, 110, 290, 173, /* 320 */ 159, 49, 51, 53, 41, 39, 43, 37, 34, 122, /* 330 */ 74, 69, 158, 384, 128, 430, 192, 208, 194, 196, /* 340 */ 80, 200, 204, 292, 210, 122, 74, 69, 84, 84, /* 350 */ 174, 175, 181, 182, 183, 133, 137, 143, 125, 149, /* 360 */ 107, 107, 95, 90, 178, 176, 177, 179, 180, 55, /* 370 */ 57, 59, 61, 63, 65, 45, 47, 67, 72, 49, /* 380 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, /* 390 */ 213, 274, 258, 35, 70, 228, 169, 171, 131, 109, /* 400 */ 245, 265, 6, 214, 259, 230, 279, 286, 282, 234, /* 410 */ 173, 83, 203, 6, 129, 201, 84, 128, 173, 152, /* 420 */ 154, 207, 186, 158, 205, 162, 244, 96, 107, 85, /* 430 */ 219, 158, 173, 174, 175, 181, 182, 183, 133, 137, /* 440 */ 143, 94, 149, 173, 7, 158, 102, 178, 176, 177, /* 450 */ 179, 180, 162, 232, 35, 89, 158, 169, 171, 184, /* 460 */ 76, 112, 113, 114, 159, 211, 215, 79, 94, 78, /* 470 */ 173, 226, 221, 217, 94, 6, 277, 240, 128, 160, /* 480 */ 165, 84, 98, 158, 250, 163, 184, 162, 103, 95, /* 490 */ 104, 173, 94, 107, 174, 175, 181, 182, 183, 133, /* 500 */ 137, 143, 92, 149, 158, 173, 108, 155, 178, 176, /* 510 */ 177, 179, 180, 168, 92, 224, 35, 258, 158, 169, /* 520 */ 171, 184, 100, 27, 258, 173, 159, 166, 216, 257, /* 530 */ 191, 115, 189, 254, 105, 173, 259, 124, 158, 69, /* 540 */ 128, 110, 173, 107, 166, 281, 282, 225, 158, 252, /* 550 */ 260, 31, 253, 10, 251, 158, 174, 175, 181, 182, /* 560 */ 183, 133, 137, 143, 233, 149, 107, 106, 42, 173, /* 570 */ 178, 176, 177, 179, 180, 30, 247, 35, 329, 245, /* 580 */ 169, 171, 158, 147, 31, 229, 173, 159, 123, 328, /* 590 */ 261, 332, 256, 270, 101, 327, 162, 173, 326, 158, /* 600 */ 325, 128, 173, 173, 242, 246, 206, 28, 237, 18, /* 610 */ 158, 50, 255, 202, 173, 158, 158, 174, 175, 181, /* 620 */ 182, 183, 133, 137, 143, 121, 149, 158, 239, 173, /* 630 */ 167, 178, 176, 177, 179, 180, 97, 269, 164, 119, /* 640 */ 148, 263, 158, 173, 324, 264, 173, 71, 15, 132, /* 650 */ 150, 267, 323, 161, 145, 256, 158, 173, 73, 158, /* 660 */ 134, 170, 172, 198, 62, 173, 322, 333, 173, 60, /* 670 */ 158, 262, 173, 66, 93, 266, 173, 195, 158, 173, /* 680 */ 173, 158, 173, 187, 139, 158, 136, 173, 268, 158, /* 690 */ 11, 173, 158, 158, 76, 158, 295, 185, 58, 340, /* 700 */ 158, 173, 173, 56, 158, 272, 236, 36, 321, 54, /* 710 */ 38, 383, 293, 157, 158, 158, 173, 127, 40, 273, /* 720 */ 193, 173, 275, 278, 173, 173, 280, 173, 173, 158, /* 730 */ 190, 173, 68, 52, 158, 173, 173, 158, 158, 138, /* 740 */ 158, 158, 48, 283, 158, 13, 25, 88, 158, 158, /* 750 */ 173, 173, 16, 248, 87, 86, 44, 46, 64, 297, /* 760 */ 173, 294, 141, 158, 158, 296, 142, 288, 153, 289, /* 770 */ 346, 173, 291, 158, 173, 173, 173, 12, 29, 75, /* 780 */ 77, 144, 9, 235, 158, 117, 241, 158, 158, 158, /* 790 */ 118, 231, 243, 296, 116, 14, }; static PPCODETYPE pp_lookahead[] = { /* 0 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, /* 10 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, /* 20 */ 21, 22, 23, 1, 2, 3, 4, 5, 6, 7, /* 30 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, /* 40 */ 18, 19, 20, 21, 22, 23, 19, 20, 21, 22, /* 50 */ 23, 25, 30, 25, 32, 9, 10, 11, 12, 13, /* 60 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /* 70 */ 71, 45, 73, 45, 1, 2, 3, 4, 5, 6, /* 80 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, /* 90 */ 17, 18, 19, 20, 21, 22, 23, 1, 2, 3, /* 100 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, /* 110 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /* 120 */ 60, 61, 62, 63, 64, 45, 53, 54, 11, 12, /* 130 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 140 */ 23, 45, 56, 1, 2, 3, 4, 5, 6, 7, /* 150 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, /* 160 */ 18, 19, 20, 21, 22, 23, 16, 17, 18, 19, /* 170 */ 20, 21, 22, 23, 32, 88, 1, 2, 3, 4, /* 180 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 190 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 1, /* 200 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, /* 210 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 220 */ 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, /* 230 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 240 */ 19, 20, 21, 22, 23, 17, 31, 72, 20, 119, /* 250 */ 120, 23, 24, 51, 26, 127, 128, 96, 30, 44, /* 260 */ 25, 100, 101, 102, 103, 25, 68, 98, 33, 34, /* 270 */ 35, 36, 44, 38, 39, 28, 29, 80, 81, 82, /* 280 */ 83, 84, 85, 86, 34, 116, 117, 37, 60, 61, /* 290 */ 62, 63, 64, 65, 66, 67, 26, 69, 129, 59, /* 300 */ 97, 98, 74, 75, 76, 77, 78, 17, 82, 112, /* 310 */ 20, 41, 86, 23, 24, 118, 46, 30, 48, 116, /* 320 */ 30, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 330 */ 22, 23, 129, 0, 44, 45, 33, 34, 35, 36, /* 340 */ 95, 38, 39, 99, 99, 21, 22, 23, 104, 104, /* 350 */ 60, 61, 62, 63, 64, 65, 66, 67, 74, 69, /* 360 */ 116, 116, 119, 120, 74, 75, 76, 77, 78, 3, /* 370 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, /* 380 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /* 390 */ 17, 58, 98, 20, 11, 12, 23, 24, 82, 31, /* 400 */ 98, 107, 86, 30, 110, 22, 114, 115, 116, 82, /* 410 */ 116, 99, 34, 86, 98, 37, 104, 44, 116, 70, /* 420 */ 71, 34, 73, 129, 37, 98, 124, 30, 116, 32, /* 430 */ 30, 129, 116, 60, 61, 62, 63, 64, 65, 66, /* 440 */ 67, 30, 69, 116, 87, 129, 49, 74, 75, 76, /* 450 */ 77, 78, 98, 126, 20, 44, 129, 23, 24, 132, /* 460 */ 26, 101, 102, 103, 30, 25, 31, 27, 30, 94, /* 470 */ 116, 82, 97, 98, 30, 86, 99, 55, 44, 44, /* 480 */ 126, 104, 44, 129, 42, 131, 132, 98, 44, 119, /* 490 */ 120, 116, 30, 116, 60, 61, 62, 63, 64, 65, /* 500 */ 66, 67, 25, 69, 129, 116, 30, 98, 74, 75, /* 510 */ 76, 77, 78, 17, 25, 126, 20, 98, 129, 23, /* 520 */ 24, 132, 45, 52, 98, 116, 30, 25, 17, 110, /* 530 */ 30, 104, 32, 107, 45, 116, 110, 23, 129, 23, /* 540 */ 44, 30, 116, 116, 25, 115, 116, 45, 129, 43, /* 550 */ 44, 98, 44, 90, 104, 129, 60, 61, 62, 63, /* 560 */ 64, 65, 66, 67, 45, 69, 116, 119, 98, 116, /* 570 */ 74, 75, 76, 77, 78, 122, 50, 20, 30, 98, /* 580 */ 23, 24, 129, 30, 98, 98, 116, 30, 74, 30, /* 590 */ 108, 0, 25, 111, 119, 30, 98, 116, 30, 129, /* 600 */ 30, 44, 116, 116, 123, 124, 34, 121, 122, 125, /* 610 */ 129, 98, 45, 34, 116, 129, 129, 60, 61, 62, /* 620 */ 63, 64, 65, 66, 67, 98, 69, 129, 98, 116, /* 630 */ 132, 74, 75, 76, 77, 78, 49, 30, 45, 98, /* 640 */ 45, 43, 129, 116, 30, 44, 116, 98, 58, 45, /* 650 */ 98, 25, 30, 130, 98, 25, 129, 116, 98, 129, /* 660 */ 44, 98, 98, 34, 98, 116, 30, 0, 116, 98, /* 670 */ 129, 45, 116, 98, 119, 45, 116, 34, 129, 116, /* 680 */ 116, 129, 116, 98, 98, 129, 45, 116, 111, 129, /* 690 */ 91, 116, 129, 129, 26, 129, 0, 28, 98, 0, /* 700 */ 129, 116, 116, 98, 129, 87, 98, 98, 30, 98, /* 710 */ 98, 0, 0, 98, 129, 129, 116, 98, 98, 113, /* 720 */ 34, 116, 125, 47, 116, 116, 25, 116, 116, 129, /* 730 */ 30, 116, 98, 98, 129, 116, 116, 129, 129, 44, /* 740 */ 129, 129, 98, 3, 129, 57, 125, 119, 129, 129, /* 750 */ 116, 116, 125, 98, 49, 30, 98, 98, 98, 0, /* 760 */ 116, 0, 30, 129, 129, 0, 45, 87, 128, 113, /* 770 */ 0, 116, 27, 129, 116, 116, 116, 92, 25, 44, /* 780 */ 93, 44, 89, 45, 129, 106, 52, 129, 129, 129, /* 790 */ 40, 44, 25, 133, 105, 46, }; #define PP_SHIFT_USE_DFLT (-2) static short pp_shift_ofst[] = { /* 0 */ 270, 712, 761, 696, 765, 759, 526, 422, 86, 202, /* 10 */ 590, 688, -2, 749, -2, 60, 240, 60, -2, -2, /* 20 */ -2, -2, -2, -2, 60, -2, 471, 557, 753, 557, /* 30 */ -2, 73, -2, -2, 557, 557, 324, 557, 324, 557, /* 40 */ 27, 557, 27, 557, 27, 557, 117, 557, 117, 557, /* 50 */ 150, 557, 150, 557, 150, 557, 46, 557, 46, 557, /* 60 */ 46, 557, 46, 557, 46, 557, 46, 557, 308, 383, /* 70 */ 557, 516, 557, 308, 735, 228, 247, 373, 440, 476, /* 80 */ 235, -2, 476, -2, 397, 725, 705, 411, -2, 462, /* 90 */ 28, -2, 462, -2, -2, -2, 587, 438, 462, 477, /* 100 */ -2, -2, 444, 462, 489, -2, -2, -2, 368, 287, /* 110 */ -2, 303, -2, -2, 476, 500, 750, -2, 557, 221, /* 120 */ 557, 221, 514, -2, 284, -2, 557, 366, 434, 96, /* 130 */ -2, 604, -2, 616, 668, 641, -2, 695, 557, 142, /* 140 */ 732, 721, -2, 737, 557, 198, 553, 595, -2, 557, /* 150 */ -1, 349, -2, -2, 557, 175, 557, 221, -2, 215, /* 160 */ 669, 290, 221, 593, -2, 26, 496, -2, -2, 557, /* 170 */ 516, 557, 516, -2, -2, -2, -2, -2, -2, -2, /* 180 */ -2, -2, -2, -2, -2, -2, 557, 221, -2, 700, /* 190 */ -2, -2, 686, 678, 643, 636, 250, 629, 622, 614, /* 200 */ 378, 579, 570, 568, 387, 572, 565, 559, 548, -2, /* 210 */ -2, 373, -2, -2, 435, 511, -2, 22, 400, -2, /* 220 */ -2, -2, -2, -2, 502, -2, 80, -2, 557, 516, /* 230 */ 747, 228, 519, -2, 738, -2, 324, -2, 557, 221, /* 240 */ 734, 557, 767, 557, -2, 221, -2, 557, 221, 442, /* 250 */ 476, 506, 508, 557, 567, 591, 557, -2, 221, -2, /* 260 */ 607, 626, 598, 601, 557, 630, 667, 607, -2, -2, /* 270 */ -2, 526, 333, 699, 60, 711, 476, 676, 476, 701, /* 280 */ 476, -2, 740, 557, -2, 221, -2, 526, 333, 770, /* 290 */ 745, 476, -2, }; #define PP_REDUCE_USE_DFLT (-1) static short pp_reduce_ofst[] = { /* 0 */ 197, -1, -1, -1, -1, -1, 357, 87, 693, 463, /* 10 */ 599, 685, -1, -1, -1, 627, -1, 484, -1, -1, /* 20 */ -1, -1, -1, -1, 621, -1, -1, 486, -1, 453, /* 30 */ -1, -1, -1, -1, 608, 609, -1, 612, -1, 620, /* 40 */ -1, 470, -1, 658, -1, 659, -1, 644, -1, 513, /* 50 */ -1, 635, -1, 611, -1, 605, -1, 600, -1, 571, /* 60 */ -1, 566, -1, 660, -1, 575, -1, 634, -1, -1, /* 70 */ 549, -1, 560, -1, -1, 389, 687, 375, -1, 245, /* 80 */ 161, -1, 312, -1, -1, -1, -1, 628, -1, 243, /* 90 */ -1, -1, 555, -1, -1, -1, -1, 475, 130, -1, /* 100 */ -1, -1, 448, 370, -1, -1, -1, -1, -1, -1, /* 110 */ -1, 360, -1, -1, 427, 689, 679, -1, 541, -1, /* 120 */ 527, -1, -1, -1, -1, -1, 619, -1, 316, -1, /* 130 */ -1, -1, -1, -1, 226, -1, -1, -1, 586, -1, /* 140 */ -1, -1, -1, -1, 556, -1, -1, -1, -1, 552, /* 150 */ 128, 640, -1, -1, 409, -1, 615, -1, -1, -1, /* 160 */ 523, 354, -1, -1, -1, -1, 498, -1, -1, 563, /* 170 */ -1, 564, -1, -1, -1, -1, -1, -1, -1, -1, /* 180 */ -1, -1, -1, -1, -1, -1, 585, -1, -1, -1, /* 190 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 200 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 210 */ -1, 203, -1, -1, -1, -1, -1, -1, -1, -1, /* 220 */ -1, -1, -1, -1, -1, -1, -1, -1, 487, -1, /* 230 */ -1, 327, -1, -1, -1, -1, -1, -1, 530, -1, /* 240 */ -1, 481, -1, 302, -1, -1, -1, 655, -1, -1, /* 250 */ 450, -1, -1, 426, -1, -1, 419, -1, -1, -1, /* 260 */ 482, -1, -1, -1, 294, -1, -1, 577, -1, -1, /* 270 */ -1, 618, 606, -1, 597, -1, 377, -1, 292, -1, /* 280 */ 430, -1, -1, 169, -1, -1, -1, 680, 656, -1, /* 290 */ -1, 244, -1, }; static PPACTIONTYPE pp_default[] = { /* 0 */ 454, 454, 454, 454, 454, 454, 362, 371, 376, 364, /* 10 */ 382, 378, 298, 454, 377, 454, 379, 454, 380, 385, /* 20 */ 386, 387, 388, 389, 454, 381, 454, 454, 363, 454, /* 30 */ 365, 367, 368, 369, 454, 454, 390, 454, 392, 454, /* 40 */ 393, 454, 394, 454, 395, 454, 396, 454, 397, 454, /* 50 */ 398, 454, 399, 454, 400, 454, 401, 454, 402, 454, /* 60 */ 403, 454, 404, 454, 405, 454, 406, 454, 407, 454, /* 70 */ 454, 408, 454, 409, 454, 454, 302, 454, 454, 454, /* 80 */ 313, 299, 454, 310, 350, 454, 348, 454, 351, 454, /* 90 */ 454, 352, 454, 357, 359, 358, 349, 454, 454, 454, /* 100 */ 353, 354, 454, 454, 454, 355, 356, 360, 453, 454, /* 110 */ 452, 312, 314, 316, 454, 320, 331, 317, 454, 330, /* 120 */ 454, 417, 454, 435, 454, 436, 454, 437, 454, 454, /* 130 */ 440, 454, 413, 454, 454, 454, 416, 454, 454, 454, /* 140 */ 454, 454, 418, 454, 454, 454, 454, 454, 419, 454, /* 150 */ 454, 454, 420, 421, 454, 454, 454, 423, 425, 453, /* 160 */ 428, 454, 434, 454, 426, 454, 454, 431, 433, 454, /* 170 */ 438, 454, 439, 441, 442, 443, 444, 445, 446, 447, /* 180 */ 448, 449, 450, 451, 432, 427, 454, 424, 422, 454, /* 190 */ 318, 319, 454, 454, 454, 454, 454, 454, 454, 454, /* 200 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 315, /* 210 */ 311, 454, 303, 305, 453, 454, 306, 309, 454, 307, /* 220 */ 308, 304, 300, 301, 454, 411, 454, 414, 454, 410, /* 230 */ 454, 454, 454, 412, 454, 415, 391, 366, 454, 375, /* 240 */ 454, 454, 370, 454, 372, 374, 373, 454, 361, 454, /* 250 */ 454, 454, 454, 454, 454, 454, 454, 334, 336, 335, /* 260 */ 454, 454, 454, 454, 454, 454, 454, 454, 337, 339, /* 270 */ 338, 362, 454, 454, 454, 454, 454, 454, 454, 341, /* 280 */ 454, 342, 454, 454, 344, 345, 343, 362, 454, 454, /* 290 */ 454, 454, 347, }; #define PP_SZ_ACTTAB (sizeof(pp_action)/sizeof(pp_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammer, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. */ #ifdef PPFALLBACK static const PPCODETYPE ppFallback[] = { }; #endif /* PPFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct ppStackEntry { int stateno; /* The state-number */ int major; /* The major token value. This is the code ** number for the token at this stack level */ PPMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct ppStackEntry ppStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct ppParser { int ppidx; /* Index of top element in stack */ int pperrcnt; /* Shifts left before out of the error */ phql_ARG_SDECL /* A place to hold %extra_argument */ ppStackEntry ppstack[PPSTACKDEPTH]; /* The parser's stack */ }; typedef struct ppParser ppParser; #ifndef NDEBUG #include <stdio.h> static FILE *ppTraceFILE = 0; static char *ppTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG static void phql_Trace(FILE *TraceFILE, char *zTracePrompt){ ppTraceFILE = TraceFILE; ppTracePrompt = zTracePrompt; if( ppTraceFILE==0 ) ppTracePrompt = 0; else if( ppTracePrompt==0 ) ppTraceFILE = 0; } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *ppTokenName[] = { "$", "AGAINST", "BETWEEN", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "GREATEREQUAL", "LESSEQUAL", "AND", "OR", "LIKE", "ILIKE", "BITWISE_AND", "BITWISE_OR", "BITWISE_XOR", "DIVIDE", "TIMES", "MOD", "PLUS", "MINUS", "IS", "IN", "NOT", "BITWISE_NOT", "COMMA", "SELECT", "FROM", "DISTINCT", "ALL", "IDENTIFIER", "DOT", "AS", "INNER", "JOIN", "CROSS", "LEFT", "OUTER", "RIGHT", "FULL", "ON", "INSERT", "INTO", "VALUES", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "UPDATE", "SET", "DELETE", "WITH", "WHERE", "ORDER", "BY", "ASC", "DESC", "GROUP", "HAVING", "FOR", "LIMIT", "OFFSET", "INTEGER", "HINTEGER", "NPLACEHOLDER", "SPLACEHOLDER", "BPLACEHOLDER", "EXISTS", "CAST", "CONVERT", "USING", "CASE", "END", "WHEN", "THEN", "ELSE", "NULL", "STRING", "DOUBLE", "TRUE", "FALSE", "error", "program", "query_language", "select_statement", "insert_statement", "update_statement", "delete_statement", "select_clause", "where_clause", "group_clause", "having_clause", "order_clause", "select_limit_clause", "for_update_clause", "distinct_all", "column_list", "associated_name_list", "join_list_or_null", "column_item", "expr", "associated_name", "join_list", "join_item", "join_clause", "join_type", "aliased_or_qualified_name", "join_associated_name", "join_conditions", "values_list", "field_list", "value_list", "value_item", "field_item", "update_clause", "limit_clause", "update_item_list", "update_item", "qualified_name", "new_value", "delete_clause", "with_item", "with_list", "order_list", "order_item", "group_list", "group_item", "integer_or_placeholder", "argument_list", "when_clauses", "when_clause", "function_call", "distinct_or_null", "argument_list_or_null", "argument_item", }; #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *ppRuleName[] = { /* 0 */ "program ::= query_language", /* 1 */ "query_language ::= select_statement", /* 2 */ "query_language ::= insert_statement", /* 3 */ "query_language ::= update_statement", /* 4 */ "query_language ::= delete_statement", /* 5 */ "select_statement ::= select_clause where_clause group_clause having_clause order_clause select_limit_clause for_update_clause", /* 6 */ "select_clause ::= SELECT distinct_all column_list FROM associated_name_list join_list_or_null", /* 7 */ "distinct_all ::= DISTINCT", /* 8 */ "distinct_all ::= ALL", /* 9 */ "distinct_all ::=", /* 10 */ "column_list ::= column_list COMMA column_item", /* 11 */ "column_list ::= column_item", /* 12 */ "column_item ::= TIMES", /* 13 */ "column_item ::= IDENTIFIER DOT TIMES", /* 14 */ "column_item ::= expr AS IDENTIFIER", /* 15 */ "column_item ::= expr IDENTIFIER", /* 16 */ "column_item ::= expr", /* 17 */ "associated_name_list ::= associated_name_list COMMA associated_name", /* 18 */ "associated_name_list ::= associated_name", /* 19 */ "join_list_or_null ::= join_list", /* 20 */ "join_list_or_null ::=", /* 21 */ "join_list ::= join_list join_item", /* 22 */ "join_list ::= join_item", /* 23 */ "join_item ::= join_clause", /* 24 */ "join_clause ::= join_type aliased_or_qualified_name join_associated_name join_conditions", /* 25 */ "join_associated_name ::= AS IDENTIFIER", /* 26 */ "join_associated_name ::= IDENTIFIER", /* 27 */ "join_associated_name ::=", /* 28 */ "join_type ::= INNER JOIN", /* 29 */ "join_type ::= CROSS JOIN", /* 30 */ "join_type ::= LEFT OUTER JOIN", /* 31 */ "join_type ::= LEFT JOIN", /* 32 */ "join_type ::= RIGHT OUTER JOIN", /* 33 */ "join_type ::= RIGHT JOIN", /* 34 */ "join_type ::= FULL OUTER JOIN", /* 35 */ "join_type ::= FULL JOIN", /* 36 */ "join_type ::= JOIN", /* 37 */ "join_conditions ::= ON expr", /* 38 */ "join_conditions ::=", /* 39 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", /* 40 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name PARENTHESES_OPEN field_list PARENTHESES_CLOSE VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", /* 41 */ "values_list ::= values_list COMMA value_item", /* 42 */ "values_list ::= value_item", /* 43 */ "value_item ::= expr", /* 44 */ "field_list ::= field_list COMMA field_item", /* 45 */ "field_list ::= field_item", /* 46 */ "field_item ::= IDENTIFIER", /* 47 */ "update_statement ::= update_clause where_clause limit_clause", /* 48 */ "update_clause ::= UPDATE associated_name SET update_item_list", /* 49 */ "update_item_list ::= update_item_list COMMA update_item", /* 50 */ "update_item_list ::= update_item", /* 51 */ "update_item ::= qualified_name EQUALS new_value", /* 52 */ "new_value ::= expr", /* 53 */ "delete_statement ::= delete_clause where_clause limit_clause", /* 54 */ "delete_clause ::= DELETE FROM associated_name", /* 55 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER", /* 56 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER", /* 57 */ "associated_name ::= aliased_or_qualified_name", /* 58 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH with_item", /* 59 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", /* 60 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", /* 61 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH with_item", /* 62 */ "associated_name ::= aliased_or_qualified_name WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", /* 63 */ "associated_name ::= aliased_or_qualified_name WITH with_item", /* 64 */ "with_list ::= with_list COMMA with_item", /* 65 */ "with_list ::= with_item", /* 66 */ "with_item ::= IDENTIFIER", /* 67 */ "aliased_or_qualified_name ::= qualified_name", /* 68 */ "where_clause ::= WHERE expr", /* 69 */ "where_clause ::=", /* 70 */ "order_clause ::= ORDER BY order_list", /* 71 */ "order_clause ::=", /* 72 */ "order_list ::= order_list COMMA order_item", /* 73 */ "order_list ::= order_item", /* 74 */ "order_item ::= expr", /* 75 */ "order_item ::= expr ASC", /* 76 */ "order_item ::= expr DESC", /* 77 */ "group_clause ::= GROUP BY group_list", /* 78 */ "group_clause ::=", /* 79 */ "group_list ::= group_list COMMA group_item", /* 80 */ "group_list ::= group_item", /* 81 */ "group_item ::= expr", /* 82 */ "having_clause ::= HAVING expr", /* 83 */ "having_clause ::=", /* 84 */ "for_update_clause ::= FOR UPDATE", /* 85 */ "for_update_clause ::=", /* 86 */ "select_limit_clause ::= LIMIT integer_or_placeholder", /* 87 */ "select_limit_clause ::= LIMIT integer_or_placeholder COMMA integer_or_placeholder", /* 88 */ "select_limit_clause ::= LIMIT integer_or_placeholder OFFSET integer_or_placeholder", /* 89 */ "select_limit_clause ::=", /* 90 */ "limit_clause ::= LIMIT integer_or_placeholder", /* 91 */ "limit_clause ::=", /* 92 */ "integer_or_placeholder ::= INTEGER", /* 93 */ "integer_or_placeholder ::= HINTEGER", /* 94 */ "integer_or_placeholder ::= NPLACEHOLDER", /* 95 */ "integer_or_placeholder ::= SPLACEHOLDER", /* 96 */ "integer_or_placeholder ::= BPLACEHOLDER", /* 97 */ "expr ::= MINUS expr", /* 98 */ "expr ::= expr MINUS expr", /* 99 */ "expr ::= expr PLUS expr", /* 100 */ "expr ::= expr TIMES expr", /* 101 */ "expr ::= expr DIVIDE expr", /* 102 */ "expr ::= expr MOD expr", /* 103 */ "expr ::= expr AND expr", /* 104 */ "expr ::= expr OR expr", /* 105 */ "expr ::= expr BITWISE_AND expr", /* 106 */ "expr ::= expr BITWISE_OR expr", /* 107 */ "expr ::= expr BITWISE_XOR expr", /* 108 */ "expr ::= expr EQUALS expr", /* 109 */ "expr ::= expr NOTEQUALS expr", /* 110 */ "expr ::= expr LESS expr", /* 111 */ "expr ::= expr GREATER expr", /* 112 */ "expr ::= expr GREATEREQUAL expr", /* 113 */ "expr ::= expr LESSEQUAL expr", /* 114 */ "expr ::= expr LIKE expr", /* 115 */ "expr ::= expr NOT LIKE expr", /* 116 */ "expr ::= expr ILIKE expr", /* 117 */ "expr ::= expr NOT ILIKE expr", /* 118 */ "expr ::= expr IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", /* 119 */ "expr ::= expr NOT IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", /* 120 */ "expr ::= PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", /* 121 */ "expr ::= expr IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", /* 122 */ "expr ::= expr NOT IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", /* 123 */ "expr ::= EXISTS PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", /* 124 */ "expr ::= expr AGAINST expr", /* 125 */ "expr ::= CAST PARENTHESES_OPEN expr AS IDENTIFIER PARENTHESES_CLOSE", /* 126 */ "expr ::= CONVERT PARENTHESES_OPEN expr USING IDENTIFIER PARENTHESES_CLOSE", /* 127 */ "expr ::= CASE expr when_clauses END", /* 128 */ "when_clauses ::= when_clauses when_clause", /* 129 */ "when_clauses ::= when_clause", /* 130 */ "when_clause ::= WHEN expr THEN expr", /* 131 */ "when_clause ::= ELSE expr", /* 132 */ "expr ::= function_call", /* 133 */ "function_call ::= IDENTIFIER PARENTHESES_OPEN distinct_or_null argument_list_or_null PARENTHESES_CLOSE", /* 134 */ "distinct_or_null ::= DISTINCT", /* 135 */ "distinct_or_null ::=", /* 136 */ "argument_list_or_null ::= argument_list", /* 137 */ "argument_list_or_null ::=", /* 138 */ "argument_list ::= argument_list COMMA argument_item", /* 139 */ "argument_list ::= argument_item", /* 140 */ "argument_item ::= TIMES", /* 141 */ "argument_item ::= expr", /* 142 */ "expr ::= expr IS NULL", /* 143 */ "expr ::= expr IS NOT NULL", /* 144 */ "expr ::= expr BETWEEN expr", /* 145 */ "expr ::= NOT expr", /* 146 */ "expr ::= BITWISE_NOT expr", /* 147 */ "expr ::= PARENTHESES_OPEN expr PARENTHESES_CLOSE", /* 148 */ "expr ::= qualified_name", /* 149 */ "expr ::= INTEGER", /* 150 */ "expr ::= HINTEGER", /* 151 */ "expr ::= STRING", /* 152 */ "expr ::= DOUBLE", /* 153 */ "expr ::= NULL", /* 154 */ "expr ::= TRUE", /* 155 */ "expr ::= FALSE", /* 156 */ "expr ::= NPLACEHOLDER", /* 157 */ "expr ::= SPLACEHOLDER", /* 158 */ "expr ::= BPLACEHOLDER", /* 159 */ "qualified_name ::= IDENTIFIER DOT IDENTIFIER", /* 160 */ "qualified_name ::= IDENTIFIER", }; #endif /* NDEBUG */ const char *phql_TokenName(int tokenType){ #ifndef NDEBUG if( tokenType>0 && tokenType<(sizeof(ppTokenName)/sizeof(ppTokenName[0])) ){ return ppTokenName[tokenType]; }else{ return "Unknown"; } #else return ""; #endif } void *phql_Alloc(void *(*mallocProc)(size_t)){ ppParser *pParser; pParser = (ppParser*)(*mallocProc)( (size_t)sizeof(ppParser) ); if( pParser ){ pParser->ppidx = -1; } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "ppmajor" is the symbol code, and "pppminor" is a pointer to ** the value. */ static void pp_destructor(PPCODETYPE ppmajor, PPMINORTYPE *pppminor){ switch( ppmajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: // 558 "parser.lemon" { if ((pppminor->pp0)) { if ((pppminor->pp0)->free_flag) { efree((pppminor->pp0)->token); } efree((pppminor->pp0)); } } // 1270 "parser.c" break; case 81: case 82: case 83: case 84: case 85: case 86: case 94: case 95: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 108: case 109: case 111: case 112: case 114: case 115: case 116: case 118: case 119: case 120: case 121: case 122: case 123: case 124: case 126: case 129: case 132: // 571 "parser.lemon" { zval_ptr_dtor(&(pppminor->pp162)); } // 1307 "parser.c" break; case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 105: case 106: case 113: case 130: case 131: // 899 "parser.lemon" { zephir_safe_zval_ptr_dtor((pppminor->pp162)); } // 1323 "parser.c" break; default: break; /* If no destructor action specified: do nothing */ } } static int pp_pop_parser_stack(ppParser *pParser){ PPCODETYPE ppmajor; ppStackEntry *pptos = &pParser->ppstack[pParser->ppidx]; if( pParser->ppidx<0 ) return 0; #ifndef NDEBUG if( ppTraceFILE && pParser->ppidx>=0 ){ fprintf(ppTraceFILE,"%sPopping %s\n", ppTracePrompt, ppTokenName[pptos->major]); } #endif ppmajor = pptos->major; pp_destructor( ppmajor, &pptos->minor); pParser->ppidx--; return ppmajor; } static void phql_Free( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ ppParser *pParser = (ppParser*)p; if( pParser==0 ) return; while( pParser->ppidx>=0 ) pp_pop_parser_stack(pParser); (*freeProc)((void*)pParser); } static int pp_find_shift_action( ppParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->ppstack[pParser->ppidx].stateno; /* if( pParser->ppidx<0 ) return PP_NO_ACTION; */ i = pp_shift_ofst[stateno]; if( i==PP_SHIFT_USE_DFLT ){ return pp_default[stateno]; } if( iLookAhead==PPNOCODE ){ return PP_NO_ACTION; } i += iLookAhead; if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ #ifdef PPFALLBACK int iFallback; /* Fallback token */ if( iLookAhead<sizeof(ppFallback)/sizeof(ppFallback[0]) && (iFallback = ppFallback[iLookAhead])!=0 ){ #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE, "%sFALLBACK %s => %s\n", ppTracePrompt, ppTokenName[iLookAhead], ppTokenName[iFallback]); } #endif return pp_find_shift_action(pParser, iFallback); } #endif return pp_default[stateno]; }else{ return pp_action[i]; } } static int pp_find_reduce_action( ppParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->ppstack[pParser->ppidx].stateno; i = pp_reduce_ofst[stateno]; if( i==PP_REDUCE_USE_DFLT ){ return pp_default[stateno]; } if( iLookAhead==PPNOCODE ){ return PP_NO_ACTION; } i += iLookAhead; if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ return pp_default[stateno]; }else{ return pp_action[i]; } } static void pp_shift( ppParser *pppParser, /* The parser to be shifted */ int ppNewState, /* The new state to shift in */ int ppMajor, /* The major token to shift in */ PPMINORTYPE *pppMinor /* Pointer ot the minor token to shift in */ ){ ppStackEntry *pptos; pppParser->ppidx++; if( pppParser->ppidx>=PPSTACKDEPTH ){ phql_ARG_FETCH; pppParser->ppidx--; #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sStack Overflow!\n",ppTracePrompt); } #endif while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ phql_ARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } pptos = &pppParser->ppstack[pppParser->ppidx]; pptos->stateno = ppNewState; pptos->major = ppMajor; pptos->minor = *pppMinor; #ifndef NDEBUG if( ppTraceFILE && pppParser->ppidx>0 ){ int i; fprintf(ppTraceFILE,"%sShift %d\n",ppTracePrompt,ppNewState); fprintf(ppTraceFILE,"%sStack:",ppTracePrompt); for(i=1; i<=pppParser->ppidx; i++) fprintf(ppTraceFILE," %s",ppTokenName[pppParser->ppstack[i].major]); fprintf(ppTraceFILE,"\n"); } #endif } /* The following table contains information about every rule that ** is used during the reduce. */ static struct { PPCODETYPE lhs; /* Symbol on the left-hand side of the rule */ unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } ppRuleInfo[] = { { 80, 1 }, { 81, 1 }, { 81, 1 }, { 81, 1 }, { 81, 1 }, { 82, 7 }, { 86, 6 }, { 93, 1 }, { 93, 1 }, { 93, 0 }, { 94, 3 }, { 94, 1 }, { 97, 1 }, { 97, 3 }, { 97, 3 }, { 97, 2 }, { 97, 1 }, { 95, 3 }, { 95, 1 }, { 96, 1 }, { 96, 0 }, { 100, 2 }, { 100, 1 }, { 101, 1 }, { 102, 4 }, { 105, 2 }, { 105, 1 }, { 105, 0 }, { 103, 2 }, { 103, 2 }, { 103, 3 }, { 103, 2 }, { 103, 3 }, { 103, 2 }, { 103, 3 }, { 103, 2 }, { 103, 1 }, { 106, 2 }, { 106, 0 }, { 83, 7 }, { 83, 10 }, { 107, 3 }, { 107, 1 }, { 110, 1 }, { 108, 3 }, { 108, 1 }, { 111, 1 }, { 84, 3 }, { 112, 4 }, { 114, 3 }, { 114, 1 }, { 115, 3 }, { 117, 1 }, { 85, 3 }, { 118, 3 }, { 99, 3 }, { 99, 2 }, { 99, 1 }, { 99, 5 }, { 99, 7 }, { 99, 6 }, { 99, 4 }, { 99, 5 }, { 99, 3 }, { 120, 3 }, { 120, 1 }, { 119, 1 }, { 104, 1 }, { 87, 2 }, { 87, 0 }, { 90, 3 }, { 90, 0 }, { 121, 3 }, { 121, 1 }, { 122, 1 }, { 122, 2 }, { 122, 2 }, { 88, 3 }, { 88, 0 }, { 123, 3 }, { 123, 1 }, { 124, 1 }, { 89, 2 }, { 89, 0 }, { 92, 2 }, { 92, 0 }, { 91, 2 }, { 91, 4 }, { 91, 4 }, { 91, 0 }, { 113, 2 }, { 113, 0 }, { 125, 1 }, { 125, 1 }, { 125, 1 }, { 125, 1 }, { 125, 1 }, { 98, 2 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 3 }, { 98, 4 }, { 98, 3 }, { 98, 4 }, { 98, 5 }, { 98, 6 }, { 98, 3 }, { 98, 5 }, { 98, 6 }, { 98, 4 }, { 98, 3 }, { 98, 6 }, { 98, 6 }, { 98, 4 }, { 127, 2 }, { 127, 1 }, { 128, 4 }, { 128, 2 }, { 98, 1 }, { 129, 5 }, { 130, 1 }, { 130, 0 }, { 131, 1 }, { 131, 0 }, { 126, 3 }, { 126, 1 }, { 132, 1 }, { 132, 1 }, { 98, 3 }, { 98, 4 }, { 98, 3 }, { 98, 2 }, { 98, 2 }, { 98, 3 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 98, 1 }, { 116, 3 }, { 116, 1 }, }; static void pp_accept(ppParser*); /* Forward Declaration */ static void pp_reduce( ppParser *pppParser, /* The parser */ int ppruleno /* Number of the rule by which to reduce */ ){ int ppgoto; /* The next state */ int ppact; /* The next action */ PPMINORTYPE ppgotominor; /* The LHS of the rule reduced */ ppStackEntry *ppmsp; /* The top of the parser's stack */ int ppsize; /* Amount to pop the stack */ phql_ARG_FETCH; ppmsp = &pppParser->ppstack[pppParser->ppidx]; #ifndef NDEBUG if( ppTraceFILE && ppruleno>=0 && ppruleno<sizeof(ppRuleName)/sizeof(ppRuleName[0]) ){ fprintf(ppTraceFILE, "%sReduce [%s].\n", ppTracePrompt, ppRuleName[ppruleno]); } #endif /* NDEBUG */ switch( ppruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** // <lineno> <grammarfile> ** { ... } // User supplied code ** // <lineno> <thisfile> ** break; */ case 0: // 567 "parser.lemon" { status->ret = ppmsp[0].minor.pp162; } // 1701 "parser.c" break; case 1: case 2: case 3: case 4: case 18: case 19: case 22: case 23: case 43: case 50: case 52: case 65: case 67: case 73: case 80: case 81: case 132: case 136: case 141: case 148: // 573 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; } // 1727 "parser.c" break; case 5: // 591 "parser.lemon" { ppgotominor.pp162 = phql_ret_select_statement(ppmsp[-6].minor.pp162, ppmsp[-5].minor.pp162, ppmsp[-2].minor.pp162, ppmsp[-4].minor.pp162, ppmsp[-3].minor.pp162, ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); } // 1734 "parser.c" break; case 6: // 597 "parser.lemon" { ppgotominor.pp162 = phql_ret_select_clause(ppmsp[-4].minor.pp162, ppmsp[-3].minor.pp162, ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(26,&ppmsp[-5].minor); pp_destructor(27,&ppmsp[-2].minor); } // 1743 "parser.c" break; case 7: // 603 "parser.lemon" { ppgotominor.pp162 = phql_ret_distinct_all(1); pp_destructor(28,&ppmsp[0].minor); } // 1751 "parser.c" break; case 8: // 607 "parser.lemon" { ppgotominor.pp162 = phql_ret_distinct_all(0); pp_destructor(29,&ppmsp[0].minor); } // 1759 "parser.c" break; case 9: case 20: case 27: case 38: case 69: case 71: case 78: case 83: case 85: case 89: case 91: case 135: case 137: // 611 "parser.lemon" { ppgotominor.pp162 = NULL; } // 1778 "parser.c" break; case 10: case 17: case 41: case 44: case 49: case 64: case 72: case 79: case 138: // 617 "parser.lemon" { ppgotominor.pp162 = phql_ret_zval_list(ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(25,&ppmsp[-1].minor); } // 1794 "parser.c" break; case 11: case 42: case 45: case 129: case 139: // 621 "parser.lemon" { ppgotominor.pp162 = phql_ret_zval_list(ppmsp[0].minor.pp162, NULL); } // 1805 "parser.c" break; case 12: case 140: // 627 "parser.lemon" { ppgotominor.pp162 = phql_ret_column_item(PHQL_T_STARALL, NULL, NULL, NULL); pp_destructor(17,&ppmsp[0].minor); } // 1814 "parser.c" break; case 13: // 631 "parser.lemon" { ppgotominor.pp162 = phql_ret_column_item(PHQL_T_DOMAINALL, NULL, ppmsp[-2].minor.pp0, NULL); pp_destructor(31,&ppmsp[-1].minor); pp_destructor(17,&ppmsp[0].minor); } // 1823 "parser.c" break; case 14: // 635 "parser.lemon" { ppgotominor.pp162 = phql_ret_column_item(PHQL_T_EXPR, ppmsp[-2].minor.pp162, NULL, ppmsp[0].minor.pp0); pp_destructor(32,&ppmsp[-1].minor); } // 1831 "parser.c" break; case 15: // 639 "parser.lemon" { ppgotominor.pp162 = phql_ret_column_item(PHQL_T_EXPR, ppmsp[-1].minor.pp162, NULL, ppmsp[0].minor.pp0); } // 1838 "parser.c" break; case 16: // 643 "parser.lemon" { ppgotominor.pp162 = phql_ret_column_item(PHQL_T_EXPR, ppmsp[0].minor.pp162, NULL, NULL); } // 1845 "parser.c" break; case 21: case 128: // 667 "parser.lemon" { ppgotominor.pp162 = phql_ret_zval_list(ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); } // 1853 "parser.c" break; case 24: // 684 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_item(ppmsp[-3].minor.pp162, ppmsp[-2].minor.pp162, ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); } // 1860 "parser.c" break; case 25: // 690 "parser.lemon" { ppgotominor.pp162 = phql_ret_qualified_name(NULL, NULL, ppmsp[0].minor.pp0); pp_destructor(32,&ppmsp[-1].minor); } // 1868 "parser.c" break; case 26: case 46: case 66: case 160: // 694 "parser.lemon" { ppgotominor.pp162 = phql_ret_qualified_name(NULL, NULL, ppmsp[0].minor.pp0); } // 1878 "parser.c" break; case 28: // 704 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_INNERJOIN); pp_destructor(33,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1887 "parser.c" break; case 29: // 708 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_CROSSJOIN); pp_destructor(35,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1896 "parser.c" break; case 30: // 712 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_LEFTJOIN); pp_destructor(36,&ppmsp[-2].minor); pp_destructor(37,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1906 "parser.c" break; case 31: // 716 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_LEFTJOIN); pp_destructor(36,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1915 "parser.c" break; case 32: // 720 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_RIGHTJOIN); pp_destructor(38,&ppmsp[-2].minor); pp_destructor(37,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1925 "parser.c" break; case 33: // 724 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_RIGHTJOIN); pp_destructor(38,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1934 "parser.c" break; case 34: // 728 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_FULLJOIN); pp_destructor(39,&ppmsp[-2].minor); pp_destructor(37,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1944 "parser.c" break; case 35: // 732 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_FULLJOIN); pp_destructor(39,&ppmsp[-1].minor); pp_destructor(34,&ppmsp[0].minor); } // 1953 "parser.c" break; case 36: // 736 "parser.lemon" { ppgotominor.pp162 = phql_ret_join_type(PHQL_T_INNERJOIN); pp_destructor(34,&ppmsp[0].minor); } // 1961 "parser.c" break; case 37: // 742 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; pp_destructor(40,&ppmsp[-1].minor); } // 1969 "parser.c" break; case 39: // 753 "parser.lemon" { ppgotominor.pp162 = phql_ret_insert_statement(ppmsp[-4].minor.pp162, NULL, ppmsp[-1].minor.pp162); pp_destructor(41,&ppmsp[-6].minor); pp_destructor(42,&ppmsp[-5].minor); pp_destructor(43,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 1981 "parser.c" break; case 40: // 757 "parser.lemon" { ppgotominor.pp162 = phql_ret_insert_statement(ppmsp[-7].minor.pp162, ppmsp[-5].minor.pp162, ppmsp[-1].minor.pp162); pp_destructor(41,&ppmsp[-9].minor); pp_destructor(42,&ppmsp[-8].minor); pp_destructor(44,&ppmsp[-6].minor); pp_destructor(45,&ppmsp[-4].minor); pp_destructor(43,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 1995 "parser.c" break; case 47: // 795 "parser.lemon" { ppgotominor.pp162 = phql_ret_update_statement(ppmsp[-2].minor.pp162, ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); } // 2002 "parser.c" break; case 48: // 801 "parser.lemon" { ppgotominor.pp162 = phql_ret_update_clause(ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(46,&ppmsp[-3].minor); pp_destructor(47,&ppmsp[-1].minor); } // 2011 "parser.c" break; case 51: // 817 "parser.lemon" { ppgotominor.pp162 = phql_ret_update_item(ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(3,&ppmsp[-1].minor); } // 2019 "parser.c" break; case 53: // 829 "parser.lemon" { ppgotominor.pp162 = phql_ret_delete_statement(ppmsp[-2].minor.pp162, ppmsp[-1].minor.pp162, ppmsp[0].minor.pp162); } // 2026 "parser.c" break; case 54: // 835 "parser.lemon" { ppgotominor.pp162 = phql_ret_delete_clause(ppmsp[0].minor.pp162); pp_destructor(48,&ppmsp[-2].minor); pp_destructor(27,&ppmsp[-1].minor); } // 2035 "parser.c" break; case 55: // 841 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-2].minor.pp162, ppmsp[0].minor.pp0, NULL); pp_destructor(32,&ppmsp[-1].minor); } // 2043 "parser.c" break; case 56: // 845 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-1].minor.pp162, ppmsp[0].minor.pp0, NULL); } // 2050 "parser.c" break; case 57: // 849 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[0].minor.pp162, NULL, NULL); } // 2057 "parser.c" break; case 58: // 853 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-4].minor.pp162, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp162); pp_destructor(32,&ppmsp[-3].minor); pp_destructor(49,&ppmsp[-1].minor); } // 2066 "parser.c" break; case 59: // 857 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-6].minor.pp162, ppmsp[-4].minor.pp0, ppmsp[-1].minor.pp162); pp_destructor(32,&ppmsp[-5].minor); pp_destructor(49,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2077 "parser.c" break; case 60: // 861 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-5].minor.pp162, ppmsp[-4].minor.pp0, ppmsp[-1].minor.pp162); pp_destructor(49,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2087 "parser.c" break; case 61: // 865 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-3].minor.pp162, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp162); pp_destructor(49,&ppmsp[-1].minor); } // 2095 "parser.c" break; case 62: // 869 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-4].minor.pp162, NULL, ppmsp[-1].minor.pp162); pp_destructor(49,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2105 "parser.c" break; case 63: // 873 "parser.lemon" { ppgotominor.pp162 = phql_ret_assoc_name(ppmsp[-2].minor.pp162, NULL, ppmsp[0].minor.pp162); pp_destructor(49,&ppmsp[-1].minor); } // 2113 "parser.c" break; case 68: // 901 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; pp_destructor(50,&ppmsp[-1].minor); } // 2121 "parser.c" break; case 70: // 911 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; pp_destructor(51,&ppmsp[-2].minor); pp_destructor(52,&ppmsp[-1].minor); } // 2130 "parser.c" break; case 74: // 931 "parser.lemon" { ppgotominor.pp162 = phql_ret_order_item(ppmsp[0].minor.pp162, 0); } // 2137 "parser.c" break; case 75: // 935 "parser.lemon" { ppgotominor.pp162 = phql_ret_order_item(ppmsp[-1].minor.pp162, PHQL_T_ASC); pp_destructor(53,&ppmsp[0].minor); } // 2145 "parser.c" break; case 76: // 939 "parser.lemon" { ppgotominor.pp162 = phql_ret_order_item(ppmsp[-1].minor.pp162, PHQL_T_DESC); pp_destructor(54,&ppmsp[0].minor); } // 2153 "parser.c" break; case 77: // 945 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; pp_destructor(55,&ppmsp[-2].minor); pp_destructor(52,&ppmsp[-1].minor); } // 2162 "parser.c" break; case 82: // 971 "parser.lemon" { ppgotominor.pp162 = ppmsp[0].minor.pp162; pp_destructor(56,&ppmsp[-1].minor); } // 2170 "parser.c" break; case 84: // 981 "parser.lemon" { ppgotominor.pp162 = phql_ret_for_update_clause(); pp_destructor(57,&ppmsp[-1].minor); pp_destructor(46,&ppmsp[0].minor); } // 2179 "parser.c" break; case 86: case 90: // 991 "parser.lemon" { ppgotominor.pp162 = phql_ret_limit_clause(ppmsp[0].minor.pp162, NULL); pp_destructor(58,&ppmsp[-1].minor); } // 2188 "parser.c" break; case 87: // 995 "parser.lemon" { ppgotominor.pp162 = phql_ret_limit_clause(ppmsp[0].minor.pp162, ppmsp[-2].minor.pp162); pp_destructor(58,&ppmsp[-3].minor); pp_destructor(25,&ppmsp[-1].minor); } // 2197 "parser.c" break; case 88: // 999 "parser.lemon" { ppgotominor.pp162 = phql_ret_limit_clause(ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(58,&ppmsp[-3].minor); pp_destructor(59,&ppmsp[-1].minor); } // 2206 "parser.c" break; case 92: case 149: // 1017 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_INTEGER, ppmsp[0].minor.pp0); } // 2214 "parser.c" break; case 93: case 150: // 1021 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_HINTEGER, ppmsp[0].minor.pp0); } // 2222 "parser.c" break; case 94: case 156: // 1025 "parser.lemon" { ppgotominor.pp162 = phql_ret_placeholder_zval(PHQL_T_NPLACEHOLDER, ppmsp[0].minor.pp0); } // 2230 "parser.c" break; case 95: case 157: // 1029 "parser.lemon" { ppgotominor.pp162 = phql_ret_placeholder_zval(PHQL_T_SPLACEHOLDER, ppmsp[0].minor.pp0); } // 2238 "parser.c" break; case 96: case 158: // 1033 "parser.lemon" { ppgotominor.pp162 = phql_ret_placeholder_zval(PHQL_T_BPLACEHOLDER, ppmsp[0].minor.pp0); } // 2246 "parser.c" break; case 97: // 1039 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_MINUS, NULL, ppmsp[0].minor.pp162); pp_destructor(20,&ppmsp[-1].minor); } // 2254 "parser.c" break; case 98: // 1043 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_SUB, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(20,&ppmsp[-1].minor); } // 2262 "parser.c" break; case 99: // 1047 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ADD, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(19,&ppmsp[-1].minor); } // 2270 "parser.c" break; case 100: // 1051 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_MUL, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(17,&ppmsp[-1].minor); } // 2278 "parser.c" break; case 101: // 1055 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_DIV, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(16,&ppmsp[-1].minor); } // 2286 "parser.c" break; case 102: // 1059 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_MOD, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(18,&ppmsp[-1].minor); } // 2294 "parser.c" break; case 103: // 1063 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_AND, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(9,&ppmsp[-1].minor); } // 2302 "parser.c" break; case 104: // 1067 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_OR, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(10,&ppmsp[-1].minor); } // 2310 "parser.c" break; case 105: // 1071 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_BITWISE_AND, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(13,&ppmsp[-1].minor); } // 2318 "parser.c" break; case 106: // 1075 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_BITWISE_OR, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(14,&ppmsp[-1].minor); } // 2326 "parser.c" break; case 107: // 1079 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_BITWISE_XOR, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(15,&ppmsp[-1].minor); } // 2334 "parser.c" break; case 108: // 1083 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_EQUALS, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(3,&ppmsp[-1].minor); } // 2342 "parser.c" break; case 109: // 1087 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_NOTEQUALS, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(4,&ppmsp[-1].minor); } // 2350 "parser.c" break; case 110: // 1091 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_LESS, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(5,&ppmsp[-1].minor); } // 2358 "parser.c" break; case 111: // 1095 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_GREATER, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(6,&ppmsp[-1].minor); } // 2366 "parser.c" break; case 112: // 1099 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_GREATEREQUAL, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(7,&ppmsp[-1].minor); } // 2374 "parser.c" break; case 113: // 1103 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_LESSEQUAL, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(8,&ppmsp[-1].minor); } // 2382 "parser.c" break; case 114: // 1107 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_LIKE, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(11,&ppmsp[-1].minor); } // 2390 "parser.c" break; case 115: // 1111 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_NLIKE, ppmsp[-3].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(23,&ppmsp[-2].minor); pp_destructor(11,&ppmsp[-1].minor); } // 2399 "parser.c" break; case 116: // 1115 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ILIKE, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(12,&ppmsp[-1].minor); } // 2407 "parser.c" break; case 117: // 1119 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_NILIKE, ppmsp[-3].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(23,&ppmsp[-2].minor); pp_destructor(12,&ppmsp[-1].minor); } // 2416 "parser.c" break; case 118: case 121: // 1123 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_IN, ppmsp[-4].minor.pp162, ppmsp[-1].minor.pp162); pp_destructor(22,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2427 "parser.c" break; case 119: case 122: // 1127 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_NOTIN, ppmsp[-5].minor.pp162, ppmsp[-1].minor.pp162); pp_destructor(23,&ppmsp[-4].minor); pp_destructor(22,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2439 "parser.c" break; case 120: // 1131 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_SUBQUERY, ppmsp[-1].minor.pp162, NULL); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2448 "parser.c" break; case 123: // 1143 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_EXISTS, NULL, ppmsp[-1].minor.pp162); pp_destructor(65,&ppmsp[-3].minor); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2458 "parser.c" break; case 124: // 1147 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_AGAINST, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(1,&ppmsp[-1].minor); } // 2466 "parser.c" break; case 125: // 1151 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_CAST, ppmsp[-3].minor.pp162, phql_ret_raw_qualified_name(ppmsp[-1].minor.pp0, NULL)); pp_destructor(66,&ppmsp[-5].minor); pp_destructor(44,&ppmsp[-4].minor); pp_destructor(32,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2477 "parser.c" break; case 126: // 1155 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_CONVERT, ppmsp[-3].minor.pp162, phql_ret_raw_qualified_name(ppmsp[-1].minor.pp0, NULL)); pp_destructor(67,&ppmsp[-5].minor); pp_destructor(44,&ppmsp[-4].minor); pp_destructor(68,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2488 "parser.c" break; case 127: // 1159 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_CASE, ppmsp[-2].minor.pp162, ppmsp[-1].minor.pp162); pp_destructor(69,&ppmsp[-3].minor); pp_destructor(70,&ppmsp[0].minor); } // 2497 "parser.c" break; case 130: // 1171 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_WHEN, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(71,&ppmsp[-3].minor); pp_destructor(72,&ppmsp[-1].minor); } // 2506 "parser.c" break; case 131: // 1175 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ELSE, ppmsp[0].minor.pp162, NULL); pp_destructor(73,&ppmsp[-1].minor); } // 2514 "parser.c" break; case 133: // 1185 "parser.lemon" { ppgotominor.pp162 = phql_ret_func_call(ppmsp[-4].minor.pp0, ppmsp[-1].minor.pp162, ppmsp[-2].minor.pp162); pp_destructor(44,&ppmsp[-3].minor); pp_destructor(45,&ppmsp[0].minor); } // 2523 "parser.c" break; case 134: // 1191 "parser.lemon" { ppgotominor.pp162 = phql_ret_distinct(); pp_destructor(28,&ppmsp[0].minor); } // 2531 "parser.c" break; case 142: // 1229 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ISNULL, ppmsp[-2].minor.pp162, NULL); pp_destructor(21,&ppmsp[-1].minor); pp_destructor(74,&ppmsp[0].minor); } // 2540 "parser.c" break; case 143: // 1233 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ISNOTNULL, ppmsp[-3].minor.pp162, NULL); pp_destructor(21,&ppmsp[-2].minor); pp_destructor(23,&ppmsp[-1].minor); pp_destructor(74,&ppmsp[0].minor); } // 2550 "parser.c" break; case 144: // 1237 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_BETWEEN, ppmsp[-2].minor.pp162, ppmsp[0].minor.pp162); pp_destructor(2,&ppmsp[-1].minor); } // 2558 "parser.c" break; case 145: // 1241 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_NOT, NULL, ppmsp[0].minor.pp162); pp_destructor(23,&ppmsp[-1].minor); } // 2566 "parser.c" break; case 146: // 1245 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_BITWISE_NOT, NULL, ppmsp[0].minor.pp162); pp_destructor(24,&ppmsp[-1].minor); } // 2574 "parser.c" break; case 147: // 1249 "parser.lemon" { ppgotominor.pp162 = phql_ret_expr(PHQL_T_ENCLOSED, ppmsp[-1].minor.pp162, NULL); pp_destructor(44,&ppmsp[-2].minor); pp_destructor(45,&ppmsp[0].minor); } // 2583 "parser.c" break; case 151: // 1265 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_STRING, ppmsp[0].minor.pp0); } // 2590 "parser.c" break; case 152: // 1269 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_DOUBLE, ppmsp[0].minor.pp0); } // 2597 "parser.c" break; case 153: // 1273 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_NULL, NULL); pp_destructor(74,&ppmsp[0].minor); } // 2605 "parser.c" break; case 154: // 1277 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_TRUE, NULL); pp_destructor(77,&ppmsp[0].minor); } // 2613 "parser.c" break; case 155: // 1281 "parser.lemon" { ppgotominor.pp162 = phql_ret_literal_zval(PHQL_T_FALSE, NULL); pp_destructor(78,&ppmsp[0].minor); } // 2621 "parser.c" break; case 159: // 1302 "parser.lemon" { ppgotominor.pp162 = phql_ret_qualified_name(NULL, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp0); pp_destructor(31,&ppmsp[-1].minor); } // 2629 "parser.c" break; }; ppgoto = ppRuleInfo[ppruleno].lhs; ppsize = ppRuleInfo[ppruleno].nrhs; pppParser->ppidx -= ppsize; ppact = pp_find_reduce_action(pppParser,ppgoto); if( ppact < PPNSTATE ){ pp_shift(pppParser,ppact,ppgoto,&ppgotominor); }else if( ppact == PPNSTATE + PPNRULE + 1 ){ pp_accept(pppParser); } } static void pp_parse_failed( ppParser *pppParser /* The parser */ ){ phql_ARG_FETCH; #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sFail!\n",ppTracePrompt); } #endif while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); /* Here code is inserted which will be executed whenever the ** parser fails */ phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void pp_syntax_error( ppParser *pppParser, /* The parser */ int ppmajor, /* The major type of the error token */ PPMINORTYPE ppminor /* The minor type of the error token */ ){ phql_ARG_FETCH; #define PPTOKEN (ppminor.pp0) // 491 "parser.lemon" if (status->scanner_state->start_length) { { char *token_name = NULL; int token_found = 0; unsigned int token_length; const phql_token_names *tokens = phql_tokens; int active_token = status->scanner_state->active_token; int near_length = status->scanner_state->start_length; if (active_token) { do { if (tokens->code == active_token) { token_name = tokens->name; token_length = tokens->length; token_found = 1; break; } ++tokens; } while (tokens[0].code != 0); } if (!token_name) { token_length = strlen("UNKNOWN"); token_name = estrndup("UNKNOWN", token_length); token_found = 0; } status->syntax_error_len = 96 + status->token->len + token_length + near_length + status->phql_length;; status->syntax_error = emalloc(sizeof(char) * status->syntax_error_len); if (near_length > 0) { if (status->token->value) { snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), near to '%s', when parsing: %s (%d)", token_name, status->token->value, status->scanner_state->start, status->phql, status->phql_length); } else { snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, near to '%s', when parsing: %s (%d)", token_name, status->scanner_state->start, status->phql, status->phql_length); } } else { if (active_token != PHQL_T_IGNORE) { if (status->token->value) { snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), at the end of query, when parsing: %s (%d)", token_name, status->token->value, status->phql, status->phql_length); } else { snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, at the end of query, when parsing: %s (%d)", token_name, status->phql, status->phql_length); } } else { snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected EOF, at the end of query"); } status->syntax_error[status->syntax_error_len - 1] = '\0'; } if (!token_found) { if (token_name) { efree(token_name); } } } } else { status->syntax_error_len = strlen("Syntax error, unexpected EOF"); status->syntax_error = estrndup("Syntax error, unexpected EOF", status->syntax_error_len); } status->status = PHQL_PARSING_FAILED; // 2738 "parser.c" phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void pp_accept( ppParser *pppParser /* The parser */ ){ phql_ARG_FETCH; #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sAccept!\n",ppTracePrompt); } #endif while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); /* Here code is inserted which will be executed whenever the ** parser accepts */ phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "phql_Alloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: ** <ul> ** <li> A pointer to the parser (an opaque structure.) ** <li> The major token number. ** <li> The minor token number. ** <li> An option argument of a grammar-specified type. ** </ul> ** ** Outputs: ** None. */ static void phql_( void *ppp, /* The parser */ int ppmajor, /* The major token code number */ phql_TOKENTYPE ppminor /* The value for the token */ phql_ARG_PDECL /* Optional %extra_argument parameter */ ){ PPMINORTYPE ppminorunion; int ppact; /* The parser action. */ int ppendofinput; /* True if we are at the end of input */ int pperrorhit = 0; /* True if ppmajor has invoked an error */ ppParser *pppParser; /* The parser */ /* (re)initialize the parser, if necessary */ pppParser = (ppParser*)ppp; if( pppParser->ppidx<0 ){ if( ppmajor==0 ) return; pppParser->ppidx = 0; pppParser->pperrcnt = -1; pppParser->ppstack[0].stateno = 0; pppParser->ppstack[0].major = 0; } ppminorunion.pp0 = ppminor; ppendofinput = (ppmajor==0); phql_ARG_STORE; #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sInput %s\n",ppTracePrompt,ppTokenName[ppmajor]); } #endif do{ ppact = pp_find_shift_action(pppParser,ppmajor); if( ppact<PPNSTATE ){ pp_shift(pppParser,ppact,ppmajor,&ppminorunion); pppParser->pperrcnt--; if( ppendofinput && pppParser->ppidx>=0 ){ ppmajor = 0; }else{ ppmajor = PPNOCODE; } }else if( ppact < PPNSTATE + PPNRULE ){ pp_reduce(pppParser,ppact-PPNSTATE); }else if( ppact == PP_ERROR_ACTION ){ int ppmx; #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sSyntax Error!\n",ppTracePrompt); } #endif #ifdef PPERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( pppParser->pperrcnt<0 ){ pp_syntax_error(pppParser,ppmajor,ppminorunion); } ppmx = pppParser->ppstack[pppParser->ppidx].major; if( ppmx==PPERRORSYMBOL || pperrorhit ){ #ifndef NDEBUG if( ppTraceFILE ){ fprintf(ppTraceFILE,"%sDiscard input token %s\n", ppTracePrompt,ppTokenName[ppmajor]); } #endif pp_destructor(ppmajor,&ppminorunion); ppmajor = PPNOCODE; }else{ while( pppParser->ppidx >= 0 && ppmx != PPERRORSYMBOL && (ppact = pp_find_shift_action(pppParser,PPERRORSYMBOL)) >= PPNSTATE ){ pp_pop_parser_stack(pppParser); } if( pppParser->ppidx < 0 || ppmajor==0 ){ pp_destructor(ppmajor,&ppminorunion); pp_parse_failed(pppParser); ppmajor = PPNOCODE; }else if( ppmx!=PPERRORSYMBOL ){ PPMINORTYPE u2; u2.PPERRSYMDT = 0; pp_shift(pppParser,ppact,PPERRORSYMBOL,&u2); } } pppParser->pperrcnt = 3; pperrorhit = 1; #else /* PPERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( pppParser->pperrcnt<=0 ){ pp_syntax_error(pppParser,ppmajor,ppminorunion); } pppParser->pperrcnt = 3; pp_destructor(ppmajor,&ppminorunion); if( ppendofinput ){ pp_parse_failed(pppParser); } ppmajor = PPNOCODE; #endif }else{ pp_accept(pppParser); ppmajor = PPNOCODE; } }while( ppmajor!=PPNOCODE && pppParser->ppidx>=0 ); return; } const phql_token_names phql_tokens[] = { { SL("INTEGER"), PHQL_T_INTEGER }, { SL("DOUBLE"), PHQL_T_DOUBLE }, { SL("STRING"), PHQL_T_STRING }, { SL("IDENTIFIER"), PHQL_T_IDENTIFIER }, { SL("HEXAINTEGER"), PHQL_T_HINTEGER }, { SL("MINUS"), PHQL_T_MINUS }, { SL("+"), PHQL_T_ADD }, { SL("-"), PHQL_T_SUB }, { SL("*"), PHQL_T_MUL }, { SL("/"), PHQL_T_DIV }, { SL("&"), PHQL_T_BITWISE_AND }, { SL("|"), PHQL_T_BITWISE_OR }, { SL("%%"), PHQL_T_MOD }, { SL("AND"), PHQL_T_AND }, { SL("OR"), PHQL_T_OR }, { SL("LIKE"), PHQL_T_LIKE }, { SL("ILIKE"), PHQL_T_ILIKE }, { SL("DOT"), PHQL_T_DOT }, { SL("COLON"), PHQL_T_COLON }, { SL("COMMA"), PHQL_T_COMMA }, { SL("EQUALS"), PHQL_T_EQUALS }, { SL("NOT EQUALS"), PHQL_T_NOTEQUALS }, { SL("NOT"), PHQL_T_NOT }, { SL("<"), PHQL_T_LESS }, { SL("<="), PHQL_T_LESSEQUAL }, { SL(">"), PHQL_T_GREATER }, { SL(">="), PHQL_T_GREATEREQUAL }, { SL("("), PHQL_T_PARENTHESES_OPEN }, { SL(")"), PHQL_T_PARENTHESES_CLOSE }, { SL("NUMERIC PLACEHOLDER"), PHQL_T_NPLACEHOLDER }, { SL("STRING PLACEHOLDER"), PHQL_T_SPLACEHOLDER }, { SL("UPDATE"), PHQL_T_UPDATE }, { SL("SET"), PHQL_T_SET }, { SL("WHERE"), PHQL_T_WHERE }, { SL("DELETE"), PHQL_T_DELETE }, { SL("FROM"), PHQL_T_FROM }, { SL("AS"), PHQL_T_AS }, { SL("INSERT"), PHQL_T_INSERT }, { SL("INTO"), PHQL_T_INTO }, { SL("VALUES"), PHQL_T_VALUES }, { SL("SELECT"), PHQL_T_SELECT }, { SL("ORDER"), PHQL_T_ORDER }, { SL("BY"), PHQL_T_BY }, { SL("LIMIT"), PHQL_T_LIMIT }, { SL("OFFSET"), PHQL_T_OFFSET }, { SL("GROUP"), PHQL_T_GROUP }, { SL("HAVING"), PHQL_T_HAVING }, { SL("IN"), PHQL_T_IN }, { SL("ON"), PHQL_T_ON }, { SL("INNER"), PHQL_T_INNER }, { SL("JOIN"), PHQL_T_JOIN }, { SL("LEFT"), PHQL_T_LEFT }, { SL("RIGHT"), PHQL_T_RIGHT }, { SL("IS"), PHQL_T_IS }, { SL("NULL"), PHQL_T_NULL }, { SL("NOT IN"), PHQL_T_NOTIN }, { SL("CROSS"), PHQL_T_CROSS }, { SL("OUTER"), PHQL_T_OUTER }, { SL("FULL"), PHQL_T_FULL }, { SL("ASC"), PHQL_T_ASC }, { SL("DESC"), PHQL_T_DESC }, { SL("BETWEEN"), PHQL_T_BETWEEN }, { SL("DISTINCT"), PHQL_T_DISTINCT }, { SL("AGAINST"), PHQL_T_AGAINST }, { SL("CAST"), PHQL_T_CAST }, { SL("CONVERT"), PHQL_T_CONVERT }, { SL("USING"), PHQL_T_USING }, { SL("ALL"), PHQL_T_ALL }, { SL("EXISTS"), PHQL_T_EXISTS }, { SL("CASE"), PHQL_T_CASE }, { SL("WHEN"), PHQL_T_WHEN }, { SL("THEN"), PHQL_T_THEN }, { SL("ELSE"), PHQL_T_ELSE }, { SL("END"), PHQL_T_END }, { SL("FOR"), PHQL_T_FOR }, { SL("WITH"), PHQL_T_WITH }, { NULL, 0, 0 } }; static void *phql_wrapper_alloc(size_t bytes) { return emalloc(bytes); } static void phql_wrapper_free(void *pointer) { efree(pointer); } static void phql_parse_with_token(void* phql_parser, int opcode, int parsercode, phql_scanner_token *token, phql_parser_status *parser_status) { phql_parser_token *pToken; pToken = emalloc(sizeof(phql_parser_token)); pToken->opcode = opcode; pToken->token = token->value; pToken->token_len = token->len; pToken->free_flag = 1; phql_(phql_parser, parsercode, pToken, parser_status); token->value = NULL; token->len = 0; } static void phql_scanner_error_msg(phql_parser_status *parser_status, zval **error_msg TSRMLS_DC) { char *error = NULL, *error_part; unsigned int length; phql_scanner_state *state = parser_status->scanner_state; MAKE_STD_ZVAL(*error_msg); if (state->start) { length = 64 + state->start_length + parser_status->phql_length; error = emalloc(sizeof(char) * length); if (state->start_length > 16) { error_part = estrndup(state->start, 16); snprintf(error, length, "Scanning error before '%s...' when parsing: %s (%d)", error_part, parser_status->phql, parser_status->phql_length); efree(error_part); } else { snprintf(error, length, "Scanning error before '%s' when parsing: %s (%d)", state->start, parser_status->phql, parser_status->phql_length); } error[length - 1] = '\0'; ZVAL_STRING(*error_msg, error, 1); } else { ZVAL_STRING(*error_msg, "Scanning error near to EOF", 1); } if (error) { efree(error); } } static int phql_parse_phql(zval *result, zval *phql TSRMLS_DC) { zval *error_msg = NULL; ZVAL_NULL(result); if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg TSRMLS_CC) == FAILURE) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg)); return FAILURE; } return SUCCESS; } static int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length, zval **error_msg TSRMLS_DC) { zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; phql_parser_status *parser_status = NULL; int scanner_status, status = SUCCESS, error_length, cache_level; phql_scanner_state *state; phql_scanner_token token; unsigned long phql_key = 0; void* phql_parser; char *error; zval **temp_ast; if (!phql) { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL", 1); return FAILURE; } cache_level = phalcon_globals_ptr->orm.cache_level; if (cache_level >= 0) { phql_key = zend_inline_hash_func(phql, phql_length + 1); if (phalcon_globals_ptr->orm.parser_cache != NULL) { if (zend_hash_index_find(phalcon_globals_ptr->orm.parser_cache, phql_key, (void**) &temp_ast) == SUCCESS) { ZVAL_ZVAL(*result, *temp_ast, 1, 0); Z_SET_REFCOUNT_P(*result, 1); return SUCCESS; } } } phql_parser = phql_Alloc(phql_wrapper_alloc); parser_status = emalloc(sizeof(phql_parser_status)); state = emalloc(sizeof(phql_scanner_state)); parser_status->status = PHQL_PARSING_OK; parser_status->scanner_state = state; parser_status->ret = NULL; parser_status->syntax_error = NULL; parser_status->token = &token; parser_status->enable_literals = phalcon_globals_ptr->orm.enable_literals; parser_status->phql = phql; parser_status->phql_length = phql_length; state->active_token = 0; state->start = phql; state->start_length = 0; state->end = state->start; token.value = NULL; token.len = 0; while (0 <= (scanner_status = phql_get_token(state, &token))) { /* Calculate the 'start' length */ state->start_length = (phql + phql_length - state->start); state->active_token = token.opcode; /* Parse the token found */ switch (token.opcode) { case PHQL_T_IGNORE: break; case PHQL_T_ADD: phql_(phql_parser, PHQL_PLUS, NULL, parser_status); break; case PHQL_T_SUB: phql_(phql_parser, PHQL_MINUS, NULL, parser_status); break; case PHQL_T_MUL: phql_(phql_parser, PHQL_TIMES, NULL, parser_status); break; case PHQL_T_DIV: phql_(phql_parser, PHQL_DIVIDE, NULL, parser_status); break; case PHQL_T_MOD: phql_(phql_parser, PHQL_MOD, NULL, parser_status); break; case PHQL_T_AND: phql_(phql_parser, PHQL_AND, NULL, parser_status); break; case PHQL_T_OR: phql_(phql_parser, PHQL_OR, NULL, parser_status); break; case PHQL_T_EQUALS: phql_(phql_parser, PHQL_EQUALS, NULL, parser_status); break; case PHQL_T_NOTEQUALS: phql_(phql_parser, PHQL_NOTEQUALS, NULL, parser_status); break; case PHQL_T_LESS: phql_(phql_parser, PHQL_LESS, NULL, parser_status); break; case PHQL_T_GREATER: phql_(phql_parser, PHQL_GREATER, NULL, parser_status); break; case PHQL_T_GREATEREQUAL: phql_(phql_parser, PHQL_GREATEREQUAL, NULL, parser_status); break; case PHQL_T_LESSEQUAL: phql_(phql_parser, PHQL_LESSEQUAL, NULL, parser_status); break; case PHQL_T_IDENTIFIER: phql_parse_with_token(phql_parser, PHQL_T_IDENTIFIER, PHQL_IDENTIFIER, &token, parser_status); break; case PHQL_T_DOT: phql_(phql_parser, PHQL_DOT, NULL, parser_status); break; case PHQL_T_COMMA: phql_(phql_parser, PHQL_COMMA, NULL, parser_status); break; case PHQL_T_PARENTHESES_OPEN: phql_(phql_parser, PHQL_PARENTHESES_OPEN, NULL, parser_status); break; case PHQL_T_PARENTHESES_CLOSE: phql_(phql_parser, PHQL_PARENTHESES_CLOSE, NULL, parser_status); break; case PHQL_T_LIKE: phql_(phql_parser, PHQL_LIKE, NULL, parser_status); break; case PHQL_T_ILIKE: phql_(phql_parser, PHQL_ILIKE, NULL, parser_status); break; case PHQL_T_NOT: phql_(phql_parser, PHQL_NOT, NULL, parser_status); break; case PHQL_T_BITWISE_AND: phql_(phql_parser, PHQL_BITWISE_AND, NULL, parser_status); break; case PHQL_T_BITWISE_OR: phql_(phql_parser, PHQL_BITWISE_OR, NULL, parser_status); break; case PHQL_T_BITWISE_NOT: phql_(phql_parser, PHQL_BITWISE_NOT, NULL, parser_status); break; case PHQL_T_BITWISE_XOR: phql_(phql_parser, PHQL_BITWISE_XOR, NULL, parser_status); break; case PHQL_T_AGAINST: phql_(phql_parser, PHQL_AGAINST, NULL, parser_status); break; case PHQL_T_CASE: phql_(phql_parser, PHQL_CASE, NULL, parser_status); break; case PHQL_T_WHEN: phql_(phql_parser, PHQL_WHEN, NULL, parser_status); break; case PHQL_T_THEN: phql_(phql_parser, PHQL_THEN, NULL, parser_status); break; case PHQL_T_END: phql_(phql_parser, PHQL_END, NULL, parser_status); break; case PHQL_T_ELSE: phql_(phql_parser, PHQL_ELSE, NULL, parser_status); break; case PHQL_T_FOR: phql_(phql_parser, PHQL_FOR, NULL, parser_status); break; case PHQL_T_WITH: phql_(phql_parser, PHQL_WITH, NULL, parser_status); break; case PHQL_T_INTEGER: if (parser_status->enable_literals) { phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_DOUBLE: if (parser_status->enable_literals) { phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_STRING: if (parser_status->enable_literals) { phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_TRUE: if (parser_status->enable_literals) { phql_(phql_parser, PHQL_TRUE, NULL, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_FALSE: if (parser_status->enable_literals) { phql_(phql_parser, PHQL_FALSE, NULL, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_HINTEGER: if (parser_status->enable_literals) { phql_parse_with_token(phql_parser, PHQL_T_HINTEGER, PHQL_HINTEGER, &token, parser_status); } else { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1); parser_status->status = PHQL_PARSING_FAILED; } break; case PHQL_T_NPLACEHOLDER: phql_parse_with_token(phql_parser, PHQL_T_NPLACEHOLDER, PHQL_NPLACEHOLDER, &token, parser_status); break; case PHQL_T_SPLACEHOLDER: phql_parse_with_token(phql_parser, PHQL_T_SPLACEHOLDER, PHQL_SPLACEHOLDER, &token, parser_status); break; case PHQL_T_BPLACEHOLDER: phql_parse_with_token(phql_parser, PHQL_T_BPLACEHOLDER, PHQL_BPLACEHOLDER, &token, parser_status); break; case PHQL_T_FROM: phql_(phql_parser, PHQL_FROM, NULL, parser_status); break; case PHQL_T_UPDATE: phql_(phql_parser, PHQL_UPDATE, NULL, parser_status); break; case PHQL_T_SET: phql_(phql_parser, PHQL_SET, NULL, parser_status); break; case PHQL_T_WHERE: phql_(phql_parser, PHQL_WHERE, NULL, parser_status); break; case PHQL_T_DELETE: phql_(phql_parser, PHQL_DELETE, NULL, parser_status); break; case PHQL_T_INSERT: phql_(phql_parser, PHQL_INSERT, NULL, parser_status); break; case PHQL_T_INTO: phql_(phql_parser, PHQL_INTO, NULL, parser_status); break; case PHQL_T_VALUES: phql_(phql_parser, PHQL_VALUES, NULL, parser_status); break; case PHQL_T_SELECT: phql_(phql_parser, PHQL_SELECT, NULL, parser_status); break; case PHQL_T_AS: phql_(phql_parser, PHQL_AS, NULL, parser_status); break; case PHQL_T_ORDER: phql_(phql_parser, PHQL_ORDER, NULL, parser_status); break; case PHQL_T_BY: phql_(phql_parser, PHQL_BY, NULL, parser_status); break; case PHQL_T_LIMIT: phql_(phql_parser, PHQL_LIMIT, NULL, parser_status); break; case PHQL_T_OFFSET: phql_(phql_parser, PHQL_OFFSET, NULL, parser_status); break; case PHQL_T_GROUP: phql_(phql_parser, PHQL_GROUP, NULL, parser_status); break; case PHQL_T_HAVING: phql_(phql_parser, PHQL_HAVING, NULL, parser_status); break; case PHQL_T_ASC: phql_(phql_parser, PHQL_ASC, NULL, parser_status); break; case PHQL_T_DESC: phql_(phql_parser, PHQL_DESC, NULL, parser_status); break; case PHQL_T_IN: phql_(phql_parser, PHQL_IN, NULL, parser_status); break; case PHQL_T_ON: phql_(phql_parser, PHQL_ON, NULL, parser_status); break; case PHQL_T_INNER: phql_(phql_parser, PHQL_INNER, NULL, parser_status); break; case PHQL_T_JOIN: phql_(phql_parser, PHQL_JOIN, NULL, parser_status); break; case PHQL_T_LEFT: phql_(phql_parser, PHQL_LEFT, NULL, parser_status); break; case PHQL_T_RIGHT: phql_(phql_parser, PHQL_RIGHT, NULL, parser_status); break; case PHQL_T_CROSS: phql_(phql_parser, PHQL_CROSS, NULL, parser_status); break; case PHQL_T_FULL: phql_(phql_parser, PHQL_FULL, NULL, parser_status); break; case PHQL_T_OUTER: phql_(phql_parser, PHQL_OUTER, NULL, parser_status); break; case PHQL_T_IS: phql_(phql_parser, PHQL_IS, NULL, parser_status); break; case PHQL_T_NULL: phql_(phql_parser, PHQL_NULL, NULL, parser_status); break; case PHQL_T_BETWEEN: phql_(phql_parser, PHQL_BETWEEN, NULL, parser_status); break; case PHQL_T_DISTINCT: phql_(phql_parser, PHQL_DISTINCT, NULL, parser_status); break; case PHQL_T_ALL: phql_(phql_parser, PHQL_ALL, NULL, parser_status); break; case PHQL_T_CAST: phql_(phql_parser, PHQL_CAST, NULL, parser_status); break; case PHQL_T_CONVERT: phql_(phql_parser, PHQL_CONVERT, NULL, parser_status); break; case PHQL_T_USING: phql_(phql_parser, PHQL_USING, NULL, parser_status); break; case PHQL_T_EXISTS: phql_(phql_parser, PHQL_EXISTS, NULL, parser_status); break; default: parser_status->status = PHQL_PARSING_FAILED; error_length = sizeof(char) * 32; error = emalloc(error_length); snprintf(error, error_length, "Scanner: Unknown opcode %d", token.opcode); error[error_length - 1] = '\0'; MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, error, 1); efree(error); break; } if (parser_status->status != PHQL_PARSING_OK) { status = FAILURE; break; } state->end = state->start; } if (status != FAILURE) { switch (scanner_status) { case PHQL_SCANNER_RETCODE_ERR: case PHQL_SCANNER_RETCODE_IMPOSSIBLE: if (!*error_msg) { if (!*error_msg) { phql_scanner_error_msg(parser_status, error_msg TSRMLS_CC); } } status = FAILURE; break; default: phql_(phql_parser, 0, NULL, parser_status); } } state->active_token = 0; state->start = NULL; if (parser_status->status != PHQL_PARSING_OK) { status = FAILURE; if (parser_status->syntax_error) { if (!*error_msg) { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, parser_status->syntax_error, 1); } efree(parser_status->syntax_error); } } phql_Free(phql_parser, phql_wrapper_free); if (status != FAILURE) { if (parser_status->status == PHQL_PARSING_OK) { if (parser_status->ret) { if (phalcon_globals_ptr->orm.cache_level >= 1) { if (Z_TYPE_P(parser_status->ret) == IS_ARRAY) { add_assoc_long(parser_status->ret, "id", phalcon_globals_ptr->orm.unique_cache_id++); } } ZVAL_ZVAL(*result, parser_status->ret, 0, 0); ZVAL_NULL(parser_status->ret); zval_ptr_dtor(&parser_status->ret); if (cache_level >= 0) { if (!phalcon_globals_ptr->orm.parser_cache) { ALLOC_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); zend_hash_init(phalcon_globals_ptr->orm.parser_cache, 0, NULL, ZVAL_PTR_DTOR, 0); } Z_ADDREF_PP(result); zend_hash_index_update( phalcon_globals_ptr->orm.parser_cache, phql_key, result, sizeof(zval *), NULL ); } } else { efree(parser_status->ret); } } } efree(parser_status); efree(state); return status; } /* Generated by re2c 0.13.6 on Wed Aug 5 14:30:06 2015 */ // 1 "scanner.re" #ifdef HAVE_CONFIG_H #endif #define PPCTYPE unsigned char #define PPCURSOR (s->start) #define PPLIMIT (s->end) #define PPMARKER q static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { char *q = PPCURSOR; int status = PHQL_SCANNER_RETCODE_IMPOSSIBLE; while (PHQL_SCANNER_RETCODE_IMPOSSIBLE == status) { // 45 "scanner.c" { PPCTYPE ppch; unsigned int ppaccept = 0; ppch = *PPCURSOR; switch (ppch) { case 0x00: goto pp72; case '\t': case '\n': case '\r': case ' ': goto pp70; case '!': goto pp53; case '"': goto pp32; case '%': goto pp45; case '&': goto pp64; case '\'': goto pp33; case '(': goto pp49; case ')': goto pp51; case '*': goto pp41; case '+': goto pp37; case ',': goto pp47; case '-': goto pp39; case '.': goto pp11; case '/': goto pp43; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp2; case ':': goto pp15; case '<': goto pp55; case '=': goto pp59; case '>': goto pp57; case '?': goto pp13; case '@': goto pp61; case 'A': case 'a': goto pp4; case 'B': case 'b': goto pp5; case 'C': case 'c': goto pp6; case 'D': case 'd': goto pp7; case 'E': case 'e': goto pp8; case 'F': case 'f': goto pp9; case 'G': case 'g': goto pp25; case 'H': case 'h': goto pp26; case 'I': case 'i': goto pp21; case 'J': case 'j': goto pp29; case 'K': case 'M': case 'P': case 'Q': case 'X': case 'Y': case 'Z': case '_': case 'k': case 'm': case 'p': case 'q': case 'y': case 'z': goto pp35; case 'L': case 'l': goto pp27; case 'N': case 'n': goto pp28; case 'O': case 'o': goto pp24; case 'R': case 'r': goto pp30; case 'S': case 's': goto pp20; case 'T': case 't': goto pp31; case 'U': case 'u': goto pp18; case 'V': case 'v': goto pp22; case 'W': case 'w': goto pp23; case '[': goto pp36; case '\\': goto pp34; case '^': goto pp68; case 'x': goto pp10; case '{': goto pp17; case '|': goto pp62; case '~': goto pp66; default: goto pp74; } pp2: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '.': goto pp340; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp342; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'x': goto pp344; default: goto pp3; } pp3: // 46 "scanner.re" { token->value = estrndup(q, PPCURSOR - q); token->len = PPCURSOR - q; if (token->len > 2 && !memcmp(token->value, "0x", 2)) { token->opcode = PHQL_T_HINTEGER; } else { int i, alpha = 0; for (i = 0; i < token->len; i++) { unsigned char ch = token->value[i]; if (!((ch >= '0') && (ch <= '9'))) { alpha = 1; break; } } if (alpha) { token->opcode = PHQL_T_IDENTIFIER; } else { token->opcode = PHQL_T_INTEGER; } } q = PPCURSOR; return 0; } // 201 "scanner.c" pp4: ppch = *++PPCURSOR; switch (ppch) { case 'G': case 'g': goto pp323; case 'L': case 'l': goto pp324; case 'N': case 'n': goto pp325; case 'S': case 's': goto pp326; default: goto pp248; } pp5: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp314; case 'Y': case 'y': goto pp315; default: goto pp248; } pp6: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp296; case 'O': case 'o': goto pp297; case 'R': case 'r': goto pp298; default: goto pp248; } pp7: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp279; case 'I': case 'i': goto pp280; default: goto pp248; } pp8: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp265; case 'N': case 'n': goto pp266; case 'X': goto pp267; case 'x': goto pp268; default: goto pp248; } pp9: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp249; case 'O': case 'o': goto pp250; case 'R': case 'r': goto pp251; case 'U': case 'u': goto pp252; default: goto pp248; } pp10: ppch = *++PPCURSOR; goto pp248; pp11: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp244; default: goto pp12; } pp12: // 432 "scanner.re" { token->opcode = PHQL_T_DOT; return 0; } // 292 "scanner.c" pp13: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp241; default: goto pp14; } pp14: // 557 "scanner.re" { status = PHQL_SCANNER_RETCODE_ERR; break; } // 314 "scanner.c" pp15: ppaccept = 0; ppch = *(PPMARKER = ++PPCURSOR); switch (ppch) { case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp237; default: goto pp16; } pp16: // 437 "scanner.re" { token->opcode = PHQL_T_COLON; return 0; } // 391 "scanner.c" pp17: ppaccept = 1; ppch = *(PPMARKER = ++PPCURSOR); switch (ppch) { case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp233; default: goto pp14; } pp18: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case 'P': case 'p': goto pp222; case 'S': case 's': goto pp223; default: goto pp101; } pp19: // 380 "scanner.re" { token->opcode = PHQL_T_IDENTIFIER; if ((PPCURSOR - q) > 1) { if (q[0] == '\\') { token->value = estrndup(q + 1, PPCURSOR - q - 1); token->len = PPCURSOR - q - 1; } else { token->value = estrndup(q, PPCURSOR - q); token->len = PPCURSOR - q; } } else { token->value = estrndup(q, PPCURSOR - q); token->len = PPCURSOR - q; } q = PPCURSOR; return 0; } // 491 "scanner.c" pp20: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp214; default: goto pp101; } pp21: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp193; case 'N': case 'n': goto pp194; case 'S': case 's': goto pp196; default: goto pp101; } pp22: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp187; default: goto pp101; } pp23: ppch = *++PPCURSOR; switch (ppch) { case 'H': case 'h': goto pp176; case 'I': case 'i': goto pp177; default: goto pp101; } pp24: ppch = *++PPCURSOR; switch (ppch) { case 'F': case 'f': goto pp157; case 'N': case 'n': goto pp158; case 'R': case 'r': goto pp160; case 'U': case 'u': goto pp162; default: goto pp101; } pp25: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp152; default: goto pp101; } pp26: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp146; default: goto pp101; } pp27: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp134; case 'I': case 'i': goto pp135; default: goto pp101; } pp28: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp127; case 'U': case 'u': goto pp128; default: goto pp101; } pp29: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp123; default: goto pp101; } pp30: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp118; default: goto pp101; } pp31: ppch = *++PPCURSOR; switch (ppch) { case 'H': case 'h': goto pp110; case 'R': case 'r': goto pp111; default: goto pp101; } pp32: ppaccept = 1; ppch = *(PPMARKER = ++PPCURSOR); if (ppch <= 0x00) goto pp14; goto pp108; pp33: ppaccept = 1; ppch = *(PPMARKER = ++PPCURSOR); if (ppch <= 0x00) goto pp14; goto pp103; pp34: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp14; } pp35: ppch = *++PPCURSOR; goto pp101; pp36: ppaccept = 1; ppch = *(PPMARKER = ++PPCURSOR); switch (ppch) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp95; default: goto pp14; } pp37: ++PPCURSOR; // 407 "scanner.re" { token->opcode = PHQL_T_ADD; return 0; } // 732 "scanner.c" pp39: ++PPCURSOR; // 412 "scanner.re" { token->opcode = PHQL_T_SUB; return 0; } // 740 "scanner.c" pp41: ++PPCURSOR; // 417 "scanner.re" { token->opcode = PHQL_T_MUL; return 0; } // 748 "scanner.c" pp43: ++PPCURSOR; // 422 "scanner.re" { token->opcode = PHQL_T_DIV; return 0; } // 756 "scanner.c" pp45: ++PPCURSOR; // 427 "scanner.re" { token->opcode = PHQL_T_MOD; return 0; } // 764 "scanner.c" pp47: ++PPCURSOR; // 442 "scanner.re" { token->opcode = PHQL_T_COMMA; return 0; } // 772 "scanner.c" pp49: ++PPCURSOR; // 447 "scanner.re" { token->opcode = PHQL_T_PARENTHESES_OPEN; return 0; } // 780 "scanner.c" pp51: ++PPCURSOR; // 452 "scanner.re" { token->opcode = PHQL_T_PARENTHESES_CLOSE; return 0; } // 788 "scanner.c" pp53: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '!': goto pp91; case '=': goto pp93; default: goto pp54; } pp54: // 522 "scanner.re" { token->opcode = PHQL_T_NOT; return 0; } // 802 "scanner.c" pp55: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '=': goto pp87; case '>': goto pp89; default: goto pp56; } pp56: // 477 "scanner.re" { token->opcode = PHQL_T_LESS; return 0; } // 816 "scanner.c" pp57: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '=': goto pp85; default: goto pp58; } pp58: // 482 "scanner.re" { token->opcode = PHQL_T_GREATER; return 0; } // 829 "scanner.c" pp59: ++PPCURSOR; // 487 "scanner.re" { token->opcode = PHQL_T_EQUALS; return 0; } // 837 "scanner.c" pp61: ppch = *++PPCURSOR; switch (ppch) { case '>': goto pp81; case '@': goto pp83; default: goto pp14; } pp62: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '|': goto pp79; default: goto pp63; } pp63: // 542 "scanner.re" { token->opcode = PHQL_T_BITWISE_OR; return 0; } // 857 "scanner.c" pp64: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '&': goto pp77; default: goto pp65; } pp65: // 537 "scanner.re" { token->opcode = PHQL_T_BITWISE_AND; return 0; } // 870 "scanner.c" pp66: ++PPCURSOR; // 527 "scanner.re" { token->opcode = PHQL_T_BITWISE_NOT; return 0; } // 878 "scanner.c" pp68: ++PPCURSOR; // 532 "scanner.re" { token->opcode = PHQL_T_BITWISE_XOR; return 0; } // 886 "scanner.c" pp70: ++PPCURSOR; ppch = *PPCURSOR; goto pp76; pp71: // 547 "scanner.re" { token->opcode = PHQL_T_IGNORE; return 0; } // 897 "scanner.c" pp72: ++PPCURSOR; // 552 "scanner.re" { status = PHQL_SCANNER_RETCODE_EOF; break; } // 905 "scanner.c" pp74: ppch = *++PPCURSOR; goto pp14; pp75: ++PPCURSOR; ppch = *PPCURSOR; pp76: switch (ppch) { case '\t': case '\n': case '\r': case ' ': goto pp75; default: goto pp71; } pp77: ++PPCURSOR; // 502 "scanner.re" { token->opcode = PHQL_T_TS_AND; return 0; } // 927 "scanner.c" pp79: ++PPCURSOR; // 497 "scanner.re" { token->opcode = PHQL_T_TS_OR; return 0; } // 935 "scanner.c" pp81: ++PPCURSOR; // 512 "scanner.re" { token->opcode = PHQL_T_TS_CONTAINS_ANOTHER; return 0; } // 943 "scanner.c" pp83: ++PPCURSOR; // 492 "scanner.re" { token->opcode = PHQL_T_TS_MATCHES; return 0; } // 951 "scanner.c" pp85: ++PPCURSOR; // 472 "scanner.re" { token->opcode = PHQL_T_GREATEREQUAL; return 0; } // 959 "scanner.c" pp87: ++PPCURSOR; // 467 "scanner.re" { token->opcode = PHQL_T_LESSEQUAL; return 0; } // 967 "scanner.c" pp89: ++PPCURSOR; // 462 "scanner.re" { token->opcode = PHQL_T_NOTEQUALS; return 0; } // 975 "scanner.c" pp91: ++PPCURSOR; // 507 "scanner.re" { token->opcode = PHQL_T_TS_NEGATE; return 0; } // 983 "scanner.c" pp93: ++PPCURSOR; // 457 "scanner.re" { token->opcode = PHQL_T_NOTEQUALS; return 0; } // 991 "scanner.c" pp95: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp95; case ']': goto pp98; default: goto pp97; } pp97: PPCURSOR = PPMARKER; if (ppaccept == 0) { goto pp16; } else { goto pp14; } pp98: ++PPCURSOR; // 399 "scanner.re" { token->opcode = PHQL_T_IDENTIFIER; token->value = estrndup(q, PPCURSOR - q - 1); token->len = PPCURSOR - q - 1; q = PPCURSOR; return 0; } // 1081 "scanner.c" pp100: ++PPCURSOR; ppch = *PPCURSOR; pp101: switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp19; } pp102: ++PPCURSOR; ppch = *PPCURSOR; pp103: switch (ppch) { case 0x00: goto pp97; case '\'': goto pp105; case '\\': goto pp104; default: goto pp102; } pp104: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '\n': goto pp97; default: goto pp102; } pp105: ++PPCURSOR; // 371 "scanner.re" { token->opcode = PHQL_T_STRING; token->value = estrndup(q, PPCURSOR - q - 1); token->len = PPCURSOR - q - 1; q = PPCURSOR; return 0; } // 1181 "scanner.c" pp107: ++PPCURSOR; ppch = *PPCURSOR; pp108: switch (ppch) { case 0x00: goto pp97; case '"': goto pp105; case '\\': goto pp109; default: goto pp107; } pp109: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '\n': goto pp97; default: goto pp107; } pp110: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp115; default: goto pp101; } pp111: ppch = *++PPCURSOR; switch (ppch) { case 'U': case 'u': goto pp112; default: goto pp101; } pp112: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp113; default: goto pp101; } pp113: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp114; } pp114: // 325 "scanner.re" { token->opcode = PHQL_T_TRUE; return 0; } // 1296 "scanner.c" pp115: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp116; default: goto pp101; } pp116: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp117; } pp117: // 345 "scanner.re" { token->opcode = PHQL_T_THEN; return 0; } // 1380 "scanner.c" pp118: ppch = *++PPCURSOR; switch (ppch) { case 'G': case 'g': goto pp119; default: goto pp101; } pp119: ppch = *++PPCURSOR; switch (ppch) { case 'H': case 'h': goto pp120; default: goto pp101; } pp120: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp121; default: goto pp101; } pp121: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp122; } pp122: // 260 "scanner.re" { token->opcode = PHQL_T_RIGHT; return 0; } // 1478 "scanner.c" pp123: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp124; default: goto pp101; } pp124: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp125; default: goto pp101; } pp125: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp126; } pp126: // 245 "scanner.re" { token->opcode = PHQL_T_JOIN; return 0; } // 1569 "scanner.c" pp127: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp132; default: goto pp101; } pp128: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp129; default: goto pp101; } pp129: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp130; default: goto pp101; } pp130: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp131; } pp131: // 285 "scanner.re" { token->opcode = PHQL_T_NULL; return 0; } // 1667 "scanner.c" pp132: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp133; } pp133: // 205 "scanner.re" { token->opcode = PHQL_T_NOT; return 0; } // 1744 "scanner.c" pp134: ppch = *++PPCURSOR; switch (ppch) { case 'F': case 'f': goto pp143; default: goto pp101; } pp135: ppch = *++PPCURSOR; switch (ppch) { case 'K': case 'k': goto pp137; case 'M': case 'm': goto pp136; default: goto pp101; } pp136: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp140; default: goto pp101; } pp137: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp138; default: goto pp101; } pp138: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp139; } pp139: // 220 "scanner.re" { token->opcode = PHQL_T_LIKE; return 0; } // 1851 "scanner.c" pp140: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp141; default: goto pp101; } pp141: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp142; } pp142: // 195 "scanner.re" { token->opcode = PHQL_T_LIMIT; return 0; } // 1935 "scanner.c" pp143: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp144; default: goto pp101; } pp144: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp145; } pp145: // 255 "scanner.re" { token->opcode = PHQL_T_LEFT; return 0; } // 2019 "scanner.c" pp146: ppch = *++PPCURSOR; switch (ppch) { case 'V': case 'v': goto pp147; default: goto pp101; } pp147: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp148; default: goto pp101; } pp148: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp149; default: goto pp101; } pp149: ppch = *++PPCURSOR; switch (ppch) { case 'G': case 'g': goto pp150; default: goto pp101; } pp150: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp151; } pp151: // 190 "scanner.re" { token->opcode = PHQL_T_HAVING; return 0; } // 2124 "scanner.c" pp152: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp153; default: goto pp101; } pp153: ppch = *++PPCURSOR; switch (ppch) { case 'U': case 'u': goto pp154; default: goto pp101; } pp154: ppch = *++PPCURSOR; switch (ppch) { case 'P': case 'p': goto pp155; default: goto pp101; } pp155: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp156; } pp156: // 185 "scanner.re" { token->opcode = PHQL_T_GROUP; return 0; } // 2222 "scanner.c" pp157: ppch = *++PPCURSOR; switch (ppch) { case 'F': case 'f': goto pp171; default: goto pp101; } pp158: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp159; } pp159: // 240 "scanner.re" { token->opcode = PHQL_T_ON; return 0; } // 2306 "scanner.c" pp160: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; case 'D': case 'd': goto pp167; default: goto pp161; } pp161: // 215 "scanner.re" { token->opcode = PHQL_T_OR; return 0; } // 2383 "scanner.c" pp162: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp163; default: goto pp101; } pp163: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp164; default: goto pp101; } pp164: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp165; default: goto pp101; } pp165: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp166; } pp166: // 270 "scanner.re" { token->opcode = PHQL_T_OUTER; return 0; } // 2481 "scanner.c" pp167: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp168; default: goto pp101; } pp168: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp169; default: goto pp101; } pp169: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp170; } pp170: // 165 "scanner.re" { token->opcode = PHQL_T_ORDER; return 0; } // 2572 "scanner.c" pp171: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp172; default: goto pp101; } pp172: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp173; default: goto pp101; } pp173: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp174; default: goto pp101; } pp174: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp175; } pp175: // 200 "scanner.re" { token->opcode = PHQL_T_OFFSET; return 0; } // 2670 "scanner.c" pp176: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp181; default: goto pp101; } pp177: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp178; default: goto pp101; } pp178: ppch = *++PPCURSOR; switch (ppch) { case 'H': case 'h': goto pp179; default: goto pp101; } pp179: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp180; } pp180: // 365 "scanner.re" { token->opcode = PHQL_T_WITH; return 0; } // 2768 "scanner.c" pp181: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp182; case 'R': case 'r': goto pp184; default: goto pp101; } pp182: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp183; } pp183: // 340 "scanner.re" { token->opcode = PHQL_T_WHEN; return 0; } // 2854 "scanner.c" pp184: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp185; default: goto pp101; } pp185: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp186; } pp186: // 155 "scanner.re" { token->opcode = PHQL_T_WHERE; return 0; } // 2938 "scanner.c" pp187: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp188; default: goto pp101; } pp188: ppch = *++PPCURSOR; switch (ppch) { case 'U': case 'u': goto pp189; default: goto pp101; } pp189: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp190; default: goto pp101; } pp190: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp191; default: goto pp101; } pp191: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp192; } pp192: // 150 "scanner.re" { token->opcode = PHQL_T_VALUES; return 0; } // 3043 "scanner.c" pp193: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp210; default: goto pp101; } pp194: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'O': case 'P': case 'Q': case 'R': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'o': case 'p': case 'q': case 'r': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; case 'N': case 'n': goto pp200; case 'S': case 's': goto pp198; case 'T': case 't': goto pp199; default: goto pp195; } pp195: // 235 "scanner.re" { token->opcode = PHQL_T_IN; return 0; } // 3127 "scanner.c" pp196: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp197; } pp197: // 280 "scanner.re" { token->opcode = PHQL_T_IS; return 0; } // 3204 "scanner.c" pp198: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp206; default: goto pp101; } pp199: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp204; default: goto pp101; } pp200: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp201; default: goto pp101; } pp201: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp202; default: goto pp101; } pp202: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp203; } pp203: // 250 "scanner.re" { token->opcode = PHQL_T_INNER; return 0; } // 3309 "scanner.c" pp204: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp205; } pp205: // 145 "scanner.re" { token->opcode = PHQL_T_INTO; return 0; } // 3386 "scanner.c" pp206: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp207; default: goto pp101; } pp207: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp208; default: goto pp101; } pp208: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp209; } pp209: // 140 "scanner.re" { token->opcode = PHQL_T_INSERT; return 0; } // 3477 "scanner.c" pp210: ppch = *++PPCURSOR; switch (ppch) { case 'K': case 'k': goto pp211; default: goto pp101; } pp211: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp212; default: goto pp101; } pp212: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp213; } pp213: // 225 "scanner.re" { token->opcode = PHQL_T_ILIKE; return 0; } // 3568 "scanner.c" pp214: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp217; case 'T': case 't': goto pp215; default: goto pp101; } pp215: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp216; } pp216: // 120 "scanner.re" { token->opcode = PHQL_T_SET; return 0; } // 3654 "scanner.c" pp217: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp218; default: goto pp101; } pp218: ppch = *++PPCURSOR; switch (ppch) { case 'C': case 'c': goto pp219; default: goto pp101; } pp219: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp220; default: goto pp101; } pp220: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp221; } pp221: // 160 "scanner.re" { token->opcode = PHQL_T_SELECT; return 0; } // 3752 "scanner.c" pp222: ppch = *++PPCURSOR; switch (ppch) { case 'D': case 'd': goto pp228; default: goto pp101; } pp223: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp224; default: goto pp101; } pp224: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp225; default: goto pp101; } pp225: ppch = *++PPCURSOR; switch (ppch) { case 'G': case 'g': goto pp226; default: goto pp101; } pp226: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp227; } pp227: // 315 "scanner.re" { token->opcode = PHQL_T_USING; return 0; } // 3857 "scanner.c" pp228: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp229; default: goto pp101; } pp229: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp230; default: goto pp101; } pp230: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp231; default: goto pp101; } pp231: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp232; } pp232: // 115 "scanner.re" { token->opcode = PHQL_T_UPDATE; return 0; } // 3955 "scanner.c" pp233: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp233; case '}': goto pp235; default: goto pp97; } pp235: ++PPCURSOR; // 107 "scanner.re" { token->opcode = PHQL_T_BPLACEHOLDER; token->value = estrndup(q, PPCURSOR - q - 1); token->len = PPCURSOR - q - 1; q = PPCURSOR; return 0; } // 4038 "scanner.c" pp237: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp237; case ':': goto pp239; default: goto pp97; } pp239: ++PPCURSOR; // 98 "scanner.re" { token->opcode = PHQL_T_SPLACEHOLDER; token->value = estrndup(q, PPCURSOR - q - 1); token->len = PPCURSOR - q - 1; q = PPCURSOR; return 0; } // 4120 "scanner.c" pp241: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp241; default: goto pp243; } pp243: // 89 "scanner.re" { token->opcode = PHQL_T_NPLACEHOLDER; token->value = estrndup(q, PPCURSOR - q); token->len = PPCURSOR - q; q = PPCURSOR; return 0; } // 4146 "scanner.c" pp244: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp244; default: goto pp246; } pp246: // 80 "scanner.re" { token->opcode = PHQL_T_DOUBLE; token->value = estrndup(q, PPCURSOR - q); token->len = PPCURSOR - q; q = PPCURSOR; return 0; } // 4172 "scanner.c" pp247: ++PPCURSOR; ppch = *PPCURSOR; pp248: switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'x': goto pp247; case ':': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'y': case 'z': goto pp100; default: goto pp3; } pp249: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp261; default: goto pp248; } pp250: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp259; default: goto pp101; } pp251: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp256; default: goto pp101; } pp252: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp253; default: goto pp101; } pp253: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp254; default: goto pp101; } pp254: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp255; } pp255: // 275 "scanner.re" { token->opcode = PHQL_T_FULL; return 0; } // 4356 "scanner.c" pp256: ppch = *++PPCURSOR; switch (ppch) { case 'M': case 'm': goto pp257; default: goto pp101; } pp257: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp258; } pp258: // 130 "scanner.re" { token->opcode = PHQL_T_FROM; return 0; } // 4440 "scanner.c" pp259: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp260; } pp260: // 360 "scanner.re" { token->opcode = PHQL_T_FOR; return 0; } // 4517 "scanner.c" pp261: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp262; default: goto pp101; } pp262: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp263; default: goto pp101; } pp263: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp264; } pp264: // 330 "scanner.re" { token->opcode = PHQL_T_FALSE; return 0; } // 4608 "scanner.c" pp265: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp276; default: goto pp101; } pp266: ppch = *++PPCURSOR; switch (ppch) { case 'D': case 'd': goto pp274; default: goto pp101; } pp267: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp269; default: goto pp101; } pp268: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp269; default: goto pp248; } pp269: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp270; default: goto pp101; } pp270: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp271; default: goto pp101; } pp271: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp272; default: goto pp101; } pp272: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp273; } pp273: // 320 "scanner.re" { token->opcode = PHQL_T_EXISTS; return 0; } // 4734 "scanner.c" pp274: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp275; } pp275: // 355 "scanner.re" { token->opcode = PHQL_T_END; return 0; } // 4811 "scanner.c" pp276: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp277; default: goto pp101; } pp277: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp278; } pp278: // 350 "scanner.re" { token->opcode = PHQL_T_ELSE; return 0; } // 4895 "scanner.c" pp279: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp288; case 'S': case 's': goto pp289; default: goto pp248; } pp280: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp281; default: goto pp101; } pp281: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp282; default: goto pp101; } pp282: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp283; default: goto pp101; } pp283: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp284; default: goto pp101; } pp284: ppch = *++PPCURSOR; switch (ppch) { case 'C': case 'c': goto pp285; default: goto pp101; } pp285: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp286; default: goto pp101; } pp286: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp287; } pp287: // 290 "scanner.re" { token->opcode = PHQL_T_DISTINCT; return 0; } // 5023 "scanner.c" pp288: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp292; default: goto pp101; } pp289: ppch = *++PPCURSOR; switch (ppch) { case 'C': case 'c': goto pp290; default: goto pp101; } pp290: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp291; } pp291: // 180 "scanner.re" { token->opcode = PHQL_T_DESC; return 0; } // 5114 "scanner.c" pp292: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp293; default: goto pp101; } pp293: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp294; default: goto pp101; } pp294: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp295; } pp295: // 125 "scanner.re" { token->opcode = PHQL_T_DELETE; return 0; } // 5205 "scanner.c" pp296: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp309; default: goto pp248; } pp297: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp303; default: goto pp101; } pp298: ppch = *++PPCURSOR; switch (ppch) { case 'O': case 'o': goto pp299; default: goto pp101; } pp299: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp300; default: goto pp101; } pp300: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp301; default: goto pp101; } pp301: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp302; } pp302: // 265 "scanner.re" { token->opcode = PHQL_T_CROSS; return 0; } // 5317 "scanner.c" pp303: ppch = *++PPCURSOR; switch (ppch) { case 'V': case 'v': goto pp304; default: goto pp101; } pp304: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp305; default: goto pp101; } pp305: ppch = *++PPCURSOR; switch (ppch) { case 'R': case 'r': goto pp306; default: goto pp101; } pp306: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp307; default: goto pp101; } pp307: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp308; } pp308: // 310 "scanner.re" { token->opcode = PHQL_T_CONVERT; return 0; } // 5422 "scanner.c" pp309: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp310; case 'T': case 't': goto pp312; default: goto pp101; } pp310: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp311; } pp311: // 335 "scanner.re" { token->opcode = PHQL_T_CASE; return 0; } // 5508 "scanner.c" pp312: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp313; } pp313: // 305 "scanner.re" { token->opcode = PHQL_T_CAST; return 0; } // 5585 "scanner.c" pp314: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp317; default: goto pp248; } pp315: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp316; } pp316: // 170 "scanner.re" { token->opcode = PHQL_T_BY; return 0; } // 5669 "scanner.c" pp317: ppch = *++PPCURSOR; switch (ppch) { case 'W': case 'w': goto pp318; default: goto pp101; } pp318: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp319; default: goto pp101; } pp319: ppch = *++PPCURSOR; switch (ppch) { case 'E': case 'e': goto pp320; default: goto pp101; } pp320: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp321; default: goto pp101; } pp321: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp322; } pp322: // 300 "scanner.re" { token->opcode = PHQL_T_BETWEEN; return 0; } // 5774 "scanner.c" pp323: ppch = *++PPCURSOR; switch (ppch) { case 'A': case 'a': goto pp334; default: goto pp101; } pp324: ppch = *++PPCURSOR; switch (ppch) { case 'L': case 'l': goto pp332; default: goto pp101; } pp325: ppch = *++PPCURSOR; switch (ppch) { case 'D': case 'd': goto pp330; default: goto pp101; } pp326: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; case 'C': case 'c': goto pp328; default: goto pp327; } pp327: // 135 "scanner.re" { token->opcode = PHQL_T_AS; return 0; } // 5872 "scanner.c" pp328: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp329; } pp329: // 175 "scanner.re" { token->opcode = PHQL_T_ASC; return 0; } // 5949 "scanner.c" pp330: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp331; } pp331: // 210 "scanner.re" { token->opcode = PHQL_T_AND; return 0; } // 6026 "scanner.c" pp332: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp333; } pp333: // 295 "scanner.re" { token->opcode = PHQL_T_ALL; return 0; } // 6103 "scanner.c" pp334: ppch = *++PPCURSOR; switch (ppch) { case 'I': case 'i': goto pp335; default: goto pp101; } pp335: ppch = *++PPCURSOR; switch (ppch) { case 'N': case 'n': goto pp336; default: goto pp101; } pp336: ppch = *++PPCURSOR; switch (ppch) { case 'S': case 's': goto pp337; default: goto pp101; } pp337: ppch = *++PPCURSOR; switch (ppch) { case 'T': case 't': goto pp338; default: goto pp101; } pp338: ++PPCURSOR; switch ((ppch = *PPCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto pp100; default: goto pp339; } pp339: // 230 "scanner.re" { token->opcode = PHQL_T_AGAINST; return 0; } // 6208 "scanner.c" pp340: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp340; default: goto pp246; } pp342: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '.': goto pp340; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto pp342; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'x': goto pp344; default: goto pp3; } pp344: ++PPCURSOR; ppch = *PPCURSOR; switch (ppch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'x': goto pp344; default: goto pp3; } } // 562 "scanner.re" } return status; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Status) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Status, phalcon, mvc_model_query_status, phalcon_mvc_model_query_status_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("_success"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_query_status_ce TSRMLS_CC, 1, phalcon_mvc_model_query_statusinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, __construct) { zval *success_param = NULL, *model = NULL; zend_bool success; zephir_fetch_params(0, 1, 1, &success_param, &model); success = zephir_get_boolval(success_param); if (!model) { model = ZEPHIR_GLOBAL(global_null); } if (success) { zephir_update_property_this(this_ptr, SL("_success"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_success"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getModel) { RETURN_MEMBER(this_ptr, "_model"); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages) { int ZEPHIR_LAST_CALL_STATUS; zval *model; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(model); zephir_read_property_this(&model, this_ptr, SL("_model"), PH_NOISY_CC); if (Z_TYPE_P(model) != IS_OBJECT) { array_init(return_value); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(model, "getmessages", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, success) { RETURN_MEMBER(this_ptr, "_success"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_StatusInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, StatusInterface, phalcon, mvc_model_query_statusinterface, phalcon_mvc_model_query_statusinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getModel); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getMessages); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, success); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Complex) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Complex, phalcon, mvc_model_resultset_complex, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_complex_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_resultset_complex_ce, SL("_columnTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_resultset_complex_ce, SL("_disableHydration"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_resultset_complex_ce TSRMLS_CC, 1, phalcon_mvc_model_resultsetinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *columnTypes, *result = NULL, *cache = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &columnTypes, &result, &cache); if (!result) { result = ZEPHIR_GLOBAL(global_null); } if (!cache) { cache = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_columnTypes"), columnTypes TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_complex_ce, this_ptr, "__construct", &_0, 351, result, cache); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, current) { zephir_fcall_cache_entry *_13 = NULL, *_15 = NULL; zend_class_entry *_12; HashTable *_3, *_6; HashPosition _2, _5; int dirtyState, ZEPHIR_LAST_CALL_STATUS; zval *row, *hydrateMode, *eager, *alias = NULL, *activeRow = NULL, *type = NULL, *column = NULL, *columnValue = NULL, *value = NULL, *attribute = NULL, *source = NULL, *attributes = NULL, *columnMap = NULL, *rowModel = NULL, *keepSnapshots = NULL, *sqlAlias = NULL, *modelName = NULL, *_0, *_1, **_4, **_7, *_8 = NULL, *_9 = NULL, *_10, *_11 = NULL, *_14, _16 = zval_used_for_init, _17 = zval_used_for_init; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_disableHydration"), PH_NOISY_CC); if (zephir_is_true(_0)) { zephir_update_property_this(this_ptr, SL("_activeRow"), row TSRMLS_CC); RETURN_CCTOR(row); } if (Z_TYPE_P(row) != IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { ZEPHIR_INIT_NVAR(activeRow); object_init_ex(activeRow, phalcon_mvc_model_row_ce); if (zephir_has_constructor(activeRow TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, activeRow, "__construct", NULL, 0); zephir_check_call_status(); } break; } if (ZEPHIR_IS_LONG(hydrateMode, 1)) { ZEPHIR_INIT_NVAR(activeRow); array_init(activeRow); break; } ZEPHIR_INIT_NVAR(activeRow); object_init(activeRow); break; } while(0); dirtyState = 0; _1 = zephir_fetch_nproperty_this(this_ptr, SL("_columnTypes"), PH_NOISY_CC); zephir_is_iterable(_1, &_3, &_2, 0, 0, "phalcon/mvc/model/resultset/complex.zep", 246); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(alias, _3, _2); ZEPHIR_GET_HVALUE(column, _4); if (Z_TYPE_P(column) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/mvc/model/resultset/complex.zep", 133); return; } ZEPHIR_OBS_NVAR(type); zephir_array_fetch_string(&type, column, SL("type"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 136 TSRMLS_CC); if (ZEPHIR_IS_STRING(type, "object")) { ZEPHIR_OBS_NVAR(source); zephir_array_fetch_string(&source, column, SL("column"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 142 TSRMLS_CC); ZEPHIR_OBS_NVAR(attributes); zephir_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 143 TSRMLS_CC); ZEPHIR_OBS_NVAR(columnMap); zephir_array_fetch_string(&columnMap, column, SL("columnMap"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 144 TSRMLS_CC); ZEPHIR_INIT_NVAR(rowModel); array_init(rowModel); zephir_is_iterable(attributes, &_6, &_5, 0, 0, "phalcon/mvc/model/resultset/complex.zep", 162); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(attribute, _7); ZEPHIR_OBS_NVAR(columnValue); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSV(_8, "_", source, "_", attribute); zephir_array_fetch(&columnValue, row, _8, PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 155 TSRMLS_CC); zephir_array_update_zval(&rowModel, attribute, &columnValue, PH_COPY | PH_SEPARATE); } do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { ZEPHIR_OBS_NVAR(keepSnapshots); if (!(zephir_array_isset_string_fetch(&keepSnapshots, column, SS("keepSnapshots"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(keepSnapshots); ZVAL_BOOL(keepSnapshots, 0); } if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_OBS_NVAR(_9); zephir_array_fetch_string(&_9, column, SL("instance"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 173 TSRMLS_CC); if (zephir_instance_of_ev(_9, phalcon_mvc_model_ce TSRMLS_CC)) { zephir_array_fetch_string(&_10, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 174 TSRMLS_CC); ZEPHIR_INIT_NVAR(modelName); zephir_get_class(modelName, _10, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); } zephir_array_fetch_string(&_10, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 180 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, dirtyState); _12 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&value, _12, "cloneresultmap", NULL, 0, _10, rowModel, columnMap, _11, keepSnapshots); zephir_check_call_status(); } else { zephir_array_fetch_string(&_14, column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 188 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_LONG(_11, dirtyState); ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_13, 0, _14, rowModel, columnMap, _11, keepSnapshots); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_15, 0, rowModel, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); ZEPHIR_OBS_NVAR(attribute); zephir_array_fetch_string(&attribute, column, SL("balias"), PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 202 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(sqlAlias); if (zephir_array_isset_string_fetch(&sqlAlias, column, SS("sqlAlias"), 0 TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, row, sqlAlias, PH_NOISY, "phalcon/mvc/model/resultset/complex.zep", 210 TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(value); zephir_array_isset_fetch(&value, row, alias, 0 TSRMLS_CC); } if (zephir_array_isset_string(column, SS("balias"))) { ZEPHIR_CPY_WRT(attribute, alias); } else { ZEPHIR_SINIT_NVAR(_16); ZVAL_STRING(&_16, "_", 0); ZEPHIR_SINIT_NVAR(_17); ZVAL_STRING(&_17, "", 0); ZEPHIR_INIT_NVAR(attribute); zephir_fast_str_replace(&attribute, &_16, &_17, alias TSRMLS_CC); } } if (!(zephir_array_isset_string_fetch(&eager, column, SS("eager"), 1 TSRMLS_CC))) { do { if (ZEPHIR_IS_LONG(hydrateMode, 1)) { zephir_array_update_zval(&activeRow, attribute, &value, PH_COPY | PH_SEPARATE); break; } zephir_update_property_zval_zval(activeRow, attribute, value TSRMLS_CC); break; } while(0); } } zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, toArray) { zend_object_iterator *_0; zval *records, *current = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(records); array_init(records); _0 = zephir_get_iterator(this_ptr TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(current, (*ZEPHIR_TMP_ITERATOR_PTR)); } zephir_array_append(&records, current, PH_SEPARATE, "phalcon/mvc/model/resultset/complex.zep", 259); } _0->funcs->dtor(_0 TSRMLS_CC); RETURN_CCTOR(records); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize) { zval *_0; int ZEPHIR_LAST_CALL_STATUS; zval *records = NULL, *cache, *columnTypes, *hydrateMode, *serialized = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&records, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(cache); zephir_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnTypes); zephir_read_property_this(&columnTypes, this_ptr, SL("_columnTypes"), PH_NOISY_CC); ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 4, 0 TSRMLS_CC); zephir_array_update_string(&_0, SL("cache"), &cache, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("rows"), &records, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("columnTypes"), &columnTypes, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("hydrateMode"), &hydrateMode, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&serialized, "serialize", NULL, 74, _0); zephir_check_call_status(); RETURN_CCTOR(serialized); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, unserialize) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *resultset = NULL, *_0, *_1, *_2, *_3, *_4, *_5; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); if (unlikely(Z_TYPE_P(data_param) != IS_STRING && Z_TYPE_P(data_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'data' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(data_param) == IS_STRING)) { zephir_get_strval(data, data_param); } else { ZEPHIR_INIT_VAR(data); ZVAL_EMPTY_STRING(data); } if (1) { zephir_update_property_this(this_ptr, SL("_disableHydration"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_disableHydration"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 75, data); zephir_check_call_status(); if (Z_TYPE_P(resultset) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/mvc/model/resultset/complex.zep", 304); return; } zephir_array_fetch_string(&_0, resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 307 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_rows"), _0 TSRMLS_CC); zephir_array_fetch_string(&_1, resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 308 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_2); ZVAL_LONG(_2, zephir_fast_count_int(_1 TSRMLS_CC)); zephir_update_property_this(this_ptr, SL("_count"), _2 TSRMLS_CC); zephir_array_fetch_string(&_3, resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 309 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_cache"), _3 TSRMLS_CC); zephir_array_fetch_string(&_4, resultset, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 310 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_columnTypes"), _4 TSRMLS_CC); zephir_array_fetch_string(&_5, resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/complex.zep", 311 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_hydrateMode"), _5 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Simple) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Simple, phalcon, mvc_model_resultset_simple, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_simple_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("_model"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("_columnMap"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_resultset_simple_ce, SL("_keepSnapshots"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_resultset_simple_ce TSRMLS_CC, 1, zend_ce_iterator); zend_class_implements(phalcon_mvc_model_resultset_simple_ce TSRMLS_CC, 1, spl_ce_SeekableIterator); zend_class_implements(phalcon_mvc_model_resultset_simple_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_mvc_model_resultset_simple_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_mvc_model_resultset_simple_ce TSRMLS_CC, 1, zend_ce_serializable); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *columnMap, *model, *result, *cache = NULL, *keepSnapshots = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 2, &columnMap, &model, &result, &cache, &keepSnapshots); if (!cache) { cache = ZEPHIR_GLOBAL(global_null); } if (!keepSnapshots) { keepSnapshots = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_model"), model TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_columnMap"), columnMap TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_keepSnapshots"), keepSnapshots TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_simple_ce, this_ptr, "__construct", &_0, 351, result, cache); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_4; zval *row, *hydrateMode, *columnMap, *activeRow = NULL, *modelName = NULL, *_0, *_1, *_2, *_3 = NULL, *_6; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(activeRow); zephir_read_property_this(&activeRow, this_ptr, SL("_activeRow"), PH_NOISY_CC); if (Z_TYPE_P(activeRow) != IS_NULL) { RETURN_CCTOR(activeRow); } ZEPHIR_OBS_VAR(row); zephir_read_property_this(&row, this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(row) != IS_ARRAY) { if (0) { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_activeRow"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(0); } ZEPHIR_OBS_VAR(hydrateMode); zephir_read_property_this(&hydrateMode, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); do { if (ZEPHIR_IS_LONG(hydrateMode, 0)) { if (ZEPHIR_GLOBAL(orm).late_state_binding) { ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_model"), PH_NOISY_CC); if (zephir_instance_of_ev(_0, phalcon_mvc_model_ce TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); ZEPHIR_INIT_VAR(modelName); zephir_get_class(modelName, _1, 0 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(modelName); ZVAL_STRING(modelName, "Phalcon\\Mvc\\Model", 1); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); _4 = zephir_fetch_class(modelName TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&activeRow, _4, "cloneresultmap", NULL, 0, _1, row, columnMap, _3, _2); zephir_check_call_status(); } else { _2 = zephir_fetch_nproperty_this(this_ptr, SL("_model"), PH_NOISY_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_keepSnapshots"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", &_5, 352, _2, row, columnMap, _3, _6); zephir_check_call_status(); } break; } ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_7, 353, row, columnMap, hydrateMode); zephir_check_call_status(); break; } while(0); zephir_update_property_this(this_ptr, SL("_activeRow"), activeRow TSRMLS_CC); RETURN_CCTOR(activeRow); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) { zephir_fcall_cache_entry *_9 = NULL; HashTable *_2, *_5; HashPosition _1, _4; int ZEPHIR_LAST_CALL_STATUS; zval *renameColumns_param = NULL, *result, *records = NULL, *record = NULL, *renamed = NULL, *renamedKey = NULL, *key = NULL, *value = NULL, *renamedRecords, *columnMap, *_0, **_3, **_6, *_7 = NULL, *_8 = NULL; zend_bool renameColumns; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &renameColumns_param); if (!renameColumns_param) { renameColumns = 1; } else { renameColumns = zephir_get_boolval(renameColumns_param); } ZEPHIR_OBS_VAR(records); zephir_read_property_this(&records, this_ptr, SL("_rows"), PH_NOISY_CC); if (Z_TYPE_P(records) != IS_ARRAY) { ZEPHIR_OBS_VAR(result); zephir_read_property_this(&result, this_ptr, SL("_result"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_row"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, result, "execute", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&records, result, "fetchall", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_row"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_rows"), records TSRMLS_CC); } if (renameColumns) { ZEPHIR_OBS_VAR(columnMap); zephir_read_property_this(&columnMap, this_ptr, SL("_columnMap"), PH_NOISY_CC); if (Z_TYPE_P(columnMap) != IS_ARRAY) { RETURN_CCTOR(records); } ZEPHIR_INIT_VAR(renamedRecords); array_init(renamedRecords); if (Z_TYPE_P(records) == IS_ARRAY) { zephir_is_iterable(records, &_2, &_1, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 218); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(record, _3); ZEPHIR_INIT_NVAR(renamed); array_init(renamed); zephir_is_iterable(record, &_5, &_4, 0, 0, "phalcon/mvc/model/resultset/simple.zep", 216); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(key, _5, _4); ZEPHIR_GET_HVALUE(value, _6); ZEPHIR_OBS_NVAR(renamedKey); if (!(zephir_array_isset_fetch(&renamedKey, columnMap, key, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "Column '", key, "' is not part of the column map"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_9, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/resultset/simple.zep", 200 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(renamedKey) == IS_ARRAY) { ZEPHIR_OBS_NVAR(renamedKey); if (!(zephir_array_isset_long_fetch(&renamedKey, renamedKey, 0, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_7); object_init_ex(_7, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "Column '", key, "' is not part of the column map"); ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_9, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_7, "phalcon/mvc/model/resultset/simple.zep", 206 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_array_update_zval(&renamed, renamedKey, &value, PH_COPY | PH_SEPARATE); } zephir_array_append(&renamedRecords, renamed, PH_SEPARATE, "phalcon/mvc/model/resultset/simple.zep", 216); } } RETURN_CCTOR(renamedRecords); } RETURN_CCTOR(records); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, serialize) { int ZEPHIR_LAST_CALL_STATUS; zval *_1 = NULL, *_2 = NULL, *_3; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 5, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_model"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("model"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_cache"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("cache"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, 0); ZEPHIR_CALL_METHOD(&_2, this_ptr, "toarray", NULL, 0, _3); zephir_check_call_status(); zephir_array_update_string(&_0, SL("rows"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_columnMap"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("columnMap"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_hydrateMode"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("hydrateMode"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 74, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, unserialize) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *resultset = NULL, *_0, *_1, *_2, *_3, *_4, *_5, *_6; zval *data = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); if (unlikely(Z_TYPE_P(data_param) != IS_STRING && Z_TYPE_P(data_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'data' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(data_param) == IS_STRING)) { zephir_get_strval(data, data_param); } else { ZEPHIR_INIT_VAR(data); ZVAL_EMPTY_STRING(data); } ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 75, data); zephir_check_call_status(); if (Z_TYPE_P(resultset) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/mvc/model/resultset/simple.zep", 252); return; } zephir_array_fetch_string(&_0, resultset, SL("model"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 255 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_model"), _0 TSRMLS_CC); zephir_array_fetch_string(&_1, resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 256 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_rows"), _1 TSRMLS_CC); zephir_array_fetch_string(&_2, resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 257 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, zephir_fast_count_int(_2 TSRMLS_CC)); zephir_update_property_this(this_ptr, SL("_count"), _3 TSRMLS_CC); zephir_array_fetch_string(&_4, resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 258 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_cache"), _4 TSRMLS_CC); zephir_array_fetch_string(&_5, resultset, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 259 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_columnMap"), _5 TSRMLS_CC); zephir_array_fetch_string(&_6, resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/mvc/model/resultset/simple.zep", 260 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_hydrateMode"), _6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Exception, phalcon, mvc_model_transaction_exception, phalcon_mvc_model_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Failed) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Failed, phalcon, mvc_model_transaction_failed, phalcon_mvc_model_transaction_exception_ce, phalcon_mvc_model_transaction_failed_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_transaction_failed_ce, SL("_record"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *record = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &message_param, &record); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!record) { record = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_record"), record TSRMLS_CC); ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_transaction_failed_ce, this_ptr, "__construct", NULL, 0, message); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecordMessages) { int ZEPHIR_LAST_CALL_STATUS; zval *record; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(record); zephir_read_property_this(&record, this_ptr, SL("_record"), PH_NOISY_CC); if (Z_TYPE_P(record) != IS_NULL) { ZEPHIR_RETURN_CALL_METHOD(record, "getmessages", NULL, 0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getmessage", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecord) { RETURN_MEMBER(this_ptr, "_record"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Manager) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Transaction, Manager, phalcon, mvc_model_transaction_manager, phalcon_mvc_model_transaction_manager_method_entry, 0); zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("_initialized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("_rollbackPendent"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_model_transaction_manager_ce, SL("_number"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_model_transaction_manager_ce, SL("_service"), "db", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("_transactions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_model_transaction_manager_ce TSRMLS_CC, 1, phalcon_mvc_model_transaction_managerinterface_ce); zend_class_implements(phalcon_mvc_model_transaction_manager_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *dependencyInjector = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &dependencyInjector); if (!dependencyInjector) { ZEPHIR_CPY_WRT(dependencyInjector, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(dependencyInjector); } if (zephir_is_true(dependencyInjector)) { zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } else { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model/transaction/manager.zep", 100); return; } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDbService) { zval *service_param = NULL; zval *service = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &service_param); if (unlikely(Z_TYPE_P(service_param) != IS_STRING && Z_TYPE_P(service_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'service' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(service_param) == IS_STRING)) { zephir_get_strval(service, service_param); } else { ZEPHIR_INIT_VAR(service); ZVAL_EMPTY_STRING(service); } zephir_update_property_this(this_ptr, SL("_service"), service TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDbService) { RETURN_MEMBER(this_ptr, "_service"); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setRollbackPendent) { zval *rollbackPendent_param = NULL; zend_bool rollbackPendent; zephir_fetch_params(0, 1, 0, &rollbackPendent_param); rollbackPendent = zephir_get_boolval(rollbackPendent_param); if (rollbackPendent) { zephir_update_property_this(this_ptr, SL("_rollbackPendent"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_rollbackPendent"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getRollbackPendent) { RETURN_MEMBER(this_ptr, "_rollbackPendent"); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, has) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_number"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_GT_LONG(_0, 0)); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, get) { int ZEPHIR_LAST_CALL_STATUS; zval *_2; zval *autoBegin_param = NULL, *_0, *_1, *_3 = NULL; zend_bool autoBegin; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &autoBegin_param); if (!autoBegin_param) { autoBegin = 1; } else { autoBegin = zephir_get_boolval(autoBegin_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_rollbackPendent"), PH_NOISY_CC); if (zephir_is_true(_1)) { ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, this_ptr); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "rollbackPendent", 1); zephir_array_fast_append(_2, _3); ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", NULL, 356, _2); zephir_check_call_status(); } if (1) { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_INIT_NVAR(_3); if (autoBegin) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getorcreatetransaction", NULL, 0, _3); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getOrCreateTransaction) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *autoBegin_param = NULL, *dependencyInjector = NULL, *transaction = NULL, *transactions, *_0, **_3, *_4 = NULL, *_5; zend_bool autoBegin; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &autoBegin_param); if (!autoBegin_param) { autoBegin = 1; } else { autoBegin = zephir_get_boolval(autoBegin_param); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injector container is required to obtain the services related to the ORM", "phalcon/mvc/model/transaction/manager.zep", 188); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_number"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (Z_TYPE_P(transactions) == IS_ARRAY) { zephir_is_iterable(transactions, &_2, &_1, 0, 1, "phalcon/mvc/model/transaction/manager.zep", 200); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_backwards_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(transaction, _3); if (Z_TYPE_P(transaction) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_4); ZVAL_BOOL(_4, 0); ZEPHIR_CALL_METHOD(NULL, transaction, "setisnewtransaction", NULL, 0, _4); zephir_check_call_status(); RETURN_CCTOR(transaction); } } } } ZEPHIR_INIT_VAR(transaction); object_init_ex(transaction, phalcon_mvc_model_transaction_ce); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_service"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_4); if (autoBegin) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(NULL, transaction, "__construct", NULL, 357, dependencyInjector, _4, _5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, transaction, "settransactionmanager", NULL, 358, this_ptr); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_transactions"), transaction TSRMLS_CC); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_number") TSRMLS_CC)); RETURN_CCTOR(transaction); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollbackPendent) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, commit) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *transactions, *transaction = NULL, *connection = NULL, **_2, *_3 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (Z_TYPE_P(transactions) == IS_ARRAY) { zephir_is_iterable(transactions, &_1, &_0, 0, 0, "phalcon/mvc/model/transaction/manager.zep", 233); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(transaction, _2); ZEPHIR_CALL_METHOD(&connection, transaction, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, connection, "isundertransaction", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0); zephir_check_call_status(); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollback) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *collect = NULL, *transactions, *transaction = NULL, *connection = NULL, **_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &collect); if (!collect) { collect = ZEPHIR_GLOBAL(global_true); } ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (Z_TYPE_P(transactions) == IS_ARRAY) { zephir_is_iterable(transactions, &_1, &_0, 0, 0, "phalcon/mvc/model/transaction/manager.zep", 258); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(transaction, _2); ZEPHIR_CALL_METHOD(&connection, transaction, "getconnection", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, connection, "isundertransaction", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_CALL_METHOD(NULL, connection, "rollback", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, connection, "close", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(collect)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "_collecttransaction", &_4, 0, transaction); zephir_check_call_status(); } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyRollback) { int ZEPHIR_LAST_CALL_STATUS; zval *transaction; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &transaction); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_collecttransaction", NULL, 0, transaction); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyCommit) { int ZEPHIR_LAST_CALL_STATUS; zval *transaction; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &transaction); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_collecttransaction", NULL, 0, transaction); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, _collectTransaction) { HashTable *_1; HashPosition _0; zval *transaction, *transactions, *newTransactions, *managedTransaction = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &transaction); ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (zephir_fast_count_int(transactions TSRMLS_CC)) { ZEPHIR_INIT_VAR(newTransactions); array_init(newTransactions); zephir_is_iterable(transactions, &_1, &_0, 0, 0, "phalcon/mvc/model/transaction/manager.zep", 293); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(managedTransaction, _2); if (ZEPHIR_IS_EQUAL(managedTransaction, transaction)) { zephir_array_append(&newTransactions, transaction, PH_SEPARATE, "phalcon/mvc/model/transaction/manager.zep", 289); RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_number") TSRMLS_CC)); } } zephir_update_property_this(this_ptr, SL("_transactions"), newTransactions TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, collectTransactions) { HashTable *_2; HashPosition _1; zval *transactions, *_0 = NULL, **_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(transactions); zephir_read_property_this(&transactions, this_ptr, SL("_transactions"), PH_NOISY_CC); if (zephir_fast_count_int(transactions TSRMLS_CC)) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(transactions, &_2, &_1, 0, 0, "phalcon/mvc/model/transaction/manager.zep", 309); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(_0, _3); RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_number") TSRMLS_CC)); } zephir_update_property_this(this_ptr, SL("_transactions"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_ManagerInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Transaction, ManagerInterface, phalcon, mvc_model_transaction_managerinterface, phalcon_mvc_model_transaction_managerinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, has); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollbackPendent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, commit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollback); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyRollback); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyCommit); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, collectTransactions); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Email) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Email, phalcon, mvc_model_validator_email, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_email_method_entry, 0); phalcon_mvc_model_validator_email_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Email; zend_class_implements(phalcon_mvc_model_validator_email_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Email, validate) { zval *_5; zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/email.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 274); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 192, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' must have a valid e-mail format", 1); } ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_5, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, _5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _6, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Email(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Exclusionin) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Exclusionin, phalcon, mvc_model_validator_exclusionin, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_exclusionin_method_entry, 0); phalcon_mvc_model_validator_exclusionin_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Exclusionin; zend_class_implements(phalcon_mvc_model_validator_exclusionin_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Exclusionin, validate) { zval *_4; zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *domain = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/exclusionin.zep", 65); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required by this validator", "phalcon/mvc/model/validator/exclusionin.zep", 72); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array", "phalcon/mvc/model/validator/exclusionin.zep", 77); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } if (zephir_fast_in_array(value, domain TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' must not be part of list: :domain", 1); } ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&_4, SL(":domain"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 54, message, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Exclusion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _5, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Exclusionin(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Inclusionin) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Inclusionin, phalcon, mvc_model_validator_inclusionin, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_inclusionin_method_entry, 0); phalcon_mvc_model_validator_inclusionin_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Inclusionin; zend_class_implements(phalcon_mvc_model_validator_inclusionin_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Inclusionin, validate) { zval *_6; zend_bool _3; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *domain = NULL, *value = NULL, *message = NULL, *strict = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/inclusionin.zep", 63); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required for this validator", "phalcon/mvc/model/validator/inclusionin.zep", 70); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array", "phalcon/mvc/model/validator/inclusionin.zep", 75); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_VAR(strict); ZVAL_BOOL(strict, 0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_4, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_4)) { if (Z_TYPE_P(strict) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Option 'strict' must be a boolean", "phalcon/mvc/model/validator/inclusionin.zep", 87); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_5, "in_array", NULL, 359, value, domain, strict); zephir_check_call_status(); if (!(zephir_is_true(_5))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' must be part of list: :domain", 1); } ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 2, 0 TSRMLS_CC); zephir_array_update_string(&_6, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&_6, SL(":domain"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7, "strtr", NULL, 54, message, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Inclusion", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Inclusionin(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Ip) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Ip, phalcon, mvc_model_validator_ip, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_ip_method_entry, 0); phalcon_mvc_model_validator_ip_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Ip; zend_declare_class_constant_long(phalcon_mvc_model_validator_ip_ce, SL("VERSION_4"), 1048576 TSRMLS_CC); zend_declare_class_constant_long(phalcon_mvc_model_validator_ip_ce, SL("VERSION_6"), 2097152 TSRMLS_CC); zend_class_implements(phalcon_mvc_model_validator_ip_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Ip, validate) { zval *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *version = NULL, *allowPrivate = NULL, *allowReserved = NULL, *options, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, _5 = zval_used_for_init, *_6, *_7 = NULL, *_8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/ip.zep", 87); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "version", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, (1048576 | 2097152)); ZEPHIR_CALL_METHOD(&version, this_ptr, "getoption", NULL, 0, _0, _1); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowPrivate", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_VAR(allowPrivate); ZVAL_LONG(allowPrivate, 0); } else { ZEPHIR_INIT_NVAR(allowPrivate); ZVAL_LONG(allowPrivate, 8388608); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowReserved", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_INIT_VAR(allowReserved); ZVAL_LONG(allowReserved, 0); } else { ZEPHIR_INIT_NVAR(allowReserved); ZVAL_LONG(allowReserved, 4194304); } ZEPHIR_INIT_VAR(options); zephir_create_array(options, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL("default"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); zephir_array_update_string(&options, SL("options"), &_4, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_5); zephir_bitwise_or_function(&_5, version, allowPrivate TSRMLS_CC); ZEPHIR_INIT_VAR(_6); zephir_bitwise_or_function(_6, &_5, allowReserved TSRMLS_CC); zephir_array_update_string(&options, SL("flags"), &_6, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 275); ZEPHIR_CALL_FUNCTION(&_7, "filter_var", NULL, 192, value, &_5, options); zephir_check_call_status(); if (!(zephir_is_true(_7))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "IP address is incorrect", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0, _1); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 1, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_8, "strtr", NULL, 54, message, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "IP", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _8, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Ip(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Numericality) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Numericality, phalcon, mvc_model_validator_numericality, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_numericality_method_entry, 0); phalcon_mvc_model_validator_numericality_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Numericality; zend_class_implements(phalcon_mvc_model_validator_numericality_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Numericality, validate) { zval *_3; zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/numericality.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } if (!(zephir_is_numeric(value))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field :field must be numeric", 1); } ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Numericality", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _4, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Numericality(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_PresenceOf) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, PresenceOf, phalcon, mvc_model_validator_presenceof, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_presenceof_method_entry, 0); phalcon_mvc_model_validator_presenceof_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_PresenceOf; zend_class_implements(phalcon_mvc_model_validator_presenceof_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_PresenceOf, validate) { zval *_3; zend_bool _1, _2; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/presenceof.zep", 63); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); _1 = Z_TYPE_P(value) == IS_NULL; if (!(_1)) { _2 = Z_TYPE_P(value) == IS_STRING; if (_2) { _2 = !(zephir_fast_strlen_ev(value)); } _1 = _2; } if (_1) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "':field' is required", 1); } ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, _3); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "PresenceOf", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _4, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_PresenceOf(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Regex) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Regex, phalcon, mvc_model_validator_regex, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_regex_method_entry, 0); phalcon_mvc_model_validator_regex_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Regex; zend_class_implements(phalcon_mvc_model_validator_regex_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Regex, validate) { zval *_6; int ZEPHIR_LAST_CALL_STATUS; zend_bool failed, _3; zval *record, *field = NULL, *value = NULL, *matches, *pattern = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/regex.zep", 63); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Validator requires a perl-compatible regex pattern", "phalcon/mvc/model/validator/regex.zep", 70); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&pattern, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); failed = 0; ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_NVAR(_0); zephir_preg_match(_0, pattern, value, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_0)) { zephir_array_fetch_long(&_4, matches, 0, PH_NOISY | PH_READONLY, "phalcon/mvc/model/validator/regex.zep", 89 TSRMLS_CC); failed = !ZEPHIR_IS_EQUAL(_4, value); } else { failed = 1; } if (failed == 1) { ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' doesn't match regular expression", 1); } ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 1, 0 TSRMLS_CC); zephir_array_update_string(&_6, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_7, "strtr", NULL, 54, message, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _7, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Regex(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_StringLength) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, StringLength, phalcon, mvc_model_validator_stringlength, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_stringlength_method_entry, 0); phalcon_mvc_model_validator_stringlength_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_StringLength; zend_class_implements(phalcon_mvc_model_validator_stringlength_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_StringLength, validate) { zephir_fcall_cache_entry *_6 = NULL; zval *_4 = NULL; zend_bool _1, _3; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *maximum = NULL, *minimum = NULL, *message = NULL, *_0 = NULL, *_2 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/stringlength.zep", 67); return; } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A minimum or maximum must be set", "phalcon/mvc/model/validator/stringlength.zep", 77); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 360, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' exceeds the maximum :max characters", 1); } ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_5, "strtr", &_6, 54, message, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _5, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field ':field' is less than the minimum :min characters", 1); } ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL(":field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_5, "strtr", &_6, 54, message, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _5, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_StringLength(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Uniqueness) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Uniqueness, phalcon, mvc_model_validator_uniqueness, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_uniqueness_method_entry, 0); phalcon_mvc_model_validator_uniqueness_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Uniqueness; zend_class_implements(phalcon_mvc_model_validator_uniqueness_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Uniqueness, validate) { zend_class_entry *_17; zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL, *_16 = NULL; HashTable *_2, *_12; HashPosition _1, _11; int number, ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *dependencyInjector = NULL, *metaData = NULL, *message = NULL, *bindTypes, *bindDataTypes = NULL, *columnMap = NULL, *conditions, *bindParams, *composeField = NULL, *columnField = NULL, *bindType = NULL, *primaryField = NULL, *attributeField = NULL, *params, *className, *replacePairs, *_0 = NULL, **_3, *_4 = NULL, _6 = zval_used_for_init, *_7 = NULL, *_8 = NULL, *_10 = NULL, **_13, *_14 = NULL, *_15 = NULL, *_18 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_CALL_METHOD(&dependencyInjector, record, "getdi", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "modelsMetadata", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&metaData, dependencyInjector, "getshared", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(bindTypes); array_init(bindTypes); ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, record); zephir_check_call_status(); if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getreversecolumnmap", NULL, 0, record); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } ZEPHIR_INIT_VAR(conditions); array_init(conditions); ZEPHIR_INIT_VAR(bindParams); array_init(bindParams); number = 0; ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_2, &_1, 0, 0, "phalcon/mvc/model/validator/uniqueness.zep", 120); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(composeField, _3); if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(columnField); if (!(zephir_array_isset_fetch(&columnField, columnMap, composeField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", composeField, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 97 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(columnField, composeField); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, columnField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "Column '", columnField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _4); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 107 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, number); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSV(_7, "[", composeField, "] = ?", &_6); zephir_array_append(&conditions, _7, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 113); ZEPHIR_CALL_METHOD(&_8, record, "readattribute", &_9, 0, composeField); zephir_check_call_status(); zephir_array_append(&bindParams, _8, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 114); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 115); number++; } } else { if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(columnField); if (!(zephir_array_isset_fetch(&columnField, columnMap, field, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", field, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 127 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(columnField, field); } ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, columnField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", columnField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 137 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "[", field, "] = ?0"); zephir_array_append(&conditions, _7, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 143); ZEPHIR_CALL_METHOD(&_8, record, "readattribute", NULL, 0, field); zephir_check_call_status(); zephir_array_append(&bindParams, _8, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 144); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 145); number++; } ZEPHIR_CALL_METHOD(&_10, record, "getoperationmade", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_LONG(_10, 2)) { if (ZEPHIR_GLOBAL(orm).column_renaming) { ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, record); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(columnMap); ZVAL_NULL(columnMap); } ZEPHIR_CALL_METHOD(&_8, metaData, "getprimarykeyattributes", NULL, 0, record); zephir_check_call_status(); zephir_is_iterable(_8, &_12, &_11, 0, 0, "phalcon/mvc/model/validator/uniqueness.zep", 190); for ( ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS ; zephir_hash_move_forward_ex(_12, &_11) ) { ZEPHIR_GET_HVALUE(primaryField, _13); ZEPHIR_OBS_NVAR(bindType); if (!(zephir_array_isset_fetch(&bindType, bindDataTypes, primaryField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Column '", primaryField, "' isn't part of the table columns"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 167 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(columnMap) == IS_ARRAY) { ZEPHIR_OBS_NVAR(attributeField); if (!(zephir_array_isset_fetch(&attributeField, columnMap, primaryField, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_LNVAR(_14); ZEPHIR_CONCAT_SVS(_14, "Column '", primaryField, "' isn't part of the column map"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_5, 9, _14); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/model/validator/uniqueness.zep", 175 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CPY_WRT(attributeField, primaryField); } ZEPHIR_SINIT_NVAR(_6); ZVAL_LONG(&_6, number); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVSV(_4, "[", attributeField, "] <> ?", &_6); zephir_array_append(&conditions, _4, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 184); ZEPHIR_CALL_METHOD(&_15, record, "readattribute", &_16, 0, primaryField); zephir_check_call_status(); zephir_array_append(&bindParams, _15, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 185); zephir_array_append(&bindTypes, bindType, PH_SEPARATE, "phalcon/mvc/model/validator/uniqueness.zep", 186); number++; } } ZEPHIR_INIT_VAR(params); array_init(params); zephir_array_update_string(¶ms, SL("di"), &dependencyInjector, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_0); zephir_fast_join_str(_0, SL(" AND "), conditions TSRMLS_CC); zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); zephir_array_update_string(¶ms, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); zephir_array_update_string(¶ms, SL("bindTypes"), &bindTypes, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(className); zephir_get_class(className, record, 0 TSRMLS_CC); _17 = zephir_fetch_class(className TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_8, _17, "count", NULL, 0, params); zephir_check_call_status(); if (!ZEPHIR_IS_LONG(_8, 0)) { ZEPHIR_INIT_VAR(_18); ZVAL_STRING(_18, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _18); zephir_check_temp_parameter(_18); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); if (Z_TYPE_P(field) == IS_ARRAY) { zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_18); zephir_fast_join_str(_18, SL(", "), field TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":fields"), &_18, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of fields: :fields are already present in another record", 1); } } else { zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &field, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, "Value of field: ':field' is already present in another record", 1); } } ZEPHIR_CALL_FUNCTION(&_8, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_18); ZVAL_STRING(_18, "Unique", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _8, field, _18); zephir_check_temp_parameter(_18); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Uniqueness(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Validator_Url) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Validator, Url, phalcon, mvc_model_validator_url, phalcon_mvc_model_validator_ce, phalcon_mvc_model_validator_url_method_entry, 0); phalcon_mvc_model_validator_url_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Validator_Url; zend_class_implements(phalcon_mvc_model_validator_url_ce TSRMLS_CC, 1, phalcon_mvc_model_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Model_Validator_Url, validate) { zval *_5; zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *record, *field = NULL, *value = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &record); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "field", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&field, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(field) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Field name must be a string", "phalcon/mvc/model/validator/url.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, record, "readattribute", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 273); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 192, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(message); ZVAL_STRING(message, ":field does not have a valid url format", 1); } ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 1, 0 TSRMLS_CC); zephir_array_update_string(&_5, SL(":field"), &field, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, _5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, _6, field, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static zend_object_value zephir_init_properties_Phalcon_Mvc_Model_Validator_Url(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_messages"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Annotations) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Annotations, phalcon, mvc_router_annotations, phalcon_mvc_router_ce, phalcon_mvc_router_annotations_method_entry, 0); zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("_handlers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_router_annotations_ce, SL("_processed"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("_controllerSuffix"), "Controller", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("_actionSuffix"), "Action", ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("_routePrefix"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addResource) { zval *_0; zval *handler_param = NULL, *prefix_param = NULL; zval *handler = NULL, *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &handler_param, &prefix_param); if (unlikely(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(handler_param) == IS_STRING)) { zephir_get_strval(handler, handler_param); } else { ZEPHIR_INIT_VAR(handler); ZVAL_EMPTY_STRING(handler); } if (!prefix_param) { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } else { if (unlikely(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, prefix); zephir_array_fast_append(_0, handler); zephir_update_property_array_append(this_ptr, SL("_handlers"), _0 TSRMLS_CC); if (0) { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource) { zval *_0; zval *module_param = NULL, *handler_param = NULL, *prefix_param = NULL; zval *module = NULL, *handler = NULL, *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &module_param, &handler_param, &prefix_param); if (unlikely(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(module_param) == IS_STRING)) { zephir_get_strval(module, module_param); } else { ZEPHIR_INIT_VAR(module); ZVAL_EMPTY_STRING(module); } if (unlikely(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(handler_param) == IS_STRING)) { zephir_get_strval(handler, handler_param); } else { ZEPHIR_INIT_VAR(handler); ZVAL_EMPTY_STRING(handler); } if (!prefix_param) { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } else { if (unlikely(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } } ZEPHIR_INIT_VAR(_0); zephir_create_array(_0, 3, 0 TSRMLS_CC); zephir_array_fast_append(_0, prefix); zephir_array_fast_append(_0, handler); zephir_array_fast_append(_0, module); zephir_update_property_array_append(this_ptr, SL("_handlers"), _0 TSRMLS_CC); if (0) { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) { zephir_fcall_cache_entry *_9 = NULL, *_17 = NULL, *_18 = NULL; HashTable *_2, *_7, *_11, *_15; HashPosition _1, _6, _10, _14; int ZEPHIR_LAST_CALL_STATUS; zval *uri_param = NULL, *realUri = NULL, *annotationsService = NULL, *handlers, *controllerSuffix, *scope = NULL, *prefix = NULL, *dependencyInjector = NULL, *handler = NULL, *controllerName = NULL, *lowerControllerName = NULL, *namespaceName = NULL, *moduleName = NULL, *sufixed = NULL, *handlerAnnotations = NULL, *classAnnotations = NULL, *annotations = NULL, *annotation = NULL, *methodAnnotations = NULL, *lowercased = NULL, *method = NULL, *collection = NULL, *_0, **_3, *_4, *_5 = NULL, **_8, **_12, *_13 = NULL, **_16; zval *uri = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &uri_param); if (!uri_param) { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } else { if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { zephir_get_strval(uri, uri_param); } else { ZEPHIR_INIT_VAR(uri); ZVAL_EMPTY_STRING(uri); } } if (!(!(!uri) && Z_STRLEN_P(uri))) { ZEPHIR_CALL_METHOD(&realUri, this_ptr, "getrewriteuri", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(realUri, uri); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_processed"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_INIT_VAR(annotationsService); ZVAL_NULL(annotationsService); ZEPHIR_OBS_VAR(handlers); zephir_read_property_this(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC); if (Z_TYPE_P(handlers) == IS_ARRAY) { ZEPHIR_OBS_VAR(controllerSuffix); zephir_read_property_this(&controllerSuffix, this_ptr, SL("_controllerSuffix"), PH_NOISY_CC); zephir_is_iterable(handlers, &_2, &_1, 0, 0, "phalcon/mvc/router/annotations.zep", 208); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(scope, _3); if (Z_TYPE_P(scope) == IS_ARRAY) { ZEPHIR_OBS_NVAR(prefix); zephir_array_fetch_long(&prefix, scope, 0, PH_NOISY, "phalcon/mvc/router/annotations.zep", 117 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(prefix))) { if (!(zephir_start_with(realUri, prefix, NULL))) { continue; } } if (Z_TYPE_P(annotationsService) != IS_OBJECT) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _4); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/mvc/router/annotations.zep", 129); return; } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "annotations", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&annotationsService, dependencyInjector, "getshared", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(handler); zephir_array_fetch_long(&handler, scope, 1, PH_NOISY, "phalcon/mvc/router/annotations.zep", 138 TSRMLS_CC); if (zephir_memnstr_str(handler, SL("\\"), "phalcon/mvc/router/annotations.zep", 140)) { ZEPHIR_INIT_NVAR(controllerName); zephir_get_class_ns(controllerName, handler, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); zephir_get_ns_class(namespaceName, handler, 0 TSRMLS_CC); } else { ZEPHIR_CPY_WRT(controllerName, handler); ZEPHIR_INIT_NVAR(lowerControllerName); zephir_uncamelize(lowerControllerName, controllerName); ZEPHIR_INIT_NVAR(namespaceName); ZVAL_NULL(namespaceName); } zephir_update_property_this(this_ptr, SL("_routePrefix"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_OBS_NVAR(moduleName); zephir_array_isset_long_fetch(&moduleName, scope, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(sufixed); ZEPHIR_CONCAT_VV(sufixed, handler, controllerSuffix); ZEPHIR_CALL_METHOD(&handlerAnnotations, annotationsService, "get", NULL, 0, sufixed); zephir_check_call_status(); if (Z_TYPE_P(handlerAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&classAnnotations, handlerAnnotations, "getclassannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(classAnnotations) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&annotations, classAnnotations, "getannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(annotations) == IS_ARRAY) { zephir_is_iterable(annotations, &_7, &_6, 0, 0, "phalcon/mvc/router/annotations.zep", 187); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(annotation, _8); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_9, 0, controllerName, annotation); zephir_check_call_status(); } } } ZEPHIR_CALL_METHOD(&methodAnnotations, handlerAnnotations, "getmethodsannotations", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(methodAnnotations) == IS_ARRAY) { ZEPHIR_INIT_NVAR(lowercased); zephir_uncamelize(lowercased, handler); zephir_is_iterable(methodAnnotations, &_11, &_10, 0, 0, "phalcon/mvc/router/annotations.zep", 203); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) ) { ZEPHIR_GET_HMKEY(method, _11, _10); ZEPHIR_GET_HVALUE(collection, _12); if (Z_TYPE_P(collection) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_13, collection, "getannotations", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_13, &_15, &_14, 0, 0, "phalcon/mvc/router/annotations.zep", 201); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(annotation, _16); ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_17, 0, moduleName, namespaceName, lowerControllerName, method, annotation); zephir_check_call_status(); } } } } } } } } if (1) { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_processed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, this_ptr, "handle", &_18, 361, realUri); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processControllerAnnotation) { int ZEPHIR_LAST_CALL_STATUS; zval *handler_param = NULL, *annotation, *_0 = NULL, *_1 = NULL, *_2; zval *handler = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &handler_param, &annotation); if (unlikely(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(handler_param) == IS_STRING)) { zephir_get_strval(handler, handler_param); } else { ZEPHIR_INIT_VAR(handler); ZVAL_EMPTY_STRING(handler); } ZEPHIR_CALL_METHOD(&_0, annotation, "getname", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_STRING(_0, "RoutePrefix")) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(&_1, annotation, "getargument", NULL, 0, _2); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_routePrefix"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) { zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; HashTable *_5, *_9; HashPosition _4, _8; int ZEPHIR_LAST_CALL_STATUS; zend_bool isRoute, _12; zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, *name = NULL, *actionName, *routePrefix, *paths = NULL, *value = NULL, *uri = NULL, *route = NULL, *methods = NULL, *converts = NULL, *param = NULL, *convert = NULL, *conversorParam = NULL, *routeName = NULL, *beforeMatch = NULL, *_0, *_1, _2, *_3 = NULL, **_6, **_10; zval *module = NULL, *namespaceName = NULL, *controller = NULL, *action = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); if (unlikely(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(module_param) == IS_STRING)) { zephir_get_strval(module, module_param); } else { ZEPHIR_INIT_VAR(module); ZVAL_EMPTY_STRING(module); } if (unlikely(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(namespaceName_param) == IS_STRING)) { zephir_get_strval(namespaceName, namespaceName_param); } else { ZEPHIR_INIT_VAR(namespaceName); ZVAL_EMPTY_STRING(namespaceName); } if (unlikely(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controller_param) == IS_STRING)) { zephir_get_strval(controller, controller_param); } else { ZEPHIR_INIT_VAR(controller); ZVAL_EMPTY_STRING(controller); } if (unlikely(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(action_param) == IS_STRING)) { zephir_get_strval(action, action_param); } else { ZEPHIR_INIT_VAR(action); ZVAL_EMPTY_STRING(action); } isRoute = 0; ZEPHIR_INIT_VAR(methods); ZVAL_NULL(methods); ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL, 0); zephir_check_call_status(); do { if (ZEPHIR_IS_STRING(name, "Route")) { isRoute = 1; break; } if (ZEPHIR_IS_STRING(name, "Get")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "GET", 1); break; } if (ZEPHIR_IS_STRING(name, "Post")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "POST", 1); break; } if (ZEPHIR_IS_STRING(name, "Put")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "PUT", 1); break; } if (ZEPHIR_IS_STRING(name, "Delete")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "DELETE", 1); break; } if (ZEPHIR_IS_STRING(name, "Options")) { isRoute = 1; ZEPHIR_INIT_NVAR(methods); ZVAL_STRING(methods, "OPTIONS", 1); break; } } while(0); if (isRoute == 1) { ZEPHIR_INIT_VAR(_0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "", 0); zephir_fast_str_replace(&_0, _1, &_2, action TSRMLS_CC); ZEPHIR_INIT_VAR(actionName); zephir_fast_strtolower(actionName, _0); ZEPHIR_OBS_VAR(routePrefix); zephir_read_property_this(&routePrefix, this_ptr, SL("_routePrefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "paths", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(paths) != IS_ARRAY) { ZEPHIR_INIT_NVAR(paths); array_init(paths); } if (!(ZEPHIR_IS_EMPTY(module))) { zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); } if (!(ZEPHIR_IS_EMPTY(namespaceName))) { zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, 0, _3); zephir_check_call_status(); if (Z_TYPE_P(value) != IS_NULL) { if (!ZEPHIR_IS_STRING(value, "/")) { ZEPHIR_INIT_VAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, value); } else { if (Z_TYPE_P(routePrefix) != IS_NULL) { ZEPHIR_CPY_WRT(uri, routePrefix); } else { ZEPHIR_CPY_WRT(uri, value); } } } else { ZEPHIR_INIT_NVAR(uri); ZEPHIR_CONCAT_VV(uri, routePrefix, actionName); } ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, 0, uri, paths); zephir_check_call_status(); if (Z_TYPE_P(methods) != IS_NULL) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "methods", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(methods) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } else { if (Z_TYPE_P(methods) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "via", NULL, 0, methods); zephir_check_call_status(); } } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "converts", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_5, &_4, 0, 0, "phalcon/mvc/router/annotations.zep", 354); for ( ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS ; zephir_hash_move_forward_ex(_5, &_4) ) { ZEPHIR_GET_HMKEY(param, _5, _4); ZEPHIR_GET_HVALUE(convert, _6); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_7, 0, param, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "conversors", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(converts) == IS_ARRAY) { zephir_is_iterable(converts, &_9, &_8, 0, 0, "phalcon/mvc/router/annotations.zep", 364); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(conversorParam, _9, _8); ZEPHIR_GET_HVALUE(convert, _10); ZEPHIR_CALL_METHOD(NULL, route, "convert", &_11, 0, conversorParam, convert); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "beforeMatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&beforeMatch, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); _12 = Z_TYPE_P(beforeMatch) == IS_ARRAY; if (!(_12)) { _12 = Z_TYPE_P(beforeMatch) == IS_STRING; } if (_12) { ZEPHIR_CALL_METHOD(NULL, route, "beforematch", NULL, 0, beforeMatch); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (Z_TYPE_P(routeName) == IS_STRING) { ZEPHIR_CALL_METHOD(NULL, route, "setname", NULL, 0, routeName); zephir_check_call_status(); } RETURN_MM_BOOL(1); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setControllerSuffix) { zval *controllerSuffix_param = NULL; zval *controllerSuffix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &controllerSuffix_param); if (unlikely(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { zephir_get_strval(controllerSuffix, controllerSuffix_param); } else { ZEPHIR_INIT_VAR(controllerSuffix); ZVAL_EMPTY_STRING(controllerSuffix); } zephir_update_property_this(this_ptr, SL("_controllerSuffix"), controllerSuffix TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionSuffix) { zval *actionSuffix_param = NULL; zval *actionSuffix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &actionSuffix_param); if (unlikely(Z_TYPE_P(actionSuffix_param) != IS_STRING && Z_TYPE_P(actionSuffix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionSuffix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(actionSuffix_param) == IS_STRING)) { zephir_get_strval(actionSuffix, actionSuffix_param); } else { ZEPHIR_INIT_VAR(actionSuffix); ZVAL_EMPTY_STRING(actionSuffix); } zephir_update_property_this(this_ptr, SL("_actionSuffix"), actionSuffix TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getResources) { zval *_1 = NULL; zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_handlers"), PH_NOISY_CC); zephir_get_arrval(_1, _0); RETURN_CTOR(_1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Exception, phalcon, mvc_router_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Group) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Group, phalcon, mvc_router_group, phalcon_mvc_router_group_method_entry, 0); zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_prefix"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_hostname"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_paths"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_routes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_beforeMatch"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_router_group_ce TSRMLS_CC, 1, phalcon_mvc_router_groupinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Router_Group, __construct) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0; zval *paths = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &paths); if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(paths) == IS_ARRAY; if (!(_0)) { _0 = Z_TYPE_P(paths) == IS_STRING; } if (_0) { zephir_update_property_this(this_ptr, SL("_paths"), paths TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, paths); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, setHostname) { zval *hostname_param = NULL; zval *hostname = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &hostname_param); zephir_get_strval(hostname, hostname_param); zephir_update_property_this(this_ptr, SL("_hostname"), hostname TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, getHostname) { RETURN_MEMBER(this_ptr, "_hostname"); } static PHP_METHOD(Phalcon_Mvc_Router_Group, setPrefix) { zval *prefix_param = NULL; zval *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &prefix_param); zephir_get_strval(prefix, prefix_param); zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, getPrefix) { RETURN_MEMBER(this_ptr, "_prefix"); } static PHP_METHOD(Phalcon_Mvc_Router_Group, beforeMatch) { zval *beforeMatch; zephir_fetch_params(0, 1, 0, &beforeMatch); zephir_update_property_this(this_ptr, SL("_beforeMatch"), beforeMatch TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, getBeforeMatch) { RETURN_MEMBER(this_ptr, "_beforeMatch"); } static PHP_METHOD(Phalcon_Mvc_Router_Group, setPaths) { zval *paths; zephir_fetch_params(0, 1, 0, &paths); zephir_update_property_this(this_ptr, SL("_paths"), paths TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, getPaths) { RETURN_MEMBER(this_ptr, "_paths"); } static PHP_METHOD(Phalcon_Mvc_Router_Group, getRoutes) { RETURN_MEMBER(this_ptr, "_routes"); } static PHP_METHOD(Phalcon_Mvc_Router_Group, add) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *httpMethods = NULL; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!httpMethods) { httpMethods = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, httpMethods); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addGet) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "GET", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addPost) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "POST", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addPut) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PUT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addPatch) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "PATCH", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addDelete) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "DELETE", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addOptions) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "OPTIONS", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, addHead) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "HEAD", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_addroute", NULL, 0, pattern, paths, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, clear) { zval *_0; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("_routes"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Group, _addRoute) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *pattern_param = NULL, *paths = NULL, *httpMethods = NULL, *mergedPaths = NULL, *route, *defaultPaths, *processedPaths = NULL, *_1, *_2; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!httpMethods) { httpMethods = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(defaultPaths); zephir_read_property_this(&defaultPaths, this_ptr, SL("_paths"), PH_NOISY_CC); if (Z_TYPE_P(defaultPaths) == IS_ARRAY) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_CALL_CE_STATIC(&processedPaths, phalcon_mvc_router_route_ce, "getroutepaths", &_0, 78, paths); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(processedPaths, paths); } if (Z_TYPE_P(processedPaths) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedPaths); zephir_fast_array_merge(mergedPaths, &(defaultPaths), &(processedPaths) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedPaths, defaultPaths); } } else { ZEPHIR_CPY_WRT(mergedPaths, paths); } ZEPHIR_INIT_VAR(route); object_init_ex(route, phalcon_mvc_router_route_ce); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VV(_2, _1, pattern); ZEPHIR_CALL_METHOD(NULL, route, "__construct", NULL, 77, _2, mergedPaths, httpMethods); zephir_check_call_status(); zephir_update_property_array_append(this_ptr, SL("_routes"), route TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, route, "setgroup", NULL, 362, this_ptr); zephir_check_call_status(); RETURN_CCTOR(route); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_GroupInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, GroupInterface, phalcon, mvc_router_groupinterface, phalcon_mvc_router_groupinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setHostname); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getHostname); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPrefix); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPrefix); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, beforeMatch); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getBeforeMatch); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPaths); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPaths); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getRoutes); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, add); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addGet); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPost); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPut); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPatch); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addDelete); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addOptions); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addHead); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, clear); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Route) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Route, phalcon, mvc_router_route, phalcon_mvc_router_route_method_entry, 0); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_pattern"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_compiledPattern"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_paths"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_methods"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_hostname"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_converters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_id"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_beforeMatch"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_group"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_router_route_ce, SL("_uniqueId"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); zend_class_implements(phalcon_mvc_router_route_ce TSRMLS_CC, 1, phalcon_mvc_router_routeinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_Router_Route, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *httpMethods = NULL, *routeId = NULL, *uniqueId = NULL, *_0; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (!httpMethods) { httpMethods = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, pattern, paths); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_methods"), httpMethods TSRMLS_CC); ZEPHIR_OBS_VAR(uniqueId); zephir_read_static_property_ce(&uniqueId, phalcon_mvc_router_route_ce, SL("_uniqueId") TSRMLS_CC); if (Z_TYPE_P(uniqueId) == IS_NULL) { ZEPHIR_INIT_NVAR(uniqueId); ZVAL_LONG(uniqueId, 0); } ZEPHIR_CPY_WRT(routeId, uniqueId); zephir_update_property_this(this_ptr, SL("_id"), routeId TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, (zephir_get_numberval(uniqueId) + 1)); zephir_update_static_property_ce(phalcon_mvc_router_route_ce, SL("_uniqueId"), &_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, compilePattern) { zval *pattern_param = NULL, *idPattern, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (zephir_memnstr_str(pattern, SL(":"), "phalcon/mvc/router/route.zep", 87)) { ZEPHIR_INIT_VAR(idPattern); ZVAL_STRING(idPattern, "/([a-zA-Z0-9\\_\\-]+)", 1); if (zephir_memnstr_str(pattern, SL("/:module"), "phalcon/mvc/router/route.zep", 93)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "/:module", 0); zephir_fast_str_replace(&_0, &_1, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } if (zephir_memnstr_str(pattern, SL("/:controller"), "phalcon/mvc/router/route.zep", 98)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/:controller", 0); zephir_fast_str_replace(&_0, &_1, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } if (zephir_memnstr_str(pattern, SL("/:namespace"), "phalcon/mvc/router/route.zep", 103)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/:namespace", 0); zephir_fast_str_replace(&_0, &_1, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } if (zephir_memnstr_str(pattern, SL("/:action"), "phalcon/mvc/router/route.zep", 108)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/:action", 0); zephir_fast_str_replace(&_0, &_1, idPattern, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } if (zephir_memnstr_str(pattern, SL("/:params"), "phalcon/mvc/router/route.zep", 113)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/:params", 0); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "(/.*)*", 0); zephir_fast_str_replace(&_0, &_1, &_2, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } if (zephir_memnstr_str(pattern, SL("/:int"), "phalcon/mvc/router/route.zep", 118)) { ZEPHIR_INIT_NVAR(_0); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "/:int", 0); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "/([0-9]+)", 0); zephir_fast_str_replace(&_0, &_1, &_2, pattern TSRMLS_CC); zephir_get_strval(pattern, _0); } } if (zephir_memnstr_str(pattern, SL("("), "phalcon/mvc/router/route.zep", 124)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } if (zephir_memnstr_str(pattern, SL("["), "phalcon/mvc/router/route.zep", 129)) { ZEPHIR_CONCAT_SVS(return_value, "#^", pattern, "$#"); RETURN_MM(); } RETURN_CTOR(pattern); } static PHP_METHOD(Phalcon_Mvc_Router_Route, via) { zval *httpMethods; zephir_fetch_params(0, 1, 0, &httpMethods); zephir_update_property_this(this_ptr, SL("_methods"), httpMethods TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, extractNamedParams) { long _0, _5, _25; zend_bool notValid, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; int tmp, cursor, cursorVar, marker, bracketCount = 0, parenthesesCount = 0, foundPattern = 0, intermediate = 0, numberMatches = 0; char ch; zval *pattern_param = NULL, *matches, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, _18 = zval_used_for_init, _19 = zval_used_for_init, *_20 = NULL, _22 = zval_used_for_init, *_23 = NULL; zval *pattern = NULL, *route, *item = NULL, *variable = NULL, *regexp = NULL, *_4 = NULL, *_21 = NULL, *_24 = NULL, *_26 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &pattern_param); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (zephir_fast_strlen_ev(pattern) <= 0) { RETURN_MM_BOOL(0); } ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(route); ZVAL_EMPTY_STRING(route); for (_0 = 0; _0 < Z_STRLEN_P(pattern); _0++) { cursor = _0; ch = ZEPHIR_STRING_OFFSET(pattern, _0); if (parenthesesCount == 0) { if (ch == '{') { if (bracketCount == 0) { marker = (cursor + 1); intermediate = 0; notValid = 0; } bracketCount++; } else { if (ch == '}') { bracketCount--; if (intermediate > 0) { if (bracketCount == 0) { numberMatches++; ZEPHIR_INIT_NVAR(variable); ZVAL_EMPTY_STRING(variable); ZEPHIR_INIT_NVAR(regexp); ZVAL_EMPTY_STRING(regexp); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, marker); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (cursor - marker)); ZEPHIR_INIT_NVAR(_3); zephir_substr(_3, pattern, zephir_get_intval(&_1), zephir_get_intval(&_2), 0); zephir_get_strval(_4, _3); ZEPHIR_CPY_WRT(item, _4); for (_5 = 0; _5 < Z_STRLEN_P(item); _5++) { cursorVar = _5; ch = ZEPHIR_STRING_OFFSET(item, _5); if (ch == '\0') { break; } _6 = cursorVar == 0; if (_6) { _7 = ch >= 'a'; if (_7) { _7 = ch <= 'z'; } _8 = _7; if (!(_8)) { _9 = ch >= 'A'; if (_9) { _9 = ch <= 'Z'; } _8 = _9; } _6 = !(_8); } if (_6) { notValid = 1; break; } _10 = ch >= 'a'; if (_10) { _10 = ch <= 'z'; } _11 = _10; if (!(_11)) { _12 = ch >= 'A'; if (_12) { _12 = ch <= 'Z'; } _11 = _12; } _13 = _11; if (!(_13)) { _14 = ch >= '0'; if (_14) { _14 = ch <= '9'; } _13 = _14; } _15 = _13; if (!(_15)) { _15 = ch == '-'; } _16 = _15; if (!(_16)) { _16 = ch == '_'; } _17 = _16; if (!(_17)) { _17 = ch == ':'; } if (_17) { if (ch == ':') { ZEPHIR_SINIT_NVAR(_18); ZVAL_LONG(&_18, 0); ZEPHIR_SINIT_NVAR(_19); ZVAL_LONG(&_19, cursorVar); ZEPHIR_INIT_NVAR(_20); zephir_substr(_20, item, 0 , zephir_get_intval(&_19), 0); zephir_get_strval(_21, _20); ZEPHIR_CPY_WRT(variable, _21); ZEPHIR_SINIT_NVAR(_22); ZVAL_LONG(&_22, (cursorVar + 1)); ZEPHIR_INIT_NVAR(_23); zephir_substr(_23, item, zephir_get_intval(&_22), 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_get_strval(_24, _23); ZEPHIR_CPY_WRT(regexp, _24); break; } } else { notValid = 1; break; } } if (!(notValid)) { tmp = numberMatches; _6 = zephir_is_true(variable); if (_6) { _6 = zephir_is_true(regexp); } if (_6) { foundPattern = 0; for (_25 = 0; _25 < Z_STRLEN_P(regexp); _25++) { ch = ZEPHIR_STRING_OFFSET(regexp, _25); if (ch == '\0') { break; } if (!(foundPattern)) { if (ch == '(') { foundPattern = 1; } } else { if (ch == ')') { foundPattern = 2; break; } } } if (foundPattern != 2) { ZEPHIR_INIT_LNVAR(_26); ZEPHIR_CONCAT_SVS(_26, "(", regexp, ")"); zephir_concat_self(&route, _26 TSRMLS_CC); } else { zephir_concat_self(&route, regexp TSRMLS_CC); } ZEPHIR_INIT_NVAR(_20); ZVAL_LONG(_20, tmp); zephir_array_update_zval(&matches, variable, &_20, PH_COPY | PH_SEPARATE); } else { zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)")-1 TSRMLS_CC); ZEPHIR_INIT_NVAR(_23); ZVAL_LONG(_23, tmp); zephir_array_update_zval(&matches, item, &_23, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_LNVAR(_26); ZEPHIR_CONCAT_SVS(_26, "{", item, "}"); zephir_concat_self(&route, _26 TSRMLS_CC); } continue; } } } } } if (bracketCount == 0) { if (ch == '(') { parenthesesCount++; } else { if (ch == ')') { parenthesesCount--; if (parenthesesCount == 0) { numberMatches++; } } } } if (bracketCount > 0) { intermediate++; } else { zephir_concat_self_char(&route, ch TSRMLS_CC); } } zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, route); zephir_array_fast_append(return_value, matches); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, reConfigure) { int ZEPHIR_LAST_CALL_STATUS; zval *pattern_param = NULL, *paths = NULL, *routePaths = NULL, *pcrePattern = NULL, *compiledPattern = NULL, *extracted = NULL, *_0, *_1; zval *pattern = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &pattern_param, &paths); if (unlikely(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(pattern_param) == IS_STRING)) { zephir_get_strval(pattern, pattern_param); } else { ZEPHIR_INIT_VAR(pattern); ZVAL_EMPTY_STRING(pattern); } if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_SELF(&routePaths, "getroutepaths", NULL, 0, paths); zephir_check_call_status(); if (!(zephir_start_with_str(pattern, SL("#")))) { if (zephir_memnstr_str(pattern, SL("{"), "phalcon/mvc/router/route.zep", 295)) { ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, pattern); zephir_check_call_status(); ZEPHIR_OBS_VAR(pcrePattern); zephir_array_fetch_long(&pcrePattern, extracted, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 300 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); zephir_array_fetch_long(&_1, extracted, 1, PH_NOISY | PH_READONLY, "phalcon/mvc/router/route.zep", 301 TSRMLS_CC); zephir_fast_array_merge(_0, &(routePaths), &(_1) TSRMLS_CC); ZEPHIR_CPY_WRT(routePaths, _0); } else { ZEPHIR_CPY_WRT(pcrePattern, pattern); } ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, pcrePattern); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(compiledPattern, pattern); } zephir_update_property_this(this_ptr, SL("_pattern"), pattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_compiledPattern"), compiledPattern TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_paths"), routePaths TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getRoutePaths) { int _0; zval *paths = NULL, *moduleName = NULL, *controllerName = NULL, *actionName = NULL, *parts, *routePaths = NULL, *realClassName = NULL, *namespaceName, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &paths); if (!paths) { paths = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(paths) != IS_NULL) { if (Z_TYPE_P(paths) == IS_STRING) { ZEPHIR_INIT_VAR(moduleName); ZVAL_NULL(moduleName); ZEPHIR_INIT_VAR(controllerName); ZVAL_NULL(controllerName); ZEPHIR_INIT_VAR(actionName); ZVAL_NULL(actionName); ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("::"), paths, LONG_MAX TSRMLS_CC); do { _0 = zephir_fast_count_int(parts TSRMLS_CC); if (_0 == 3) { ZEPHIR_OBS_NVAR(moduleName); zephir_array_fetch_long(&moduleName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 353 TSRMLS_CC); ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 1, PH_NOISY, "phalcon/mvc/router/route.zep", 354 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 2, PH_NOISY, "phalcon/mvc/router/route.zep", 355 TSRMLS_CC); break; } if (_0 == 2) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 359 TSRMLS_CC); ZEPHIR_OBS_NVAR(actionName); zephir_array_fetch_long(&actionName, parts, 1, PH_NOISY, "phalcon/mvc/router/route.zep", 360 TSRMLS_CC); break; } if (_0 == 1) { ZEPHIR_OBS_NVAR(controllerName); zephir_array_fetch_long(&controllerName, parts, 0, PH_NOISY, "phalcon/mvc/router/route.zep", 364 TSRMLS_CC); break; } } while(0); ZEPHIR_INIT_VAR(routePaths); array_init(routePaths); if (Z_TYPE_P(moduleName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(controllerName) != IS_NULL) { if (zephir_memnstr_str(controllerName, SL("\\"), "phalcon/mvc/router/route.zep", 379)) { ZEPHIR_INIT_VAR(realClassName); zephir_get_class_ns(realClassName, controllerName, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(namespaceName); zephir_get_ns_class(namespaceName, controllerName, 0 TSRMLS_CC); if (zephir_is_true(namespaceName)) { zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(realClassName, controllerName); } ZEPHIR_INIT_VAR(_1); zephir_uncamelize(_1, realClassName); zephir_array_update_string(&routePaths, SL("controller"), &_1, PH_COPY | PH_SEPARATE); } if (Z_TYPE_P(actionName) != IS_NULL) { zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_CPY_WRT(routePaths, paths); } } else { ZEPHIR_INIT_NVAR(routePaths); array_init(routePaths); } if (Z_TYPE_P(routePaths) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The route contains invalid paths", "phalcon/mvc/router/route.zep", 411); return; } RETURN_CCTOR(routePaths); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getName) { RETURN_MEMBER(this_ptr, "_name"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, setName) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, beforeMatch) { zval *callback; zephir_fetch_params(0, 1, 0, &callback); zephir_update_property_this(this_ptr, SL("_beforeMatch"), callback TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getBeforeMatch) { RETURN_MEMBER(this_ptr, "_beforeMatch"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getRouteId) { RETURN_MEMBER(this_ptr, "_id"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getPattern) { RETURN_MEMBER(this_ptr, "_pattern"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getCompiledPattern) { RETURN_MEMBER(this_ptr, "_compiledPattern"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getPaths) { RETURN_MEMBER(this_ptr, "_paths"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getReversedPaths) { HashTable *_2; HashPosition _1; zval *reversed, *path = NULL, *position = NULL, *_0, **_3; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(reversed); array_init(reversed); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_paths"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/mvc/router/route.zep", 502); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(path, _2, _1); ZEPHIR_GET_HVALUE(position, _3); zephir_array_update_zval(&reversed, position, &path, PH_COPY | PH_SEPARATE); } RETURN_CCTOR(reversed); } static PHP_METHOD(Phalcon_Mvc_Router_Route, setHttpMethods) { zval *httpMethods; zephir_fetch_params(0, 1, 0, &httpMethods); zephir_update_property_this(this_ptr, SL("_methods"), httpMethods TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getHttpMethods) { RETURN_MEMBER(this_ptr, "_methods"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, setHostname) { zval *hostname_param = NULL; zval *hostname = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &hostname_param); if (unlikely(Z_TYPE_P(hostname_param) != IS_STRING && Z_TYPE_P(hostname_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hostname' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(hostname_param) == IS_STRING)) { zephir_get_strval(hostname, hostname_param); } else { ZEPHIR_INIT_VAR(hostname); ZVAL_EMPTY_STRING(hostname); } zephir_update_property_this(this_ptr, SL("_hostname"), hostname TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getHostname) { RETURN_MEMBER(this_ptr, "_hostname"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, setGroup) { zval *group; zephir_fetch_params(0, 1, 0, &group); zephir_update_property_this(this_ptr, SL("_group"), group TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getGroup) { RETURN_MEMBER(this_ptr, "_group"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, convert) { zval *name_param = NULL, *converter; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &converter); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_converters"), name, converter TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_Router_Route, getConverters) { RETURN_MEMBER(this_ptr, "_converters"); } static PHP_METHOD(Phalcon_Mvc_Router_Route, reset) { zephir_update_static_property_ce(phalcon_mvc_router_route_ce, SL("_uniqueId"), &ZEPHIR_GLOBAL(global_null) TSRMLS_CC); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_RouteInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, RouteInterface, phalcon, mvc_router_routeinterface, phalcon_mvc_router_routeinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, compilePattern); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, via); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reConfigure); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setName); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHttpMethods); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getRouteId); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPattern); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getCompiledPattern); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPaths); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getReversedPaths); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHttpMethods); ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reset); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Url, Exception, phalcon, mvc_url_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <ext/standard/php_smart_str.h> #include <ext/standard/php_string.h> static void phalcon_get_uri(zval *return_value, zval *path) { int i, found = 0, mark = 0; char *cursor, *str, ch; if (Z_TYPE_P(path) != IS_STRING) { RETURN_EMPTY_STRING(); } if (Z_STRLEN_P(path) > 0) { cursor = Z_STRVAL_P(path) + Z_STRLEN_P(path) - 1; for (i = Z_STRLEN_P(path); i > 0; i--) { ch = *cursor; if (ch == '/' || ch == '\\') { found++; if (found == 1) { mark = i - 1; } else { str = emalloc(mark - i + 1); memcpy(str, Z_STRVAL_P(path) + i, mark - i); str[mark - i] = '\0'; ZVAL_STRINGL(return_value, str, mark - i, 0); return; } } cursor--; } } RETURN_EMPTY_STRING(); } zval *phalcon_replace_marker(int named, zval *paths, zval *replacements, unsigned long *position, char *cursor, char *marker){ zval **zv, **tmp; int result = FAILURE; unsigned int length = 0, variable_length, ch, j; char *item = NULL, *cursor_var, *variable = NULL; int not_valid = 0; if (named) { length = cursor - marker - 1; item = estrndup(marker + 1, length); cursor_var = item; marker = item; for (j = 0; j < length; j++) { ch = *cursor_var; if (ch == '\0') { not_valid = 1; break; } if (j == 0 && !((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z'))){ not_valid = 1; break; } if ((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == ':') { if (ch == ':') { variable_length = cursor_var - marker; variable = estrndup(marker, variable_length); break; } } else { not_valid = 1; break; } cursor_var++; } } if (!not_valid) { if (zend_hash_index_exists(Z_ARRVAL_P(paths), *position)) { if (named) { if (variable) { efree(item); item = variable; length = variable_length; } if (zend_hash_exists(Z_ARRVAL_P(replacements), item, length + 1)) { if ((result = zend_hash_find(Z_ARRVAL_P(replacements), item, length + 1, (void**) &zv)) == SUCCESS) { efree(item); (*position)++; return *zv; } } } else { if ((result = zend_hash_index_find(Z_ARRVAL_P(paths), *position, (void**) &zv)) == SUCCESS) { if (Z_TYPE_PP(zv) == IS_STRING) { if (zend_hash_exists(Z_ARRVAL_P(replacements), Z_STRVAL_PP(zv), Z_STRLEN_PP(zv) + 1)) { if ((result = zend_hash_find(Z_ARRVAL_P(replacements), Z_STRVAL_PP(zv), Z_STRLEN_PP(zv) + 1, (void**) &tmp)) == SUCCESS) { (*position)++; return *tmp; } } } } } } (*position)++; } if (item) { efree(item); } return NULL; } static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths, zval *replacements TSRMLS_DC){ char *cursor, *marker = NULL; unsigned int bracket_count = 0, parentheses_count = 0, intermediate = 0; unsigned char ch; smart_str route_str = {0}; ulong position = 1; int i; zval *replace, replace_copy; int use_copy, looking_placeholder = 0; if (Z_TYPE_P(pattern) != IS_STRING || Z_TYPE_P(replacements) != IS_ARRAY || Z_TYPE_P(paths) != IS_ARRAY) { ZVAL_NULL(return_value); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid arguments supplied for phalcon_replace_paths()"); return; } if (Z_STRLEN_P(pattern) <= 0) { ZVAL_FALSE(return_value); return; } cursor = Z_STRVAL_P(pattern); if (*cursor == '/') { ++cursor; i = 1; } else { i = 0; } if (!zend_hash_num_elements(Z_ARRVAL_P(paths))) { ZVAL_STRINGL(return_value, Z_STRVAL_P(pattern) + i, Z_STRLEN_P(pattern) - i, 1); return; } for (; i < Z_STRLEN_P(pattern); ++i) { ch = *cursor; if (ch == '\0') { break; } if (parentheses_count == 0 && !looking_placeholder) { if (ch == '{') { if (bracket_count == 0) { marker = cursor; intermediate = 0; } bracket_count++; } else { if (ch == '}') { bracket_count--; if (intermediate > 0) { if (bracket_count == 0) { replace = phalcon_replace_marker(1, paths, replacements, &position, cursor, marker); if (replace) { use_copy = 0; if (Z_TYPE_P(replace) != IS_STRING) { zend_make_printable_zval(replace, &replace_copy, &use_copy); if (use_copy) { replace = &replace_copy; } } smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); if (use_copy) { zval_dtor(&replace_copy); } } cursor++; continue; } } } } } if (bracket_count == 0 && !looking_placeholder) { if (ch == '(') { if (parentheses_count == 0) { marker = cursor; intermediate = 0; } parentheses_count++; } else { if (ch == ')') { parentheses_count--; if (intermediate > 0) { if (parentheses_count == 0) { replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); if (replace) { use_copy = 0; if (Z_TYPE_P(replace) != IS_STRING) { zend_make_printable_zval(replace, &replace_copy, &use_copy); if (use_copy) { replace = &replace_copy; } } smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); if (use_copy) { zval_dtor(&replace_copy); } } cursor++; continue; } } } } } if (bracket_count == 0 && parentheses_count == 0) { if (looking_placeholder) { if (intermediate > 0) { if (ch < 'a' || ch > 'z' || i == (Z_STRLEN_P(pattern) - 1)) { replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); if (replace) { use_copy = 0; if (Z_TYPE_P(replace) != IS_STRING) { zend_make_printable_zval(replace, &replace_copy, &use_copy); if (use_copy) { replace = &replace_copy; } } smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); if (use_copy) { zval_dtor(&replace_copy); } } looking_placeholder = 0; continue; } } } else { if (ch == ':') { looking_placeholder = 1; marker = cursor; intermediate = 0; } } } if (bracket_count > 0 || parentheses_count > 0 || looking_placeholder) { intermediate++; } else { smart_str_appendc(&route_str, ch); } cursor++; } smart_str_0(&route_str); if (route_str.len) { RETURN_STRINGL(route_str.c, route_str.len, 0); } else { smart_str_free(&route_str); RETURN_EMPTY_STRING(); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_User_Component) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\User, Component, phalcon, mvc_user_component, phalcon_di_injectable_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_User_Module) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\User, Module, phalcon, mvc_user_module, phalcon_di_injectable_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_User_Plugin) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\User, Plugin, phalcon, mvc_user_plugin, phalcon_di_injectable_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View, Engine, phalcon, mvc_view_engine, phalcon_di_injectable_ce, phalcon_mvc_view_engine_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_mvc_view_engine_ce, SL("_view"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View_Engine, __construct) { zval *view, *dependencyInjector = NULL; zephir_fetch_params(0, 1, 1, &view, &dependencyInjector); if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } zephir_update_property_this(this_ptr, SL("_view"), view TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_View_Engine, getContent) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "getcontent", NULL, 0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine, partial) { int ZEPHIR_LAST_CALL_STATUS; zval *partialPath_param = NULL, *params = NULL, *_0; zval *partialPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); if (unlikely(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(partialPath_param) == IS_STRING)) { zephir_get_strval(partialPath, partialPath_param); } else { ZEPHIR_INIT_VAR(partialPath); ZVAL_EMPTY_STRING(partialPath); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "partial", NULL, 0, partialPath, params); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine, getView) { RETURN_MEMBER(this_ptr, "_view"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_EngineInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\View, EngineInterface, phalcon, mvc_view_engineinterface, phalcon_mvc_view_engineinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Mvc_View_EngineInterface, getContent); ZEPHIR_DOC_METHOD(Phalcon_Mvc_View_EngineInterface, partial); ZEPHIR_DOC_METHOD(Phalcon_Mvc_View_EngineInterface, render); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View, Exception, phalcon, mvc_view_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Simple) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View, Simple, phalcon, mvc_view_simple, phalcon_di_injectable_ce, phalcon_mvc_view_simple_method_entry, 0); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_viewsDir"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_partialsDir"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_viewParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_simple_ce, SL("_engines"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_registeredEngines"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_activeRenderPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_content"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_simple_ce, SL("_cache"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_simple_ce, SL("_cacheOptions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_view_simple_ce TSRMLS_CC, 1, phalcon_mvc_viewbaseinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View_Simple, getRegisteredEngines) { RETURN_MEMBER(this_ptr, "_registeredEngines"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, __construct) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_View_Simple, setViewsDir) { zval *viewsDir_param = NULL; zval *viewsDir = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &viewsDir_param); if (unlikely(Z_TYPE_P(viewsDir_param) != IS_STRING && Z_TYPE_P(viewsDir_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewsDir' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewsDir_param) == IS_STRING)) { zephir_get_strval(viewsDir, viewsDir_param); } else { ZEPHIR_INIT_VAR(viewsDir); ZVAL_EMPTY_STRING(viewsDir); } zephir_update_property_this(this_ptr, SL("_viewsDir"), viewsDir TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getViewsDir) { RETURN_MEMBER(this_ptr, "_viewsDir"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, registerEngines) { zval *engines_param = NULL; zval *engines = NULL; zephir_fetch_params(0, 1, 0, &engines_param); engines = engines_param; zephir_update_property_this(this_ptr, SL("_registeredEngines"), engines TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_View_Simple, _loadTemplateEngines) { zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *engines = NULL, *dependencyInjector, *registeredEngines, *arguments, *extension = NULL, *engineService = NULL, *engineObject = NULL, *_0 = NULL, **_3, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(engines); zephir_read_property_this(&engines, this_ptr, SL("_engines"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(engines)) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(engines); array_init(engines); ZEPHIR_OBS_VAR(registeredEngines); zephir_read_property_this(®isteredEngines, this_ptr, SL("_registeredEngines"), PH_NOISY_CC); if (Z_TYPE_P(registeredEngines) != IS_ARRAY) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_php_ce); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 364, this_ptr, dependencyInjector); zephir_check_call_status(); zephir_array_update_string(&engines, SL(".phtml"), &_0, PH_COPY | PH_SEPARATE); } else { if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injector container is required to obtain the application services", "phalcon/mvc/view/simple.zep", 139); return; } ZEPHIR_INIT_VAR(arguments); zephir_create_array(arguments, 2, 0 TSRMLS_CC); zephir_array_fast_append(arguments, this_ptr); zephir_array_fast_append(arguments, dependencyInjector); zephir_is_iterable(registeredEngines, &_2, &_1, 0, 0, "phalcon/mvc/view/simple.zep", 171); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(extension, _2, _1); ZEPHIR_GET_HVALUE(engineService, _3); if (Z_TYPE_P(engineService) == IS_OBJECT) { if (zephir_instance_of_ev(engineService, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(engineObject); ZEPHIR_CALL_USER_FUNC_ARRAY(engineObject, engineService, arguments); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(engineObject, engineService); } } else { if (Z_TYPE_P(engineService) == IS_STRING) { ZEPHIR_CALL_METHOD(&engineObject, dependencyInjector, "getshared", &_4, 0, engineService, arguments); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SV(_5, "Invalid template engine registration for extension: ", extension); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_6, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/simple.zep", 165 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } zephir_array_update_zval(&engines, extension, &engineObject, PH_COPY | PH_SEPARATE); } } zephir_update_property_this(this_ptr, SL("_engines"), engines TSRMLS_CC); } else { ZEPHIR_OBS_NVAR(engines); zephir_read_property_this(&engines, this_ptr, SL("_engines"), PH_NOISY_CC); } RETURN_CCTOR(engines); } static PHP_METHOD(Phalcon_Mvc_View_Simple, _internalRender) { zephir_fcall_cache_entry *_11 = NULL, *_13 = NULL; HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zend_bool notExists, mustClean, _7, _9; zval *path_param = NULL, *params, *eventsManager, *engines = NULL, *extension = NULL, *engine = NULL, *viewEnginePath = NULL, *viewsDirPath, *_0 = NULL, *_1 = NULL, *_2, **_5, *_6 = NULL, _8 = zval_used_for_init, *_10 = NULL, *_12 = NULL; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &path_param, ¶ms); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } ZEPHIR_OBS_VAR(eventsManager); zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_activeRenderPath"), path TSRMLS_CC); } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "view:beforeRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { RETURN_MM_NULL(); } } notExists = 1; mustClean = 1; _2 = zephir_fetch_nproperty_this(this_ptr, SL("_viewsDir"), PH_NOISY_CC); ZEPHIR_INIT_VAR(viewsDirPath); ZEPHIR_CONCAT_VV(viewsDirPath, _2, path); ZEPHIR_CALL_METHOD(&engines, this_ptr, "_loadtemplateengines", NULL, 0); zephir_check_call_status(); zephir_is_iterable(engines, &_4, &_3, 0, 0, "phalcon/mvc/view/simple.zep", 261); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(extension, _4, _3); ZEPHIR_GET_HVALUE(engine, _5); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_VV(_6, viewsDirPath, extension); if ((zephir_file_exists(_6 TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_NVAR(viewEnginePath); ZEPHIR_CONCAT_VV(viewEnginePath, viewsDirPath, extension); } else { _7 = zephir_is_true(extension); if (_7) { ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, -zephir_fast_strlen_ev(extension)); ZEPHIR_INIT_NVAR(_1); zephir_substr(_1, viewsDirPath, zephir_get_intval(&_8), 0, ZEPHIR_SUBSTR_NO_LENGTH); _7 = ZEPHIR_IS_EQUAL(_1, extension); } _9 = _7; if (_9) { _9 = (zephir_file_exists(viewsDirPath TSRMLS_CC) == SUCCESS); } if (_9) { ZEPHIR_CPY_WRT(viewEnginePath, viewsDirPath); } else { ZEPHIR_INIT_NVAR(viewEnginePath); ZVAL_STRING(viewEnginePath, "", 1); } } if (zephir_is_true(viewEnginePath)) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_10); ZVAL_STRING(_10, "view:beforeRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", &_11, 0, _10, this_ptr, viewEnginePath); zephir_check_temp_parameter(_10); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { continue; } } ZEPHIR_INIT_NVAR(_10); if (mustClean) { ZVAL_BOOL(_10, 1); } else { ZVAL_BOOL(_10, 0); } ZEPHIR_CALL_METHOD(NULL, engine, "render", NULL, 0, viewEnginePath, params, _10); zephir_check_call_status(); notExists = 0; if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_12); ZVAL_STRING(_12, "view:afterRenderView", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_13, 0, _12, this_ptr); zephir_check_temp_parameter(_12); zephir_check_call_status(); } break; } } if (notExists == 1) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "View '", viewsDirPath, "' was not found in the views directory"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/view/simple.zep", 262 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "view:afterRender", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _1, this_ptr); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, render) { int ZEPHIR_LAST_CALL_STATUS; zval *path_param = NULL, *params = NULL, *cache = NULL, *key = NULL, *lifetime = NULL, *cacheOptions, *content = NULL, *viewParams, *mergedParams = NULL, *_0 = NULL, *_1, *_2 = NULL; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &path_param, ¶ms); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_METHOD(&cache, this_ptr, "getcache", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(cache) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_0, cache, "isstarted", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_INIT_VAR(key); ZVAL_NULL(key); ZEPHIR_INIT_VAR(lifetime); ZVAL_NULL(lifetime); ZEPHIR_OBS_VAR(cacheOptions); zephir_read_property_this(&cacheOptions, this_ptr, SL("_cacheOptions"), PH_NOISY_CC); if (Z_TYPE_P(cacheOptions) == IS_ARRAY) { ZEPHIR_OBS_NVAR(key); zephir_array_isset_string_fetch(&key, cacheOptions, SS("key"), 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(lifetime); zephir_array_isset_string_fetch(&lifetime, cacheOptions, SS("lifetime"), 0 TSRMLS_CC); } if (Z_TYPE_P(key) == IS_NULL) { ZEPHIR_INIT_NVAR(key); zephir_md5(key, path); } ZEPHIR_CALL_METHOD(&content, cache, "start", NULL, 0, key, lifetime); zephir_check_call_status(); if (Z_TYPE_P(content) != IS_NULL) { zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_CCTOR(content); } } } ZEPHIR_INIT_VAR(_1); zephir_create_symbol_table(TSRMLS_C); ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (Z_TYPE_P(params) == IS_ARRAY) { if (Z_TYPE_P(viewParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(viewParams), &(params) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, params); } } else { ZEPHIR_CPY_WRT(mergedParams, viewParams); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_internalrender", NULL, 383, path, mergedParams); zephir_check_call_status(); if (Z_TYPE_P(cache) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_0, cache, "isstarted", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(&_2, cache, "isfresh", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_2)) { ZEPHIR_CALL_METHOD(NULL, cache, "save", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, cache, "stop", NULL, 0); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, cache, "stop", NULL, 0); zephir_check_call_status(); } } ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); RETURN_MM_MEMBER(this_ptr, "_content"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, partial) { int ZEPHIR_LAST_CALL_STATUS; zval *partialPath_param = NULL, *params = NULL, *viewParams, *mergedParams = NULL, *_0, *_1; zval *partialPath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); if (unlikely(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(partialPath_param) == IS_STRING)) { zephir_get_strval(partialPath, partialPath_param); } else { ZEPHIR_INIT_VAR(partialPath); ZVAL_EMPTY_STRING(partialPath); } if (!params) { params = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 119); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (Z_TYPE_P(viewParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(viewParams), &(params) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, params); } ZEPHIR_INIT_VAR(_0); zephir_create_symbol_table(TSRMLS_C); } else { ZEPHIR_CPY_WRT(mergedParams, params); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_internalrender", NULL, 383, partialPath, mergedParams); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_viewParams"), viewParams TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 121); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_content"), PH_NOISY_CC); zend_print_zval(_1, 0); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, setCacheOptions) { zval *options; zephir_fetch_params(0, 1, 0, &options); zephir_update_property_this(this_ptr, SL("_cacheOptions"), options TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getCacheOptions) { RETURN_MEMBER(this_ptr, "_cacheOptions"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, _createCache) { int ZEPHIR_LAST_CALL_STATUS; zval *dependencyInjector, *cacheService = NULL, *cacheOptions, *viewCache = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injector container is required to obtain the view cache services", "phalcon/mvc/view/simple.zep", 478); return; } ZEPHIR_INIT_VAR(cacheService); ZVAL_STRING(cacheService, "viewCache", 1); ZEPHIR_OBS_VAR(cacheOptions); zephir_read_property_this(&cacheOptions, this_ptr, SL("_cacheOptions"), PH_NOISY_CC); if (Z_TYPE_P(cacheOptions) == IS_ARRAY) { if (zephir_array_isset_string(cacheOptions, SS("service"))) { ZEPHIR_OBS_NVAR(cacheService); zephir_array_isset_string_fetch(&cacheService, cacheOptions, SS("service"), 0 TSRMLS_CC); } } ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "getshared", NULL, 0, cacheService); zephir_check_call_status(); ZEPHIR_CPY_WRT(viewCache, _0); if (Z_TYPE_P(viewCache) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "The injected caching service is invalid", "phalcon/mvc/view/simple.zep", 495); return; } RETURN_CCTOR(viewCache); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getCache) { int ZEPHIR_LAST_CALL_STATUS; zval *cache = NULL; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(cache); zephir_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY_CC); if (zephir_is_true(cache)) { if (Z_TYPE_P(cache) != IS_OBJECT) { ZEPHIR_CALL_METHOD(&cache, this_ptr, "_createcache", NULL, 0); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } } RETURN_CCTOR(cache); } static PHP_METHOD(Phalcon_Mvc_View_Simple, cache) { zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_true); } if (Z_TYPE_P(options) == IS_ARRAY) { if (1) { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_cacheOptions"), options TSRMLS_CC); } else { if (zephir_is_true(options)) { if (1) { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } else { if (0) { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_cache"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } } RETURN_THISW(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, setParamToView) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, setVars) { zend_bool merge; zval *params_param = NULL, *merge_param = NULL, *viewParams, *mergedParams = NULL; zval *params = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, ¶ms_param, &merge_param); params = params_param; if (!merge_param) { merge = 1; } else { merge = zephir_get_boolval(merge_param); } if (merge) { ZEPHIR_OBS_VAR(viewParams); zephir_read_property_this(&viewParams, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (Z_TYPE_P(viewParams) == IS_ARRAY) { ZEPHIR_INIT_VAR(mergedParams); zephir_fast_array_merge(mergedParams, &(viewParams), &(params) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(mergedParams, params); } zephir_update_property_this(this_ptr, SL("_viewParams"), mergedParams TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_viewParams"), params TSRMLS_CC); } RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, setVar) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getVar) { zval *key_param = NULL, *value, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_viewParams"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getParamsToView) { RETURN_MEMBER(this_ptr, "_viewParams"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, setContent) { zval *content_param = NULL; zval *content = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &content_param); if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(content_param) == IS_STRING)) { zephir_get_strval(content, content_param); } else { ZEPHIR_INIT_VAR(content); ZVAL_EMPTY_STRING(content); } zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getContent) { RETURN_MEMBER(this_ptr, "_content"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, getActiveRenderPath) { RETURN_MEMBER(this_ptr, "_activeRenderPath"); } static PHP_METHOD(Phalcon_Mvc_View_Simple, __set) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Simple, __get) { zval *key_param = NULL, *value, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_viewParams"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Php) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View\\Engine, Php, phalcon, mvc_view_engine_php, phalcon_mvc_view_engine_ce, phalcon_mvc_view_engine_php_method_entry, 0); zend_class_implements(phalcon_mvc_view_engine_php_ce TSRMLS_CC, 1, phalcon_mvc_view_engineinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Php, render) { HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zend_bool mustClean; zval *path_param = NULL, *params, *mustClean_param = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5 = NULL; zval *path = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &path_param, ¶ms, &mustClean_param); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (!mustClean_param) { mustClean = 0; } else { mustClean = zephir_get_boolval(mustClean_param); } if (mustClean == 1) { ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 365); zephir_check_call_status(); } if (Z_TYPE_P(params) == IS_ARRAY) { zephir_is_iterable(params, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/php.zep", 51); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CPY_WRT(_3, value); if (zephir_set_symbol(key, _3 TSRMLS_CC) == FAILURE){ return; } } } if (zephir_require_zval(path TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } if (mustClean == 1) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_5, "ob_get_contents", NULL, 120); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _4, "setcontent", NULL, 0, _5); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Volt) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View\\Engine, Volt, phalcon, mvc_view_engine_volt, phalcon_mvc_view_engine_ce, phalcon_mvc_view_engine_volt_method_entry, 0); zend_declare_property_null(phalcon_mvc_view_engine_volt_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_ce, SL("_compiler"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_ce, SL("_macros"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_view_engine_volt_ce TSRMLS_CC, 1, phalcon_mvc_view_engineinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, setOptions) { zval *options_param = NULL; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, getCompiler) { int ZEPHIR_LAST_CALL_STATUS; zval *compiler = NULL, *dependencyInjector = NULL, *options, *_0, *_1; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(compiler); zephir_read_property_this(&compiler, this_ptr, SL("_compiler"), PH_NOISY_CC); if (Z_TYPE_P(compiler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(compiler); object_init_ex(compiler, phalcon_mvc_view_engine_volt_compiler_ce); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, compiler, "__construct", NULL, 366, _0); zephir_check_call_status(); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _1); if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_CALL_METHOD(NULL, compiler, "setdi", NULL, 367, dependencyInjector); zephir_check_call_status(); } ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, compiler, "setoptions", NULL, 368, options); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_compiler"), compiler TSRMLS_CC); } RETURN_CCTOR(compiler); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, render) { HashTable *_1; HashPosition _0; int ZEPHIR_LAST_CALL_STATUS; zend_bool mustClean; zval *templatePath_param = NULL, *params, *mustClean_param = NULL, *compiler = NULL, *compiledTemplatePath = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL, *_4, *_5 = NULL; zval *templatePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &templatePath_param, ¶ms, &mustClean_param); if (unlikely(Z_TYPE_P(templatePath_param) != IS_STRING && Z_TYPE_P(templatePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'templatePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(templatePath_param) == IS_STRING)) { zephir_get_strval(templatePath, templatePath_param); } else { ZEPHIR_INIT_VAR(templatePath); ZVAL_EMPTY_STRING(templatePath); } if (!mustClean_param) { mustClean = 0; } else { mustClean = zephir_get_boolval(mustClean_param); } if (mustClean) { ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 365); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&compiler, this_ptr, "getcompiler", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, compiler, "compile", NULL, 0, templatePath); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&compiledTemplatePath, compiler, "getcompiledtemplatepath", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(params) == IS_ARRAY) { zephir_is_iterable(params, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/volt.zep", 118); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CPY_WRT(_3, value); if (zephir_set_symbol(key, _3 TSRMLS_CC) == FAILURE){ return; } } } if (zephir_require_zval(compiledTemplatePath TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } if (mustClean) { _4 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC); ZEPHIR_CALL_FUNCTION(&_5, "ob_get_contents", NULL, 120); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _4, "setcontent", NULL, 0, _5); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, length) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0; zval *item, *length = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &item); ZEPHIR_INIT_VAR(length); ZVAL_LONG(length, 0); _0 = Z_TYPE_P(item) == IS_OBJECT; if (!(_0)) { _0 = Z_TYPE_P(item) == IS_ARRAY; } if (_0) { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_count_int(item TSRMLS_CC)); } else { if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 360, item); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(item)); } } RETURN_CCTOR(length); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, isIncluded) { int ZEPHIR_LAST_CALL_STATUS; zval *needle, *haystack, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &needle, &haystack); if (Z_TYPE_P(haystack) == IS_ARRAY) { RETURN_MM_BOOL(zephir_fast_in_array(needle, haystack TSRMLS_CC)); } if (Z_TYPE_P(haystack) == IS_STRING) { if ((zephir_function_exists_ex(SS("mb_strpos") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&_0, "mb_strpos", NULL, 369, haystack, needle); zephir_check_call_status(); RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(_0)); } ZEPHIR_INIT_VAR(_1); zephir_fast_strpos(_1, haystack, needle, 0 ); RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(_1)); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Invalid haystack", "phalcon/mvc/view/engine/volt.zep", 166); return; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, convertEncoding) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0, _1; zval *text_param = NULL, *from_param = NULL, *to_param = NULL; zval *text = NULL, *from = NULL, *to = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &text_param, &from_param, &to_param); zephir_get_strval(text, text_param); if (unlikely(Z_TYPE_P(from_param) != IS_STRING && Z_TYPE_P(from_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { ZEPHIR_INIT_VAR(from); ZVAL_EMPTY_STRING(from); } if (unlikely(Z_TYPE_P(to_param) != IS_STRING && Z_TYPE_P(to_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'to' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(to_param) == IS_STRING)) { zephir_get_strval(to, to_param); } else { ZEPHIR_INIT_VAR(to); ZVAL_EMPTY_STRING(to); } _0 = ZEPHIR_IS_STRING(from, "latin1"); if (!(_0)) { _0 = ZEPHIR_IS_STRING(to, "utf8"); } if (_0) { ZEPHIR_RETURN_CALL_FUNCTION("utf8_encode", NULL, 370, text); zephir_check_call_status(); RETURN_MM(); } _1 = ZEPHIR_IS_STRING(to, "latin1"); if (!(_1)) { _1 = ZEPHIR_IS_STRING(from, "utf8"); } if (_1) { ZEPHIR_RETURN_CALL_FUNCTION("utf8_decode", NULL, 371, text); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("mb_convert_encoding") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_encoding", NULL, 181, text, from, to); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("iconv") TSRMLS_CC) == SUCCESS)) { ZEPHIR_RETURN_CALL_FUNCTION("iconv", NULL, 372, from, to, text); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Any of 'mbstring' or 'iconv' is required to perform the charset conversion", "phalcon/mvc/view/engine/volt.zep", 205); return; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, slice) { zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_6 = NULL; zend_bool _1; int start, position, ZEPHIR_LAST_CALL_STATUS; zval *value, *start_param = NULL, *end = NULL, *length, *slice, *_0 = NULL, *_2 = NULL, _5 = zval_used_for_init; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &value, &start_param, &end); if (!start_param) { start = 0; } else { start = zephir_get_intval(start_param); } if (!end) { ZEPHIR_CPY_WRT(end, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(end); } if (Z_TYPE_P(value) == IS_OBJECT) { if (Z_TYPE_P(end) == IS_NULL) { ZEPHIR_INIT_NVAR(end); ZVAL_LONG(end, (zephir_fast_count_int(value TSRMLS_CC) - 1)); } position = 0; ZEPHIR_INIT_VAR(slice); array_init(slice); ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_0, value, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_0))) { break; } _1 = position >= start; if (_1) { _1 = ZEPHIR_GE_LONG(end, position); } if (_1) { ZEPHIR_CALL_METHOD(&_2, value, "current", &_3, 0); zephir_check_call_status(); zephir_array_append(&slice, _2, PH_SEPARATE, "phalcon/mvc/view/engine/volt.zep", 231); } ZEPHIR_CALL_METHOD(NULL, value, "next", &_4, 0); zephir_check_call_status(); position++; } RETURN_CCTOR(slice); } ZEPHIR_INIT_VAR(length); if (Z_TYPE_P(end) != IS_NULL) { ZVAL_LONG(length, (((zephir_get_numberval(end) - start)) + 1)); } else { ZVAL_NULL(length); } if (Z_TYPE_P(value) == IS_ARRAY) { ZEPHIR_SINIT_VAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 373, value, &_5, length); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("mb_substr") TSRMLS_CC) == SUCCESS)) { if (Z_TYPE_P(length) != IS_NULL) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("mb_substr", &_6, 374, value, &_5, length); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); ZEPHIR_RETURN_CALL_FUNCTION("mb_substr", &_6, 374, value, &_5); zephir_check_call_status(); RETURN_MM(); } if (Z_TYPE_P(length) != IS_NULL) { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); zephir_substr(return_value, value, zephir_get_intval(&_5), zephir_get_intval(length), 0); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, start); zephir_substr(return_value, value, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, sort) { int ZEPHIR_LAST_CALL_STATUS; zval *value_param = NULL; zval *value = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value_param); zephir_get_arrval(value, value_param); ZEPHIR_MAKE_REF(value); ZEPHIR_CALL_FUNCTION(NULL, "asort", NULL, 375, value); ZEPHIR_UNREF(value); zephir_check_call_status(); RETURN_CTOR(value); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt, callMacro) { int ZEPHIR_LAST_CALL_STATUS; zval *arguments = NULL; zval *name_param = NULL, *arguments_param = NULL, *macro, *_0, *_1; zval *name = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &arguments_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_get_arrval(arguments, arguments_param); ZEPHIR_OBS_VAR(macro); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_macros"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(¯o, _0, name, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_view_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Macro '", name, "' does not exist"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/view/engine/volt.zep", 293 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_RETURN_CALL_FUNCTION("call_user_func", NULL, 376, macro, arguments); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Volt_Compiler) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\View\\Engine\\Volt, Compiler, phalcon, mvc_view_engine_volt_compiler, phalcon_mvc_view_engine_volt_compiler_method_entry, 0); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_view"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_arrayHelpers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_engine_volt_compiler_ce, SL("_level"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_engine_volt_compiler_ce, SL("_foreachLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_engine_volt_compiler_ce, SL("_blockLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_mvc_view_engine_volt_compiler_ce, SL("_exprLevel"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_engine_volt_compiler_ce, SL("_extended"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_mvc_view_engine_volt_compiler_ce, SL("_autoescape"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_extendedBlocks"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_currentBlock"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_blocks"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_forElsePointers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_loopPointers"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_extensions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_functions"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_macros"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_prefix"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_currentPath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_mvc_view_engine_volt_compiler_ce, SL("_compiledTemplatePath"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_mvc_view_engine_volt_compiler_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, __construct) { zval *view = NULL; zephir_fetch_params(0, 0, 1, &view); if (!view) { view = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(view) == IS_OBJECT) { zephir_update_property_this(this_ptr, SL("_view"), view TSRMLS_CC); } } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, setOptions) { zval *options_param = NULL; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, setOption) { zval *option_param = NULL, *value; zval *option = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &option_param, &value); if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(option_param) == IS_STRING)) { zephir_get_strval(option, option_param); } else { ZEPHIR_INIT_VAR(option); ZVAL_EMPTY_STRING(option); } zephir_update_property_array(this_ptr, SL("_options"), option, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getOption) { zval *option_param = NULL, *value, *_0; zval *option = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &option_param); if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(option_param) == IS_STRING)) { zephir_get_strval(option, option_param); } else { ZEPHIR_INIT_VAR(option); ZVAL_EMPTY_STRING(option); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _0, option, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETURN_MM_NULL(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, fireExtensionEvent) { zval *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *name_param = NULL, *arguments = NULL, *extensions, *extension = NULL, *status = NULL, **_2; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &name_param, &arguments); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } if (!arguments) { arguments = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); if (Z_TYPE_P(extensions) == IS_ARRAY) { zephir_is_iterable(extensions, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 189); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(extension, _2); if ((zephir_method_exists(extension, name TSRMLS_CC) == SUCCESS)) { if (Z_TYPE_P(arguments) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_fast_append(_3, extension); zephir_array_fast_append(_3, name); ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC_ARRAY(status, _3, arguments); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_fast_append(_3, extension); zephir_array_fast_append(_3, name); ZEPHIR_INIT_NVAR(status); ZEPHIR_CALL_USER_FUNC(status, _3); zephir_check_call_status(); } if (Z_TYPE_P(status) == IS_STRING) { RETURN_CCTOR(status); } } } } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, addExtension) { int ZEPHIR_LAST_CALL_STATUS; zval *extension; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &extension); if (Z_TYPE_P(extension) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "The extension is not valid", "phalcon/mvc/view/engine/volt/compiler.zep", 198); return; } if ((zephir_method_exists_ex(extension, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, extension, "initialize", NULL, 0, this_ptr); zephir_check_call_status(); } zephir_update_property_array_append(this_ptr, SL("_extensions"), extension TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getExtensions) { RETURN_MEMBER(this_ptr, "_extensions"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, addFunction) { zval *name_param = NULL, *definition; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_functions"), name, definition TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getFunctions) { RETURN_MEMBER(this_ptr, "_functions"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, addFilter) { zval *name_param = NULL, *definition; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name_param, &definition); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_array(this_ptr, SL("_filters"), name, definition TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getFilters) { RETURN_MEMBER(this_ptr, "_filters"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, setUniquePrefix) { zval *prefix_param = NULL; zval *prefix = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &prefix_param); if (unlikely(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(prefix_param) == IS_STRING)) { zephir_get_strval(prefix, prefix_param); } else { ZEPHIR_INIT_VAR(prefix); ZVAL_EMPTY_STRING(prefix); } zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getUniquePrefix) { zval *_1; int ZEPHIR_LAST_CALL_STATUS; zval *prefix = NULL, *calculatedPrefix, *_0; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(prefix); zephir_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); if (!(zephir_is_true(prefix))) { ZEPHIR_INIT_NVAR(prefix); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_currentPath"), PH_NOISY_CC); zephir_unique_path_key(prefix, _0 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } if (Z_TYPE_P(prefix) == IS_OBJECT) { if (zephir_instance_of_ev(prefix, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1, this_ptr); ZEPHIR_INIT_VAR(calculatedPrefix); ZEPHIR_CALL_USER_FUNC_ARRAY(calculatedPrefix, prefix, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_prefix"), calculatedPrefix TSRMLS_CC); ZEPHIR_CPY_WRT(prefix, calculatedPrefix); } } if (Z_TYPE_P(prefix) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "The unique compilation prefix is invalid", "phalcon/mvc/view/engine/volt/compiler.zep", 292); return; } RETURN_CCTOR(prefix); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, attributeReader) { zend_bool _5; zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *expr_param = NULL, *exprCode, *left, *leftType, *variable, *level, *dependencyInjector, *leftCode = NULL, *right, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_6, *_7; zval *expr = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_INIT_VAR(exprCode); ZVAL_NULL(exprCode); ZEPHIR_OBS_VAR(left); zephir_array_fetch_string(&left, expr, SL("left"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 308 TSRMLS_CC); zephir_array_fetch_string(&_0, left, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 310 TSRMLS_CC); if (ZEPHIR_IS_LONG(_0, 265)) { ZEPHIR_OBS_VAR(variable); zephir_array_fetch_string(&variable, left, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 312 TSRMLS_CC); if (ZEPHIR_IS_STRING(variable, "loop")) { ZEPHIR_OBS_VAR(level); zephir_read_property_this(&level, this_ptr, SL("_foreachLevel"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getuniqueprefix", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVVS(_2, "$", _1, level, "loop"); zephir_concat_self(&exprCode, _2 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_loopPointers"), level, level TSRMLS_CC); } else { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "has", NULL, 0, variable); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SV(_2, "$this->", variable); zephir_concat_self(&exprCode, _2 TSRMLS_CC); } else { ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SV(_3, "$", variable); zephir_concat_self(&exprCode, _3 TSRMLS_CC); } } else { ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SV(_3, "$", variable); zephir_concat_self(&exprCode, _3 TSRMLS_CC); } } } else { ZEPHIR_CALL_METHOD(&leftCode, this_ptr, "expression", &_4, 377, left); zephir_check_call_status(); ZEPHIR_OBS_VAR(leftType); zephir_array_fetch_string(&leftType, left, SL("type"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 339 TSRMLS_CC); _5 = !ZEPHIR_IS_LONG(leftType, '.'); if (_5) { _5 = !ZEPHIR_IS_LONG(leftType, 350); } if (_5) { zephir_concat_self(&exprCode, leftCode TSRMLS_CC); } else { zephir_concat_self(&exprCode, leftCode TSRMLS_CC); } } zephir_concat_self_str(&exprCode, SL("->") TSRMLS_CC); ZEPHIR_OBS_VAR(right); zephir_array_fetch_string(&right, expr, SL("right"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 349 TSRMLS_CC); zephir_array_fetch_string(&_6, right, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 351 TSRMLS_CC); if (ZEPHIR_IS_LONG(_6, 265)) { zephir_array_fetch_string(&_7, right, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 352 TSRMLS_CC); zephir_concat_self(&exprCode, _7 TSRMLS_CC); } else { ZEPHIR_CALL_METHOD(&_1, this_ptr, "expression", &_4, 377, right); zephir_check_call_status(); zephir_concat_self(&exprCode, _1 TSRMLS_CC); } RETURN_CCTOR(exprCode); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, functionCall) { zend_bool _6; zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *expr_param = NULL, *code = NULL, *funcArguments = NULL, *arguments = NULL, *nameExpr, *nameType, *name, *extensions, *functions, *definition, *extendedBlocks, *block, *currentBlock, *exprLevel, *escapedCode = NULL, *method = NULL, *arrayHelpers = NULL, *className, *_2 = NULL, *_3, *_4, *_5, *_7 = NULL; zval *expr = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_INIT_VAR(code); ZVAL_NULL(code); ZEPHIR_INIT_VAR(funcArguments); ZVAL_NULL(funcArguments); ZEPHIR_OBS_NVAR(funcArguments); if (zephir_array_isset_string_fetch(&funcArguments, expr, SS("arguments"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&arguments, this_ptr, "expression", &_0, 377, funcArguments); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(arguments); ZVAL_STRING(arguments, "", 1); } ZEPHIR_OBS_VAR(nameExpr); zephir_array_fetch_string(&nameExpr, expr, SL("name"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 379 TSRMLS_CC); ZEPHIR_OBS_VAR(nameType); zephir_array_fetch_string(&nameType, nameExpr, SL("type"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 379 TSRMLS_CC); if (ZEPHIR_IS_LONG(nameType, 265)) { ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, nameExpr, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 386 TSRMLS_CC); ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); if (Z_TYPE_P(extensions) == IS_ARRAY) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 3, 0 TSRMLS_CC); zephir_array_fast_append(_1, name); zephir_array_fast_append(_1, arguments); zephir_array_fast_append(_1, funcArguments); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "compileFunction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "fireextensionevent", NULL, 378, _2, _1); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_STRING) { RETURN_CCTOR(code); } } ZEPHIR_OBS_VAR(functions); zephir_read_property_this(&functions, this_ptr, SL("_functions"), PH_NOISY_CC); if (Z_TYPE_P(functions) == IS_ARRAY) { ZEPHIR_OBS_VAR(definition); if (zephir_array_isset_fetch(&definition, functions, name, 0 TSRMLS_CC)) { if (Z_TYPE_P(definition) == IS_STRING) { ZEPHIR_CONCAT_VSVS(return_value, definition, "(", arguments, ")"); RETURN_MM(); } if (Z_TYPE_P(definition) == IS_OBJECT) { if (zephir_instance_of_ev(definition, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); zephir_array_fast_append(_1, arguments); zephir_array_fast_append(_1, funcArguments); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, definition, _1); zephir_check_call_status(); RETURN_MM(); } } ZEPHIR_INIT_NVAR(_2); object_init_ex(_2, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_3, expr, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 427 TSRMLS_CC); zephir_array_fetch_string(&_4, expr, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 427 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVSVSV(_5, "Invalid definition for user function '", name, "' in ", _3, " on line ", _4); ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _5); zephir_check_call_status(); zephir_throw_exception_debug(_2, "phalcon/mvc/view/engine/volt/compiler.zep", 427 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } _6 = ZEPHIR_IS_STRING(name, "get_content"); if (!(_6)) { _6 = ZEPHIR_IS_STRING(name, "content"); } if (_6) { RETURN_MM_STRING("$this->getContent()", 1); } if (ZEPHIR_IS_STRING(name, "partial")) { ZEPHIR_CONCAT_SVS(return_value, "$this->partial(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "super")) { ZEPHIR_OBS_VAR(extendedBlocks); zephir_read_property_this(&extendedBlocks, this_ptr, SL("_extendedBlocks"), PH_NOISY_CC); if (Z_TYPE_P(extendedBlocks) == IS_ARRAY) { ZEPHIR_OBS_VAR(currentBlock); zephir_read_property_this(¤tBlock, this_ptr, SL("_currentBlock"), PH_NOISY_CC); ZEPHIR_OBS_VAR(block); if (zephir_array_isset_fetch(&block, extendedBlocks, currentBlock, 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(exprLevel); zephir_read_property_this(&exprLevel, this_ptr, SL("_exprLevel"), PH_NOISY_CC); if (Z_TYPE_P(block) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&code, this_ptr, "_statementlistorextends", NULL, 379, block); zephir_check_call_status(); if (ZEPHIR_IS_LONG(exprLevel, 1)) { ZEPHIR_CPY_WRT(escapedCode, code); } else { ZEPHIR_INIT_NVAR(escapedCode); zephir_addslashes(escapedCode, code TSRMLS_CC); } } else { if (ZEPHIR_IS_LONG(exprLevel, 1)) { ZEPHIR_CPY_WRT(escapedCode, block); } else { ZEPHIR_INIT_NVAR(escapedCode); zephir_addslashes(escapedCode, block TSRMLS_CC); } } if (ZEPHIR_IS_LONG(exprLevel, 1)) { RETURN_CCTOR(escapedCode); } ZEPHIR_CONCAT_SVS(return_value, "'", escapedCode, "'"); RETURN_MM(); } } RETURN_MM_STRING("''", 1); } ZEPHIR_INIT_NVAR(_2); zephir_camelize(_2, name); ZEPHIR_CALL_FUNCTION(&method, "lcfirst", NULL, 68, _2); zephir_check_call_status(); ZEPHIR_INIT_VAR(className); ZVAL_STRING(className, "Phalcon\\Tag", 1); if ((zephir_method_exists(className, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_OBS_VAR(arrayHelpers); zephir_read_property_this(&arrayHelpers, this_ptr, SL("_arrayHelpers"), PH_NOISY_CC); if (Z_TYPE_P(arrayHelpers) != IS_ARRAY) { ZEPHIR_INIT_NVAR(arrayHelpers); zephir_create_array(arrayHelpers, 18, 0 TSRMLS_CC); zephir_array_update_string(&arrayHelpers, SL("link_to"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("image"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("form"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("select"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("select_static"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("submit_button"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("radio_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("check_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("file_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("hidden_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("password_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("text_area"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("text_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("email_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("date_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("tel_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("numeric_field"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_array_update_string(&arrayHelpers, SL("image_input"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_arrayHelpers"), arrayHelpers TSRMLS_CC); } if (zephir_array_isset(arrayHelpers, name)) { ZEPHIR_CONCAT_SVSVS(return_value, "$this->tag->", method, "(array(", arguments, "))"); RETURN_MM(); } ZEPHIR_CONCAT_SVSVS(return_value, "$this->tag->", method, "(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "url")) { ZEPHIR_CONCAT_SVS(return_value, "$this->url->get(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "static_url")) { ZEPHIR_CONCAT_SVS(return_value, "$this->url->getStatic(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "date")) { ZEPHIR_CONCAT_SVS(return_value, "date(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "time")) { RETURN_MM_STRING("time()", 1); } if (ZEPHIR_IS_STRING(name, "dump")) { ZEPHIR_CONCAT_SVS(return_value, "var_dump(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "version")) { RETURN_MM_STRING("Phalcon\\Version::get()", 1); } if (ZEPHIR_IS_STRING(name, "version_id")) { RETURN_MM_STRING("Phalcon\\Version::getId()", 1); } if (ZEPHIR_IS_STRING(name, "constant")) { ZEPHIR_CONCAT_SVS(return_value, "constant(", arguments, ")"); RETURN_MM(); } ZEPHIR_CONCAT_SVSVS(return_value, "$this->callMacro('", name, "', array(", arguments, "))"); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_7, this_ptr, "expression", &_0, 377, nameExpr); zephir_check_call_status(); ZEPHIR_CONCAT_VSVS(return_value, _7, "(", arguments, ")"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, resolveTest) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *left = NULL; zval *test_param = NULL, *left_param = NULL, *type, *name = NULL, *testName, *_0 = NULL, *_1; zval *test = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &test_param, &left_param); test = test_param; zephir_get_strval(left, left_param); ZEPHIR_OBS_VAR(type); zephir_array_fetch_string(&type, test, SL("type"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 579 TSRMLS_CC); if (ZEPHIR_IS_LONG(type, 265)) { ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, test, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 586 TSRMLS_CC); if (ZEPHIR_IS_STRING(name, "empty")) { ZEPHIR_CONCAT_SVS(return_value, "empty(", left, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "even")) { ZEPHIR_CONCAT_SVS(return_value, "(((", left, ") % 2) == 0)"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "odd")) { ZEPHIR_CONCAT_SVS(return_value, "(((", left, ") % 2) != 0)"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "numeric")) { ZEPHIR_CONCAT_SVS(return_value, "is_numeric(", left, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "scalar")) { ZEPHIR_CONCAT_SVS(return_value, "is_scalar(", left, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "iterable")) { ZEPHIR_CONCAT_SVSVS(return_value, "(is_array(", left, ") || (", left, ") instanceof Traversable)"); RETURN_MM(); } } if (ZEPHIR_IS_LONG(type, 350)) { ZEPHIR_OBS_VAR(testName); zephir_array_fetch_string(&testName, test, SL("name"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 637 TSRMLS_CC); ZEPHIR_OBS_NVAR(name); if (zephir_array_isset_string_fetch(&name, testName, SS("value"), 0 TSRMLS_CC)) { if (ZEPHIR_IS_STRING(name, "divisibleby")) { zephir_array_fetch_string(&_1, test, SL("arguments"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 641 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", &_2, 377, _1); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "(((", left, ") % (", _0, ")) == 0)"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "sameas")) { zephir_array_fetch_string(&_1, test, SL("arguments"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 648 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", &_2, 377, _1); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "(", left, ") === (", _0, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "type")) { zephir_array_fetch_string(&_1, test, SL("arguments"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 655 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", &_2, 377, _1); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "gettype(", left, ") === (", _0, ")"); RETURN_MM(); } } } ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", &_2, 377, test); zephir_check_call_status(); ZEPHIR_CONCAT_VSV(return_value, left, " == ", _0); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, resolveFilter) { zend_bool _6, _7, _8; int ZEPHIR_LAST_CALL_STATUS; zval *left = NULL; zval *filter_param = NULL, *left_param = NULL, *code = NULL, *type, *functionName, *name = NULL, *file, *line, *extensions, *filters, *funcArguments = NULL, *arguments = NULL, *definition, *_0 = NULL, *_1, *_2, *_3 = NULL; zval *filter = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &filter_param, &left_param); filter = filter_param; zephir_get_strval(left, left_param); ZEPHIR_INIT_VAR(code); ZVAL_NULL(code); ZEPHIR_OBS_VAR(type); zephir_array_fetch_string(&type, filter, SL("type"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 674 TSRMLS_CC); if (ZEPHIR_IS_LONG(type, 265)) { ZEPHIR_OBS_VAR(name); zephir_array_fetch_string(&name, filter, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 680 TSRMLS_CC); } else { if (!ZEPHIR_IS_LONG(type, 350)) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_1, filter, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 688 TSRMLS_CC); zephir_array_fetch_string(&_2, filter, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 688 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSV(_3, "Unknown filter type in ", _1, " on line ", _2); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/engine/volt/compiler.zep", 688 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_VAR(functionName); zephir_array_fetch_string(&functionName, filter, SL("name"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 691 TSRMLS_CC); ZEPHIR_OBS_NVAR(name); zephir_array_fetch_string(&name, functionName, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 692 TSRMLS_CC); } ZEPHIR_INIT_VAR(funcArguments); ZVAL_NULL(funcArguments); ZEPHIR_INIT_VAR(arguments); ZVAL_NULL(arguments); ZEPHIR_OBS_NVAR(funcArguments); if (zephir_array_isset_string_fetch(&funcArguments, filter, SS("arguments"), 0 TSRMLS_CC)) { if (!ZEPHIR_IS_STRING(name, "default")) { ZEPHIR_OBS_VAR(file); zephir_array_fetch_string(&file, filter, SL("file"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 707 TSRMLS_CC); ZEPHIR_OBS_VAR(line); zephir_array_fetch_string(&line, filter, SL("line"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 707 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 4, 0 TSRMLS_CC); add_assoc_long_ex(_5, SS("type"), 364); zephir_array_update_string(&_5, SL("value"), &left, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_5, SL("file"), &file, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_5, SL("line"), &line, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("expr"), &_5, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("file"), &file, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("line"), &line, PH_COPY | PH_SEPARATE); ZEPHIR_MAKE_REF(funcArguments); ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 380, funcArguments, _4); ZEPHIR_UNREF(funcArguments); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&arguments, this_ptr, "expression", NULL, 377, funcArguments); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(arguments, left); } ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); if (Z_TYPE_P(extensions) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); zephir_array_fast_append(_4, name); zephir_array_fast_append(_4, arguments); zephir_array_fast_append(_4, funcArguments); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "compileFilter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&code, this_ptr, "fireextensionevent", NULL, 378, _0, _4); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (Z_TYPE_P(code) == IS_STRING) { RETURN_CCTOR(code); } } ZEPHIR_OBS_VAR(filters); zephir_read_property_this(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); if (Z_TYPE_P(filters) == IS_ARRAY) { ZEPHIR_OBS_VAR(definition); if (zephir_array_isset_fetch(&definition, filters, name, 0 TSRMLS_CC)) { if (Z_TYPE_P(definition) == IS_STRING) { ZEPHIR_CONCAT_VSVS(return_value, definition, "(", arguments, ")"); RETURN_MM(); } if (Z_TYPE_P(definition) == IS_OBJECT) { if (zephir_instance_of_ev(definition, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_fast_append(_4, arguments); zephir_array_fast_append(_4, funcArguments); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, definition, _4); zephir_check_call_status(); RETURN_MM(); } } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_1, filter, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 770 TSRMLS_CC); zephir_array_fetch_string(&_2, filter, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 770 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVSVSV(_3, "Invalid definition for user filter '", name, "' in ", _1, " on line ", _2); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/engine/volt/compiler.zep", 770 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } if (ZEPHIR_IS_STRING(name, "length")) { ZEPHIR_CONCAT_SVS(return_value, "$this->length(", arguments, ")"); RETURN_MM(); } _6 = ZEPHIR_IS_STRING(name, "e"); if (!(_6)) { _6 = ZEPHIR_IS_STRING(name, "escape"); } if (_6) { ZEPHIR_CONCAT_SVS(return_value, "$this->escaper->escapeHtml(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "escape_css")) { ZEPHIR_CONCAT_SVS(return_value, "$this->escaper->escapeCss(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "escape_js")) { ZEPHIR_CONCAT_SVS(return_value, "$this->escaper->escapeJs(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "escape_attr")) { ZEPHIR_CONCAT_SVS(return_value, "$this->escaper->escapeHtmlAttr(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "trim")) { ZEPHIR_CONCAT_SVS(return_value, "trim(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "left_trim")) { ZEPHIR_CONCAT_SVS(return_value, "ltrim(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "right_trim")) { ZEPHIR_CONCAT_SVS(return_value, "rtrim(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "striptags")) { ZEPHIR_CONCAT_SVS(return_value, "strip_tags(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "url_encode")) { ZEPHIR_CONCAT_SVS(return_value, "urlencode(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "slashes")) { ZEPHIR_CONCAT_SVS(return_value, "addslashes(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "stripslashes")) { ZEPHIR_CONCAT_SVS(return_value, "stripslashes(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "nl2br")) { ZEPHIR_CONCAT_SVS(return_value, "nl2br(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "keys")) { ZEPHIR_CONCAT_SVS(return_value, "array_keys(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "join")) { ZEPHIR_CONCAT_SVS(return_value, "join(", arguments, ")"); RETURN_MM(); } _7 = ZEPHIR_IS_STRING(name, "lower"); if (!(_7)) { _7 = ZEPHIR_IS_STRING(name, "lowercase"); } if (_7) { ZEPHIR_CONCAT_SVS(return_value, "Phalcon\\Text::lower(", arguments, ")"); RETURN_MM(); } _8 = ZEPHIR_IS_STRING(name, "upper"); if (!(_8)) { _8 = ZEPHIR_IS_STRING(name, "uppercase"); } if (_8) { ZEPHIR_CONCAT_SVS(return_value, "Phalcon\\Text::upper(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "capitalize")) { ZEPHIR_CONCAT_SVS(return_value, "ucwords(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "sort")) { ZEPHIR_CONCAT_SVS(return_value, "$this->sort(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "json_encode")) { ZEPHIR_CONCAT_SVS(return_value, "json_encode(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "json_decode")) { ZEPHIR_CONCAT_SVS(return_value, "json_decode(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "format")) { ZEPHIR_CONCAT_SVS(return_value, "sprintf(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "abs")) { ZEPHIR_CONCAT_SVS(return_value, "abs(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "slice")) { ZEPHIR_CONCAT_SVS(return_value, "$this->slice(", arguments, ")"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "default")) { ZEPHIR_CONCAT_SVSVSVS(return_value, "(empty(", left, ") ? (", arguments, ") : (", left, "))"); RETURN_MM(); } if (ZEPHIR_IS_STRING(name, "convert_encoding")) { ZEPHIR_CONCAT_SVS(return_value, "$this->convertEncoding(", arguments, ")"); RETURN_MM(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_1, filter, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 959 TSRMLS_CC); zephir_array_fetch_string(&_2, filter, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 959 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVSVSV(_3, "Unknown filter \"", name, "\" in ", _1, " on line ", _2); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _3); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/engine/volt/compiler.zep", 959 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, expression) { HashTable *_4; HashPosition _3; zephir_fcall_cache_entry *_2 = NULL, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *expr_param = NULL, *exprCode = NULL, *extensions, *items = NULL, *singleExpr = NULL, *singleExprCode = NULL, *name = NULL, *left = NULL, *leftCode = NULL, *right = NULL, *rightCode = NULL, *type = NULL, *startCode = NULL, *endCode = NULL, *start = NULL, *end = NULL, *_1 = NULL, **_5, *_6, *_8 = NULL, *_11, _13 = zval_used_for_init, _14 = zval_used_for_init, *_16 = NULL, *_17; zval *expr = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &expr_param); expr = expr_param; ZEPHIR_INIT_VAR(exprCode); ZVAL_NULL(exprCode); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_exprLevel") TSRMLS_CC)); ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); while (1) { if (Z_TYPE_P(extensions) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_0); zephir_create_array(_0, 1, 0 TSRMLS_CC); zephir_array_fast_append(_0, expr); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "resolveExpression", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "fireextensionevent", &_2, 378, _1, _0); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(exprCode) == IS_STRING) { break; } } ZEPHIR_OBS_NVAR(type); if (!(zephir_array_isset_string_fetch(&type, expr, SS("type"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(items); array_init(items); zephir_is_iterable(expr, &_4, &_3, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 1000); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HVALUE(singleExpr, _5); zephir_array_fetch_string(&_6, singleExpr, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 993 TSRMLS_CC); ZEPHIR_CALL_METHOD(&singleExprCode, this_ptr, "expression", &_7, 377, _6); zephir_check_call_status(); ZEPHIR_OBS_NVAR(name); if (zephir_array_isset_string_fetch(&name, singleExpr, SS("name"), 0 TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSV(_8, "'", name, "' => ", singleExprCode); zephir_array_append(&items, _8, PH_SEPARATE, "phalcon/mvc/view/engine/volt/compiler.zep", 995); } else { zephir_array_append(&items, singleExprCode, PH_SEPARATE, "phalcon/mvc/view/engine/volt/compiler.zep", 997); } } ZEPHIR_INIT_NVAR(exprCode); zephir_fast_join_str(exprCode, SL(", "), items TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, '.')) { ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "attributereader", &_9, 0, expr); zephir_check_call_status(); break; } ZEPHIR_OBS_NVAR(left); if (zephir_array_isset_string_fetch(&left, expr, SS("left"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&leftCode, this_ptr, "expression", &_7, 377, left); zephir_check_call_status(); } if (ZEPHIR_IS_LONG(type, 311)) { zephir_array_fetch_string(&_6, expr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1023 TSRMLS_CC); ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "resolvetest", &_10, 0, _6, leftCode); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 124)) { zephir_array_fetch_string(&_11, expr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1031 TSRMLS_CC); ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "resolvefilter", &_12, 381, _11, leftCode); zephir_check_call_status(); break; } ZEPHIR_OBS_NVAR(right); if (zephir_array_isset_string_fetch(&right, expr, SS("right"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&rightCode, this_ptr, "expression", &_7, 377, right); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(exprCode); ZVAL_NULL(exprCode); do { if (ZEPHIR_IS_LONG(type, '!')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SV(exprCode, "!", rightCode); break; } if (ZEPHIR_IS_LONG(type, '*')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " * ", rightCode); break; } if (ZEPHIR_IS_LONG(type, '+')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " + ", rightCode); break; } if (ZEPHIR_IS_LONG(type, '-')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " - ", rightCode); break; } if (ZEPHIR_IS_LONG(type, '/')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " / ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 37)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " % ", rightCode); break; } if (ZEPHIR_IS_LONG(type, '<')) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " < ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 61)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " > ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 62)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " > ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 126)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " . ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 278)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "pow(", leftCode, ", ", rightCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 360)) { ZEPHIR_INIT_NVAR(exprCode); if (zephir_array_isset_string(expr, SS("left"))) { ZEPHIR_CONCAT_SVS(exprCode, "array(", leftCode, ")"); } else { ZVAL_STRING(exprCode, "array()", 1); } break; } if (ZEPHIR_IS_LONG(type, 258)) { ZEPHIR_OBS_NVAR(exprCode); zephir_array_fetch_string(&exprCode, expr, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1098 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 259)) { ZEPHIR_OBS_NVAR(exprCode); zephir_array_fetch_string(&exprCode, expr, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1102 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 260)) { ZEPHIR_INIT_NVAR(_1); zephir_array_fetch_string(&_6, expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1106 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_13); ZVAL_STRING(&_13, "'", 0); ZEPHIR_SINIT_NVAR(_14); ZVAL_STRING(&_14, "\\'", 0); zephir_fast_str_replace(&_1, &_13, &_14, _6 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "'", _1, "'"); break; } if (ZEPHIR_IS_LONG(type, 261)) { ZEPHIR_INIT_NVAR(exprCode); ZVAL_STRING(exprCode, "null", 1); break; } if (ZEPHIR_IS_LONG(type, 262)) { ZEPHIR_INIT_NVAR(exprCode); ZVAL_STRING(exprCode, "false", 1); break; } if (ZEPHIR_IS_LONG(type, 263)) { ZEPHIR_INIT_NVAR(exprCode); ZVAL_STRING(exprCode, "true", 1); break; } if (ZEPHIR_IS_LONG(type, 265)) { zephir_array_fetch_string(&_11, expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1122 TSRMLS_CC); ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SV(exprCode, "$", _11); break; } if (ZEPHIR_IS_LONG(type, 266)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " && ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 267)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " || ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 270)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " <= ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 271)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " >= ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 272)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " == ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 273)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " != ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 274)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " === ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 275)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSV(exprCode, leftCode, " !== ", rightCode); break; } if (ZEPHIR_IS_LONG(type, 276)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "range(", leftCode, ", ", rightCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 350)) { ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "functioncall", &_15, 0, expr); zephir_check_call_status(); break; } if (ZEPHIR_IS_LONG(type, 356)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 361)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_VSVS(exprCode, leftCode, "[", rightCode, "]"); break; } if (ZEPHIR_IS_LONG(type, 365)) { ZEPHIR_OBS_NVAR(start); if (zephir_array_isset_string_fetch(&start, expr, SS("start"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&startCode, this_ptr, "expression", &_7, 377, start); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(startCode); ZVAL_STRING(startCode, "null", 1); } ZEPHIR_OBS_NVAR(end); if (zephir_array_isset_string_fetch(&end, expr, SS("end"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&endCode, this_ptr, "expression", &_7, 377, end); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(endCode); ZVAL_STRING(endCode, "null", 1); } ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVSVS(exprCode, "$this->slice(", leftCode, ", ", startCode, ", ", endCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 362)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!isset(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 363)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "isset(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 392)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!empty(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 386)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "empty(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 393)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!(((", leftCode, ") % 2) == 0)"); break; } if (ZEPHIR_IS_LONG(type, 387)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "(((", leftCode, ") % 2) == 0)"); break; } if (ZEPHIR_IS_LONG(type, 394)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!(((", leftCode, ") % 2) != 0)"); break; } if (ZEPHIR_IS_LONG(type, 388)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "(((", leftCode, ") % 2) != 0)"); break; } if (ZEPHIR_IS_LONG(type, 395)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!is_numeric(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 389)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "is_numeric(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 396)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "!is_scalar(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 390)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVS(exprCode, "is_scalar(", leftCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 397)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "!(is_array(", leftCode, ") || (", leftCode, ") instanceof Traversable)"); break; } if (ZEPHIR_IS_LONG(type, 391)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "(is_array(", leftCode, ") || (", leftCode, ") instanceof Traversable)"); break; } if (ZEPHIR_IS_LONG(type, 309)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "$this->isIncluded(", leftCode, ", ", rightCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 367)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVS(exprCode, "!$this->isIncluded(", leftCode, ", ", rightCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 366)) { zephir_array_fetch_string(&_6, expr, SL("ternary"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1261 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_16, this_ptr, "expression", &_7, 377, _6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SVSVSVS(exprCode, "(", _16, " ? ", leftCode, " : ", rightCode, ")"); break; } if (ZEPHIR_IS_LONG(type, 368)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SV(exprCode, "-", rightCode); break; } if (ZEPHIR_IS_LONG(type, 369)) { ZEPHIR_INIT_NVAR(exprCode); ZEPHIR_CONCAT_SV(exprCode, "+", rightCode); break; } if (ZEPHIR_IS_LONG(type, 364)) { ZEPHIR_OBS_NVAR(exprCode); zephir_array_fetch_string(&exprCode, expr, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1273 TSRMLS_CC); break; } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_11, expr, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1277 TSRMLS_CC); zephir_array_fetch_string(&_17, expr, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1277 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVSV(_8, "Unknown expression ", type, " in ", _11, " on line ", _17); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_18, 9, _8); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/view/engine/volt/compiler.zep", 1277 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); break; } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_exprLevel") TSRMLS_CC)); RETURN_CCTOR(exprCode); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, _statementListOrExtends) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zend_bool isStatementList; zval *statements, *statement = NULL, **_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statements); if (Z_TYPE_P(statements) != IS_ARRAY) { RETVAL_ZVAL(statements, 1, 0); RETURN_MM(); } isStatementList = 1; if (!(zephir_array_isset_string(statements, SS("type")))) { zephir_is_iterable(statements, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 1317); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(statement, _2); if (Z_TYPE_P(statement) != IS_ARRAY) { isStatementList = 0; break; } } } if (isStatementList == 1) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_statementlist", NULL, 382, statements); zephir_check_call_status(); RETURN_MM(); } RETVAL_ZVAL(statements, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileForeach) { HashTable *_2; HashPosition _1; zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL, *compilation, *prefix = NULL, *level, *prefixLevel, *expr, *exprCode = NULL, *bstatement = NULL, *type = NULL, *blockStatements, *forElse = NULL, *code = NULL, *loopContext, *iterator = NULL, *key, *ifExpr, *variable, **_3, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12, *_13 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &statement_param, &extendsMode_param); statement = statement_param; if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } if (!(zephir_array_isset_string(statement, SS("expr")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1345); return; } ZEPHIR_INIT_VAR(compilation); ZVAL_STRING(compilation, "", 1); ZEPHIR_INIT_VAR(forElse); ZVAL_NULL(forElse); RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_foreachLevel") TSRMLS_CC)); ZEPHIR_CALL_METHOD(&prefix, this_ptr, "getuniqueprefix", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(level); zephir_read_property_this(&level, this_ptr, SL("_foreachLevel"), PH_NOISY_CC); ZEPHIR_INIT_VAR(prefixLevel); ZEPHIR_CONCAT_VV(prefixLevel, prefix, level); ZEPHIR_OBS_VAR(expr); zephir_array_fetch_string(&expr, statement, SL("expr"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1363 TSRMLS_CC); ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "expression", &_0, 377, expr); zephir_check_call_status(); ZEPHIR_OBS_VAR(blockStatements); zephir_array_fetch_string(&blockStatements, statement, SL("block_statements"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1369 TSRMLS_CC); ZEPHIR_INIT_NVAR(forElse); ZVAL_BOOL(forElse, 0); if (Z_TYPE_P(blockStatements) == IS_ARRAY) { zephir_is_iterable(blockStatements, &_2, &_1, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 1395); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(bstatement, _3); if (Z_TYPE_P(bstatement) != IS_ARRAY) { break; } ZEPHIR_OBS_NVAR(type); if (!(zephir_array_isset_string_fetch(&type, bstatement, SS("type"), 0 TSRMLS_CC))) { break; } if (ZEPHIR_IS_LONG(type, 321)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVS(_4, "<?php $", prefixLevel, "iterated = false; ?>"); zephir_concat_self(&compilation, _4 TSRMLS_CC); ZEPHIR_CPY_WRT(forElse, prefixLevel); zephir_update_property_array(this_ptr, SL("_forElsePointers"), level, forElse TSRMLS_CC); break; } } } ZEPHIR_INIT_VAR(_5); if (extendsMode) { ZVAL_BOOL(_5, 1); } else { ZVAL_BOOL(_5, 0); } ZEPHIR_CALL_METHOD(&code, this_ptr, "_statementlist", NULL, 382, blockStatements, _5); zephir_check_call_status(); ZEPHIR_OBS_VAR(loopContext); zephir_read_property_this(&loopContext, this_ptr, SL("_loopPointers"), PH_NOISY_CC); if (zephir_array_isset(loopContext, level)) { ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVSVS(_4, "<?php $", prefixLevel, "iterator = ", exprCode, "; "); zephir_concat_self(&compilation, _4 TSRMLS_CC); ZEPHIR_INIT_VAR(_6); ZEPHIR_CONCAT_SVS(_6, "$", prefixLevel, "incr = 0; "); zephir_concat_self(&compilation, _6 TSRMLS_CC); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "$", prefixLevel, "loop = new stdClass(); "); zephir_concat_self(&compilation, _7 TSRMLS_CC); ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "$", prefixLevel, "loop->length = count($", prefixLevel, "iterator); "); zephir_concat_self(&compilation, _8 TSRMLS_CC); ZEPHIR_INIT_VAR(_9); ZEPHIR_CONCAT_SVS(_9, "$", prefixLevel, "loop->index = 1; "); zephir_concat_self(&compilation, _9 TSRMLS_CC); ZEPHIR_INIT_VAR(_10); ZEPHIR_CONCAT_SVS(_10, "$", prefixLevel, "loop->index0 = 1; "); zephir_concat_self(&compilation, _10 TSRMLS_CC); ZEPHIR_INIT_VAR(_11); ZEPHIR_CONCAT_SVSVS(_11, "$", prefixLevel, "loop->revindex = $", prefixLevel, "loop->length; "); zephir_concat_self(&compilation, _11 TSRMLS_CC); ZEPHIR_INIT_VAR(_12); ZEPHIR_CONCAT_SVSVS(_12, "$", prefixLevel, "loop->revindex0 = $", prefixLevel, "loop->length - 1; ?>"); zephir_concat_self(&compilation, _12 TSRMLS_CC); ZEPHIR_INIT_VAR(iterator); ZEPHIR_CONCAT_SVS(iterator, "$", prefixLevel, "iterator"); } else { ZEPHIR_CPY_WRT(iterator, exprCode); } ZEPHIR_OBS_VAR(variable); zephir_array_fetch_string(&variable, statement, SL("variable"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1424 TSRMLS_CC); ZEPHIR_OBS_VAR(key); if (zephir_array_isset_string_fetch(&key, statement, SS("key"), 0 TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVSVSVS(_6, "<?php foreach (", iterator, " as $", key, " => $", variable, ") { "); zephir_concat_self(&compilation, _6 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVSVS(_6, "<?php foreach (", iterator, " as $", variable, ") { "); zephir_concat_self(&compilation, _6 TSRMLS_CC); } ZEPHIR_OBS_VAR(ifExpr); if (zephir_array_isset_string_fetch(&ifExpr, statement, SS("if_expr"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_13, this_ptr, "expression", &_0, 377, ifExpr); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "if (", _13, ") { ?>"); zephir_concat_self(&compilation, _6 TSRMLS_CC); } else { zephir_concat_self_str(&compilation, SL("?>") TSRMLS_CC); } if (zephir_array_isset(loopContext, level)) { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVSVS(_6, "<?php $", prefixLevel, "loop->first = ($", prefixLevel, "incr == 0); "); zephir_concat_self(&compilation, _6 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "$", prefixLevel, "loop->index = $", prefixLevel, "incr + 1; "); zephir_concat_self(&compilation, _7 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVS(_8, "$", prefixLevel, "loop->index0 = $", prefixLevel, "incr; "); zephir_concat_self(&compilation, _8 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVSVS(_9, "$", prefixLevel, "loop->revindex = $", prefixLevel, "loop->length - $", prefixLevel, "incr; "); zephir_concat_self(&compilation, _9 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_SVSVSVS(_10, "$", prefixLevel, "loop->revindex0 = $", prefixLevel, "loop->length - ($", prefixLevel, "incr + 1); "); zephir_concat_self(&compilation, _10 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSVSVS(_11, "$", prefixLevel, "loop->last = ($", prefixLevel, "incr == ($", prefixLevel, "loop->length - 1)); ?>"); zephir_concat_self(&compilation, _11 TSRMLS_CC); } if (Z_TYPE_P(forElse) == IS_STRING) { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "<?php $", forElse, "iterated = true; ?>"); zephir_concat_self(&compilation, _6 TSRMLS_CC); } zephir_concat_self(&compilation, code TSRMLS_CC); if (zephir_array_isset_string(statement, SS("if_expr"))) { zephir_concat_self_str(&compilation, SL("<?php } ?>") TSRMLS_CC); } if (Z_TYPE_P(forElse) == IS_STRING) { zephir_concat_self_str(&compilation, SL("<?php } ?>") TSRMLS_CC); } else { if (zephir_array_isset(loopContext, level)) { ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "<?php $", prefixLevel, "incr++; } ?>"); zephir_concat_self(&compilation, _6 TSRMLS_CC); } else { zephir_concat_self_str(&compilation, SL("<?php } ?>") TSRMLS_CC); } } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_foreachLevel") TSRMLS_CC)); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileForElse) { zval *level, *prefix, *_0, *_1; level = zephir_fetch_nproperty_this(this_ptr, SL("_foreachLevel"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_forElsePointers"), PH_NOISY_CC); if (zephir_array_isset_fetch(&prefix, _0, level, 1 TSRMLS_CC)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_loopPointers"), PH_NOISY_CC); if (zephir_array_isset(_1, level)) { ZEPHIR_CONCAT_SVSVS(return_value, "<?php $", prefix, "incr++; } if (!$", prefix, "iterated) { ?>"); return; } ZEPHIR_CONCAT_SVS(return_value, "<?php } if (!$", prefix, "iterated) { ?>"); return; } RETURN_STRING("", 1); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileIf) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL, *compilation, *blockStatements, *expr, *_0 = NULL, *_1 = NULL, *_2, *_3, *_5 = NULL, *_6, *_7; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &statement_param, &extendsMode_param); statement = statement_param; if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupt statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1515); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", NULL, 377, expr); zephir_check_call_status(); zephir_array_fetch_string(&_2, statement, SL("true_statements"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1521 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); if (extendsMode) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "_statementlist", &_4, 382, _2, _3); zephir_check_call_status(); ZEPHIR_INIT_VAR(compilation); ZEPHIR_CONCAT_SVSV(compilation, "<?php if (", _0, ") { ?>", _1); ZEPHIR_OBS_VAR(blockStatements); if (zephir_array_isset_string_fetch(&blockStatements, statement, SS("false_statements"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_6); if (extendsMode) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(&_5, this_ptr, "_statementlist", &_4, 382, blockStatements, _6); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SV(_7, "<?php } else { ?>", _5); zephir_concat_self(&compilation, _7 TSRMLS_CC); } zephir_concat_self_str(&compilation, SL("<?php } ?>") TSRMLS_CC); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileElseIf) { int ZEPHIR_LAST_CALL_STATUS; zval *statement_param = NULL, *expr, *_0 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupt statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1550); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", NULL, 377, expr); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "<?php } elseif (", _0, ") { ?>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileCache) { zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL, *compilation, *expr, *exprCode = NULL, *lifetime = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4, *_5 = NULL, *_6 = NULL, *_7, *_8; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &statement_param, &extendsMode_param); statement = statement_param; if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupt statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1570); return; } ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "expression", &_0, 377, expr); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "expression", &_0, 377, expr); zephir_check_call_status(); ZEPHIR_INIT_VAR(compilation); ZEPHIR_CONCAT_SVS(compilation, "<?php $_cache[", _1, "] = $this->di->get('viewCache'); "); ZEPHIR_OBS_VAR(lifetime); if (zephir_array_isset_string_fetch(&lifetime, statement, SS("lifetime"), 0 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "$_cacheKey[", exprCode, "]"); zephir_concat_self(&compilation, _2 TSRMLS_CC); zephir_array_fetch_string(&_3, lifetime, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1580 TSRMLS_CC); if (ZEPHIR_IS_LONG(_3, 265)) { zephir_array_fetch_string(&_4, lifetime, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1581 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SVSVSVS(_5, " = $_cache[", exprCode, "]->start(", exprCode, ", $", _4, "); "); zephir_concat_self(&compilation, _5 TSRMLS_CC); } else { zephir_array_fetch_string(&_4, lifetime, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1583 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVSVS(_5, " = $_cache[", exprCode, "]->start(", exprCode, ", ", _4, "); "); zephir_concat_self(&compilation, _5 TSRMLS_CC); } } else { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSVSVS(_2, "$_cacheKey[", exprCode, "] = $_cache[", exprCode, "]->start(", exprCode, "); "); zephir_concat_self(&compilation, _2 TSRMLS_CC); } ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVS(_2, "if ($_cacheKey[", exprCode, "] === null) { ?>"); zephir_concat_self(&compilation, _2 TSRMLS_CC); zephir_array_fetch_string(&_3, statement, SL("block_statements"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1593 TSRMLS_CC); ZEPHIR_INIT_VAR(_7); if (extendsMode) { ZVAL_BOOL(_7, 1); } else { ZVAL_BOOL(_7, 0); } ZEPHIR_CALL_METHOD(&_6, this_ptr, "_statementlist", NULL, 382, _3, _7); zephir_check_call_status(); zephir_concat_self(&compilation, _6 TSRMLS_CC); ZEPHIR_OBS_NVAR(lifetime); if (zephir_array_isset_string_fetch(&lifetime, statement, SS("lifetime"), 0 TSRMLS_CC)) { zephir_array_fetch_string(&_4, lifetime, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1599 TSRMLS_CC); if (ZEPHIR_IS_LONG(_4, 265)) { zephir_array_fetch_string(&_8, lifetime, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1600 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVSVS(_5, "<?php $_cache[", exprCode, "]->save(", exprCode, ", null, $", _8, "); "); zephir_concat_self(&compilation, _5 TSRMLS_CC); } else { zephir_array_fetch_string(&_4, lifetime, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1602 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVSVSVS(_5, "<?php $_cache[", exprCode, "]->save(", exprCode, ", null, ", _4, "); "); zephir_concat_self(&compilation, _5 TSRMLS_CC); } ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "} else { echo $_cacheKey[", exprCode, "]; } ?>"); zephir_concat_self(&compilation, _5 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_SVSVSVS(_2, "<?php $_cache[", exprCode, "]->save(", exprCode, "); } else { echo $_cacheKey[", exprCode, "]; } ?>"); zephir_concat_self(&compilation, _2 TSRMLS_CC); } RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileSet) { zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *statement_param = NULL, *assignments, *assignment = NULL, *exprCode = NULL, *target = NULL, *compilation, **_2, *_3, *_5, *_6, *_7 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(assignments); if (!(zephir_array_isset_string_fetch(&assignments, statement, SS("assignments"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1623); return; } ZEPHIR_INIT_VAR(compilation); ZVAL_STRING(compilation, "<?php", 1); zephir_is_iterable(assignments, &_1, &_0, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 1669); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(assignment, _2); zephir_array_fetch_string(&_3, assignment, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1633 TSRMLS_CC); ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "expression", &_4, 377, _3); zephir_check_call_status(); zephir_array_fetch_string(&_5, assignment, SL("variable"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1638 TSRMLS_CC); ZEPHIR_CALL_METHOD(&target, this_ptr, "expression", &_4, 377, _5); zephir_check_call_status(); zephir_array_fetch_string(&_6, assignment, SL("op"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1644 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(_6, 281)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, " ", target, " += ", exprCode, ";"); zephir_concat_self(&compilation, _7 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_6, 282)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, " ", target, " -= ", exprCode, ";"); zephir_concat_self(&compilation, _7 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_6, 283)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, " ", target, " *= ", exprCode, ";"); zephir_concat_self(&compilation, _7 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(_6, 284)) { ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, " ", target, " /= ", exprCode, ";"); zephir_concat_self(&compilation, _7 TSRMLS_CC); break; } ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, " ", target, " = ", exprCode, ";"); zephir_concat_self(&compilation, _7 TSRMLS_CC); break; } while(0); } zephir_concat_self_str(&compilation, SL(" ?>") TSRMLS_CC); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileDo) { int ZEPHIR_LAST_CALL_STATUS; zval *statement_param = NULL, *expr, *_0 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1684); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", NULL, 377, expr); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "<?php ", _0, "; ?>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileReturn) { int ZEPHIR_LAST_CALL_STATUS; zval *statement_param = NULL, *expr, *_0 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1704); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "expression", NULL, 377, expr); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "<?php return ", _0, "; ?>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileAutoEscape) { int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL, *autoescape, *oldAutoescape, *compilation = NULL, *_0, *_1; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &statement_param, &extendsMode_param); statement = statement_param; extendsMode = zephir_get_boolval(extendsMode_param); ZEPHIR_OBS_VAR(autoescape); if (!(zephir_array_isset_string_fetch(&autoescape, statement, SS("enable"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1724); return; } ZEPHIR_OBS_VAR(oldAutoescape); zephir_read_property_this(&oldAutoescape, this_ptr, SL("_autoescape"), PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("_autoescape"), autoescape TSRMLS_CC); zephir_array_fetch_string(&_0, statement, SL("block_statements"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1733 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); if (extendsMode) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "_statementlist", NULL, 382, _0, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_autoescape"), oldAutoescape TSRMLS_CC); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileEcho) { int ZEPHIR_LAST_CALL_STATUS; zval *statement_param = NULL, *expr, *exprCode = NULL, *name, *_0, *_1, *_2, *_3; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(expr); if (!(zephir_array_isset_string_fetch(&expr, statement, SS("expr"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupt statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1754); return; } ZEPHIR_CALL_METHOD(&exprCode, this_ptr, "expression", NULL, 377, expr); zephir_check_call_status(); zephir_array_fetch_string(&_0, expr, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1762 TSRMLS_CC); if (ZEPHIR_IS_LONG(_0, 350)) { zephir_array_fetch_string(&name, expr, SL("name"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1764 TSRMLS_CC); zephir_array_fetch_string(&_1, name, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1766 TSRMLS_CC); if (ZEPHIR_IS_LONG(_1, 265)) { zephir_array_fetch_string(&_2, name, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1771 TSRMLS_CC); if (ZEPHIR_IS_STRING(_2, "super")) { RETURN_CCTOR(exprCode); } } } _3 = zephir_fetch_nproperty_this(this_ptr, SL("_autoescape"), PH_NOISY_CC); if (zephir_is_true(_3)) { ZEPHIR_CONCAT_SVS(return_value, "<?php echo $this->escaper->escapeHtml(", exprCode, "); ?>"); RETURN_MM(); } ZEPHIR_CONCAT_SVS(return_value, "<?php echo ", exprCode, "; ?>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileInclude) { zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *statement_param = NULL, *pathExpr, *path = NULL, *view, *subCompiler, *finalPath = NULL, *compilation = NULL, *params, *_0, *_1 = NULL, *_2; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &statement_param); statement = statement_param; ZEPHIR_OBS_VAR(pathExpr); if (!(zephir_array_isset_string_fetch(&pathExpr, statement, SS("path"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1799); return; } zephir_array_fetch_string(&_0, pathExpr, SL("type"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1806 TSRMLS_CC); if (ZEPHIR_IS_LONG(_0, 260)) { if (!(zephir_array_isset_string(statement, SS("params")))) { ZEPHIR_OBS_VAR(path); zephir_array_fetch_string(&path, pathExpr, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1816 TSRMLS_CC); ZEPHIR_OBS_VAR(view); zephir_read_property_this(&view, this_ptr, SL("_view"), PH_NOISY_CC); if (Z_TYPE_P(view) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_1, view, "getviewsdir", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(finalPath); ZEPHIR_CONCAT_VV(finalPath, _1, path); } else { ZEPHIR_CPY_WRT(finalPath, path); } ZEPHIR_INIT_VAR(subCompiler); if (zephir_clone(subCompiler, this_ptr TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 0); ZEPHIR_CALL_METHOD(&compilation, subCompiler, "compile", NULL, 0, finalPath, _2); zephir_check_call_status(); if (Z_TYPE_P(compilation) == IS_NULL) { ZEPHIR_CALL_METHOD(&_1, subCompiler, "getcompiledtemplatepath", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(compilation); zephir_file_get_contents(compilation, _1 TSRMLS_CC); } RETURN_CCTOR(compilation); } } ZEPHIR_CALL_METHOD(&path, this_ptr, "expression", &_3, 377, pathExpr); zephir_check_call_status(); ZEPHIR_OBS_VAR(params); if (!(zephir_array_isset_string_fetch(¶ms, statement, SS("params"), 0 TSRMLS_CC))) { ZEPHIR_CONCAT_SVS(return_value, "<?php $this->partial(", path, "); ?>"); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_1, this_ptr, "expression", &_3, 377, params); zephir_check_call_status(); ZEPHIR_CONCAT_SVSVS(return_value, "<?php $this->partial(", path, ", ", _1, "); ?>"); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileMacro) { zephir_fcall_cache_entry *_11 = NULL; HashTable *_4; HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL, *code, *name, *defaultValue = NULL, *macroName, *parameters, *position = NULL, *parameter = NULL, *variableName = NULL, *blockStatements, *_0, *_1 = NULL, *_2 = NULL, **_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_12 = NULL; zval *statement = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &statement_param, &extendsMode_param); statement = statement_param; extendsMode = zephir_get_boolval(extendsMode_param); ZEPHIR_OBS_VAR(name); if (!(zephir_array_isset_string_fetch(&name, statement, SS("name"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1871); return; } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_macros"), PH_NOISY_CC); if (zephir_array_isset(_0, name)) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_mvc_view_engine_volt_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Macro '", name, "' is already defined"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/mvc/view/engine/volt/compiler.zep", 1878 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_property_array(this_ptr, SL("_macros"), name, name TSRMLS_CC); ZEPHIR_INIT_VAR(macroName); ZEPHIR_CONCAT_SVS(macroName, "$this->_macros['", name, "']"); ZEPHIR_INIT_VAR(code); ZVAL_STRING(code, "<?php ", 1); ZEPHIR_OBS_VAR(parameters); if (!(zephir_array_isset_string_fetch(¶meters, statement, SS("parameters"), 0 TSRMLS_CC))) { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, macroName, " = function() { ?>"); zephir_concat_self(&code, _2 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, macroName, " = function($__p = null) { "); zephir_concat_self(&code, _2 TSRMLS_CC); zephir_is_iterable(parameters, &_4, &_3, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 1916); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(position, _4, _3); ZEPHIR_GET_HVALUE(parameter, _5); ZEPHIR_OBS_NVAR(variableName); zephir_array_fetch_string(&variableName, parameter, SL("variable"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 1900 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SVS(_6, "if (isset($__p[", position, "])) { "); zephir_concat_self(&code, _6 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVS(_7, "$", variableName, " = $__p[", position, "];"); zephir_concat_self(&code, _7 TSRMLS_CC); zephir_concat_self_str(&code, SL(" } else { ") TSRMLS_CC); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVS(_8, "if (isset($__p[\"", variableName, "\"])) { "); zephir_concat_self(&code, _8 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVS(_9, "$", variableName, " = $__p[\"", variableName, "\"];"); zephir_concat_self(&code, _9 TSRMLS_CC); zephir_concat_self_str(&code, SL(" } else { ") TSRMLS_CC); ZEPHIR_OBS_NVAR(defaultValue); if (zephir_array_isset_string_fetch(&defaultValue, parameter, SS("default"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_10, this_ptr, "expression", &_11, 377, defaultValue); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SVSVS(_12, "$", variableName, " = ", _10, ";"); zephir_concat_self(&code, _12 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_SVSVS(_12, " throw new \\Phalcon\\Mvc\\View\\Exception(\"Macro '", name, "' was called without parameter: ", variableName, "\"); "); zephir_concat_self(&code, _12 TSRMLS_CC); } zephir_concat_self_str(&code, SL(" } } ") TSRMLS_CC); } zephir_concat_self_str(&code, SL(" ?>") TSRMLS_CC); } ZEPHIR_OBS_VAR(blockStatements); if (zephir_array_isset_string_fetch(&blockStatements, statement, SS("block_statements"), 0 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_1); if (extendsMode) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_CALL_METHOD(&_10, this_ptr, "_statementlist", NULL, 382, blockStatements, _1); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, _10, "<?php }; "); zephir_concat_self(&code, _2 TSRMLS_CC); } else { zephir_concat_self_str(&code, SL("<?php }; ") TSRMLS_CC); } if (zephir_is_php_version(50300)) { zephir_concat_self_str(&code, SL(" ?>") TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VSVS(_2, macroName, " = \\Closure::bind(", macroName, ", $this); ?>"); zephir_concat_self(&code, _2 TSRMLS_CC); } RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileCall) { zend_bool extendsMode; zval *statement_param = NULL, *extendsMode_param = NULL; zval *statement = NULL; zephir_fetch_params(0, 2, 0, &statement_param, &extendsMode_param); statement = statement_param; extendsMode = zephir_get_boolval(extendsMode_param); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, _statementList) { zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_23 = NULL, *_24 = NULL, *_25 = NULL, *_26 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zend_bool extendsMode, _0; zval *statements_param = NULL, *extendsMode_param = NULL, *extended = NULL, *blockMode = NULL, *compilation = NULL, *extensions, *statement = NULL, *tempCompilation = NULL, *type = NULL, *blockName = NULL, *blockStatements = NULL, *blocks = NULL, *path = NULL, *view = NULL, *finalPath = NULL, *subCompiler = NULL, *level, **_3, *_4 = NULL, *_5, *_6, *_7 = NULL, *_11 = NULL, *_18 = NULL; zval *statements = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &statements_param, &extendsMode_param); statements = statements_param; if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } if (!(zephir_fast_count_int(statements TSRMLS_CC))) { RETURN_MM_STRING("", 1); } ZEPHIR_OBS_VAR(extended); zephir_read_property_this(&extended, this_ptr, SL("_extended"), PH_NOISY_CC); _0 = zephir_is_true(extended); if (!(_0)) { _0 = extendsMode; } ZEPHIR_INIT_VAR(blockMode); ZVAL_BOOL(blockMode, _0); if (ZEPHIR_IS_TRUE_IDENTICAL(blockMode)) { RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_blockLevel") TSRMLS_CC)); } RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_level") TSRMLS_CC)); ZEPHIR_INIT_VAR(compilation); ZVAL_NULL(compilation); ZEPHIR_OBS_VAR(extensions); zephir_read_property_this(&extensions, this_ptr, SL("_extensions"), PH_NOISY_CC); zephir_is_iterable(statements, &_2, &_1, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 2192); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(statement, _3); if (Z_TYPE_P(statement) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Corrupted statement", "phalcon/mvc/view/engine/volt/compiler.zep", 1992); return; } if (!(zephir_array_isset_string(statement, SS("type")))) { ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_5, statement, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1999 TSRMLS_CC); zephir_array_fetch_string(&_6, statement, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 1999 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSV(_7, "Invalid statement in ", _5, " on line ", _6); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/mvc/view/engine/volt/compiler.zep", 1999 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(extensions) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_9); zephir_create_array(_9, 1, 0 TSRMLS_CC); zephir_array_fast_append(_9, statement); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "compileStatement", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&tempCompilation, this_ptr, "fireextensionevent", &_10, 378, _4, _9); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (Z_TYPE_P(tempCompilation) == IS_STRING) { zephir_concat_self(&compilation, tempCompilation TSRMLS_CC); continue; } } ZEPHIR_OBS_NVAR(type); zephir_array_fetch_string(&type, statement, SL("type"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2020 TSRMLS_CC); do { if (ZEPHIR_IS_LONG(type, 357)) { zephir_array_fetch_string(&_5, statement, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 2028 TSRMLS_CC); zephir_concat_self(&compilation, _5 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 300)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileif", &_12, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 302)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileelseif", &_13, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 304)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileforeach", &_14, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 306)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileset", &_15, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 359)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileecho", &_16, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 307)) { ZEPHIR_OBS_NVAR(blockName); zephir_array_fetch_string(&blockName, statement, SL("name"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2056 TSRMLS_CC); ZEPHIR_OBS_NVAR(blockStatements); zephir_array_isset_string_fetch(&blockStatements, statement, SS("block_statements"), 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(blocks); zephir_read_property_this(&blocks, this_ptr, SL("_blocks"), PH_NOISY_CC); if (zephir_is_true(blockMode)) { if (Z_TYPE_P(blocks) != IS_ARRAY) { ZEPHIR_INIT_NVAR(blocks); array_init(blocks); } if (Z_TYPE_P(compilation) != IS_NULL) { zephir_array_append(&blocks, compilation, PH_SEPARATE, "phalcon/mvc/view/engine/volt/compiler.zep", 2071); ZEPHIR_INIT_NVAR(compilation); ZVAL_NULL(compilation); } zephir_array_update_zval(&blocks, blockName, &blockStatements, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("_blocks"), blocks TSRMLS_CC); } else { if (Z_TYPE_P(blockStatements) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "_statementlist", &_17, 382, blockStatements, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); } } break; } if (ZEPHIR_IS_LONG(type, 310)) { ZEPHIR_OBS_NVAR(path); zephir_array_fetch_string(&path, statement, SL("path"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2093 TSRMLS_CC); ZEPHIR_OBS_NVAR(view); zephir_read_property_this(&view, this_ptr, SL("_view"), PH_NOISY_CC); if (Z_TYPE_P(view) == IS_OBJECT) { ZEPHIR_CALL_METHOD(&_11, view, "getviewsdir", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_5, path, SL("value"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 2097 TSRMLS_CC); ZEPHIR_INIT_NVAR(finalPath); ZEPHIR_CONCAT_VV(finalPath, _11, _5); } else { ZEPHIR_OBS_NVAR(finalPath); zephir_array_fetch_string(&finalPath, path, SL("value"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2099 TSRMLS_CC); } ZEPHIR_INIT_NVAR(extended); ZVAL_BOOL(extended, 1); ZEPHIR_INIT_NVAR(subCompiler); if (zephir_clone(subCompiler, this_ptr TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_CALL_METHOD(&tempCompilation, subCompiler, "compile", NULL, 0, finalPath, extended); zephir_check_call_status(); if (Z_TYPE_P(tempCompilation) == IS_NULL) { ZEPHIR_CALL_METHOD(&_18, subCompiler, "getcompiledtemplatepath", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(tempCompilation); zephir_file_get_contents(tempCompilation, _18 TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_extended"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_extended"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_extendedBlocks"), tempCompilation TSRMLS_CC); ZEPHIR_CPY_WRT(blockMode, extended); break; } if (ZEPHIR_IS_LONG(type, 313)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileinclude", &_19, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 314)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compilecache", &_20, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 316)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compiledo", &_21, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 327)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compilereturn", &_22, 0, statement); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 317)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileautoescape", &_23, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 319)) { zephir_concat_self_str(&compilation, SL("<?php continue; ?>") TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 320)) { zephir_concat_self_str(&compilation, SL("<?php break; ?>") TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 321)) { ZEPHIR_CALL_METHOD(&_11, this_ptr, "compileforelse", &_24, 0); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 322)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compilemacro", &_25, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 325)) { ZEPHIR_INIT_NVAR(_4); if (extendsMode) { ZVAL_BOOL(_4, 1); } else { ZVAL_BOOL(_4, 0); } ZEPHIR_CALL_METHOD(&_11, this_ptr, "compilecall", &_26, 0, statement, _4); zephir_check_call_status(); zephir_concat_self(&compilation, _11 TSRMLS_CC); break; } if (ZEPHIR_IS_LONG(type, 358)) { break; } ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_mvc_view_engine_volt_exception_ce); zephir_array_fetch_string(&_5, statement, SL("file"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 2184 TSRMLS_CC); zephir_array_fetch_string(&_6, statement, SL("line"), PH_NOISY | PH_READONLY, "phalcon/mvc/view/engine/volt/compiler.zep", 2184 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVSVSV(_7, "Unknown statement ", type, " in ", _5, " on line ", _6); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_4, "phalcon/mvc/view/engine/volt/compiler.zep", 2184 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while(0); } if (ZEPHIR_IS_TRUE_IDENTICAL(blockMode)) { level = zephir_fetch_nproperty_this(this_ptr, SL("_blockLevel"), PH_NOISY_CC); if (ZEPHIR_IS_LONG(level, 1)) { if (Z_TYPE_P(compilation) != IS_NULL) { zephir_update_property_array_append(this_ptr, SL("_blocks"), compilation TSRMLS_CC); } } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_blockLevel") TSRMLS_CC)); } RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("_level") TSRMLS_CC)); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, _compileSource) { HashTable *_3; HashPosition _2; zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *viewCode_param = NULL, *extendsMode_param = NULL, *currentPath, *intermediate, *extended, *finalCompilation, *blocks, *extendedBlocks, *name = NULL, *block = NULL, *blockCompilation = NULL, *localBlock = NULL, *compilation = NULL, *options, *autoescape, *_0, **_4; zval *viewCode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewCode_param, &extendsMode_param); if (unlikely(Z_TYPE_P(viewCode_param) != IS_STRING && Z_TYPE_P(viewCode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewCode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewCode_param) == IS_STRING)) { zephir_get_strval(viewCode, viewCode_param); } else { ZEPHIR_INIT_VAR(viewCode); ZVAL_EMPTY_STRING(viewCode); } if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } ZEPHIR_OBS_VAR(currentPath); zephir_read_property_this(¤tPath, this_ptr, SL("_currentPath"), PH_NOISY_CC); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_VAR(autoescape); if (zephir_array_isset_string_fetch(&autoescape, options, SS("autoescape"), 0 TSRMLS_CC)) { if (Z_TYPE_P(autoescape) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'autoescape' must be boolean", "phalcon/mvc/view/engine/volt/compiler.zep", 2229); return; } zephir_update_property_this(this_ptr, SL("_autoescape"), autoescape TSRMLS_CC); } } ZEPHIR_INIT_VAR(intermediate); ZEPHIR_LAST_CALL_STATUS = phvolt_parse_view(intermediate, viewCode, currentPath TSRMLS_CC); zephir_check_call_status(); if (Z_TYPE_P(intermediate) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Invalid intermediate representation", "phalcon/mvc/view/engine/volt/compiler.zep", 2241); return; } ZEPHIR_INIT_VAR(_0); if (extendsMode) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "_statementlist", &_1, 382, intermediate, _0); zephir_check_call_status(); ZEPHIR_OBS_VAR(extended); zephir_read_property_this(&extended, this_ptr, SL("_extended"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(extended)) { ZEPHIR_INIT_VAR(finalCompilation); if (extendsMode == 1) { array_init(finalCompilation); } else { ZVAL_NULL(finalCompilation); } ZEPHIR_OBS_VAR(blocks); zephir_read_property_this(&blocks, this_ptr, SL("_blocks"), PH_NOISY_CC); ZEPHIR_OBS_VAR(extendedBlocks); zephir_read_property_this(&extendedBlocks, this_ptr, SL("_extendedBlocks"), PH_NOISY_CC); zephir_is_iterable(extendedBlocks, &_3, &_2, 0, 0, "phalcon/mvc/view/engine/volt/compiler.zep", 2307); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(name, _3, _2); ZEPHIR_GET_HVALUE(block, _4); if (Z_TYPE_P(name) == IS_STRING) { if (zephir_array_isset(blocks, name)) { ZEPHIR_OBS_NVAR(localBlock); zephir_array_fetch(&localBlock, blocks, name, PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2275 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_currentBlock"), name TSRMLS_CC); ZEPHIR_CALL_METHOD(&blockCompilation, this_ptr, "_statementlist", &_1, 382, localBlock); zephir_check_call_status(); } else { if (Z_TYPE_P(block) == IS_ARRAY) { ZEPHIR_CALL_METHOD(&blockCompilation, this_ptr, "_statementlist", &_1, 382, block); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(blockCompilation, block); } } if (extendsMode == 1) { zephir_array_update_zval(&finalCompilation, name, &blockCompilation, PH_COPY | PH_SEPARATE); } else { zephir_concat_self(&finalCompilation, blockCompilation TSRMLS_CC); } } else { if (extendsMode == 1) { zephir_array_append(&finalCompilation, block, PH_SEPARATE, "phalcon/mvc/view/engine/volt/compiler.zep", 2300); } else { zephir_concat_self(&finalCompilation, block TSRMLS_CC); } } } RETURN_CCTOR(finalCompilation); } if (extendsMode == 1) { RETURN_MM_MEMBER(this_ptr, "_blocks"); } RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileString) { int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *viewCode_param = NULL, *extendsMode_param = NULL, *_0, *_1; zval *viewCode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &viewCode_param, &extendsMode_param); if (unlikely(Z_TYPE_P(viewCode_param) != IS_STRING && Z_TYPE_P(viewCode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewCode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewCode_param) == IS_STRING)) { zephir_get_strval(viewCode, viewCode_param); } else { ZEPHIR_INIT_VAR(viewCode); ZVAL_EMPTY_STRING(viewCode); } if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_STRING(_0, "eval code", 1); zephir_update_property_this(this_ptr, SL("_currentPath"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); if (extendsMode) { ZVAL_BOOL(_1, 1); } else { ZVAL_BOOL(_1, 0); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_compilesource", NULL, 0, viewCode, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compileFile) { int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *path_param = NULL, *compiledPath_param = NULL, *extendsMode_param = NULL, *viewCode, *compilation = NULL, *finalCompilation = NULL, *_0 = NULL; zval *path = NULL, *compiledPath = NULL, *_1 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &path_param, &compiledPath_param, &extendsMode_param); if (unlikely(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(path_param) == IS_STRING)) { zephir_get_strval(path, path_param); } else { ZEPHIR_INIT_VAR(path); ZVAL_EMPTY_STRING(path); } if (unlikely(Z_TYPE_P(compiledPath_param) != IS_STRING && Z_TYPE_P(compiledPath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'compiledPath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(compiledPath_param) == IS_STRING)) { zephir_get_strval(compiledPath, compiledPath_param); } else { ZEPHIR_INIT_VAR(compiledPath); ZVAL_EMPTY_STRING(compiledPath); } if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } if (ZEPHIR_IS_EQUAL(path, compiledPath)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Template path and compilation template path cannot be the same", "phalcon/mvc/view/engine/volt/compiler.zep", 2349); return; } if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_volt_exception_ce); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "Template file ", path, " does not exist"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/engine/volt/compiler.zep", 2356 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(viewCode); zephir_file_get_contents(viewCode, path TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(viewCode)) { ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_mvc_view_engine_volt_exception_ce); ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVS(_1, "Template file ", path, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 9, _1); zephir_check_call_status(); zephir_throw_exception_debug(_0, "phalcon/mvc/view/engine/volt/compiler.zep", 2364 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } zephir_update_property_this(this_ptr, SL("_currentPath"), path TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); if (extendsMode) { ZVAL_BOOL(_0, 1); } else { ZVAL_BOOL(_0, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "_compilesource", NULL, 0, viewCode, _0); zephir_check_call_status(); if (Z_TYPE_P(compilation) == IS_ARRAY) { ZEPHIR_CALL_FUNCTION(&finalCompilation, "serialize", NULL, 74, compilation); zephir_check_call_status(); } else { ZEPHIR_CPY_WRT(finalCompilation, compilation); } ZEPHIR_INIT_NVAR(_0); zephir_file_put_contents(_0, compiledPath, finalCompilation TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "Volt directory can't be written", "phalcon/mvc/view/engine/volt/compiler.zep", 2383); return; } RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, compile) { zephir_fcall_cache_entry *_4 = NULL; zval *_2; int ZEPHIR_LAST_CALL_STATUS; zend_bool extendsMode; zval *templatePath_param = NULL, *extendsMode_param = NULL, *stat = NULL, *compileAlways = NULL, *prefix = NULL, *compiledPath = NULL, *compiledSeparator = NULL, *blocksCode, *compiledExtension = NULL, *compilation = NULL, *options, *realCompiledPath = NULL, *compiledTemplatePath = NULL, *templateSepPath = NULL, *_0, *_1 = NULL, *_3 = NULL, *_5, *_6 = NULL, *_7 = NULL; zval *templatePath = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &templatePath_param, &extendsMode_param); if (unlikely(Z_TYPE_P(templatePath_param) != IS_STRING && Z_TYPE_P(templatePath_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'templatePath' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(templatePath_param) == IS_STRING)) { zephir_get_strval(templatePath, templatePath_param); } else { ZEPHIR_INIT_VAR(templatePath); ZVAL_EMPTY_STRING(templatePath); } if (!extendsMode_param) { extendsMode = 0; } else { extendsMode = zephir_get_boolval(extendsMode_param); } if (0) { zephir_update_property_this(this_ptr, SL("_extended"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_extended"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } if (0) { zephir_update_property_this(this_ptr, SL("_extendedBlocks"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_extendedBlocks"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_blocks"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_level"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_foreachLevel"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_blockLevel"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_exprLevel"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(stat); ZVAL_BOOL(stat, 1); ZEPHIR_INIT_VAR(compileAlways); ZVAL_BOOL(compileAlways, 0); ZEPHIR_INIT_VAR(compiledPath); ZVAL_STRING(compiledPath, "", 1); ZEPHIR_INIT_VAR(prefix); ZVAL_NULL(prefix); ZEPHIR_INIT_VAR(compiledSeparator); ZVAL_STRING(compiledSeparator, "%%", 1); ZEPHIR_INIT_VAR(compiledExtension); ZVAL_STRING(compiledExtension, ".php", 1); ZEPHIR_INIT_VAR(compilation); ZVAL_NULL(compilation); ZEPHIR_OBS_VAR(options); zephir_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_string(options, SS("compileAlways"))) { ZEPHIR_OBS_NVAR(compileAlways); zephir_array_fetch_string(&compileAlways, options, SL("compileAlways"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2430 TSRMLS_CC); if (Z_TYPE_P(compileAlways) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'compileAlways' must be a bool value", "phalcon/mvc/view/engine/volt/compiler.zep", 2432); return; } } if (zephir_array_isset_string(options, SS("prefix"))) { ZEPHIR_OBS_NVAR(prefix); zephir_array_fetch_string(&prefix, options, SL("prefix"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2440 TSRMLS_CC); if (Z_TYPE_P(prefix) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'prefix' must be a string", "phalcon/mvc/view/engine/volt/compiler.zep", 2442); return; } } if (zephir_array_isset_string(options, SS("compiledPath"))) { ZEPHIR_OBS_NVAR(compiledPath); zephir_array_fetch_string(&compiledPath, options, SL("compiledPath"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2450 TSRMLS_CC); if (Z_TYPE_P(compiledPath) != IS_STRING) { if (Z_TYPE_P(compiledPath) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'compiledPath' must be a string or a closure", "phalcon/mvc/view/engine/volt/compiler.zep", 2453); return; } } } if (zephir_array_isset_string(options, SS("compiledSeparator"))) { ZEPHIR_OBS_NVAR(compiledSeparator); zephir_array_fetch_string(&compiledSeparator, options, SL("compiledSeparator"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2462 TSRMLS_CC); if (Z_TYPE_P(compiledSeparator) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'compiledSeparator' must be a string", "phalcon/mvc/view/engine/volt/compiler.zep", 2464); return; } } if (zephir_array_isset_string(options, SS("compiledExtension"))) { ZEPHIR_OBS_NVAR(compiledExtension); zephir_array_fetch_string(&compiledExtension, options, SL("compiledExtension"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2472 TSRMLS_CC); if (Z_TYPE_P(compiledExtension) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "'compiledExtension' must be a string", "phalcon/mvc/view/engine/volt/compiler.zep", 2474); return; } } if (zephir_array_isset_string(options, SS("stat"))) { ZEPHIR_OBS_NVAR(stat); zephir_array_fetch_string(&stat, options, SL("stat"), PH_NOISY, "phalcon/mvc/view/engine/volt/compiler.zep", 2482 TSRMLS_CC); } } if (Z_TYPE_P(compiledPath) == IS_STRING) { if (!(ZEPHIR_IS_EMPTY(compiledPath))) { ZEPHIR_CALL_FUNCTION(&_1, "realpath", NULL, 63, templatePath); zephir_check_call_status(); ZEPHIR_INIT_VAR(templateSepPath); zephir_prepare_virtual_path(templateSepPath, _1, compiledSeparator TSRMLS_CC); } else { ZEPHIR_CPY_WRT(templateSepPath, templatePath); } ZEPHIR_INIT_VAR(compiledTemplatePath); if (extendsMode == 1) { ZEPHIR_CONCAT_VVVVSVV(compiledTemplatePath, compiledPath, prefix, templateSepPath, compiledSeparator, "e", compiledSeparator, compiledExtension); } else { ZEPHIR_CONCAT_VVVV(compiledTemplatePath, compiledPath, prefix, templateSepPath, compiledExtension); } } else { if (Z_TYPE_P(compiledPath) == IS_OBJECT) { if (zephir_instance_of_ev(compiledPath, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 3, 0 TSRMLS_CC); zephir_array_fast_append(_2, templatePath); zephir_array_fast_append(_2, options); ZEPHIR_INIT_VAR(_3); ZVAL_BOOL(_3, extendsMode); zephir_array_fast_append(_2, _3); ZEPHIR_INIT_NVAR(compiledTemplatePath); ZEPHIR_CALL_USER_FUNC_ARRAY(compiledTemplatePath, compiledPath, _2); zephir_check_call_status(); if (Z_TYPE_P(compiledTemplatePath) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "compiledPath closure didn't return a valid string", "phalcon/mvc/view/engine/volt/compiler.zep", 2527); return; } } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_engine_volt_exception_ce, "compiledPath must be a string or a closure", "phalcon/mvc/view/engine/volt/compiler.zep", 2530); return; } } } ZEPHIR_CPY_WRT(realCompiledPath, compiledTemplatePath); if (zephir_is_true(compileAlways)) { ZEPHIR_INIT_NVAR(_3); if (extendsMode) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "compilefile", &_4, 0, templatePath, realCompiledPath, _3); zephir_check_call_status(); } else { if (ZEPHIR_IS_TRUE_IDENTICAL(stat)) { if ((zephir_file_exists(compiledTemplatePath TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_5); if (zephir_compare_mtime(templatePath, realCompiledPath TSRMLS_CC)) { ZEPHIR_INIT_VAR(_6); if (extendsMode) { ZVAL_BOOL(_6, 1); } else { ZVAL_BOOL(_6, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "compilefile", &_4, 0, templatePath, realCompiledPath, _6); zephir_check_call_status(); } else { if (extendsMode == 1) { ZEPHIR_INIT_VAR(blocksCode); zephir_file_get_contents(blocksCode, realCompiledPath TSRMLS_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(blocksCode)) { ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_mvc_view_engine_volt_exception_ce); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVS(_7, "Extends compilation file ", realCompiledPath, " could not be opened"); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_6, "phalcon/mvc/view/engine/volt/compiler.zep", 2564 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(blocksCode)) { ZEPHIR_CALL_FUNCTION(&compilation, "unserialize", NULL, 75, blocksCode); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(compilation); array_init(compilation); } } } } else { ZEPHIR_INIT_NVAR(_3); if (extendsMode) { ZVAL_BOOL(_3, 1); } else { ZVAL_BOOL(_3, 0); } ZEPHIR_CALL_METHOD(&compilation, this_ptr, "compilefile", &_4, 0, templatePath, realCompiledPath, _3); zephir_check_call_status(); } } else { if (!((zephir_file_exists(realCompiledPath TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_NVAR(_3); object_init_ex(_3, phalcon_mvc_view_engine_volt_exception_ce); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SVS(_7, "Compiled template file ", realCompiledPath, " does not exist"); ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 9, _7); zephir_check_call_status(); zephir_throw_exception_debug(_3, "phalcon/mvc/view/engine/volt/compiler.zep", 2590 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } zephir_update_property_this(this_ptr, SL("_compiledTemplatePath"), realCompiledPath TSRMLS_CC); RETURN_CCTOR(compilation); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getTemplatePath) { RETURN_MEMBER(this_ptr, "_currentPath"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, getCompiledTemplatePath) { RETURN_MEMBER(this_ptr, "_compiledTemplatePath"); } static PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, parse) { int ZEPHIR_LAST_CALL_STATUS; zval *viewCode_param = NULL, *currentPath; zval *viewCode = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &viewCode_param); if (unlikely(Z_TYPE_P(viewCode_param) != IS_STRING && Z_TYPE_P(viewCode_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewCode' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewCode_param) == IS_STRING)) { zephir_get_strval(viewCode, viewCode_param); } else { ZEPHIR_INIT_VAR(viewCode); ZVAL_EMPTY_STRING(viewCode); } ZEPHIR_INIT_VAR(currentPath); ZVAL_STRING(currentPath, "eval code", 1); ZEPHIR_LAST_CALL_STATUS = phvolt_parse_view(return_value, viewCode, currentPath TSRMLS_CC); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Volt_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View\\Engine\\Volt, Exception, phalcon, mvc_view_engine_volt_exception, phalcon_mvc_view_exception_ce, NULL, 0); return SUCCESS; } /* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> // 42 "parser.lemon" #ifdef HAVE_CONFIG_H #endif static zval *phvolt_ret_literal_zval(int type, phvolt_parser_token *T, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", type); if (T) { add_assoc_stringl(ret, "value", T->token, T->token_len, 0); efree(T); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_if_statement(zval *expr, zval *true_statements, zval *false_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 7); add_assoc_long(ret, "type", PHVOLT_T_IF); add_assoc_zval(ret, "expr", expr); if (true_statements) { add_assoc_zval(ret, "true_statements", true_statements); } if (false_statements) { add_assoc_zval(ret, "false_statements", false_statements); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_elseif_statement(zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHVOLT_T_ELSEIF); add_assoc_zval(ret, "expr", expr); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_elsefor_statement(phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 4); add_assoc_long(ret, "type", PHVOLT_T_ELSEFOR); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_for_statement(phvolt_parser_token *variable, phvolt_parser_token *key, zval *expr, zval *if_expr, zval *block_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 9); add_assoc_long(ret, "type", PHVOLT_T_FOR); add_assoc_stringl(ret, "variable", variable->token, variable->token_len, 0); efree(variable); if (key) { add_assoc_stringl(ret, "key", key->token, key->token_len, 0); efree(key); } add_assoc_zval(ret, "expr", expr); if (if_expr) { add_assoc_zval(ret, "if_expr", if_expr); } add_assoc_zval(ret, "block_statements", block_statements); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_cache_statement(zval *expr, zval *lifetime, zval *block_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_CACHE); add_assoc_zval(ret, "expr", expr); if (lifetime) { add_assoc_zval(ret, "lifetime", lifetime); } add_assoc_zval(ret, "block_statements", block_statements); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_raw_statement(zval *statement, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_RAW); add_assoc_zval(ret, "content", statement); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_set_statement(zval *assignments) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 3); add_assoc_long(ret, "type", PHVOLT_T_SET); add_assoc_zval(ret, "assignments", assignments); return ret; } static zval *phvolt_ret_set_assignment(zval *assignable_expr, int operator, zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_zval(ret, "variable", assignable_expr); add_assoc_long(ret, "op", operator); add_assoc_zval(ret, "expr", expr); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_echo_statement(zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 4); add_assoc_long(ret, "type", PHVOLT_T_ECHO); add_assoc_zval(ret, "expr", expr); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_block_statement(phvolt_parser_token *name, zval *block_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 6); add_assoc_long(ret, "type", PHVOLT_T_BLOCK); add_assoc_stringl(ret, "name", name->token, name->token_len, 0); efree(name); if (block_statements) { add_assoc_zval(ret, "block_statements", block_statements); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_macro_statement(phvolt_parser_token *macro_name, zval *parameters, zval *block_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_MACRO); add_assoc_stringl(ret, "name", macro_name->token, macro_name->token_len, 0); efree(macro_name); if (parameters) { add_assoc_zval(ret, "parameters", parameters); } if (block_statements) { add_assoc_zval(ret, "block_statements", block_statements); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_macro_parameter(phvolt_parser_token *variable, zval *default_value, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_stringl(ret, "variable", variable->token, variable->token_len, 0); efree(variable); if (default_value) { add_assoc_zval(ret, "default", default_value); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_extends_statement(zval *path, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 4); add_assoc_long(ret, "type", PHVOLT_T_EXTENDS); add_assoc_zval(ret, "path", path); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_include_statement(zval *path, zval *params, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHVOLT_T_INCLUDE); add_assoc_zval(ret, "path", path); if (params) { add_assoc_zval(ret, "params", params); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_do_statement(zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHVOLT_T_DO); add_assoc_zval(ret, "expr", expr); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_return_statement(zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 4); add_assoc_long(ret, "type", PHVOLT_T_RETURN); add_assoc_zval(ret, "expr", expr); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_autoescape_statement(int enable, zval *block_statements, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 5); add_assoc_long(ret, "type", PHVOLT_T_AUTOESCAPE); add_assoc_long(ret, "enable", enable); add_assoc_zval(ret, "block_statements", block_statements); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_empty_statement(phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 3); add_assoc_long(ret, "type", PHVOLT_T_EMPTY_STATEMENT); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_break_statement(phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 3); add_assoc_long(ret, "type", PHVOLT_T_BREAK); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_continue_statement(phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init_size(ret, 3); add_assoc_long(ret, "type", PHVOLT_T_CONTINUE); Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_zval_list(zval *list_left, zval *right_list) { zval *ret; HashPosition pos; HashTable *list; MAKE_STD_ZVAL(ret); array_init(ret); if (list_left) { list = Z_ARRVAL_P(list_left); if (zend_hash_index_exists(list, 0)) { zend_hash_internal_pointer_reset_ex(list, &pos); for (;; zend_hash_move_forward_ex(list, &pos)) { zval ** item; if (zend_hash_get_current_data_ex(list, (void**) &item, &pos) == FAILURE) { break; } Z_ADDREF_PP(item); add_next_index_zval(ret, *item); } zval_ptr_dtor(&list_left); } else { add_next_index_zval(ret, list_left); } } add_next_index_zval(ret, right_list); return ret; } static zval *phvolt_ret_named_item(phvolt_parser_token *name, zval *expr, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_zval(ret, "expr", expr); if (name != NULL) { add_assoc_stringl(ret, "name", name->token, name->token_len, 0); efree(name); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_expr(int type, zval *left, zval *right, zval *ternary, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", type); if (ternary) { add_assoc_zval(ret, "ternary", ternary); } if (left) { add_assoc_zval(ret, "left", left); } if (right) { add_assoc_zval(ret, "right", right); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_slice(zval *left, zval *start, zval *end, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_SLICE); add_assoc_zval(ret, "left", left); if (start != NULL) { add_assoc_zval(ret, "start", start); } if (end != NULL) { add_assoc_zval(ret, "end", end); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_func_call(zval *expr, zval *arguments, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_FCALL); add_assoc_zval(ret, "name", expr); if (arguments) { add_assoc_zval(ret, "arguments", arguments); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } static zval *phvolt_ret_macro_call_statement(zval *expr, zval *arguments, zval *caller, phvolt_scanner_state *state) { zval *ret; MAKE_STD_ZVAL(ret); array_init(ret); add_assoc_long(ret, "type", PHVOLT_T_CALL); add_assoc_zval(ret, "name", expr); if (arguments) { add_assoc_zval(ret, "arguments", arguments); } if (caller) { add_assoc_zval(ret, "caller", caller); } Z_ADDREF_P(state->active_file); add_assoc_zval(ret, "file", state->active_file); add_assoc_long(ret, "line", state->active_line); return ret; } // 584 "parser.c" /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ /* Make sure the INTERFACE macro is defined. */ #ifndef INTERFACE # define INTERFACE 1 #endif /* The next thing included is series of defines which control ** various aspects of the generated parser. ** VVCODETYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 terminals ** and nonterminals. "int" is used otherwise. ** VVNOCODE is a number of type VVCODETYPE which corresponds ** to no legal terminal or nonterminal number. This ** number is used to fill in empty slots of the hash ** table. ** VVFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the ** original value of the token will not parse. ** VVACTIONTYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. ** phvolt_TOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** VVMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of ** which is phvolt_TOKENTYPE. The entry in the union ** for base tokens is called "vv0". ** VVSTACKDEPTH is the maximum depth of the parser's stack. ** phvolt_ARG_SDECL A static variable declaration for the %extra_argument ** phvolt_ARG_PDECL A parameter declaration for the %extra_argument ** phvolt_ARG_STORE Code to store %extra_argument into vvpParser ** phvolt_ARG_FETCH Code to extract %extra_argument from vvpParser ** VVNSTATE the combined number of states. ** VVNRULE the number of rules in the grammar ** VVERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define VVCODETYPE unsigned char #define VVNOCODE 125 #define VVACTIONTYPE unsigned short int #define phvolt_TOKENTYPE phvolt_parser_token* typedef union { phvolt_TOKENTYPE vv0; zval* vv40; int vv249; } VVMINORTYPE; #define VVSTACKDEPTH 100 #define phvolt_ARG_SDECL phvolt_parser_status *status; #define phvolt_ARG_PDECL ,phvolt_parser_status *status #define phvolt_ARG_FETCH phvolt_parser_status *status = vvpParser->status #define phvolt_ARG_STORE vvpParser->status = status #define VVNSTATE 348 #define VVNRULE 152 #define VVERRORSYMBOL 85 #define VVERRSYMDT vv249 #define VV_NO_ACTION (VVNSTATE+VVNRULE+2) #define VV_ACCEPT_ACTION (VVNSTATE+VVNRULE+1) #define VV_ERROR_ACTION (VVNSTATE+VVNRULE) /* Next are that tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N < VVNSTATE Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** VVNSTATE <= N < VVNSTATE+VVNRULE Reduce by rule N-VVNSTATE. ** ** N == VVNSTATE+VVNRULE A syntax error has occurred. ** ** N == VVNSTATE+VVNRULE+1 The parser accepts its input. ** ** N == VVNSTATE+VVNRULE+2 No such action. Denotes unused ** slots in the vv_action[] table. ** ** The action table is constructed as a single large table named vv_action[]. ** Given state S and lookahead X, the action is computed as ** ** vv_action[ vv_shift_ofst[S] + X ] ** ** If the index value vv_shift_ofst[S]+X is out of range or if the value ** vv_lookahead[vv_shift_ofst[S]+X] is not equal to X or if vv_shift_ofst[S] ** is equal to VV_SHIFT_USE_DFLT, it means that the action is not in the table ** and that vv_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the vv_reduce_ofst[] array is used in place of ** the vv_shift_ofst[] array and VV_REDUCE_USE_DFLT is used in place of ** VV_SHIFT_USE_DFLT. ** ** The following are the tables generated in this section: ** ** vv_action[] A single table containing all actions. ** vv_lookahead[] A table containing the lookahead for each entry in ** vv_action. Used to detect hash collisions. ** vv_shift_ofst[] For each state, the offset into vv_action for ** shifting terminals. ** vv_reduce_ofst[] For each state, the offset into vv_action for ** shifting non-terminals after a reduce. ** vv_default[] Default action for each state. */ static VVACTIONTYPE vv_action[] = { /* 0 */ 83, 93, 109, 61, 53, 55, 67, 63, 65, 73, /* 10 */ 75, 77, 79, 69, 71, 49, 47, 51, 44, 41, /* 20 */ 57, 90, 59, 85, 88, 89, 97, 81, 86, 231, /* 30 */ 85, 88, 89, 97, 81, 286, 44, 41, 57, 90, /* 40 */ 59, 85, 88, 89, 97, 81, 108, 285, 180, 201, /* 50 */ 184, 83, 93, 182, 61, 53, 55, 67, 63, 65, /* 60 */ 73, 75, 77, 79, 69, 71, 49, 47, 51, 44, /* 70 */ 41, 57, 90, 59, 85, 88, 89, 97, 81, 223, /* 80 */ 251, 83, 93, 181, 61, 53, 55, 67, 63, 65, /* 90 */ 73, 75, 77, 79, 69, 71, 49, 47, 51, 44, /* 100 */ 41, 57, 90, 59, 85, 88, 89, 97, 81, 314, /* 110 */ 174, 321, 172, 37, 83, 93, 252, 61, 53, 55, /* 120 */ 67, 63, 65, 73, 75, 77, 79, 69, 71, 49, /* 130 */ 47, 51, 44, 41, 57, 90, 59, 85, 88, 89, /* 140 */ 97, 81, 330, 325, 83, 93, 228, 61, 53, 55, /* 150 */ 67, 63, 65, 73, 75, 77, 79, 69, 71, 49, /* 160 */ 47, 51, 44, 41, 57, 90, 59, 85, 88, 89, /* 170 */ 97, 81, 279, 260, 83, 93, 95, 61, 53, 55, /* 180 */ 67, 63, 65, 73, 75, 77, 79, 69, 71, 49, /* 190 */ 47, 51, 44, 41, 57, 90, 59, 85, 88, 89, /* 200 */ 97, 81, 83, 93, 302, 61, 53, 55, 67, 63, /* 210 */ 65, 73, 75, 77, 79, 69, 71, 49, 47, 51, /* 220 */ 44, 41, 57, 90, 59, 85, 88, 89, 97, 81, /* 230 */ 49, 47, 51, 44, 41, 57, 90, 59, 85, 88, /* 240 */ 89, 97, 81, 304, 295, 313, 199, 103, 109, 346, /* 250 */ 296, 83, 93, 205, 61, 53, 55, 67, 63, 65, /* 260 */ 73, 75, 77, 79, 69, 71, 49, 47, 51, 44, /* 270 */ 41, 57, 90, 59, 85, 88, 89, 97, 81, 129, /* 280 */ 316, 83, 93, 145, 61, 53, 55, 67, 63, 65, /* 290 */ 73, 75, 77, 79, 69, 71, 49, 47, 51, 44, /* 300 */ 41, 57, 90, 59, 85, 88, 89, 97, 81, 90, /* 310 */ 59, 85, 88, 89, 97, 81, 307, 308, 309, 310, /* 320 */ 311, 312, 183, 184, 92, 215, 262, 273, 83, 93, /* 330 */ 113, 61, 53, 55, 67, 63, 65, 73, 75, 77, /* 340 */ 79, 69, 71, 49, 47, 51, 44, 41, 57, 90, /* 350 */ 59, 85, 88, 89, 97, 81, 140, 140, 224, 271, /* 360 */ 284, 56, 91, 235, 143, 102, 216, 344, 139, 139, /* 370 */ 414, 197, 141, 118, 118, 83, 93, 118, 61, 53, /* 380 */ 55, 67, 63, 65, 73, 75, 77, 79, 69, 71, /* 390 */ 49, 47, 51, 44, 41, 57, 90, 59, 85, 88, /* 400 */ 89, 97, 81, 171, 40, 83, 93, 415, 61, 53, /* 410 */ 55, 67, 63, 65, 73, 75, 77, 79, 69, 71, /* 420 */ 49, 47, 51, 44, 41, 57, 90, 59, 85, 88, /* 430 */ 89, 97, 81, 237, 27, 83, 93, 481, 61, 53, /* 440 */ 55, 67, 63, 65, 73, 75, 77, 79, 69, 71, /* 450 */ 49, 47, 51, 44, 41, 57, 90, 59, 85, 88, /* 460 */ 89, 97, 81, 83, 93, 320, 61, 53, 55, 67, /* 470 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 480 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 97, /* 490 */ 81, 240, 332, 83, 93, 289, 61, 53, 55, 67, /* 500 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 510 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 97, /* 520 */ 81, 200, 248, 83, 93, 169, 61, 53, 55, 67, /* 530 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 540 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 97, /* 550 */ 81, 291, 254, 83, 93, 280, 61, 53, 55, 67, /* 560 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 570 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 97, /* 580 */ 81, 339, 257, 83, 93, 292, 61, 53, 55, 67, /* 590 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 600 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 213, /* 610 */ 81, 83, 93, 293, 61, 53, 55, 67, 63, 65, /* 620 */ 73, 75, 77, 79, 69, 71, 49, 47, 51, 44, /* 630 */ 41, 57, 90, 59, 85, 88, 89, 97, 81, 93, /* 640 */ 322, 61, 53, 55, 67, 63, 65, 73, 75, 77, /* 650 */ 79, 69, 71, 49, 47, 51, 44, 41, 57, 90, /* 660 */ 59, 85, 88, 89, 97, 81, 61, 53, 55, 67, /* 670 */ 63, 65, 73, 75, 77, 79, 69, 71, 49, 47, /* 680 */ 51, 44, 41, 57, 90, 59, 85, 88, 89, 97, /* 690 */ 81, 53, 55, 67, 63, 65, 73, 75, 77, 79, /* 700 */ 69, 71, 49, 47, 51, 44, 41, 57, 90, 59, /* 710 */ 85, 88, 89, 97, 81, 501, 1, 2, 272, 4, /* 720 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 730 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 28, /* 740 */ 272, 4, 5, 6, 7, 8, 9, 10, 11, 12, /* 750 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 760 */ 23, 207, 272, 4, 5, 6, 7, 8, 9, 10, /* 770 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, /* 780 */ 21, 22, 23, 67, 63, 65, 73, 75, 77, 79, /* 790 */ 69, 71, 49, 47, 51, 44, 41, 57, 90, 59, /* 800 */ 85, 88, 89, 97, 81, 232, 272, 4, 5, 6, /* 810 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, /* 820 */ 17, 18, 19, 20, 21, 22, 23, 264, 272, 4, /* 830 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 840 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 217, /* 850 */ 272, 4, 5, 6, 7, 8, 9, 10, 11, 12, /* 860 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 870 */ 23, 281, 272, 4, 5, 6, 7, 8, 9, 10, /* 880 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, /* 890 */ 21, 22, 23, 275, 272, 4, 5, 6, 7, 8, /* 900 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 910 */ 19, 20, 21, 22, 23, 333, 272, 4, 5, 6, /* 920 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, /* 930 */ 17, 18, 19, 20, 21, 22, 23, 175, 272, 4, /* 940 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 950 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 298, /* 960 */ 272, 4, 5, 6, 7, 8, 9, 10, 11, 12, /* 970 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 980 */ 23, 317, 272, 4, 5, 6, 7, 8, 9, 10, /* 990 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, /* 1000 */ 21, 22, 23, 326, 272, 4, 5, 6, 7, 8, /* 1010 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 1020 */ 19, 20, 21, 22, 23, 34, 272, 4, 5, 6, /* 1030 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, /* 1040 */ 17, 18, 19, 20, 21, 22, 23, 225, 272, 4, /* 1050 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 1060 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 3, /* 1070 */ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, /* 1080 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /* 1090 */ 241, 4, 5, 6, 7, 8, 9, 10, 11, 12, /* 1100 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 1110 */ 23, 25, 221, 341, 343, 38, 168, 170, 98, 294, /* 1120 */ 179, 349, 24, 105, 480, 127, 98, 202, 242, 24, /* 1130 */ 118, 135, 107, 214, 114, 118, 211, 340, 118, 135, /* 1140 */ 222, 263, 229, 26, 236, 105, 246, 249, 167, 255, /* 1150 */ 258, 261, 196, 268, 270, 118, 126, 118, 45, 42, /* 1160 */ 118, 104, 70, 99, 118, 29, 101, 243, 45, 42, /* 1170 */ 117, 104, 105, 99, 118, 119, 101, 323, 297, 238, /* 1180 */ 336, 112, 118, 114, 118, 119, 238, 120, 121, 122, /* 1190 */ 123, 124, 125, 98, 238, 239, 245, 120, 121, 122, /* 1200 */ 123, 124, 125, 245, 337, 118, 130, 118, 176, 68, /* 1210 */ 345, 245, 129, 155, 156, 157, 158, 159, 160, 161, /* 1220 */ 110, 118, 238, 148, 149, 150, 151, 152, 153, 154, /* 1230 */ 110, 25, 221, 30, 32, 38, 168, 170, 244, 245, /* 1240 */ 179, 58, 173, 247, 348, 54, 203, 202, 204, 301, /* 1250 */ 481, 304, 342, 118, 118, 118, 211, 118, 128, 31, /* 1260 */ 222, 238, 229, 35, 236, 238, 246, 249, 208, 255, /* 1270 */ 258, 261, 218, 268, 270, 33, 303, 250, 245, 25, /* 1280 */ 221, 195, 245, 38, 168, 170, 206, 198, 179, 118, /* 1290 */ 287, 137, 305, 72, 39, 202, 144, 306, 185, 187, /* 1300 */ 189, 191, 193, 116, 211, 118, 118, 138, 222, 227, /* 1310 */ 229, 226, 236, 178, 246, 249, 233, 255, 258, 261, /* 1320 */ 238, 268, 270, 347, 220, 238, 274, 25, 221, 238, /* 1330 */ 132, 38, 168, 170, 210, 265, 179, 245, 276, 253, /* 1340 */ 267, 212, 245, 202, 142, 256, 245, 238, 282, 480, /* 1350 */ 329, 118, 211, 118, 278, 269, 222, 118, 229, 234, /* 1360 */ 236, 278, 246, 249, 245, 255, 258, 261, 238, 268, /* 1370 */ 270, 278, 278, 238, 278, 25, 221, 36, 278, 38, /* 1380 */ 168, 170, 278, 299, 179, 245, 318, 278, 278, 64, /* 1390 */ 245, 202, 238, 278, 327, 238, 334, 278, 278, 278, /* 1400 */ 211, 118, 278, 278, 222, 238, 229, 278, 236, 245, /* 1410 */ 246, 249, 245, 255, 258, 261, 278, 268, 270, 278, /* 1420 */ 278, 163, 245, 25, 221, 278, 315, 38, 168, 170, /* 1430 */ 259, 335, 179, 118, 278, 278, 278, 278, 118, 202, /* 1440 */ 238, 278, 118, 238, 278, 278, 278, 278, 211, 278, /* 1450 */ 278, 238, 222, 238, 229, 278, 236, 245, 246, 249, /* 1460 */ 245, 255, 258, 261, 278, 268, 270, 76, 245, 66, /* 1470 */ 245, 25, 221, 62, 324, 38, 168, 170, 165, 118, /* 1480 */ 179, 118, 278, 278, 278, 118, 118, 202, 278, 278, /* 1490 */ 118, 52, 278, 278, 278, 278, 211, 219, 278, 278, /* 1500 */ 222, 278, 229, 118, 236, 278, 246, 249, 278, 255, /* 1510 */ 258, 261, 278, 268, 270, 186, 278, 133, 278, 25, /* 1520 */ 221, 50, 331, 38, 168, 170, 188, 118, 179, 118, /* 1530 */ 278, 278, 278, 118, 118, 202, 278, 60, 118, 278, /* 1540 */ 278, 87, 278, 278, 211, 278, 278, 278, 222, 118, /* 1550 */ 229, 283, 236, 118, 246, 249, 278, 255, 258, 261, /* 1560 */ 278, 268, 270, 48, 278, 190, 278, 25, 221, 46, /* 1570 */ 192, 38, 168, 170, 166, 118, 179, 118, 94, 84, /* 1580 */ 278, 118, 118, 202, 278, 96, 118, 230, 278, 74, /* 1590 */ 118, 118, 211, 278, 278, 278, 222, 118, 229, 118, /* 1600 */ 236, 118, 246, 249, 278, 255, 258, 261, 277, 268, /* 1610 */ 270, 82, 278, 80, 194, 25, 221, 338, 100, 38, /* 1620 */ 168, 170, 78, 118, 179, 118, 118, 278, 278, 278, /* 1630 */ 118, 202, 278, 43, 118, 278, 278, 278, 278, 278, /* 1640 */ 211, 278, 278, 278, 222, 118, 229, 278, 236, 278, /* 1650 */ 246, 249, 278, 255, 258, 261, 278, 268, 270, 278, /* 1660 */ 278, 278, 278, 25, 221, 278, 278, 38, 168, 170, /* 1670 */ 278, 278, 179, 278, 278, 278, 278, 278, 278, 202, /* 1680 */ 278, 209, 278, 278, 278, 278, 278, 278, 211, 278, /* 1690 */ 278, 278, 222, 278, 229, 278, 236, 278, 246, 249, /* 1700 */ 278, 255, 258, 261, 278, 268, 270, 278, 278, 278, /* 1710 */ 278, 25, 221, 278, 278, 38, 168, 170, 278, 278, /* 1720 */ 179, 278, 278, 278, 278, 278, 278, 202, 278, 278, /* 1730 */ 278, 278, 278, 278, 278, 278, 211, 278, 278, 278, /* 1740 */ 222, 288, 229, 278, 236, 278, 246, 249, 278, 255, /* 1750 */ 258, 261, 278, 268, 270, 278, 278, 278, 278, 25, /* 1760 */ 221, 278, 278, 38, 168, 170, 278, 278, 179, 278, /* 1770 */ 278, 278, 278, 278, 278, 202, 278, 278, 278, 278, /* 1780 */ 278, 278, 278, 278, 211, 278, 278, 278, 222, 278, /* 1790 */ 229, 278, 236, 278, 246, 249, 278, 255, 258, 261, /* 1800 */ 266, 268, 270, 278, 278, 278, 278, 25, 221, 278, /* 1810 */ 278, 38, 168, 170, 278, 328, 179, 278, 278, 278, /* 1820 */ 278, 278, 278, 202, 278, 278, 278, 278, 278, 278, /* 1830 */ 278, 278, 211, 278, 278, 278, 222, 278, 229, 278, /* 1840 */ 236, 278, 246, 249, 278, 255, 258, 261, 278, 268, /* 1850 */ 270, 278, 278, 278, 278, 25, 221, 278, 278, 38, /* 1860 */ 168, 170, 278, 278, 179, 278, 278, 278, 278, 278, /* 1870 */ 278, 202, 278, 300, 278, 278, 278, 278, 278, 278, /* 1880 */ 211, 278, 278, 278, 222, 278, 229, 278, 236, 278, /* 1890 */ 246, 249, 278, 255, 258, 261, 278, 268, 270, 278, /* 1900 */ 278, 278, 278, 25, 221, 278, 278, 38, 168, 170, /* 1910 */ 278, 177, 179, 278, 278, 278, 278, 278, 278, 202, /* 1920 */ 278, 278, 278, 278, 278, 278, 278, 278, 211, 278, /* 1930 */ 278, 278, 222, 278, 229, 278, 236, 278, 246, 249, /* 1940 */ 278, 255, 258, 261, 278, 268, 270, 278, 278, 278, /* 1950 */ 278, 25, 221, 278, 278, 38, 168, 170, 278, 319, /* 1960 */ 179, 278, 278, 278, 278, 278, 278, 202, 278, 278, /* 1970 */ 278, 278, 278, 278, 278, 278, 211, 278, 278, 278, /* 1980 */ 222, 278, 229, 278, 236, 278, 246, 249, 278, 255, /* 1990 */ 258, 261, 278, 268, 270, 278, 278, 278, 278, 25, /* 2000 */ 221, 278, 278, 38, 168, 170, 278, 278, 179, 278, /* 2010 */ 278, 278, 278, 278, 278, 202, 278, 278, 278, 278, /* 2020 */ 278, 278, 278, 278, 211, 278, 278, 278, 222, 278, /* 2030 */ 229, 278, 236, 278, 246, 249, 278, 255, 258, 261, /* 2040 */ 278, 268, 270, 278, 164, 278, 45, 42, 278, 104, /* 2050 */ 136, 99, 278, 162, 101, 278, 45, 42, 278, 104, /* 2060 */ 278, 99, 278, 119, 101, 278, 45, 42, 278, 104, /* 2070 */ 278, 99, 278, 119, 101, 120, 121, 122, 123, 124, /* 2080 */ 125, 278, 278, 147, 278, 120, 121, 122, 123, 124, /* 2090 */ 125, 278, 278, 278, 278, 146, 121, 122, 123, 124, /* 2100 */ 125, 278, 45, 42, 278, 104, 278, 99, 110, 278, /* 2110 */ 101, 278, 45, 42, 278, 104, 278, 99, 110, 119, /* 2120 */ 101, 278, 278, 278, 278, 278, 278, 106, 110, 119, /* 2130 */ 278, 120, 115, 122, 123, 124, 125, 278, 278, 134, /* 2140 */ 278, 120, 131, 122, 123, 124, 125, 278, 278, 45, /* 2150 */ 42, 278, 104, 278, 99, 45, 42, 101, 104, 278, /* 2160 */ 99, 278, 278, 101, 110, 278, 119, 278, 278, 278, /* 2170 */ 278, 278, 119, 278, 110, 278, 290, 278, 120, 131, /* 2180 */ 122, 123, 124, 125, 120, 115, 122, 123, 124, 125, /* 2190 */ 278, 278, 278, 278, 278, 278, 45, 42, 278, 104, /* 2200 */ 278, 99, 45, 42, 101, 104, 278, 99, 278, 278, /* 2210 */ 101, 110, 278, 119, 278, 278, 278, 110, 111, 119, /* 2220 */ 278, 278, 278, 278, 278, 120, 121, 122, 123, 124, /* 2230 */ 125, 120, 115, 122, 123, 124, 125, 278, 278, 45, /* 2240 */ 42, 278, 104, 278, 99, 278, 278, 101, 278, 278, /* 2250 */ 278, 278, 278, 278, 278, 278, 119, 278, 110, 278, /* 2260 */ 278, 278, 278, 278, 110, 278, 278, 278, 120, 131, /* 2270 */ 122, 123, 124, 125, 278, 278, 278, 278, 278, 278, /* 2280 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 2290 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 2300 */ 278, 110, }; static VVCODETYPE vv_lookahead[] = { /* 0 */ 3, 4, 2, 6, 7, 8, 9, 10, 11, 12, /* 10 */ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* 20 */ 23, 24, 25, 26, 27, 28, 29, 30, 3, 32, /* 30 */ 26, 27, 28, 29, 30, 38, 21, 22, 23, 24, /* 40 */ 25, 26, 27, 28, 29, 30, 46, 50, 111, 112, /* 50 */ 113, 3, 4, 2, 6, 7, 8, 9, 10, 11, /* 60 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 70 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 38, /* 80 */ 32, 3, 4, 32, 6, 7, 8, 9, 10, 11, /* 90 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 100 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 110 */ 32, 2, 3, 32, 3, 4, 68, 6, 7, 8, /* 120 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 130 */ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, /* 140 */ 29, 30, 31, 32, 3, 4, 32, 6, 7, 8, /* 150 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 160 */ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, /* 170 */ 29, 30, 118, 32, 3, 4, 5, 6, 7, 8, /* 180 */ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, /* 190 */ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, /* 200 */ 29, 30, 3, 4, 2, 6, 7, 8, 9, 10, /* 210 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, /* 220 */ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, /* 230 */ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, /* 240 */ 28, 29, 30, 38, 114, 115, 38, 48, 2, 33, /* 250 */ 48, 3, 4, 48, 6, 7, 8, 9, 10, 11, /* 260 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 270 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 2, /* 280 */ 32, 3, 4, 46, 6, 7, 8, 9, 10, 11, /* 290 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 300 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 24, /* 310 */ 25, 26, 27, 28, 29, 30, 50, 51, 52, 53, /* 320 */ 54, 55, 112, 113, 46, 48, 54, 55, 3, 4, /* 330 */ 84, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 340 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* 350 */ 25, 26, 27, 28, 29, 30, 38, 38, 32, 32, /* 360 */ 32, 110, 110, 32, 46, 110, 32, 32, 50, 50, /* 370 */ 32, 46, 120, 122, 122, 3, 4, 122, 6, 7, /* 380 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, /* 390 */ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, /* 400 */ 28, 29, 30, 38, 32, 3, 4, 32, 6, 7, /* 410 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, /* 420 */ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, /* 430 */ 28, 29, 30, 32, 32, 3, 4, 46, 6, 7, /* 440 */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, /* 450 */ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, /* 460 */ 28, 29, 30, 3, 4, 32, 6, 7, 8, 9, /* 470 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 480 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 490 */ 30, 59, 32, 3, 4, 32, 6, 7, 8, 9, /* 500 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 510 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 520 */ 30, 113, 32, 3, 4, 32, 6, 7, 8, 9, /* 530 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 540 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 550 */ 30, 32, 32, 3, 4, 32, 6, 7, 8, 9, /* 560 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 570 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 580 */ 30, 32, 32, 3, 4, 1, 6, 7, 8, 9, /* 590 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 600 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 610 */ 30, 3, 4, 57, 6, 7, 8, 9, 10, 11, /* 620 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, /* 630 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 4, /* 640 */ 38, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 650 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, /* 660 */ 25, 26, 27, 28, 29, 30, 6, 7, 8, 9, /* 670 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 680 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, /* 690 */ 30, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 700 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, /* 710 */ 26, 27, 28, 29, 30, 86, 87, 88, 89, 90, /* 720 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 730 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 88, /* 740 */ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, /* 750 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, /* 760 */ 109, 88, 89, 90, 91, 92, 93, 94, 95, 96, /* 770 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, /* 780 */ 107, 108, 109, 9, 10, 11, 12, 13, 14, 15, /* 790 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, /* 800 */ 26, 27, 28, 29, 30, 88, 89, 90, 91, 92, /* 810 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, /* 820 */ 103, 104, 105, 106, 107, 108, 109, 88, 89, 90, /* 830 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 840 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 88, /* 850 */ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, /* 860 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, /* 870 */ 109, 88, 89, 90, 91, 92, 93, 94, 95, 96, /* 880 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, /* 890 */ 107, 108, 109, 88, 89, 90, 91, 92, 93, 94, /* 900 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, /* 910 */ 105, 106, 107, 108, 109, 88, 89, 90, 91, 92, /* 920 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, /* 930 */ 103, 104, 105, 106, 107, 108, 109, 88, 89, 90, /* 940 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 950 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 88, /* 960 */ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, /* 970 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, /* 980 */ 109, 88, 89, 90, 91, 92, 93, 94, 95, 96, /* 990 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, /* 1000 */ 107, 108, 109, 88, 89, 90, 91, 92, 93, 94, /* 1010 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, /* 1020 */ 105, 106, 107, 108, 109, 88, 89, 90, 91, 92, /* 1030 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, /* 1040 */ 103, 104, 105, 106, 107, 108, 109, 88, 89, 90, /* 1050 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 1060 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 89, /* 1070 */ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, /* 1080 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, /* 1090 */ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, /* 1100 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, /* 1110 */ 109, 31, 32, 33, 34, 35, 36, 37, 110, 32, /* 1120 */ 40, 0, 1, 110, 5, 117, 110, 47, 1, 1, /* 1130 */ 122, 123, 119, 117, 121, 122, 56, 1, 122, 123, /* 1140 */ 60, 32, 62, 110, 64, 110, 66, 67, 110, 69, /* 1150 */ 70, 71, 110, 73, 74, 122, 121, 122, 21, 22, /* 1160 */ 122, 24, 110, 26, 122, 1, 29, 65, 21, 22, /* 1170 */ 110, 24, 110, 26, 122, 38, 29, 3, 32, 58, /* 1180 */ 32, 119, 122, 121, 122, 38, 58, 50, 51, 52, /* 1190 */ 53, 54, 55, 110, 58, 110, 75, 50, 51, 52, /* 1200 */ 53, 54, 55, 75, 1, 122, 123, 122, 1, 110, /* 1210 */ 1, 75, 2, 76, 77, 78, 79, 80, 81, 82, /* 1220 */ 83, 122, 58, 76, 77, 78, 79, 80, 81, 82, /* 1230 */ 83, 31, 32, 33, 34, 35, 36, 37, 32, 75, /* 1240 */ 40, 110, 110, 110, 0, 110, 38, 47, 29, 32, /* 1250 */ 5, 38, 32, 122, 122, 122, 56, 122, 48, 32, /* 1260 */ 60, 58, 62, 1, 64, 58, 66, 67, 1, 69, /* 1270 */ 70, 71, 1, 73, 74, 32, 115, 110, 75, 31, /* 1280 */ 32, 24, 75, 35, 36, 37, 32, 30, 40, 122, /* 1290 */ 1, 120, 41, 110, 110, 47, 120, 116, 41, 42, /* 1300 */ 43, 44, 45, 5, 56, 122, 122, 46, 60, 61, /* 1310 */ 62, 1, 64, 32, 66, 67, 1, 69, 70, 71, /* 1320 */ 58, 73, 74, 32, 32, 58, 32, 31, 32, 58, /* 1330 */ 5, 35, 36, 37, 32, 1, 40, 75, 1, 110, /* 1340 */ 32, 110, 75, 47, 5, 110, 75, 58, 1, 46, /* 1350 */ 32, 122, 56, 122, 32, 32, 60, 122, 62, 63, /* 1360 */ 64, 124, 66, 67, 75, 69, 70, 71, 58, 73, /* 1370 */ 74, 124, 124, 58, 124, 31, 32, 33, 124, 35, /* 1380 */ 36, 37, 124, 1, 40, 75, 1, 124, 124, 110, /* 1390 */ 75, 47, 58, 124, 1, 58, 1, 124, 124, 124, /* 1400 */ 56, 122, 124, 124, 60, 58, 62, 124, 64, 75, /* 1410 */ 66, 67, 75, 69, 70, 71, 124, 73, 74, 124, /* 1420 */ 124, 110, 75, 31, 32, 124, 110, 35, 36, 37, /* 1430 */ 110, 39, 40, 122, 124, 124, 124, 124, 122, 47, /* 1440 */ 58, 124, 122, 58, 124, 124, 124, 124, 56, 124, /* 1450 */ 124, 58, 60, 58, 62, 124, 64, 75, 66, 67, /* 1460 */ 75, 69, 70, 71, 124, 73, 74, 110, 75, 110, /* 1470 */ 75, 31, 32, 110, 110, 35, 36, 37, 110, 122, /* 1480 */ 40, 122, 124, 124, 124, 122, 122, 47, 124, 124, /* 1490 */ 122, 110, 124, 124, 124, 124, 56, 57, 124, 124, /* 1500 */ 60, 124, 62, 122, 64, 124, 66, 67, 124, 69, /* 1510 */ 70, 71, 124, 73, 74, 110, 124, 110, 124, 31, /* 1520 */ 32, 110, 110, 35, 36, 37, 110, 122, 40, 122, /* 1530 */ 124, 124, 124, 122, 122, 47, 124, 110, 122, 124, /* 1540 */ 124, 110, 124, 124, 56, 124, 124, 124, 60, 122, /* 1550 */ 62, 63, 64, 122, 66, 67, 124, 69, 70, 71, /* 1560 */ 124, 73, 74, 110, 124, 110, 124, 31, 32, 110, /* 1570 */ 110, 35, 36, 37, 110, 122, 40, 122, 110, 110, /* 1580 */ 124, 122, 122, 47, 124, 110, 122, 110, 124, 110, /* 1590 */ 122, 122, 56, 124, 124, 124, 60, 122, 62, 122, /* 1600 */ 64, 122, 66, 67, 124, 69, 70, 71, 72, 73, /* 1610 */ 74, 110, 124, 110, 110, 31, 32, 33, 110, 35, /* 1620 */ 36, 37, 110, 122, 40, 122, 122, 124, 124, 124, /* 1630 */ 122, 47, 124, 110, 122, 124, 124, 124, 124, 124, /* 1640 */ 56, 124, 124, 124, 60, 122, 62, 124, 64, 124, /* 1650 */ 66, 67, 124, 69, 70, 71, 124, 73, 74, 124, /* 1660 */ 124, 124, 124, 31, 32, 124, 124, 35, 36, 37, /* 1670 */ 124, 124, 40, 124, 124, 124, 124, 124, 124, 47, /* 1680 */ 124, 49, 124, 124, 124, 124, 124, 124, 56, 124, /* 1690 */ 124, 124, 60, 124, 62, 124, 64, 124, 66, 67, /* 1700 */ 124, 69, 70, 71, 124, 73, 74, 124, 124, 124, /* 1710 */ 124, 31, 32, 124, 124, 35, 36, 37, 124, 124, /* 1720 */ 40, 124, 124, 124, 124, 124, 124, 47, 124, 124, /* 1730 */ 124, 124, 124, 124, 124, 124, 56, 124, 124, 124, /* 1740 */ 60, 61, 62, 124, 64, 124, 66, 67, 124, 69, /* 1750 */ 70, 71, 124, 73, 74, 124, 124, 124, 124, 31, /* 1760 */ 32, 124, 124, 35, 36, 37, 124, 124, 40, 124, /* 1770 */ 124, 124, 124, 124, 124, 47, 124, 124, 124, 124, /* 1780 */ 124, 124, 124, 124, 56, 124, 124, 124, 60, 124, /* 1790 */ 62, 124, 64, 124, 66, 67, 124, 69, 70, 71, /* 1800 */ 72, 73, 74, 124, 124, 124, 124, 31, 32, 124, /* 1810 */ 124, 35, 36, 37, 124, 39, 40, 124, 124, 124, /* 1820 */ 124, 124, 124, 47, 124, 124, 124, 124, 124, 124, /* 1830 */ 124, 124, 56, 124, 124, 124, 60, 124, 62, 124, /* 1840 */ 64, 124, 66, 67, 124, 69, 70, 71, 124, 73, /* 1850 */ 74, 124, 124, 124, 124, 31, 32, 124, 124, 35, /* 1860 */ 36, 37, 124, 124, 40, 124, 124, 124, 124, 124, /* 1870 */ 124, 47, 124, 49, 124, 124, 124, 124, 124, 124, /* 1880 */ 56, 124, 124, 124, 60, 124, 62, 124, 64, 124, /* 1890 */ 66, 67, 124, 69, 70, 71, 124, 73, 74, 124, /* 1900 */ 124, 124, 124, 31, 32, 124, 124, 35, 36, 37, /* 1910 */ 124, 39, 40, 124, 124, 124, 124, 124, 124, 47, /* 1920 */ 124, 124, 124, 124, 124, 124, 124, 124, 56, 124, /* 1930 */ 124, 124, 60, 124, 62, 124, 64, 124, 66, 67, /* 1940 */ 124, 69, 70, 71, 124, 73, 74, 124, 124, 124, /* 1950 */ 124, 31, 32, 124, 124, 35, 36, 37, 124, 39, /* 1960 */ 40, 124, 124, 124, 124, 124, 124, 47, 124, 124, /* 1970 */ 124, 124, 124, 124, 124, 124, 56, 124, 124, 124, /* 1980 */ 60, 124, 62, 124, 64, 124, 66, 67, 124, 69, /* 1990 */ 70, 71, 124, 73, 74, 124, 124, 124, 124, 31, /* 2000 */ 32, 124, 124, 35, 36, 37, 124, 124, 40, 124, /* 2010 */ 124, 124, 124, 124, 124, 47, 124, 124, 124, 124, /* 2020 */ 124, 124, 124, 124, 56, 124, 124, 124, 60, 124, /* 2030 */ 62, 124, 64, 124, 66, 67, 124, 69, 70, 71, /* 2040 */ 124, 73, 74, 124, 19, 124, 21, 22, 124, 24, /* 2050 */ 5, 26, 124, 18, 29, 124, 21, 22, 124, 24, /* 2060 */ 124, 26, 124, 38, 29, 124, 21, 22, 124, 24, /* 2070 */ 124, 26, 124, 38, 29, 50, 51, 52, 53, 54, /* 2080 */ 55, 124, 124, 38, 124, 50, 51, 52, 53, 54, /* 2090 */ 55, 124, 124, 124, 124, 50, 51, 52, 53, 54, /* 2100 */ 55, 124, 21, 22, 124, 24, 124, 26, 83, 124, /* 2110 */ 29, 124, 21, 22, 124, 24, 124, 26, 83, 38, /* 2120 */ 29, 124, 124, 124, 124, 124, 124, 46, 83, 38, /* 2130 */ 124, 50, 51, 52, 53, 54, 55, 124, 124, 48, /* 2140 */ 124, 50, 51, 52, 53, 54, 55, 124, 124, 21, /* 2150 */ 22, 124, 24, 124, 26, 21, 22, 29, 24, 124, /* 2160 */ 26, 124, 124, 29, 83, 124, 38, 124, 124, 124, /* 2170 */ 124, 124, 38, 124, 83, 124, 48, 124, 50, 51, /* 2180 */ 52, 53, 54, 55, 50, 51, 52, 53, 54, 55, /* 2190 */ 124, 124, 124, 124, 124, 124, 21, 22, 124, 24, /* 2200 */ 124, 26, 21, 22, 29, 24, 124, 26, 124, 124, /* 2210 */ 29, 83, 124, 38, 124, 124, 124, 83, 84, 38, /* 2220 */ 124, 124, 124, 124, 124, 50, 51, 52, 53, 54, /* 2230 */ 55, 50, 51, 52, 53, 54, 55, 124, 124, 21, /* 2240 */ 22, 124, 24, 124, 26, 124, 124, 29, 124, 124, /* 2250 */ 124, 124, 124, 124, 124, 124, 38, 124, 83, 124, /* 2260 */ 124, 124, 124, 124, 83, 124, 124, 124, 50, 51, /* 2270 */ 52, 53, 54, 55, 124, 124, 124, 124, 124, 124, /* 2280 */ 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, /* 2290 */ 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, /* 2300 */ 124, 83, }; #define VV_SHIFT_USE_DFLT (-4) static short vv_shift_ofst[] = { /* 0 */ 1128, 1244, 1121, -4, -4, -4, -4, -4, -4, -4, /* 10 */ -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, /* 20 */ -4, -4, -4, -4, 1968, 2175, 402, 1136, 1164, 1200, /* 30 */ 1227, -4, 1243, 1203, 1262, 1344, 81, -4, 2175, 372, /* 40 */ -4, 2175, 2175, 285, 2175, 2175, 285, 2025, 15, 2035, /* 50 */ 15, 2175, 15, 2175, 774, 2175, 774, 2175, 285, 2175, /* 60 */ 4, 2175, 684, 2175, 212, 1137, 212, 1147, 212, 2175, /* 70 */ 212, 2175, 212, 2175, 212, 2175, 212, 2175, 212, 2175, /* 80 */ 212, 2175, -4, 2175, 635, 25, 2175, 4, -4, -4, /* 90 */ 2045, 278, -4, 2175, 171, 2175, 660, 2091, 608, 2175, /* 100 */ 4, 2175, 199, -4, 2081, 608, -4, 0, -4, 2181, /* 110 */ 2134, -4, 246, -4, -4, 1298, 2175, 608, -4, -4, /* 120 */ -4, -4, -4, -4, -4, -4, -4, 1210, -4, 2218, /* 130 */ -4, 1325, 2175, 608, -4, -4, 319, 1261, -4, 1303, /* 140 */ 391, 1339, 318, -4, 237, -4, 1119, 1245, -4, -4, /* 150 */ -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, /* 160 */ -4, -4, 2175, 15, 2175, 15, 285, 285, 493, -4, /* 170 */ 365, 109, 2175, 78, 1128, 1207, 1872, 1281, -4, 208, /* 180 */ 51, -4, 208, -4, 1257, 2175, 608, 2175, 608, 2175, /* 190 */ 608, 2175, 608, 2175, 608, 2175, 325, -4, 208, -4, /* 200 */ -4, -4, 1208, 1219, 205, 1254, 1128, 1267, 1632, 1302, /* 210 */ -4, 2175, 580, 2128, 277, 334, 1128, 1271, 1440, 1292, /* 220 */ -4, -4, 41, 326, 1289, 1310, 1248, 114, -4, 2175, /* 230 */ -3, 1128, 1315, 1296, 331, -4, 401, 1128, 2175, 432, /* 240 */ -4, 1127, 1102, 1206, -4, -4, 2175, 490, -4, 2175, /* 250 */ 48, -4, 2175, 520, -4, 2175, 550, -4, 2175, 141, /* 260 */ -4, 272, 1109, 1128, 1334, 1728, 1308, -4, 1323, -4, /* 270 */ 327, -4, -4, 1294, 1128, 1337, 1536, 1322, -4, 523, /* 280 */ 1128, 1347, 1488, 328, -4, 338, 375, 1680, 463, -4, /* 290 */ 519, 584, 556, 1087, -4, 202, 1146, 1128, 1382, 1824, /* 300 */ 1217, -4, 1213, -4, 1251, 266, -4, -4, -4, -4, /* 310 */ -4, -4, -4, -4, 2175, 248, 1128, 1385, 1920, 433, /* 320 */ -4, 602, 1174, 2175, 111, 1128, 1393, 1776, 1318, -4, /* 330 */ 2175, 460, 1128, 1395, 1392, 1148, -4, 1584, 549, -4, /* 340 */ 1080, 1220, -4, 335, 1209, 216, 1291, -4, }; #define VV_REDUCE_USE_DFLT (-64) static short vv_reduce_ofst[] = { /* 0 */ 629, -64, 980, -64, -64, -64, -64, -64, -64, -64, /* 10 */ -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, /* 20 */ -64, -64, -64, -64, -64, 1033, -64, 651, 980, -64, /* 30 */ -64, -64, -64, 937, 980, -64, -64, -64, 1184, -64, /* 40 */ -64, 1038, 1523, -64, 1464, 1459, -64, 1453, -64, 1411, /* 50 */ -64, 1381, -64, 1135, -64, 251, -64, 1131, -64, 1427, /* 60 */ -64, 1363, -64, 1279, -64, 1359, -64, 1099, -64, 1052, /* 70 */ -64, 1183, -64, 1479, -64, 1357, -64, 1512, -64, 1503, /* 80 */ -64, 1501, -64, 1469, -64, -64, 1431, -64, -64, -64, /* 90 */ 252, -64, -64, 1468, -64, 1475, -64, 1008, -64, 1508, /* 100 */ -64, 255, -64, -64, 1013, -64, -64, -64, -64, 1035, /* 110 */ 1062, -64, -64, -64, -64, -64, 1060, -64, -64, -64, /* 120 */ -64, -64, -64, -64, -64, -64, -64, -64, -64, 1083, /* 130 */ -64, -64, 1407, -64, -64, -64, 1171, -64, -64, -64, /* 140 */ -64, -64, 1176, -64, -64, -64, -64, -64, -64, -64, /* 150 */ -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, /* 160 */ -64, -64, 1311, -64, 1368, -64, -64, -64, -64, -64, /* 170 */ -64, -64, 1132, -64, 849, 980, -64, -64, -64, -63, /* 180 */ -64, -64, 210, -64, -64, 1405, -64, 1416, -64, 1455, /* 190 */ -64, 1460, -64, 1504, -64, 1042, -64, -64, 408, -64, /* 200 */ -64, -64, -64, -64, 130, -64, 673, 980, -64, -64, /* 210 */ -64, 1231, -64, 1016, -64, -64, 761, 980, -64, -64, /* 220 */ -64, -64, -64, -64, 959, 980, -64, -64, -64, 1477, /* 230 */ 54, 717, 980, -64, -64, -64, -64, 1001, 1085, -64, /* 240 */ -64, -64, -64, -64, -64, -64, 1133, -64, -64, 1167, /* 250 */ -64, -64, 1229, -64, -64, 1235, -64, -64, 1320, -64, /* 260 */ -64, -64, -64, 739, 980, -64, -64, -64, -64, -64, /* 270 */ -64, -64, -64, -64, 805, 980, -64, -64, -64, -64, /* 280 */ 783, 980, -64, -64, -64, -64, -64, -64, -64, -64, /* 290 */ -64, -64, -64, -64, -64, -64, -64, 871, 980, -64, /* 300 */ -64, -64, 1161, -64, -64, 1181, -64, -64, -64, -64, /* 310 */ -64, -64, -64, -64, 1316, -64, 893, 980, -64, -64, /* 320 */ -64, -64, -64, 1364, -64, 915, 980, -64, -64, -64, /* 330 */ 1412, -64, 827, 980, -64, -64, -64, -64, -64, -64, /* 340 */ -64, -64, -64, -64, -64, -64, -64, -64, }; static VVACTIONTYPE vv_default[] = { /* 0 */ 500, 500, 500, 350, 352, 353, 354, 355, 356, 357, /* 10 */ 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, /* 20 */ 368, 369, 370, 371, 500, 500, 500, 500, 500, 500, /* 30 */ 500, 372, 500, 500, 500, 500, 500, 374, 500, 500, /* 40 */ 377, 500, 500, 427, 500, 500, 428, 500, 431, 500, /* 50 */ 433, 500, 435, 500, 436, 500, 437, 500, 438, 500, /* 60 */ 439, 500, 440, 500, 441, 500, 457, 500, 456, 500, /* 70 */ 458, 500, 459, 500, 460, 500, 461, 500, 462, 500, /* 80 */ 463, 500, 464, 500, 465, 500, 500, 466, 468, 469, /* 90 */ 500, 500, 475, 500, 500, 500, 476, 500, 491, 500, /* 100 */ 467, 500, 500, 470, 500, 485, 471, 500, 472, 500, /* 110 */ 500, 473, 500, 474, 483, 495, 500, 484, 486, 493, /* 120 */ 494, 495, 496, 497, 498, 499, 482, 500, 487, 500, /* 130 */ 489, 495, 500, 492, 488, 490, 500, 500, 477, 500, /* 140 */ 500, 500, 500, 478, 500, 479, 494, 493, 443, 445, /* 150 */ 447, 449, 451, 453, 455, 442, 444, 446, 448, 450, /* 160 */ 452, 454, 500, 434, 500, 432, 430, 429, 500, 378, /* 170 */ 500, 500, 500, 500, 500, 500, 500, 500, 379, 500, /* 180 */ 500, 383, 500, 384, 500, 500, 386, 500, 387, 500, /* 190 */ 388, 500, 389, 500, 390, 500, 500, 392, 500, 391, /* 200 */ 393, 385, 500, 500, 500, 500, 500, 500, 500, 500, /* 210 */ 394, 500, 500, 500, 500, 487, 500, 500, 500, 500, /* 220 */ 406, 408, 500, 500, 500, 500, 500, 500, 410, 500, /* 230 */ 500, 500, 500, 500, 500, 412, 500, 500, 500, 500, /* 240 */ 409, 500, 500, 500, 416, 426, 500, 500, 417, 500, /* 250 */ 500, 418, 500, 500, 419, 500, 500, 420, 500, 500, /* 260 */ 421, 500, 500, 500, 500, 500, 500, 422, 500, 424, /* 270 */ 500, 425, 351, 500, 500, 500, 500, 500, 423, 500, /* 280 */ 500, 500, 500, 500, 413, 500, 500, 500, 500, 411, /* 290 */ 488, 500, 500, 500, 407, 500, 500, 500, 500, 500, /* 300 */ 500, 395, 500, 396, 398, 500, 399, 400, 401, 402, /* 310 */ 403, 404, 405, 397, 500, 500, 500, 500, 500, 500, /* 320 */ 380, 500, 500, 500, 500, 500, 500, 500, 500, 381, /* 330 */ 500, 500, 500, 500, 500, 500, 382, 500, 500, 375, /* 340 */ 500, 500, 373, 500, 500, 500, 500, 376, }; #define VV_SZ_ACTTAB (sizeof(vv_action)/sizeof(vv_action[0])) /* The next table maps tokens into fallback tokens. If a construct ** like the following: ** ** %fallback ID X Y Z. ** ** appears in the grammer, then ID becomes a fallback token for X, Y, ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser ** but it does not parse, the type of the token is changed to ID and ** the parse is retried before an error is thrown. */ #ifdef VVFALLBACK static const VVCODETYPE vvFallback[] = { }; #endif /* VVFALLBACK */ /* The following structure represents a single element of the ** parser's stack. Information stored includes: ** ** + The state number for the parser at this level of the stack. ** ** + The value of the token stored at this level of the stack. ** (In other words, the "major" token.) ** ** + The semantic value stored at this level of the stack. This is ** the information used by the action routines in the grammar. ** It is sometimes called the "minor" token. */ struct vvStackEntry { int stateno; /* The state-number */ int major; /* The major token value. This is the code ** number for the token at this stack level */ VVMINORTYPE minor; /* The user-supplied minor token value. This ** is the value of the token */ }; typedef struct vvStackEntry vvStackEntry; /* The state of the parser is completely contained in an instance of ** the following structure */ struct vvParser { int vvidx; /* Index of top element in stack */ int vverrcnt; /* Shifts left before out of the error */ phvolt_ARG_SDECL /* A place to hold %extra_argument */ vvStackEntry vvstack[VVSTACKDEPTH]; /* The parser's stack */ }; typedef struct vvParser vvParser; #ifndef NDEBUG #include <stdio.h> static FILE *vvTraceFILE = 0; static char *vvTracePrompt = 0; #endif /* NDEBUG */ #ifndef NDEBUG static void phvolt_Trace(FILE *TraceFILE, char *zTracePrompt){ vvTraceFILE = TraceFILE; vvTracePrompt = zTracePrompt; if( vvTraceFILE==0 ) vvTracePrompt = 0; else if( vvTracePrompt==0 ) vvTraceFILE = 0; } #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing shifts, the names of all terminals and nonterminals ** are required. The following table supplies these names */ static const char *vvTokenName[] = { "$", "OPEN_DELIMITER", "COMMA", "IN", "QUESTION", "COLON", "RANGE", "AND", "OR", "IS", "EQUALS", "NOTEQUALS", "LESS", "GREATER", "GREATEREQUAL", "LESSEQUAL", "IDENTICAL", "NOTIDENTICAL", "DIVIDE", "TIMES", "MOD", "PLUS", "MINUS", "CONCAT", "SBRACKET_OPEN", "PIPE", "NOT", "INCR", "DECR", "PARENTHESES_OPEN", "DOT", "IF", "CLOSE_DELIMITER", "ENDIF", "ELSE", "ELSEIF", "ELSEFOR", "FOR", "IDENTIFIER", "ENDFOR", "SET", "ASSIGN", "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "SBRACKET_CLOSE", "MACRO", "PARENTHESES_CLOSE", "ENDMACRO", "INTEGER", "STRING", "DOUBLE", "NULL", "FALSE", "TRUE", "CALL", "ENDCALL", "OPEN_EDELIMITER", "CLOSE_EDELIMITER", "BLOCK", "ENDBLOCK", "CACHE", "ENDCACHE", "RAW", "ENDRAW", "EXTENDS", "INCLUDE", "WITH", "DO", "RETURN", "AUTOESCAPE", "ENDAUTOESCAPE", "BREAK", "CONTINUE", "RAW_FRAGMENT", "DEFINED", "EMPTY", "EVEN", "ODD", "NUMERIC", "SCALAR", "ITERABLE", "CBRACKET_OPEN", "CBRACKET_CLOSE", "error", "program", "volt_language", "statement_list", "statement", "raw_fragment", "if_statement", "elseif_statement", "elsefor_statement", "for_statement", "set_statement", "echo_statement", "block_statement", "cache_statement", "extends_statement", "include_statement", "do_statement", "return_statement", "autoescape_statement", "raw_statement", "break_statement", "continue_statement", "macro_statement", "empty_statement", "macro_call_statement", "expr", "set_assignments", "set_assignment", "assignable_expr", "macro_parameters", "macro_parameter", "macro_parameter_default", "argument_list", "cache_lifetime", "array_list", "slice_offset", "array_item", "function_call", "argument_item", }; #endif /* NDEBUG */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *vvRuleName[] = { /* 0 */ "program ::= volt_language", /* 1 */ "volt_language ::= statement_list", /* 2 */ "statement_list ::= statement_list statement", /* 3 */ "statement_list ::= statement", /* 4 */ "statement ::= raw_fragment", /* 5 */ "statement ::= if_statement", /* 6 */ "statement ::= elseif_statement", /* 7 */ "statement ::= elsefor_statement", /* 8 */ "statement ::= for_statement", /* 9 */ "statement ::= set_statement", /* 10 */ "statement ::= echo_statement", /* 11 */ "statement ::= block_statement", /* 12 */ "statement ::= cache_statement", /* 13 */ "statement ::= extends_statement", /* 14 */ "statement ::= include_statement", /* 15 */ "statement ::= do_statement", /* 16 */ "statement ::= return_statement", /* 17 */ "statement ::= autoescape_statement", /* 18 */ "statement ::= raw_statement", /* 19 */ "statement ::= break_statement", /* 20 */ "statement ::= continue_statement", /* 21 */ "statement ::= macro_statement", /* 22 */ "statement ::= empty_statement", /* 23 */ "statement ::= macro_call_statement", /* 24 */ "if_statement ::= OPEN_DELIMITER IF expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDIF CLOSE_DELIMITER", /* 25 */ "if_statement ::= OPEN_DELIMITER IF expr CLOSE_DELIMITER OPEN_DELIMITER ENDIF CLOSE_DELIMITER", /* 26 */ "if_statement ::= OPEN_DELIMITER IF expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ELSE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDIF CLOSE_DELIMITER", /* 27 */ "if_statement ::= OPEN_DELIMITER IF expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ELSE CLOSE_DELIMITER OPEN_DELIMITER ENDIF CLOSE_DELIMITER", /* 28 */ "if_statement ::= OPEN_DELIMITER IF expr CLOSE_DELIMITER OPEN_DELIMITER ELSE CLOSE_DELIMITER OPEN_DELIMITER ENDIF CLOSE_DELIMITER", /* 29 */ "elseif_statement ::= OPEN_DELIMITER ELSEIF expr CLOSE_DELIMITER", /* 30 */ "elsefor_statement ::= OPEN_DELIMITER ELSEFOR CLOSE_DELIMITER", /* 31 */ "for_statement ::= OPEN_DELIMITER FOR IDENTIFIER IN expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDFOR CLOSE_DELIMITER", /* 32 */ "for_statement ::= OPEN_DELIMITER FOR IDENTIFIER IN expr IF expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDFOR CLOSE_DELIMITER", /* 33 */ "for_statement ::= OPEN_DELIMITER FOR IDENTIFIER COMMA IDENTIFIER IN expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDFOR CLOSE_DELIMITER", /* 34 */ "for_statement ::= OPEN_DELIMITER FOR IDENTIFIER COMMA IDENTIFIER IN expr IF expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDFOR CLOSE_DELIMITER", /* 35 */ "set_statement ::= OPEN_DELIMITER SET set_assignments CLOSE_DELIMITER", /* 36 */ "set_assignments ::= set_assignments COMMA set_assignment", /* 37 */ "set_assignments ::= set_assignment", /* 38 */ "set_assignment ::= assignable_expr ASSIGN expr", /* 39 */ "set_assignment ::= assignable_expr ADD_ASSIGN expr", /* 40 */ "set_assignment ::= assignable_expr SUB_ASSIGN expr", /* 41 */ "set_assignment ::= assignable_expr MUL_ASSIGN expr", /* 42 */ "set_assignment ::= assignable_expr DIV_ASSIGN expr", /* 43 */ "assignable_expr ::= IDENTIFIER", /* 44 */ "assignable_expr ::= assignable_expr SBRACKET_OPEN expr SBRACKET_CLOSE", /* 45 */ "assignable_expr ::= assignable_expr DOT assignable_expr", /* 46 */ "macro_statement ::= OPEN_DELIMITER MACRO IDENTIFIER PARENTHESES_OPEN PARENTHESES_CLOSE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDMACRO CLOSE_DELIMITER", /* 47 */ "macro_statement ::= OPEN_DELIMITER MACRO IDENTIFIER PARENTHESES_OPEN macro_parameters PARENTHESES_CLOSE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDMACRO CLOSE_DELIMITER", /* 48 */ "macro_parameters ::= macro_parameters COMMA macro_parameter", /* 49 */ "macro_parameters ::= macro_parameter", /* 50 */ "macro_parameter ::= IDENTIFIER", /* 51 */ "macro_parameter ::= IDENTIFIER ASSIGN macro_parameter_default", /* 52 */ "macro_parameter_default ::= INTEGER", /* 53 */ "macro_parameter_default ::= STRING", /* 54 */ "macro_parameter_default ::= DOUBLE", /* 55 */ "macro_parameter_default ::= NULL", /* 56 */ "macro_parameter_default ::= FALSE", /* 57 */ "macro_parameter_default ::= TRUE", /* 58 */ "macro_call_statement ::= OPEN_DELIMITER CALL expr PARENTHESES_OPEN argument_list PARENTHESES_CLOSE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDCALL CLOSE_DELIMITER", /* 59 */ "macro_call_statement ::= OPEN_DELIMITER CALL expr PARENTHESES_OPEN PARENTHESES_CLOSE CLOSE_DELIMITER OPEN_DELIMITER ENDCALL CLOSE_DELIMITER", /* 60 */ "empty_statement ::= OPEN_DELIMITER CLOSE_DELIMITER", /* 61 */ "echo_statement ::= OPEN_EDELIMITER expr CLOSE_EDELIMITER", /* 62 */ "block_statement ::= OPEN_DELIMITER BLOCK IDENTIFIER CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDBLOCK CLOSE_DELIMITER", /* 63 */ "block_statement ::= OPEN_DELIMITER BLOCK IDENTIFIER CLOSE_DELIMITER OPEN_DELIMITER ENDBLOCK CLOSE_DELIMITER", /* 64 */ "cache_statement ::= OPEN_DELIMITER CACHE expr CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDCACHE CLOSE_DELIMITER", /* 65 */ "cache_statement ::= OPEN_DELIMITER CACHE expr cache_lifetime CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDCACHE CLOSE_DELIMITER", /* 66 */ "cache_lifetime ::= INTEGER", /* 67 */ "cache_lifetime ::= IDENTIFIER", /* 68 */ "raw_statement ::= OPEN_DELIMITER RAW CLOSE_DELIMITER statement OPEN_DELIMITER ENDRAW CLOSE_DELIMITER", /* 69 */ "extends_statement ::= OPEN_DELIMITER EXTENDS expr CLOSE_DELIMITER", /* 70 */ "include_statement ::= OPEN_DELIMITER INCLUDE expr CLOSE_DELIMITER", /* 71 */ "include_statement ::= OPEN_DELIMITER INCLUDE expr WITH expr CLOSE_DELIMITER", /* 72 */ "do_statement ::= OPEN_DELIMITER DO expr CLOSE_DELIMITER", /* 73 */ "return_statement ::= OPEN_DELIMITER RETURN expr CLOSE_DELIMITER", /* 74 */ "autoescape_statement ::= OPEN_DELIMITER AUTOESCAPE FALSE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDAUTOESCAPE CLOSE_DELIMITER", /* 75 */ "autoescape_statement ::= OPEN_DELIMITER AUTOESCAPE TRUE CLOSE_DELIMITER statement_list OPEN_DELIMITER ENDAUTOESCAPE CLOSE_DELIMITER", /* 76 */ "break_statement ::= OPEN_DELIMITER BREAK CLOSE_DELIMITER", /* 77 */ "continue_statement ::= OPEN_DELIMITER CONTINUE CLOSE_DELIMITER", /* 78 */ "raw_fragment ::= RAW_FRAGMENT", /* 79 */ "expr ::= MINUS expr", /* 80 */ "expr ::= PLUS expr", /* 81 */ "expr ::= expr MINUS expr", /* 82 */ "expr ::= expr PLUS expr", /* 83 */ "expr ::= expr TIMES expr", /* 84 */ "expr ::= expr TIMES TIMES expr", /* 85 */ "expr ::= expr DIVIDE expr", /* 86 */ "expr ::= expr DIVIDE DIVIDE expr", /* 87 */ "expr ::= expr MOD expr", /* 88 */ "expr ::= expr AND expr", /* 89 */ "expr ::= expr OR expr", /* 90 */ "expr ::= expr CONCAT expr", /* 91 */ "expr ::= expr PIPE expr", /* 92 */ "expr ::= expr RANGE expr", /* 93 */ "expr ::= expr EQUALS expr", /* 94 */ "expr ::= expr NOTEQUALS DEFINED", /* 95 */ "expr ::= expr IS DEFINED", /* 96 */ "expr ::= expr NOTEQUALS EMPTY", /* 97 */ "expr ::= expr IS EMPTY", /* 98 */ "expr ::= expr NOTEQUALS EVEN", /* 99 */ "expr ::= expr IS EVEN", /* 100 */ "expr ::= expr NOTEQUALS ODD", /* 101 */ "expr ::= expr IS ODD", /* 102 */ "expr ::= expr NOTEQUALS NUMERIC", /* 103 */ "expr ::= expr IS NUMERIC", /* 104 */ "expr ::= expr NOTEQUALS SCALAR", /* 105 */ "expr ::= expr IS SCALAR", /* 106 */ "expr ::= expr NOTEQUALS ITERABLE", /* 107 */ "expr ::= expr IS ITERABLE", /* 108 */ "expr ::= expr IS expr", /* 109 */ "expr ::= expr NOTEQUALS expr", /* 110 */ "expr ::= expr IDENTICAL expr", /* 111 */ "expr ::= expr NOTIDENTICAL expr", /* 112 */ "expr ::= expr LESS expr", /* 113 */ "expr ::= expr GREATER expr", /* 114 */ "expr ::= expr GREATEREQUAL expr", /* 115 */ "expr ::= expr LESSEQUAL expr", /* 116 */ "expr ::= expr DOT expr", /* 117 */ "expr ::= expr IN expr", /* 118 */ "expr ::= expr NOT IN expr", /* 119 */ "expr ::= NOT expr", /* 120 */ "expr ::= expr INCR", /* 121 */ "expr ::= expr DECR", /* 122 */ "expr ::= PARENTHESES_OPEN expr PARENTHESES_CLOSE", /* 123 */ "expr ::= SBRACKET_OPEN SBRACKET_CLOSE", /* 124 */ "expr ::= SBRACKET_OPEN array_list SBRACKET_CLOSE", /* 125 */ "expr ::= CBRACKET_OPEN CBRACKET_CLOSE", /* 126 */ "expr ::= CBRACKET_OPEN array_list CBRACKET_CLOSE", /* 127 */ "expr ::= expr SBRACKET_OPEN expr SBRACKET_CLOSE", /* 128 */ "expr ::= expr QUESTION expr COLON expr", /* 129 */ "expr ::= expr SBRACKET_OPEN COLON slice_offset SBRACKET_CLOSE", /* 130 */ "expr ::= expr SBRACKET_OPEN slice_offset COLON SBRACKET_CLOSE", /* 131 */ "expr ::= expr SBRACKET_OPEN slice_offset COLON slice_offset SBRACKET_CLOSE", /* 132 */ "slice_offset ::= INTEGER", /* 133 */ "slice_offset ::= IDENTIFIER", /* 134 */ "array_list ::= array_list COMMA array_item", /* 135 */ "array_list ::= array_item", /* 136 */ "array_item ::= STRING COLON expr", /* 137 */ "array_item ::= expr", /* 138 */ "expr ::= function_call", /* 139 */ "function_call ::= expr PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", /* 140 */ "function_call ::= expr PARENTHESES_OPEN PARENTHESES_CLOSE", /* 141 */ "argument_list ::= argument_list COMMA argument_item", /* 142 */ "argument_list ::= argument_item", /* 143 */ "argument_item ::= expr", /* 144 */ "argument_item ::= STRING COLON expr", /* 145 */ "expr ::= IDENTIFIER", /* 146 */ "expr ::= INTEGER", /* 147 */ "expr ::= STRING", /* 148 */ "expr ::= DOUBLE", /* 149 */ "expr ::= NULL", /* 150 */ "expr ::= FALSE", /* 151 */ "expr ::= TRUE", }; #endif /* NDEBUG */ const char *phvolt_TokenName(int tokenType){ #ifndef NDEBUG if( tokenType>0 && tokenType<(sizeof(vvTokenName)/sizeof(vvTokenName[0])) ){ return vvTokenName[tokenType]; }else{ return "Unknown"; } #else return ""; #endif } void *phvolt_Alloc(void *(*mallocProc)(size_t)){ vvParser *pParser; pParser = (vvParser*)(*mallocProc)( (size_t)sizeof(vvParser) ); if( pParser ){ pParser->vvidx = -1; } return pParser; } /* The following function deletes the value associated with a ** symbol. The symbol can be either a terminal or nonterminal. ** "vvmajor" is the symbol code, and "vvpminor" is a pointer to ** the value. */ static void vv_destructor(VVCODETYPE vvmajor, VVMINORTYPE *vvpminor){ switch( vvmajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are not used ** inside the C code. */ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: // 716 "parser.lemon" { if ((vvpminor->vv0)) { if ((vvpminor->vv0)->free_flag) { efree((vvpminor->vv0)->token); } efree((vvpminor->vv0)); } } // 1705 "parser.c" break; case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: case 112: case 114: case 115: case 117: case 118: case 119: case 120: case 121: case 122: case 123: // 733 "parser.lemon" { zval_ptr_dtor(&(vvpminor->vv40)); } // 1743 "parser.c" break; default: break; /* If no destructor action specified: do nothing */ } } static int vv_pop_parser_stack(vvParser *pParser){ VVCODETYPE vvmajor; vvStackEntry *vvtos = &pParser->vvstack[pParser->vvidx]; if( pParser->vvidx<0 ) return 0; #ifndef NDEBUG if( vvTraceFILE && pParser->vvidx>=0 ){ fprintf(vvTraceFILE,"%sPopping %s\n", vvTracePrompt, vvTokenName[vvtos->major]); } #endif vvmajor = vvtos->major; vv_destructor( vvmajor, &vvtos->minor); pParser->vvidx--; return vvmajor; } static void phvolt_Free( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ vvParser *pParser = (vvParser*)p; if( pParser==0 ) return; while( pParser->vvidx>=0 ) vv_pop_parser_stack(pParser); (*freeProc)((void*)pParser); } static int vv_find_shift_action( vvParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->vvstack[pParser->vvidx].stateno; /* if( pParser->vvidx<0 ) return VV_NO_ACTION; */ i = vv_shift_ofst[stateno]; if( i==VV_SHIFT_USE_DFLT ){ return vv_default[stateno]; } if( iLookAhead==VVNOCODE ){ return VV_NO_ACTION; } i += iLookAhead; if( i<0 || i>=VV_SZ_ACTTAB || vv_lookahead[i]!=iLookAhead ){ #ifdef VVFALLBACK int iFallback; /* Fallback token */ if( iLookAhead<sizeof(vvFallback)/sizeof(vvFallback[0]) && (iFallback = vvFallback[iLookAhead])!=0 ){ #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE, "%sFALLBACK %s => %s\n", vvTracePrompt, vvTokenName[iLookAhead], vvTokenName[iFallback]); } #endif return vv_find_shift_action(pParser, iFallback); } #endif return vv_default[stateno]; }else{ return vv_action[i]; } } static int vv_find_reduce_action( vvParser *pParser, /* The parser */ int iLookAhead /* The look-ahead token */ ){ int i; int stateno = pParser->vvstack[pParser->vvidx].stateno; i = vv_reduce_ofst[stateno]; if( i==VV_REDUCE_USE_DFLT ){ return vv_default[stateno]; } if( iLookAhead==VVNOCODE ){ return VV_NO_ACTION; } i += iLookAhead; if( i<0 || i>=VV_SZ_ACTTAB || vv_lookahead[i]!=iLookAhead ){ return vv_default[stateno]; }else{ return vv_action[i]; } } static void vv_shift( vvParser *vvpParser, /* The parser to be shifted */ int vvNewState, /* The new state to shift in */ int vvMajor, /* The major token to shift in */ VVMINORTYPE *vvpMinor /* Pointer ot the minor token to shift in */ ){ vvStackEntry *vvtos; vvpParser->vvidx++; if( vvpParser->vvidx>=VVSTACKDEPTH ){ phvolt_ARG_FETCH; vvpParser->vvidx--; #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sStack Overflow!\n",vvTracePrompt); } #endif while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } vvtos = &vvpParser->vvstack[vvpParser->vvidx]; vvtos->stateno = vvNewState; vvtos->major = vvMajor; vvtos->minor = *vvpMinor; #ifndef NDEBUG if( vvTraceFILE && vvpParser->vvidx>0 ){ int i; fprintf(vvTraceFILE,"%sShift %d\n",vvTracePrompt,vvNewState); fprintf(vvTraceFILE,"%sStack:",vvTracePrompt); for(i=1; i<=vvpParser->vvidx; i++) fprintf(vvTraceFILE," %s",vvTokenName[vvpParser->vvstack[i].major]); fprintf(vvTraceFILE,"\n"); } #endif } /* The following table contains information about every rule that ** is used during the reduce. */ static struct { VVCODETYPE lhs; /* Symbol on the left-hand side of the rule */ unsigned char nrhs; /* Number of right-hand side symbols in the rule */ } vvRuleInfo[] = { { 86, 1 }, { 87, 1 }, { 88, 2 }, { 88, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 89, 1 }, { 91, 8 }, { 91, 7 }, { 91, 12 }, { 91, 11 }, { 91, 10 }, { 92, 4 }, { 93, 3 }, { 94, 10 }, { 94, 12 }, { 94, 12 }, { 94, 14 }, { 95, 4 }, { 111, 3 }, { 111, 1 }, { 112, 3 }, { 112, 3 }, { 112, 3 }, { 112, 3 }, { 112, 3 }, { 113, 1 }, { 113, 4 }, { 113, 3 }, { 107, 10 }, { 107, 11 }, { 114, 3 }, { 114, 1 }, { 115, 1 }, { 115, 3 }, { 116, 1 }, { 116, 1 }, { 116, 1 }, { 116, 1 }, { 116, 1 }, { 116, 1 }, { 109, 11 }, { 109, 9 }, { 108, 2 }, { 96, 3 }, { 97, 8 }, { 97, 7 }, { 98, 8 }, { 98, 9 }, { 118, 1 }, { 118, 1 }, { 104, 7 }, { 99, 4 }, { 100, 4 }, { 100, 6 }, { 101, 4 }, { 102, 4 }, { 103, 8 }, { 103, 8 }, { 105, 3 }, { 106, 3 }, { 90, 1 }, { 110, 2 }, { 110, 2 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 4 }, { 110, 3 }, { 110, 4 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 3 }, { 110, 4 }, { 110, 2 }, { 110, 2 }, { 110, 2 }, { 110, 3 }, { 110, 2 }, { 110, 3 }, { 110, 2 }, { 110, 3 }, { 110, 4 }, { 110, 5 }, { 110, 5 }, { 110, 5 }, { 110, 6 }, { 120, 1 }, { 120, 1 }, { 119, 3 }, { 119, 1 }, { 121, 3 }, { 121, 1 }, { 110, 1 }, { 122, 4 }, { 122, 3 }, { 117, 3 }, { 117, 1 }, { 123, 1 }, { 123, 3 }, { 110, 1 }, { 110, 1 }, { 110, 1 }, { 110, 1 }, { 110, 1 }, { 110, 1 }, { 110, 1 }, }; static void vv_accept(vvParser*); /* Forward Declaration */ static void vv_reduce( vvParser *vvpParser, /* The parser */ int vvruleno /* Number of the rule by which to reduce */ ){ int vvgoto; /* The next state */ int vvact; /* The next action */ VVMINORTYPE vvgotominor; /* The LHS of the rule reduced */ vvStackEntry *vvmsp; /* The top of the parser's stack */ int vvsize; /* Amount to pop the stack */ phvolt_ARG_FETCH; vvmsp = &vvpParser->vvstack[vvpParser->vvidx]; #ifndef NDEBUG if( vvTraceFILE && vvruleno>=0 && vvruleno<sizeof(vvRuleName)/sizeof(vvRuleName[0]) ){ fprintf(vvTraceFILE, "%sReduce [%s].\n", vvTracePrompt, vvRuleName[vvruleno]); } #endif /* NDEBUG */ switch( vvruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** // <lineno> <grammarfile> ** { ... } // User supplied code ** // <lineno> <thisfile> ** break; */ case 0: // 725 "parser.lemon" { status->ret = vvmsp[0].minor.vv40; } // 2112 "parser.c" break; case 1: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 138: // 729 "parser.lemon" { vvgotominor.vv40 = vvmsp[0].minor.vv40; } // 2140 "parser.c" break; case 2: // 735 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_zval_list(vvmsp[-1].minor.vv40, vvmsp[0].minor.vv40); } // 2147 "parser.c" break; case 3: case 37: case 49: case 135: case 142: // 739 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_zval_list(NULL, vvmsp[0].minor.vv40); } // 2158 "parser.c" break; case 24: // 827 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_if_statement(vvmsp[-5].minor.vv40, vvmsp[-3].minor.vv40, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-7].minor); vv_destructor(31,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(33,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2171 "parser.c" break; case 25: // 831 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_if_statement(vvmsp[-4].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-6].minor); vv_destructor(31,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-3].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(33,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2184 "parser.c" break; case 26: // 835 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_if_statement(vvmsp[-9].minor.vv40, vvmsp[-7].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-11].minor); vv_destructor(31,&vvmsp[-10].minor); vv_destructor(32,&vvmsp[-8].minor); vv_destructor(1,&vvmsp[-6].minor); vv_destructor(34,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(33,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2200 "parser.c" break; case 27: // 839 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_if_statement(vvmsp[-8].minor.vv40, vvmsp[-6].minor.vv40, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-10].minor); vv_destructor(31,&vvmsp[-9].minor); vv_destructor(32,&vvmsp[-7].minor); vv_destructor(1,&vvmsp[-5].minor); vv_destructor(34,&vvmsp[-4].minor); vv_destructor(32,&vvmsp[-3].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(33,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2216 "parser.c" break; case 28: // 843 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_if_statement(vvmsp[-7].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-9].minor); vv_destructor(31,&vvmsp[-8].minor); vv_destructor(32,&vvmsp[-6].minor); vv_destructor(1,&vvmsp[-5].minor); vv_destructor(34,&vvmsp[-4].minor); vv_destructor(32,&vvmsp[-3].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(33,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2232 "parser.c" break; case 29: // 849 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_elseif_statement(vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(35,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2242 "parser.c" break; case 30: // 855 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_elsefor_statement(status->scanner_state); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(36,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2252 "parser.c" break; case 31: // 861 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_for_statement(vvmsp[-7].minor.vv0, NULL, vvmsp[-5].minor.vv40, NULL, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-9].minor); vv_destructor(37,&vvmsp[-8].minor); vv_destructor(3,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(39,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2266 "parser.c" break; case 32: // 865 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_for_statement(vvmsp[-9].minor.vv0, NULL, vvmsp[-7].minor.vv40, vvmsp[-5].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-11].minor); vv_destructor(37,&vvmsp[-10].minor); vv_destructor(3,&vvmsp[-8].minor); vv_destructor(31,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(39,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2281 "parser.c" break; case 33: // 869 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_for_statement(vvmsp[-7].minor.vv0, vvmsp[-9].minor.vv0, vvmsp[-5].minor.vv40, NULL, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-11].minor); vv_destructor(37,&vvmsp[-10].minor); vv_destructor(2,&vvmsp[-8].minor); vv_destructor(3,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(39,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2296 "parser.c" break; case 34: // 873 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_for_statement(vvmsp[-9].minor.vv0, vvmsp[-11].minor.vv0, vvmsp[-7].minor.vv40, vvmsp[-5].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-13].minor); vv_destructor(37,&vvmsp[-12].minor); vv_destructor(2,&vvmsp[-10].minor); vv_destructor(3,&vvmsp[-8].minor); vv_destructor(31,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(39,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2312 "parser.c" break; case 35: // 879 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_statement(vvmsp[-1].minor.vv40); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(40,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2322 "parser.c" break; case 36: case 48: case 134: case 141: // 885 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_zval_list(vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40); vv_destructor(2,&vvmsp[-1].minor); } // 2333 "parser.c" break; case 38: // 895 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_assignment(vvmsp[-2].minor.vv40, PHVOLT_T_ASSIGN, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(41,&vvmsp[-1].minor); } // 2341 "parser.c" break; case 39: // 899 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_assignment(vvmsp[-2].minor.vv40, PHVOLT_T_ADD_ASSIGN, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(42,&vvmsp[-1].minor); } // 2349 "parser.c" break; case 40: // 903 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_assignment(vvmsp[-2].minor.vv40, PHVOLT_T_SUB_ASSIGN, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(43,&vvmsp[-1].minor); } // 2357 "parser.c" break; case 41: // 907 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_assignment(vvmsp[-2].minor.vv40, PHVOLT_T_MUL_ASSIGN, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(44,&vvmsp[-1].minor); } // 2365 "parser.c" break; case 42: // 911 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_set_assignment(vvmsp[-2].minor.vv40, PHVOLT_T_DIV_ASSIGN, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(45,&vvmsp[-1].minor); } // 2373 "parser.c" break; case 43: case 67: case 133: case 145: // 915 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_IDENTIFIER, vvmsp[0].minor.vv0, status->scanner_state); } // 2383 "parser.c" break; case 44: case 127: // 919 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ARRAYACCESS, vvmsp[-3].minor.vv40, vvmsp[-1].minor.vv40, NULL, status->scanner_state); vv_destructor(24,&vvmsp[-2].minor); vv_destructor(46,&vvmsp[0].minor); } // 2393 "parser.c" break; case 45: case 116: // 923 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_DOT, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(30,&vvmsp[-1].minor); } // 2402 "parser.c" break; case 46: // 929 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_statement(vvmsp[-7].minor.vv0, NULL, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-9].minor); vv_destructor(47,&vvmsp[-8].minor); vv_destructor(29,&vvmsp[-6].minor); vv_destructor(48,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(49,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2417 "parser.c" break; case 47: // 933 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_statement(vvmsp[-8].minor.vv0, vvmsp[-6].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-10].minor); vv_destructor(47,&vvmsp[-9].minor); vv_destructor(29,&vvmsp[-7].minor); vv_destructor(48,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(49,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2432 "parser.c" break; case 50: // 949 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_parameter(vvmsp[0].minor.vv0, NULL, status->scanner_state); } // 2439 "parser.c" break; case 51: // 953 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_parameter(vvmsp[-2].minor.vv0, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(41,&vvmsp[-1].minor); } // 2447 "parser.c" break; case 52: case 66: case 132: case 146: // 957 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_INTEGER, vvmsp[0].minor.vv0, status->scanner_state); } // 2457 "parser.c" break; case 53: case 147: // 961 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_STRING, vvmsp[0].minor.vv0, status->scanner_state); } // 2465 "parser.c" break; case 54: case 148: // 965 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_DOUBLE, vvmsp[0].minor.vv0, status->scanner_state); } // 2473 "parser.c" break; case 55: case 149: // 969 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_NULL, NULL, status->scanner_state); vv_destructor(53,&vvmsp[0].minor); } // 2482 "parser.c" break; case 56: case 150: // 973 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_FALSE, NULL, status->scanner_state); vv_destructor(54,&vvmsp[0].minor); } // 2491 "parser.c" break; case 57: case 151: // 977 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_TRUE, NULL, status->scanner_state); vv_destructor(55,&vvmsp[0].minor); } // 2500 "parser.c" break; case 58: // 983 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_call_statement(vvmsp[-8].minor.vv40, vvmsp[-6].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-10].minor); vv_destructor(56,&vvmsp[-9].minor); vv_destructor(29,&vvmsp[-7].minor); vv_destructor(48,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(57,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2515 "parser.c" break; case 59: // 987 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_macro_call_statement(vvmsp[-6].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-8].minor); vv_destructor(56,&vvmsp[-7].minor); vv_destructor(29,&vvmsp[-5].minor); vv_destructor(48,&vvmsp[-4].minor); vv_destructor(32,&vvmsp[-3].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(57,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2530 "parser.c" break; case 60: // 993 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_empty_statement(status->scanner_state); vv_destructor(1,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2539 "parser.c" break; case 61: // 999 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_echo_statement(vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(58,&vvmsp[-2].minor); vv_destructor(59,&vvmsp[0].minor); } // 2548 "parser.c" break; case 62: // 1005 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_block_statement(vvmsp[-5].minor.vv0, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-7].minor); vv_destructor(60,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(61,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2561 "parser.c" break; case 63: // 1009 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_block_statement(vvmsp[-4].minor.vv0, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-6].minor); vv_destructor(60,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-3].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(61,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2574 "parser.c" break; case 64: // 1015 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_cache_statement(vvmsp[-5].minor.vv40, NULL, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-7].minor); vv_destructor(62,&vvmsp[-6].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(63,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2587 "parser.c" break; case 65: // 1019 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_cache_statement(vvmsp[-6].minor.vv40, vvmsp[-5].minor.vv40, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-8].minor); vv_destructor(62,&vvmsp[-7].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(63,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2600 "parser.c" break; case 68: // 1035 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_raw_statement(vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-6].minor); vv_destructor(64,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(65,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2613 "parser.c" break; case 69: // 1041 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_extends_statement(vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(66,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2623 "parser.c" break; case 70: // 1047 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_include_statement(vvmsp[-1].minor.vv40, NULL, status->scanner_state); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(67,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2633 "parser.c" break; case 71: // 1051 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_include_statement(vvmsp[-3].minor.vv40, vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-5].minor); vv_destructor(67,&vvmsp[-4].minor); vv_destructor(68,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2644 "parser.c" break; case 72: // 1057 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_do_statement(vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(69,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2654 "parser.c" break; case 73: // 1063 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_return_statement(vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-3].minor); vv_destructor(70,&vvmsp[-2].minor); vv_destructor(32,&vvmsp[0].minor); } // 2664 "parser.c" break; case 74: // 1069 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_autoescape_statement(0, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-7].minor); vv_destructor(71,&vvmsp[-6].minor); vv_destructor(54,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(72,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2678 "parser.c" break; case 75: // 1073 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_autoescape_statement(1, vvmsp[-3].minor.vv40, status->scanner_state); vv_destructor(1,&vvmsp[-7].minor); vv_destructor(71,&vvmsp[-6].minor); vv_destructor(55,&vvmsp[-5].minor); vv_destructor(32,&vvmsp[-4].minor); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(72,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2692 "parser.c" break; case 76: // 1079 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_break_statement(status->scanner_state); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(73,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2702 "parser.c" break; case 77: // 1085 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_continue_statement(status->scanner_state); vv_destructor(1,&vvmsp[-2].minor); vv_destructor(74,&vvmsp[-1].minor); vv_destructor(32,&vvmsp[0].minor); } // 2712 "parser.c" break; case 78: // 1091 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_literal_zval(PHVOLT_T_RAW_FRAGMENT, vvmsp[0].minor.vv0, status->scanner_state); } // 2719 "parser.c" break; case 79: // 1097 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_MINUS, NULL, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(22,&vvmsp[-1].minor); } // 2727 "parser.c" break; case 80: // 1101 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_PLUS, NULL, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(21,&vvmsp[-1].minor); } // 2735 "parser.c" break; case 81: // 1105 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_SUB, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(22,&vvmsp[-1].minor); } // 2743 "parser.c" break; case 82: // 1109 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ADD, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(21,&vvmsp[-1].minor); } // 2751 "parser.c" break; case 83: // 1113 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_MUL, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(19,&vvmsp[-1].minor); } // 2759 "parser.c" break; case 84: // 1117 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_POW, vvmsp[-3].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(19,&vvmsp[-2].minor); vv_destructor(19,&vvmsp[-1].minor); } // 2768 "parser.c" break; case 85: // 1121 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_DIV, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(18,&vvmsp[-1].minor); } // 2776 "parser.c" break; case 86: // 1125 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_MOD, vvmsp[-3].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(18,&vvmsp[-2].minor); vv_destructor(18,&vvmsp[-1].minor); } // 2785 "parser.c" break; case 87: // 1129 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_MOD, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(20,&vvmsp[-1].minor); } // 2793 "parser.c" break; case 88: // 1133 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_AND, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(7,&vvmsp[-1].minor); } // 2801 "parser.c" break; case 89: // 1137 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_OR, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(8,&vvmsp[-1].minor); } // 2809 "parser.c" break; case 90: // 1141 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_CONCAT, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(23,&vvmsp[-1].minor); } // 2817 "parser.c" break; case 91: // 1145 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_PIPE, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(25,&vvmsp[-1].minor); } // 2825 "parser.c" break; case 92: // 1149 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_RANGE, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(6,&vvmsp[-1].minor); } // 2833 "parser.c" break; case 93: // 1153 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_EQUALS, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(10,&vvmsp[-1].minor); } // 2841 "parser.c" break; case 94: // 1157 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISSET, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(76,&vvmsp[0].minor); } // 2850 "parser.c" break; case 95: // 1161 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISSET, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(76,&vvmsp[0].minor); } // 2859 "parser.c" break; case 96: // 1165 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISEMPTY, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(77,&vvmsp[0].minor); } // 2868 "parser.c" break; case 97: // 1169 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISEMPTY, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(77,&vvmsp[0].minor); } // 2877 "parser.c" break; case 98: // 1173 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISEVEN, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(78,&vvmsp[0].minor); } // 2886 "parser.c" break; case 99: // 1177 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISEVEN, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(78,&vvmsp[0].minor); } // 2895 "parser.c" break; case 100: // 1181 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISODD, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(79,&vvmsp[0].minor); } // 2904 "parser.c" break; case 101: // 1185 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISODD, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(79,&vvmsp[0].minor); } // 2913 "parser.c" break; case 102: // 1189 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISNUMERIC, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(80,&vvmsp[0].minor); } // 2922 "parser.c" break; case 103: // 1193 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISNUMERIC, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(80,&vvmsp[0].minor); } // 2931 "parser.c" break; case 104: // 1197 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISSCALAR, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(81,&vvmsp[0].minor); } // 2940 "parser.c" break; case 105: // 1201 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISSCALAR, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(81,&vvmsp[0].minor); } // 2949 "parser.c" break; case 106: // 1205 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_ISITERABLE, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); vv_destructor(82,&vvmsp[0].minor); } // 2958 "parser.c" break; case 107: // 1209 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ISITERABLE, vvmsp[-2].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); vv_destructor(82,&vvmsp[0].minor); } // 2967 "parser.c" break; case 108: // 1213 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_IS, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(9,&vvmsp[-1].minor); } // 2975 "parser.c" break; case 109: // 1217 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOTEQUALS, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(11,&vvmsp[-1].minor); } // 2983 "parser.c" break; case 110: // 1221 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_IDENTICAL, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(16,&vvmsp[-1].minor); } // 2991 "parser.c" break; case 111: // 1225 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOTIDENTICAL, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(17,&vvmsp[-1].minor); } // 2999 "parser.c" break; case 112: // 1229 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_LESS, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(12,&vvmsp[-1].minor); } // 3007 "parser.c" break; case 113: // 1233 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_GREATER, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(13,&vvmsp[-1].minor); } // 3015 "parser.c" break; case 114: // 1237 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_GREATEREQUAL, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(14,&vvmsp[-1].minor); } // 3023 "parser.c" break; case 115: // 1241 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_LESSEQUAL, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(15,&vvmsp[-1].minor); } // 3031 "parser.c" break; case 117: // 1249 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_IN, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(3,&vvmsp[-1].minor); } // 3039 "parser.c" break; case 118: // 1253 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT_IN, vvmsp[-3].minor.vv40, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(26,&vvmsp[-2].minor); vv_destructor(3,&vvmsp[-1].minor); } // 3048 "parser.c" break; case 119: // 1257 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_NOT, NULL, vvmsp[0].minor.vv40, NULL, status->scanner_state); vv_destructor(26,&vvmsp[-1].minor); } // 3056 "parser.c" break; case 120: // 1261 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_INCR, vvmsp[-1].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(27,&vvmsp[0].minor); } // 3064 "parser.c" break; case 121: // 1265 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_DECR, vvmsp[-1].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(28,&vvmsp[0].minor); } // 3072 "parser.c" break; case 122: // 1269 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ENCLOSED, vvmsp[-1].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(29,&vvmsp[-2].minor); vv_destructor(48,&vvmsp[0].minor); } // 3081 "parser.c" break; case 123: // 1273 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ARRAY, NULL, NULL, NULL, status->scanner_state); vv_destructor(24,&vvmsp[-1].minor); vv_destructor(46,&vvmsp[0].minor); } // 3090 "parser.c" break; case 124: // 1277 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ARRAY, vvmsp[-1].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(24,&vvmsp[-2].minor); vv_destructor(46,&vvmsp[0].minor); } // 3099 "parser.c" break; case 125: // 1281 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ARRAY, NULL, NULL, NULL, status->scanner_state); vv_destructor(83,&vvmsp[-1].minor); vv_destructor(84,&vvmsp[0].minor); } // 3108 "parser.c" break; case 126: // 1285 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_ARRAY, vvmsp[-1].minor.vv40, NULL, NULL, status->scanner_state); vv_destructor(83,&vvmsp[-2].minor); vv_destructor(84,&vvmsp[0].minor); } // 3117 "parser.c" break; case 128: // 1293 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_expr(PHVOLT_T_TERNARY, vvmsp[-2].minor.vv40, vvmsp[0].minor.vv40, vvmsp[-4].minor.vv40, status->scanner_state); vv_destructor(4,&vvmsp[-3].minor); vv_destructor(5,&vvmsp[-1].minor); } // 3126 "parser.c" break; case 129: // 1297 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_slice(vvmsp[-4].minor.vv40, NULL, vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(24,&vvmsp[-3].minor); vv_destructor(5,&vvmsp[-2].minor); vv_destructor(46,&vvmsp[0].minor); } // 3136 "parser.c" break; case 130: // 1301 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_slice(vvmsp[-4].minor.vv40, vvmsp[-2].minor.vv40, NULL, status->scanner_state); vv_destructor(24,&vvmsp[-3].minor); vv_destructor(5,&vvmsp[-1].minor); vv_destructor(46,&vvmsp[0].minor); } // 3146 "parser.c" break; case 131: // 1305 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_slice(vvmsp[-5].minor.vv40, vvmsp[-3].minor.vv40, vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(24,&vvmsp[-4].minor); vv_destructor(5,&vvmsp[-2].minor); vv_destructor(46,&vvmsp[0].minor); } // 3156 "parser.c" break; case 136: case 144: // 1331 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_named_item(vvmsp[-2].minor.vv0, vvmsp[0].minor.vv40, status->scanner_state); vv_destructor(5,&vvmsp[-1].minor); } // 3165 "parser.c" break; case 137: case 143: // 1335 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_named_item(NULL, vvmsp[0].minor.vv40, status->scanner_state); } // 3173 "parser.c" break; case 139: // 1345 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_func_call(vvmsp[-3].minor.vv40, vvmsp[-1].minor.vv40, status->scanner_state); vv_destructor(29,&vvmsp[-2].minor); vv_destructor(48,&vvmsp[0].minor); } // 3182 "parser.c" break; case 140: // 1349 "parser.lemon" { vvgotominor.vv40 = phvolt_ret_func_call(vvmsp[-2].minor.vv40, NULL, status->scanner_state); vv_destructor(29,&vvmsp[-1].minor); vv_destructor(48,&vvmsp[0].minor); } // 3191 "parser.c" break; }; vvgoto = vvRuleInfo[vvruleno].lhs; vvsize = vvRuleInfo[vvruleno].nrhs; vvpParser->vvidx -= vvsize; vvact = vv_find_reduce_action(vvpParser,vvgoto); if( vvact < VVNSTATE ){ vv_shift(vvpParser,vvact,vvgoto,&vvgotominor); }else if( vvact == VVNSTATE + VVNRULE + 1 ){ vv_accept(vvpParser); } } static void vv_parse_failed( vvParser *vvpParser /* The parser */ ){ phvolt_ARG_FETCH; #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sFail!\n",vvTracePrompt); } #endif while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); /* Here code is inserted which will be executed whenever the ** parser fails */ phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void vv_syntax_error( vvParser *vvpParser, /* The parser */ int vvmajor, /* The major type of the error token */ VVMINORTYPE vvminor /* The minor type of the error token */ ){ phvolt_ARG_FETCH; #define VTOKEN (vvminor.vv0) // 618 "parser.lemon" { smart_str error_str = {0}; char *token_name = NULL; const phvolt_token_names *tokens = phvolt_tokens; int token_len = 0; int active_token = status->scanner_state->active_token; if (status->scanner_state->start_length) { if (active_token) { do { if (tokens->code == active_token) { token_name = tokens->name; token_len = tokens->len; break; } ++tokens; } while (tokens[0].code != 0); } smart_str_appendl(&error_str, "Syntax error, unexpected token ", sizeof("Syntax error, unexpected token ") - 1); if (!token_name) { smart_str_appendl(&error_str, "UNKNOWN", sizeof("UNKNOWN") - 1); } else { smart_str_appendl(&error_str, token_name, token_len); } if (status->token->value) { smart_str_appendc(&error_str, '('); smart_str_appendl(&error_str, status->token->value, status->token->len); smart_str_appendc(&error_str, ')'); } smart_str_appendl(&error_str, " in ", sizeof(" in ") - 1); smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); smart_str_appendl(&error_str, " on line ", sizeof(" on line ") - 1); { char stmp[MAX_LENGTH_OF_LONG + 1]; int str_len; str_len = slprintf(stmp, sizeof(stmp), "%ld", status->scanner_state->active_line); smart_str_appendl(&error_str, stmp, str_len); } } else { smart_str_appendl(&error_str, "Syntax error, unexpected EOF in ", sizeof("Syntax error, unexpected EOF in ") - 1); smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); /* Report unclosed 'if' blocks */ if ((status->scanner_state->if_level + status->scanner_state->old_if_level) > 0) { if ((status->scanner_state->if_level + status->scanner_state->old_if_level) == 1) { smart_str_appendl(&error_str, ", there is one 'if' block without close", sizeof(", there is one 'if' block without close") - 1); } else { smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); { char stmp[MAX_LENGTH_OF_LONG + 1]; int str_len; str_len = slprintf(stmp, sizeof(stmp), "%ld", status->scanner_state->if_level + status->scanner_state->old_if_level); smart_str_appendl(&error_str, stmp, str_len); } smart_str_appendl(&error_str, " 'if' blocks without close", sizeof(" 'if' blocks without close") - 1); } } /* Report unclosed 'for' blocks */ if (status->scanner_state->for_level > 0) { if (status->scanner_state->for_level == 1) { smart_str_appendl(&error_str, ", there is one 'for' block without close", sizeof(", there is one 'for' block without close") - 1); } else { smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); { char stmp[MAX_LENGTH_OF_LONG + 1]; int str_len; str_len = slprintf(stmp, sizeof(stmp), "%ld", status->scanner_state->if_level); smart_str_appendl(&error_str, stmp, str_len); } smart_str_appendl(&error_str, " 'for' blocks without close", sizeof(" 'for' blocks without close") - 1); } } } smart_str_0(&error_str); if (error_str.len) { status->syntax_error = error_str.c; status->syntax_error_len = error_str.len; } else { status->syntax_error = NULL; } } status->status = PHVOLT_PARSING_FAILED; // 3331 "parser.c" phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } static void vv_accept( vvParser *vvpParser /* The parser */ ){ phvolt_ARG_FETCH; #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sAccept!\n",vvTracePrompt); } #endif while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); /* Here code is inserted which will be executed whenever the ** parser accepts */ phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "phvolt_Alloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the ** user wants (and specified in the grammar) and is available for ** use by the action routines. ** ** Inputs: ** <ul> ** <li> A pointer to the parser (an opaque structure.) ** <li> The major token number. ** <li> The minor token number. ** <li> An option argument of a grammar-specified type. ** </ul> ** ** Outputs: ** None. */ static void phvolt_( void *vvp, /* The parser */ int vvmajor, /* The major token code number */ phvolt_TOKENTYPE vvminor /* The value for the token */ phvolt_ARG_PDECL /* Optional %extra_argument parameter */ ){ VVMINORTYPE vvminorunion; int vvact; /* The parser action. */ int vvendofinput; /* True if we are at the end of input */ int vverrorhit = 0; /* True if vvmajor has invoked an error */ vvParser *vvpParser; /* The parser */ /* (re)initialize the parser, if necessary */ vvpParser = (vvParser*)vvp; if( vvpParser->vvidx<0 ){ if( vvmajor==0 ) return; vvpParser->vvidx = 0; vvpParser->vverrcnt = -1; vvpParser->vvstack[0].stateno = 0; vvpParser->vvstack[0].major = 0; } vvminorunion.vv0 = vvminor; vvendofinput = (vvmajor==0); phvolt_ARG_STORE; #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sInput %s\n",vvTracePrompt,vvTokenName[vvmajor]); } #endif do{ vvact = vv_find_shift_action(vvpParser,vvmajor); if( vvact<VVNSTATE ){ vv_shift(vvpParser,vvact,vvmajor,&vvminorunion); vvpParser->vverrcnt--; if( vvendofinput && vvpParser->vvidx>=0 ){ vvmajor = 0; }else{ vvmajor = VVNOCODE; } }else if( vvact < VVNSTATE + VVNRULE ){ vv_reduce(vvpParser,vvact-VVNSTATE); }else if( vvact == VV_ERROR_ACTION ){ int vvmx; #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sSyntax Error!\n",vvTracePrompt); } #endif #ifdef VVERRORSYMBOL /* A syntax error has occurred. ** The response to an error depends upon whether or not the ** grammar defines an error token "ERROR". ** ** This is what we do if the grammar does define ERROR: ** ** * Call the %syntax_error function. ** ** * Begin popping the stack until we enter a state where ** it is legal to shift the error symbol, then shift ** the error symbol. ** ** * Set the error count to three. ** ** * Begin accepting and shifting new tokens. No new error ** processing will occur until three tokens have been ** shifted successfully. ** */ if( vvpParser->vverrcnt<0 ){ vv_syntax_error(vvpParser,vvmajor,vvminorunion); } vvmx = vvpParser->vvstack[vvpParser->vvidx].major; if( vvmx==VVERRORSYMBOL || vverrorhit ){ #ifndef NDEBUG if( vvTraceFILE ){ fprintf(vvTraceFILE,"%sDiscard input token %s\n", vvTracePrompt,vvTokenName[vvmajor]); } #endif vv_destructor(vvmajor,&vvminorunion); vvmajor = VVNOCODE; }else{ while( vvpParser->vvidx >= 0 && vvmx != VVERRORSYMBOL && (vvact = vv_find_shift_action(vvpParser,VVERRORSYMBOL)) >= VVNSTATE ){ vv_pop_parser_stack(vvpParser); } if( vvpParser->vvidx < 0 || vvmajor==0 ){ vv_destructor(vvmajor,&vvminorunion); vv_parse_failed(vvpParser); vvmajor = VVNOCODE; }else if( vvmx!=VVERRORSYMBOL ){ VVMINORTYPE u2; u2.VVERRSYMDT = 0; vv_shift(vvpParser,vvact,VVERRORSYMBOL,&u2); } } vvpParser->vverrcnt = 3; vverrorhit = 1; #else /* VVERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** ** As before, subsequent error messages are suppressed until ** three input tokens have been successfully shifted. */ if( vvpParser->vverrcnt<=0 ){ vv_syntax_error(vvpParser,vvmajor,vvminorunion); } vvpParser->vverrcnt = 3; vv_destructor(vvmajor,&vvminorunion); if( vvendofinput ){ vv_parse_failed(vvpParser); } vvmajor = VVNOCODE; #endif }else{ vv_accept(vvpParser); vvmajor = VVNOCODE; } }while( vvmajor!=VVNOCODE && vvpParser->vvidx>=0 ); return; } const phvolt_token_names phvolt_tokens[] = { { SL("INTEGER"), PHVOLT_T_INTEGER }, { SL("DOUBLE"), PHVOLT_T_DOUBLE }, { SL("STRING"), PHVOLT_T_STRING }, { SL("IDENTIFIER"), PHVOLT_T_IDENTIFIER }, { SL("MINUS"), PHVOLT_T_MINUS }, { SL("+"), PHVOLT_T_ADD }, { SL("-"), PHVOLT_T_SUB }, { SL("*"), PHVOLT_T_MUL }, { SL("/"), PHVOLT_T_DIV }, { SL("%%"), PHVOLT_T_MOD }, { SL("!"), PHVOLT_T_NOT }, { SL("~"), PHVOLT_T_CONCAT }, { SL("AND"), PHVOLT_T_AND }, { SL("OR"), PHVOLT_T_OR }, { SL("DOT"), PHVOLT_T_DOT }, { SL("COMMA"), PHVOLT_T_COMMA }, { SL("EQUALS"), PHVOLT_T_EQUALS }, { SL("NOT EQUALS"), PHVOLT_T_NOTEQUALS }, { SL("IDENTICAL"), PHVOLT_T_IDENTICAL }, { SL("NOT IDENTICAL"), PHVOLT_T_NOTIDENTICAL }, { SL("NOT"), PHVOLT_T_NOT }, { SL("RANGE"), PHVOLT_T_RANGE }, { SL("COLON"), PHVOLT_T_COLON }, { SL("QUESTION MARK"), PHVOLT_T_QUESTION }, { SL("<"), PHVOLT_T_LESS }, { SL("<="), PHVOLT_T_LESSEQUAL }, { SL(">"), PHVOLT_T_GREATER }, { SL(">="), PHVOLT_T_GREATEREQUAL }, { SL("("), PHVOLT_T_PARENTHESES_OPEN }, { SL(")"), PHVOLT_T_PARENTHESES_CLOSE }, { SL("["), PHVOLT_T_SBRACKET_OPEN }, { SL("]"), PHVOLT_T_SBRACKET_CLOSE }, { SL("{"), PHVOLT_T_CBRACKET_OPEN }, { SL("}"), PHVOLT_T_CBRACKET_CLOSE }, { SL("{%"), PHVOLT_T_OPEN_DELIMITER }, { SL("%}"), PHVOLT_T_CLOSE_DELIMITER }, { SL("{{"), PHVOLT_T_OPEN_EDELIMITER }, { SL("}}"), PHVOLT_T_CLOSE_EDELIMITER }, { SL("IF"), PHVOLT_T_IF }, { SL("ELSE"), PHVOLT_T_ELSE }, { SL("ELSEIF"), PHVOLT_T_ELSEIF }, { SL("ELSEFOR"), PHVOLT_T_ELSEFOR }, { SL("ENDIF"), PHVOLT_T_ENDIF }, { SL("FOR"), PHVOLT_T_FOR }, { SL("IN"), PHVOLT_T_IN }, { SL("ENDFOR"), PHVOLT_T_ENDFOR }, { SL("SET"), PHVOLT_T_SET }, { SL("ASSIGN"), PHVOLT_T_ASSIGN }, { SL("+="), PHVOLT_T_ADD_ASSIGN }, { SL("-="), PHVOLT_T_SUB_ASSIGN }, { SL("*="), PHVOLT_T_MUL_ASSIGN }, { SL("/="), PHVOLT_T_DIV_ASSIGN }, { SL("++"), PHVOLT_T_INCR }, { SL("--"), PHVOLT_T_DECR }, { SL("BLOCK"), PHVOLT_T_BLOCK }, { SL("ENDBLOCK"), PHVOLT_T_ENDBLOCK }, { SL("CACHE"), PHVOLT_T_CACHE }, { SL("ENDCACHE"), PHVOLT_T_ENDCACHE }, { SL("EXTENDS"), PHVOLT_T_EXTENDS }, { SL("IS"), PHVOLT_T_IS }, { SL("DEFINED"), PHVOLT_T_DEFINED }, { SL("EMPTY"), PHVOLT_T_EMPTY }, { SL("EVEN"), PHVOLT_T_EVEN }, { SL("ODD"), PHVOLT_T_ODD }, { SL("NUMERIC"), PHVOLT_T_NUMERIC }, { SL("SCALAR"), PHVOLT_T_SCALAR }, { SL("ITERABLE"), PHVOLT_T_ITERABLE }, { SL("INCLUDE"), PHVOLT_T_INCLUDE }, { SL("DO"), PHVOLT_T_DO }, { SL("WHITESPACE"), PHVOLT_T_IGNORE }, { SL("AUTOESCAPE"), PHVOLT_T_AUTOESCAPE }, { SL("ENDAUTOESCAPE"), PHVOLT_T_ENDAUTOESCAPE }, { SL("CONTINUE"), PHVOLT_T_CONTINUE }, { SL("BREAK"), PHVOLT_T_BREAK }, { SL("WITH"), PHVOLT_T_WITH }, { SL("RETURN"), PHVOLT_T_RETURN }, { SL("MACRO"), PHVOLT_T_MACRO }, { SL("ENDMACRO"), PHVOLT_T_ENDMACRO }, { SL("CALL"), PHVOLT_T_CALL }, { SL("WITH"), PHVOLT_T_WITH }, { NULL, 0, 0 } }; static void *phvolt_wrapper_alloc(size_t bytes){ return emalloc(bytes); } static void phvolt_wrapper_free(void *pointer){ efree(pointer); } static void phvolt_parse_with_token(void* phvolt_parser, int opcode, int parsercode, phvolt_scanner_token *token, phvolt_parser_status *parser_status){ phvolt_parser_token *pToken; pToken = emalloc(sizeof(phvolt_parser_token)); pToken->opcode = opcode; pToken->token = token->value; pToken->token_len = token->len; pToken->free_flag = 1; phvolt_(phvolt_parser, parsercode, pToken, parser_status); token->value = NULL; token->len = 0; } static void phvolt_create_error_msg(phvolt_parser_status *parser_status, char *message){ unsigned int length = (128 + Z_STRLEN_P(parser_status->scanner_state->active_file)); char *str = emalloc(sizeof(char) * length); snprintf(str, length, "%s in %s on line %d", message, Z_STRVAL_P(parser_status->scanner_state->active_file), parser_status->scanner_state->active_line); str[length - 1] = '\0'; parser_status->syntax_error = estrndup(str, strlen(str)); efree(str); } static void phvolt_scanner_error_msg(phvolt_parser_status *parser_status, zval **error_msg TSRMLS_DC){ char *error, *error_part; int length; phvolt_scanner_state *state = parser_status->scanner_state; MAKE_STD_ZVAL(*error_msg); if (state->start) { error = emalloc(sizeof(char) * 72 + state->start_length + Z_STRLEN_P(state->active_file)); if (state->start_length > 16) { length = 72 + Z_STRLEN_P(state->active_file); error_part = estrndup(state->start, 16); snprintf(error, length, "Scanning error before '%s...' in %s on line %d", error_part, Z_STRVAL_P(state->active_file), state->active_line); error[length - 1] = '\0'; efree(error_part); } else { length = 48 + state->start_length + Z_STRLEN_P(state->active_file); snprintf(error, length, "Scanning error before '%s' in %s on line %d", state->start, Z_STRVAL_P(state->active_file), state->active_line); } } else { error = emalloc(sizeof(char) * (32 + Z_STRLEN_P(state->active_file))); length = 32 + Z_STRLEN_P(state->active_file); snprintf(error, length, "Scanning error near to EOF in %s", Z_STRVAL_P(state->active_file)); } error[length - 1] = '\0'; ZVAL_STRING(*error_msg, error, 1); efree(error); } static int phvolt_parse_view(zval *result, zval *view_code, zval *template_path TSRMLS_DC){ zval *error_msg = NULL; ZVAL_NULL(result); if (Z_TYPE_P(view_code) != IS_STRING) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, "View code must be a string"); return FAILURE; } if (phvolt_internal_parse_view(&result, view_code, template_path, &error_msg TSRMLS_CC) == FAILURE) { ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, Z_STRVAL_P(error_msg)); zval_ptr_dtor(&error_msg); return FAILURE; } return SUCCESS; } static int phvolt_is_blank_string(phvolt_scanner_token *token){ char *marker = token->value; unsigned int ch, i; for (i = 0; i < token->len; i++) { ch = *marker; if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' && ch != 11) { return 0; } marker++; } return 1; } static int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_path, zval **error_msg TSRMLS_DC) { char *error; phvolt_scanner_state *state; phvolt_scanner_token token; int scanner_status, status = SUCCESS; phvolt_parser_status *parser_status = NULL; void* phvolt_parser; /** Check if the view has code */ if (!Z_STRVAL_P(view_code)) { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "View code cannot be null", 1); return FAILURE; } if (!Z_STRLEN_P(view_code)) { array_init(*result); return SUCCESS; } /** Start the reentrant parser */ phvolt_parser = phvolt_Alloc(phvolt_wrapper_alloc); if (unlikely(!phvolt_parser)) { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, "Memory allocation error", 1); return FAILURE; } parser_status = emalloc(sizeof(phvolt_parser_status)); state = emalloc(sizeof(phvolt_scanner_state)); parser_status->status = PHVOLT_PARSING_OK; parser_status->scanner_state = state; parser_status->ret = NULL; parser_status->token = &token; parser_status->syntax_error = NULL; /** Initialize the scanner state */ state->active_token = 0; state->start = Z_STRVAL_P(view_code); state->mode = PHVOLT_MODE_RAW; state->raw_buffer = emalloc(sizeof(char) * PHVOLT_RAW_BUFFER_SIZE); state->raw_buffer_size = PHVOLT_RAW_BUFFER_SIZE; state->raw_buffer_cursor = 0; state->active_file = template_path; state->active_line = 1; state->statement_position = 0; state->extends_mode = 0; state->block_level = 0; state->macro_level = 0; state->start_length = 0; state->old_if_level = 0; state->if_level = 0; state->for_level = 0; state->whitespace_control = 0; state->forced_raw_state = 0; state->end = state->start; token.value = NULL; token.len = 0; while (0 <= (scanner_status = phvolt_get_token(state, &token))) { state->active_token = token.opcode; state->start_length = (Z_STRVAL_P(view_code) + Z_STRLEN_P(view_code) - state->start); switch (token.opcode) { case PHVOLT_T_IGNORE: break; case PHVOLT_T_ADD: phvolt_(phvolt_parser, PHVOLT_PLUS, NULL, parser_status); break; case PHVOLT_T_SUB: phvolt_(phvolt_parser, PHVOLT_MINUS, NULL, parser_status); break; case PHVOLT_T_MUL: phvolt_(phvolt_parser, PHVOLT_TIMES, NULL, parser_status); break; case PHVOLT_T_DIV: phvolt_(phvolt_parser, PHVOLT_DIVIDE, NULL, parser_status); break; case PHVOLT_T_MOD: phvolt_(phvolt_parser, PHVOLT_MOD, NULL, parser_status); break; case PHVOLT_T_AND: phvolt_(phvolt_parser, PHVOLT_AND, NULL, parser_status); break; case PHVOLT_T_OR: phvolt_(phvolt_parser, PHVOLT_OR, NULL, parser_status); break; case PHVOLT_T_IS: phvolt_(phvolt_parser, PHVOLT_IS, NULL, parser_status); break; case PHVOLT_T_EQUALS: phvolt_(phvolt_parser, PHVOLT_EQUALS, NULL, parser_status); break; case PHVOLT_T_NOTEQUALS: phvolt_(phvolt_parser, PHVOLT_NOTEQUALS, NULL, parser_status); break; case PHVOLT_T_LESS: phvolt_(phvolt_parser, PHVOLT_LESS, NULL, parser_status); break; case PHVOLT_T_GREATER: phvolt_(phvolt_parser, PHVOLT_GREATER, NULL, parser_status); break; case PHVOLT_T_GREATEREQUAL: phvolt_(phvolt_parser, PHVOLT_GREATEREQUAL, NULL, parser_status); break; case PHVOLT_T_LESSEQUAL: phvolt_(phvolt_parser, PHVOLT_LESSEQUAL, NULL, parser_status); break; case PHVOLT_T_IDENTICAL: phvolt_(phvolt_parser, PHVOLT_IDENTICAL, NULL, parser_status); break; case PHVOLT_T_NOTIDENTICAL: phvolt_(phvolt_parser, PHVOLT_NOTIDENTICAL, NULL, parser_status); break; case PHVOLT_T_NOT: phvolt_(phvolt_parser, PHVOLT_NOT, NULL, parser_status); break; case PHVOLT_T_DOT: phvolt_(phvolt_parser, PHVOLT_DOT, NULL, parser_status); break; case PHVOLT_T_CONCAT: phvolt_(phvolt_parser, PHVOLT_CONCAT, NULL, parser_status); break; case PHVOLT_T_RANGE: phvolt_(phvolt_parser, PHVOLT_RANGE, NULL, parser_status); break; case PHVOLT_T_PIPE: phvolt_(phvolt_parser, PHVOLT_PIPE, NULL, parser_status); break; case PHVOLT_T_COMMA: phvolt_(phvolt_parser, PHVOLT_COMMA, NULL, parser_status); break; case PHVOLT_T_COLON: phvolt_(phvolt_parser, PHVOLT_COLON, NULL, parser_status); break; case PHVOLT_T_QUESTION: phvolt_(phvolt_parser, PHVOLT_QUESTION, NULL, parser_status); break; case PHVOLT_T_PARENTHESES_OPEN: phvolt_(phvolt_parser, PHVOLT_PARENTHESES_OPEN, NULL, parser_status); break; case PHVOLT_T_PARENTHESES_CLOSE: phvolt_(phvolt_parser, PHVOLT_PARENTHESES_CLOSE, NULL, parser_status); break; case PHVOLT_T_SBRACKET_OPEN: phvolt_(phvolt_parser, PHVOLT_SBRACKET_OPEN, NULL, parser_status); break; case PHVOLT_T_SBRACKET_CLOSE: phvolt_(phvolt_parser, PHVOLT_SBRACKET_CLOSE, NULL, parser_status); break; case PHVOLT_T_CBRACKET_OPEN: phvolt_(phvolt_parser, PHVOLT_CBRACKET_OPEN, NULL, parser_status); break; case PHVOLT_T_CBRACKET_CLOSE: phvolt_(phvolt_parser, PHVOLT_CBRACKET_CLOSE, NULL, parser_status); break; case PHVOLT_T_OPEN_DELIMITER: phvolt_(phvolt_parser, PHVOLT_OPEN_DELIMITER, NULL, parser_status); break; case PHVOLT_T_CLOSE_DELIMITER: phvolt_(phvolt_parser, PHVOLT_CLOSE_DELIMITER, NULL, parser_status); break; case PHVOLT_T_OPEN_EDELIMITER: if (state->extends_mode == 1 && state->block_level == 0) { phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); parser_status->status = PHVOLT_PARSING_FAILED; break; } phvolt_(phvolt_parser, PHVOLT_OPEN_EDELIMITER, NULL, parser_status); break; case PHVOLT_T_CLOSE_EDELIMITER: phvolt_(phvolt_parser, PHVOLT_CLOSE_EDELIMITER, NULL, parser_status); break; case PHVOLT_T_NULL: phvolt_(phvolt_parser, PHVOLT_NULL, NULL, parser_status); break; case PHVOLT_T_TRUE: phvolt_(phvolt_parser, PHVOLT_TRUE, NULL, parser_status); break; case PHVOLT_T_FALSE: phvolt_(phvolt_parser, PHVOLT_FALSE, NULL, parser_status); break; case PHVOLT_T_INTEGER: phvolt_parse_with_token(phvolt_parser, PHVOLT_T_INTEGER, PHVOLT_INTEGER, &token, parser_status); break; case PHVOLT_T_DOUBLE: phvolt_parse_with_token(phvolt_parser, PHVOLT_T_DOUBLE, PHVOLT_DOUBLE, &token, parser_status); break; case PHVOLT_T_STRING: phvolt_parse_with_token(phvolt_parser, PHVOLT_T_STRING, PHVOLT_STRING, &token, parser_status); break; case PHVOLT_T_IDENTIFIER: phvolt_parse_with_token(phvolt_parser, PHVOLT_T_IDENTIFIER, PHVOLT_IDENTIFIER, &token, parser_status); break; case PHVOLT_T_IF: if (state->extends_mode == 1 && state->block_level == 0){ phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); parser_status->status = PHVOLT_PARSING_FAILED; break; } else { state->if_level++; state->block_level++; } phvolt_(phvolt_parser, PHVOLT_IF, NULL, parser_status); break; case PHVOLT_T_ELSE: if (state->if_level == 0 && state->for_level > 0) { phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); } else { phvolt_(phvolt_parser, PHVOLT_ELSE, NULL, parser_status); } break; case PHVOLT_T_ELSEFOR: phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); break; case PHVOLT_T_ELSEIF: if (state->if_level == 0) { phvolt_create_error_msg(parser_status, "Unexpected ENDIF"); parser_status->status = PHVOLT_PARSING_FAILED; break; } phvolt_(phvolt_parser, PHVOLT_ELSEIF, NULL, parser_status); break; case PHVOLT_T_ENDIF: state->block_level--; state->if_level--; phvolt_(phvolt_parser, PHVOLT_ENDIF, NULL, parser_status); break; case PHVOLT_T_FOR: if (state->extends_mode == 1 && state->block_level == 0){ phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); parser_status->status = PHVOLT_PARSING_FAILED; break; } else { state->old_if_level = state->if_level; state->if_level = 0; state->for_level++; state->block_level++; } phvolt_(phvolt_parser, PHVOLT_FOR, NULL, parser_status); break; case PHVOLT_T_IN: phvolt_(phvolt_parser, PHVOLT_IN, NULL, parser_status); break; case PHVOLT_T_ENDFOR: state->block_level--; state->for_level--; state->if_level = state->old_if_level; phvolt_(phvolt_parser, PHVOLT_ENDFOR, NULL, parser_status); break; case PHVOLT_T_RAW_FRAGMENT: if (token.len > 0) { if (state->extends_mode == 1 && state->block_level == 0){ if (!phvolt_is_blank_string(&token)) { phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); parser_status->status = PHVOLT_PARSING_FAILED; } efree(token.value); break; } else { if (!phvolt_is_blank_string(&token)) { state->statement_position++; } } phvolt_parse_with_token(phvolt_parser, PHVOLT_T_RAW_FRAGMENT, PHVOLT_RAW_FRAGMENT, &token, parser_status); } else { efree(token.value); } break; case PHVOLT_T_SET: if (state->extends_mode == 1 && state->block_level == 0){ phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); parser_status->status = PHVOLT_PARSING_FAILED; break; } phvolt_(phvolt_parser, PHVOLT_SET, NULL, parser_status); break; case PHVOLT_T_ASSIGN: phvolt_(phvolt_parser, PHVOLT_ASSIGN, NULL, parser_status); break; case PHVOLT_T_ADD_ASSIGN: phvolt_(phvolt_parser, PHVOLT_ADD_ASSIGN, NULL, parser_status); break; case PHVOLT_T_SUB_ASSIGN: phvolt_(phvolt_parser, PHVOLT_SUB_ASSIGN, NULL, parser_status); break; case PHVOLT_T_MUL_ASSIGN: phvolt_(phvolt_parser, PHVOLT_MUL_ASSIGN, NULL, parser_status); break; case PHVOLT_T_DIV_ASSIGN: phvolt_(phvolt_parser, PHVOLT_DIV_ASSIGN, NULL, parser_status); break; case PHVOLT_T_INCR: phvolt_(phvolt_parser, PHVOLT_INCR, NULL, parser_status); break; case PHVOLT_T_DECR: phvolt_(phvolt_parser, PHVOLT_DECR, NULL, parser_status); break; case PHVOLT_T_BLOCK: if (state->block_level > 0) { phvolt_create_error_msg(parser_status, "Embedding blocks into other blocks is not supported"); parser_status->status = PHVOLT_PARSING_FAILED; break; } else { state->block_level++; } phvolt_(phvolt_parser, PHVOLT_BLOCK, NULL, parser_status); break; case PHVOLT_T_ENDBLOCK: state->block_level--; phvolt_(phvolt_parser, PHVOLT_ENDBLOCK, NULL, parser_status); break; case PHVOLT_T_MACRO: if (state->macro_level > 0) { phvolt_create_error_msg(parser_status, "Embedding macros into other macros is not allowed"); parser_status->status = PHVOLT_PARSING_FAILED; break; } else { state->macro_level++; } phvolt_(phvolt_parser, PHVOLT_MACRO, NULL, parser_status); break; case PHVOLT_T_ENDMACRO: state->macro_level--; phvolt_(phvolt_parser, PHVOLT_ENDMACRO, NULL, parser_status); break; case PHVOLT_T_CALL: phvolt_(phvolt_parser, PHVOLT_CALL, NULL, parser_status); break; case PHVOLT_T_ENDCALL: phvolt_(phvolt_parser, PHVOLT_ENDCALL, NULL, parser_status); break; case PHVOLT_T_CACHE: phvolt_(phvolt_parser, PHVOLT_CACHE, NULL, parser_status); break; case PHVOLT_T_ENDCACHE: phvolt_(phvolt_parser, PHVOLT_ENDCACHE, NULL, parser_status); break; case PHVOLT_T_RAW: phvolt_(phvolt_parser, PHVOLT_RAW, NULL, parser_status); state->forced_raw_state++; break; case PHVOLT_T_ENDRAW: phvolt_(phvolt_parser, PHVOLT_ENDRAW, NULL, parser_status); state->forced_raw_state--; break; case PHVOLT_T_INCLUDE: phvolt_(phvolt_parser, PHVOLT_INCLUDE, NULL, parser_status); break; case PHVOLT_T_WITH: phvolt_(phvolt_parser, PHVOLT_WITH, NULL, parser_status); break; case PHVOLT_T_DEFINED: phvolt_(phvolt_parser, PHVOLT_DEFINED, NULL, parser_status); break; case PHVOLT_T_EMPTY: phvolt_(phvolt_parser, PHVOLT_EMPTY, NULL, parser_status); break; case PHVOLT_T_EVEN: phvolt_(phvolt_parser, PHVOLT_EVEN, NULL, parser_status); break; case PHVOLT_T_ODD: phvolt_(phvolt_parser, PHVOLT_ODD, NULL, parser_status); break; case PHVOLT_T_NUMERIC: phvolt_(phvolt_parser, PHVOLT_NUMERIC, NULL, parser_status); break; case PHVOLT_T_SCALAR: phvolt_(phvolt_parser, PHVOLT_SCALAR, NULL, parser_status); break; case PHVOLT_T_ITERABLE: phvolt_(phvolt_parser, PHVOLT_ITERABLE, NULL, parser_status); break; case PHVOLT_T_DO: phvolt_(phvolt_parser, PHVOLT_DO, NULL, parser_status); break; case PHVOLT_T_RETURN: phvolt_(phvolt_parser, PHVOLT_RETURN, NULL, parser_status); break; case PHVOLT_T_AUTOESCAPE: phvolt_(phvolt_parser, PHVOLT_AUTOESCAPE, NULL, parser_status); break; case PHVOLT_T_ENDAUTOESCAPE: phvolt_(phvolt_parser, PHVOLT_ENDAUTOESCAPE, NULL, parser_status); break; case PHVOLT_T_BREAK: phvolt_(phvolt_parser, PHVOLT_BREAK, NULL, parser_status); break; case PHVOLT_T_CONTINUE: phvolt_(phvolt_parser, PHVOLT_CONTINUE, NULL, parser_status); break; case PHVOLT_T_EXTENDS: if (state->statement_position != 1) { phvolt_create_error_msg(parser_status, "Extends statement must be placed at the first line in the template"); parser_status->status = PHVOLT_PARSING_FAILED; break; } else { state->extends_mode = 1; } phvolt_(phvolt_parser, PHVOLT_EXTENDS, NULL, parser_status); break; default: parser_status->status = PHVOLT_PARSING_FAILED; if (!*error_msg) { error = emalloc(sizeof(char) * (48 + Z_STRLEN_P(state->active_file))); snprintf(error, 48 + Z_STRLEN_P(state->active_file) + state->active_line, "Scanner: unknown opcode %d on in %s line %d", token.opcode, Z_STRVAL_P(state->active_file), state->active_line); MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, error, 1); efree(error); } break; } if (parser_status->status != PHVOLT_PARSING_OK) { status = FAILURE; break; } state->end = state->start; } if (status != FAILURE) { switch (scanner_status) { case PHVOLT_SCANNER_RETCODE_ERR: case PHVOLT_SCANNER_RETCODE_IMPOSSIBLE: if (!*error_msg) { phvolt_scanner_error_msg(parser_status, error_msg TSRMLS_CC); } status = FAILURE; break; default: phvolt_(phvolt_parser, 0, NULL, parser_status); } } state->active_token = 0; state->start = NULL; efree(state->raw_buffer); if (parser_status->status != PHVOLT_PARSING_OK) { status = FAILURE; if (parser_status->syntax_error) { if (!*error_msg) { MAKE_STD_ZVAL(*error_msg); ZVAL_STRING(*error_msg, parser_status->syntax_error, 1); } efree(parser_status->syntax_error); } } phvolt_Free(phvolt_parser, phvolt_wrapper_free); if (status != FAILURE) { if (parser_status->status == PHVOLT_PARSING_OK) { if (parser_status->ret) { ZVAL_ZVAL(*result, parser_status->ret, 0, 0); ZVAL_NULL(parser_status->ret); zval_ptr_dtor(&parser_status->ret); } else { array_init(*result); } } } efree(parser_status); efree(state); return status; } /* Generated by re2c 0.13.6 on Wed Jun 10 18:00:58 2015 */ // 1 "scanner.re" #define VVCTYPE unsigned char #define VVCURSOR (s->start) #define VVLIMIT (s->end) #define VVMARKER q static void phvolt_rtrim(phvolt_scanner_token *token) { char *cursor, *removed_str; int i; char ch; if (token->len > 0) { cursor = token->value; cursor += (token->len - 1); for (i = token->len; i > 0; i--) { ch = (*cursor); if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { cursor--; continue; } break; } if (i >= 0) { removed_str = emalloc(i + 1); memcpy(removed_str, token->value, i); removed_str[i] = '\0'; efree(token->value); token->value = removed_str; token->len = i; } } } static void phvolt_ltrim(phvolt_scanner_token *token) { char *cursor, *removed_str; int i; if (token->len > 0) { cursor = token->value; for (i = 0; i < token->len; i++) { char ch = (*cursor); if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { cursor++; continue; } break; } if (i >= 0) { removed_str = emalloc(token->len - i + 1); memcpy(removed_str, token->value + i, token->len - i); removed_str[token->len - i] = '\0'; efree(token->value); token->value = removed_str; token->len = token->len - i; } } } static int phvolt_get_token(phvolt_scanner_state *s, phvolt_scanner_token *token) { unsigned char next, double_next; char *q = VVCURSOR, *start = VVCURSOR; int status = PHVOLT_SCANNER_RETCODE_IMPOSSIBLE; while (PHVOLT_SCANNER_RETCODE_IMPOSSIBLE == status) { if (s->mode == PHVOLT_MODE_RAW || s->mode == PHVOLT_MODE_COMMENT) { next = '\0'; double_next = '\0'; if (*VVCURSOR == '\n') { s->active_line++; } if (*VVCURSOR != '\0') { next = *(VVCURSOR + 1); if (next != '\0') { double_next = *(VVCURSOR + 2); } } if (*VVCURSOR == '\0' || (*VVCURSOR == '{' && (next == '%' || next == '{' || next == '#'))) { if (next != '#') { s->mode = PHVOLT_MODE_CODE; if (s->raw_buffer_cursor > 0) { token->opcode = PHVOLT_T_RAW_FRAGMENT; token->value = emalloc(sizeof(char) * s->raw_buffer_cursor + 1); memcpy(token->value, s->raw_buffer, s->raw_buffer_cursor); token->value[s->raw_buffer_cursor] = 0; token->len = s->raw_buffer_cursor; if (s->whitespace_control == 1) { phvolt_ltrim(token); s->whitespace_control = 0; } if (double_next == '-') { phvolt_rtrim(token); } s->raw_buffer_cursor = 0; q = VVCURSOR; } else { token->opcode = PHVOLT_T_IGNORE; } } else { while ((next = *(++VVCURSOR))) { if (next == '#' && *(VVCURSOR + 1) == '}') { VVCURSOR+=2; token->opcode = PHVOLT_T_IGNORE; return 0; } else { if (next == '\n') { s->active_line++; } } } return PHVOLT_SCANNER_RETCODE_EOF; } return 0; } else { if (s->raw_buffer_cursor == s->raw_buffer_size) { s->raw_buffer_size += PHVOLT_RAW_BUFFER_SIZE; s->raw_buffer = erealloc(s->raw_buffer, s->raw_buffer_size); } memcpy(s->raw_buffer+s->raw_buffer_cursor, VVCURSOR, 1); s->raw_buffer_cursor++; ++VVCURSOR; } } else { // 181 "scanner.c" { VVCTYPE vvch; unsigned int vvaccept = 0; vvch = *VVCURSOR; switch (vvch) { case 0x00: goto vv71; case '\t': case '\r': case ' ': goto vv67; case '\n': goto vv69; case '!': goto vv59; case '"': goto vv28; case '%': goto vv22; case '\'': goto vv30; case '(': goto vv45; case ')': goto vv47; case '*': goto vv35; case '+': goto vv33; case ',': goto vv43; case '-': goto vv24; case '.': goto vv41; case '/': goto vv37; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto vv2; case ':': goto vv63; case '<': goto vv53; case '=': goto vv55; case '>': goto vv57; case '?': goto vv65; case 'A': case 'a': goto vv12; case 'B': case 'b': goto vv14; case 'C': case 'c': goto vv16; case 'D': case 'd': goto vv19; case 'E': case 'e': goto vv7; case 'F': case 'f': goto vv8; case 'G': case 'H': case 'J': case 'K': case 'L': case 'P': case 'Q': case 'U': case 'V': case 'X': case 'Y': case 'Z': case '_': case 'g': case 'h': case 'j': case 'k': case 'l': case 'p': case 'q': case 'u': case 'v': case 'x': case 'y': case 'z': goto vv32; case 'I': goto vv4; case 'M': case 'm': goto vv15; case 'N': case 'n': goto vv10; case 'O': case 'o': goto vv13; case 'R': case 'r': goto vv18; case 'S': case 's': goto vv9; case 'T': case 't': goto vv11; case 'W': case 'w': goto vv17; case '[': goto vv49; case '\\': goto vv31; case ']': goto vv51; case 'i': goto vv6; case '{': goto vv20; case '|': goto vv61; case '}': goto vv26; case '~': goto vv39; default: goto vv73; } vv2: vvaccept = 0; vvch = *(VVMARKER = ++VVCURSOR); goto vv348; vv3: // 182 "scanner.re" { token->opcode = PHVOLT_T_INTEGER; token->value = estrndup(start, VVCURSOR - start); token->len = VVCURSOR - start; q = VVCURSOR; return 0; } // 295 "scanner.c" vv4: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case 'F': case 'f': goto vv310; case 'N': case 'n': goto vv312; case 'S': case 's': goto vv314; case 'T': case 't': goto vv316; default: goto vv101; } vv5: // 507 "scanner.re" { token->opcode = PHVOLT_T_IDENTIFIER; token->value = estrndup(start, VVCURSOR - start); token->len = VVCURSOR - start; q = VVCURSOR; return 0; } // 318 "scanner.c" vv6: vvch = *++VVCURSOR; switch (vvch) { case 'F': case 'f': goto vv310; case 'N': case 'n': goto vv312; case 'S': goto vv314; case 'T': case 't': goto vv316; case 's': goto vv317; default: goto vv101; } vv7: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv238; case 'M': case 'm': goto vv239; case 'N': case 'n': goto vv240; case 'V': case 'v': goto vv241; case 'X': case 'x': goto vv242; default: goto vv101; } vv8: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv230; case 'O': case 'o': goto vv231; default: goto vv101; } vv9: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv221; case 'E': case 'e': goto vv222; default: goto vv101; } vv10: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv208; case 'U': case 'u': goto vv209; default: goto vv101; } vv11: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv204; default: goto vv101; } vv12: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv191; case 'U': case 'u': goto vv192; default: goto vv101; } vv13: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv186; case 'R': case 'r': goto vv187; default: goto vv101; } vv14: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv176; case 'R': case 'r': goto vv177; default: goto vv101; } vv15: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv171; default: goto vv101; } vv16: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv155; case 'O': case 'o': goto vv156; default: goto vv101; } vv17: vvch = *++VVCURSOR; switch (vvch) { case 'I': case 'i': goto vv151; default: goto vv101; } vv18: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv142; case 'E': case 'e': goto vv143; default: goto vv101; } vv19: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv133; case 'O': case 'o': goto vv134; default: goto vv101; } vv20: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '%': goto vv127; case '{': goto vv125; default: goto vv21; } vv21: // 590 "scanner.re" { token->opcode = PHVOLT_T_CBRACKET_OPEN; return 0; } // 462 "scanner.c" vv22: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '}': goto vv123; default: goto vv23; } vv23: // 535 "scanner.re" { token->opcode = PHVOLT_T_MOD; return 0; } // 475 "scanner.c" vv24: vvaccept = 1; vvch = *(VVMARKER = ++VVCURSOR); switch (vvch) { case '%': goto vv118; case '-': goto vv115; case '=': goto vv113; case '}': goto vv117; default: goto vv25; } vv25: // 520 "scanner.re" { token->opcode = PHVOLT_T_SUB; return 0; } // 492 "scanner.c" vv26: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '}': goto vv111; default: goto vv27; } vv27: // 595 "scanner.re" { token->opcode = PHVOLT_T_CBRACKET_CLOSE; return 0; } // 505 "scanner.c" vv28: vvaccept = 2; vvch = *(VVMARKER = ++VVCURSOR); if (vvch >= 0x01) goto vv109; vv29: // 706 "scanner.re" { status = PHVOLT_SCANNER_RETCODE_ERR; break; } // 516 "scanner.c" vv30: vvaccept = 2; vvch = *(VVMARKER = ++VVCURSOR); if (vvch <= 0x00) goto vv29; goto vv103; vv31: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv29; } vv32: vvch = *++VVCURSOR; goto vv101; vv33: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '+': goto vv98; case '=': goto vv96; default: goto vv34; } vv34: // 515 "scanner.re" { token->opcode = PHVOLT_T_ADD; return 0; } // 596 "scanner.c" vv35: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv94; default: goto vv36; } vv36: // 525 "scanner.re" { token->opcode = PHVOLT_T_MUL; return 0; } // 609 "scanner.c" vv37: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv92; default: goto vv38; } vv38: // 530 "scanner.re" { token->opcode = PHVOLT_T_DIV; return 0; } // 622 "scanner.c" vv39: ++VVCURSOR; // 550 "scanner.re" { token->opcode = PHVOLT_T_CONCAT; return 0; } // 630 "scanner.c" vv41: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '.': goto vv90; default: goto vv42; } vv42: // 560 "scanner.re" { token->opcode = PHVOLT_T_DOT; return 0; } // 643 "scanner.c" vv43: ++VVCURSOR; // 565 "scanner.re" { token->opcode = PHVOLT_T_COMMA; return 0; } // 651 "scanner.c" vv45: ++VVCURSOR; // 570 "scanner.re" { token->opcode = PHVOLT_T_PARENTHESES_OPEN; return 0; } // 659 "scanner.c" vv47: ++VVCURSOR; // 575 "scanner.re" { token->opcode = PHVOLT_T_PARENTHESES_CLOSE; return 0; } // 667 "scanner.c" vv49: ++VVCURSOR; // 580 "scanner.re" { token->opcode = PHVOLT_T_SBRACKET_OPEN; return 0; } // 675 "scanner.c" vv51: ++VVCURSOR; // 585 "scanner.re" { token->opcode = PHVOLT_T_SBRACKET_CLOSE; return 0; } // 683 "scanner.c" vv53: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv88; case '>': goto vv86; default: goto vv54; } vv54: // 665 "scanner.re" { token->opcode = PHVOLT_T_LESS; return 0; } // 697 "scanner.c" vv55: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv82; default: goto vv56; } vv56: // 605 "scanner.re" { token->opcode = PHVOLT_T_ASSIGN; return 0; } // 710 "scanner.c" vv57: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv80; default: goto vv58; } vv58: // 670 "scanner.re" { token->opcode = PHVOLT_T_GREATER; return 0; } // 723 "scanner.c" vv59: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv76; default: goto vv60; } vv60: // 660 "scanner.re" { token->opcode = PHVOLT_T_NOT; return 0; } // 736 "scanner.c" vv61: ++VVCURSOR; // 675 "scanner.re" { token->opcode = PHVOLT_T_PIPE; return 0; } // 744 "scanner.c" vv63: ++VVCURSOR; // 680 "scanner.re" { token->opcode = PHVOLT_T_COLON; return 0; } // 752 "scanner.c" vv65: ++VVCURSOR; // 685 "scanner.re" { token->opcode = PHVOLT_T_QUESTION; return 0; } // 760 "scanner.c" vv67: ++VVCURSOR; vvch = *VVCURSOR; goto vv75; vv68: // 690 "scanner.re" { token->opcode = PHVOLT_T_IGNORE; return 0; } // 771 "scanner.c" vv69: ++VVCURSOR; // 695 "scanner.re" { s->active_line++; token->opcode = PHVOLT_T_IGNORE; return 0; } // 780 "scanner.c" vv71: ++VVCURSOR; // 701 "scanner.re" { status = PHVOLT_SCANNER_RETCODE_EOF; break; } // 788 "scanner.c" vv73: vvch = *++VVCURSOR; goto vv29; vv74: ++VVCURSOR; vvch = *VVCURSOR; vv75: switch (vvch) { case '\t': case '\r': case ' ': goto vv74; default: goto vv68; } vv76: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv78; default: goto vv77; } vv77: // 640 "scanner.re" { token->opcode = PHVOLT_T_NOTEQUALS; return 0; } // 814 "scanner.c" vv78: ++VVCURSOR; // 655 "scanner.re" { token->opcode = PHVOLT_T_NOTIDENTICAL; return 0; } // 822 "scanner.c" vv80: ++VVCURSOR; // 630 "scanner.re" { token->opcode = PHVOLT_T_GREATEREQUAL; return 0; } // 830 "scanner.c" vv82: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '=': goto vv84; default: goto vv83; } vv83: // 635 "scanner.re" { token->opcode = PHVOLT_T_EQUALS; return 0; } // 843 "scanner.c" vv84: ++VVCURSOR; // 650 "scanner.re" { token->opcode = PHVOLT_T_IDENTICAL; return 0; } // 851 "scanner.c" vv86: ++VVCURSOR; // 645 "scanner.re" { token->opcode = PHVOLT_T_NOTEQUALS; return 0; } // 859 "scanner.c" vv88: ++VVCURSOR; // 600 "scanner.re" { token->opcode = PHVOLT_T_LESSEQUAL; return 0; } // 867 "scanner.c" vv90: ++VVCURSOR; // 555 "scanner.re" { token->opcode = PHVOLT_T_RANGE; return 0; } // 875 "scanner.c" vv92: ++VVCURSOR; // 625 "scanner.re" { token->opcode = PHVOLT_T_DIV_ASSIGN; return 0; } // 883 "scanner.c" vv94: ++VVCURSOR; // 620 "scanner.re" { token->opcode = PHVOLT_T_MUL_ASSIGN; return 0; } // 891 "scanner.c" vv96: ++VVCURSOR; // 610 "scanner.re" { token->opcode = PHVOLT_T_ADD_ASSIGN; return 0; } // 899 "scanner.c" vv98: ++VVCURSOR; // 540 "scanner.re" { token->opcode = PHVOLT_T_INCR; return 0; } // 907 "scanner.c" vv100: ++VVCURSOR; vvch = *VVCURSOR; vv101: switch (vvch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv5; } vv102: ++VVCURSOR; vvch = *VVCURSOR; vv103: switch (vvch) { case 0x00: goto vv104; case '\'': goto vv106; case '\\': goto vv105; default: goto vv102; } vv104: VVCURSOR = VVMARKER; switch (vvaccept) { case 0: goto vv3; case 1: goto vv25; case 2: goto vv29; default: goto vv315; } vv105: ++VVCURSOR; vvch = *VVCURSOR; switch (vvch) { case '\n': goto vv104; default: goto vv102; } vv106: ++VVCURSOR; // 498 "scanner.re" { token->opcode = PHVOLT_T_STRING; token->value = estrndup(q, VVCURSOR - q - 1); token->len = VVCURSOR - q - 1; q = VVCURSOR; return 0; } // 1014 "scanner.c" vv108: ++VVCURSOR; vvch = *VVCURSOR; vv109: switch (vvch) { case 0x00: goto vv104; case '"': goto vv106; case '\\': goto vv110; default: goto vv108; } vv110: ++VVCURSOR; vvch = *VVCURSOR; switch (vvch) { case '\n': goto vv104; default: goto vv108; } vv111: ++VVCURSOR; // 477 "scanner.re" { s->mode = PHVOLT_MODE_RAW; token->opcode = PHVOLT_T_CLOSE_EDELIMITER; return 0; } // 1040 "scanner.c" vv113: ++VVCURSOR; // 615 "scanner.re" { token->opcode = PHVOLT_T_SUB_ASSIGN; return 0; } // 1048 "scanner.c" vv115: ++VVCURSOR; // 545 "scanner.re" { token->opcode = PHVOLT_T_DECR; return 0; } // 1056 "scanner.c" vv117: vvch = *++VVCURSOR; switch (vvch) { case '}': goto vv121; default: goto vv104; } vv118: vvch = *++VVCURSOR; switch (vvch) { case '}': goto vv119; default: goto vv104; } vv119: ++VVCURSOR; // 463 "scanner.re" { s->mode = PHVOLT_MODE_RAW; s->whitespace_control = 1; token->opcode = PHVOLT_T_CLOSE_DELIMITER; return 0; } // 1078 "scanner.c" vv121: ++VVCURSOR; // 490 "scanner.re" { s->mode = PHVOLT_MODE_RAW; s->whitespace_control = 1; token->opcode = PHVOLT_T_CLOSE_EDELIMITER; return 0; } // 1088 "scanner.c" vv123: ++VVCURSOR; // 451 "scanner.re" { s->mode = PHVOLT_MODE_RAW; token->opcode = PHVOLT_T_CLOSE_DELIMITER; return 0; } // 1097 "scanner.c" vv125: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '-': goto vv131; default: goto vv126; } vv126: // 470 "scanner.re" { s->whitespace_control = 0; s->statement_position++; token->opcode = PHVOLT_T_OPEN_EDELIMITER; return 0; } // 1112 "scanner.c" vv127: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '-': goto vv129; default: goto vv128; } vv128: // 445 "scanner.re" { s->whitespace_control = 0; token->opcode = PHVOLT_T_OPEN_DELIMITER; return 0; } // 1126 "scanner.c" vv129: ++VVCURSOR; // 457 "scanner.re" { s->whitespace_control = 0; token->opcode = PHVOLT_T_OPEN_DELIMITER; return 0; } // 1135 "scanner.c" vv131: ++VVCURSOR; // 483 "scanner.re" { s->whitespace_control = 0; s->statement_position++; token->opcode = PHVOLT_T_OPEN_EDELIMITER; return 0; } // 1145 "scanner.c" vv133: vvch = *++VVCURSOR; switch (vvch) { case 'F': case 'f': goto vv136; default: goto vv101; } vv134: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv135; } vv135: // 403 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_DO; return 0; } // 1229 "scanner.c" vv136: vvch = *++VVCURSOR; switch (vvch) { case 'I': case 'i': goto vv137; default: goto vv101; } vv137: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv138; default: goto vv101; } vv138: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv139; default: goto vv101; } vv139: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv140; default: goto vv101; } vv140: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv141; } vv141: // 344 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_DEFINED; return 0; } // 1334 "scanner.c" vv142: vvch = *++VVCURSOR; switch (vvch) { case 'W': case 'w': goto vv149; default: goto vv101; } vv143: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv144; default: goto vv101; } vv144: vvch = *++VVCURSOR; switch (vvch) { case 'U': case 'u': goto vv145; default: goto vv101; } vv145: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv146; default: goto vv101; } vv146: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv147; default: goto vv101; } vv147: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv148; } vv148: // 309 "scanner.re" { token->opcode = PHVOLT_T_RETURN; return 0; } // 1445 "scanner.c" vv149: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv150; } vv150: // 433 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_RAW; return 0; } // 1522 "scanner.c" vv151: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv152; default: goto vv101; } vv152: vvch = *++VVCURSOR; switch (vvch) { case 'H': case 'h': goto vv153; default: goto vv101; } vv153: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv154; } vv154: // 304 "scanner.re" { token->opcode = PHVOLT_T_WITH; return 0; } // 1612 "scanner.c" vv155: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv165; case 'L': case 'l': goto vv164; default: goto vv101; } vv156: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv157; default: goto vv101; } vv157: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv158; default: goto vv101; } vv158: vvch = *++VVCURSOR; switch (vvch) { case 'I': case 'i': goto vv159; default: goto vv101; } vv159: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv160; default: goto vv101; } vv160: vvch = *++VVCURSOR; switch (vvch) { case 'U': case 'u': goto vv161; default: goto vv101; } vv161: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv162; default: goto vv101; } vv162: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv163; } vv163: // 421 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_CONTINUE; return 0; } // 1740 "scanner.c" vv164: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv169; default: goto vv101; } vv165: vvch = *++VVCURSOR; switch (vvch) { case 'H': case 'h': goto vv166; default: goto vv101; } vv166: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv167; default: goto vv101; } vv167: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv168; } vv168: // 392 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_CACHE; return 0; } // 1838 "scanner.c" vv169: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv170; } vv170: // 293 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_CALL; return 0; } // 1915 "scanner.c" vv171: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv172; default: goto vv101; } vv172: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv173; default: goto vv101; } vv173: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv174; default: goto vv101; } vv174: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv175; } vv175: // 282 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_MACRO; return 0; } // 2013 "scanner.c" vv176: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv182; default: goto vv101; } vv177: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv178; default: goto vv101; } vv178: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv179; default: goto vv101; } vv179: vvch = *++VVCURSOR; switch (vvch) { case 'K': case 'k': goto vv180; default: goto vv101; } vv180: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv181; } vv181: // 427 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_BREAK; return 0; } // 2118 "scanner.c" vv182: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv183; default: goto vv101; } vv183: vvch = *++VVCURSOR; switch (vvch) { case 'K': case 'k': goto vv184; default: goto vv101; } vv184: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv185; } vv185: // 271 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_BLOCK; return 0; } // 2209 "scanner.c" vv186: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv189; default: goto vv101; } vv187: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv188; } vv188: // 266 "scanner.re" { token->opcode = PHVOLT_T_OR; return 0; } // 2292 "scanner.c" vv189: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv190; } vv190: // 368 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_ODD; return 0; } // 2369 "scanner.c" vv191: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv202; default: goto vv101; } vv192: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv193; default: goto vv101; } vv193: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv194; default: goto vv101; } vv194: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv195; default: goto vv101; } vv195: vvch = *++VVCURSOR; switch (vvch) { case 'S': case 's': goto vv196; default: goto vv101; } vv196: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv197; default: goto vv101; } vv197: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv198; default: goto vv101; } vv198: vvch = *++VVCURSOR; switch (vvch) { case 'P': case 'p': goto vv199; default: goto vv101; } vv199: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv200; default: goto vv101; } vv200: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv201; } vv201: // 409 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_AUTOESCAPE; return 0; } // 2509 "scanner.c" vv202: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv203; } vv203: // 261 "scanner.re" { token->opcode = PHVOLT_T_AND; return 0; } // 2585 "scanner.c" vv204: vvch = *++VVCURSOR; switch (vvch) { case 'U': case 'u': goto vv205; default: goto vv101; } vv205: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv206; default: goto vv101; } vv206: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv207; } vv207: // 256 "scanner.re" { token->opcode = PHVOLT_T_TRUE; return 0; } // 2675 "scanner.c" vv208: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv219; default: goto vv101; } vv209: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv210; case 'M': case 'm': goto vv211; default: goto vv101; } vv210: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv217; default: goto vv101; } vv211: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv212; default: goto vv101; } vv212: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv213; default: goto vv101; } vv213: vvch = *++VVCURSOR; switch (vvch) { case 'I': case 'i': goto vv214; default: goto vv101; } vv214: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv215; default: goto vv101; } vv215: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv216; } vv216: // 374 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_NUMERIC; return 0; } // 2803 "scanner.c" vv217: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv218; } vv218: // 246 "scanner.re" { token->opcode = PHVOLT_T_NULL; return 0; } // 2879 "scanner.c" vv219: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv220; } vv220: // 338 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_NOT; return 0; } // 2956 "scanner.c" vv221: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv225; default: goto vv101; } vv222: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv223; default: goto vv101; } vv223: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv224; } vv224: // 241 "scanner.re" { token->opcode = PHVOLT_T_SET; return 0; } // 3046 "scanner.c" vv225: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv226; default: goto vv101; } vv226: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv227; default: goto vv101; } vv227: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv228; default: goto vv101; } vv228: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv229; } vv229: // 380 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_SCALAR; return 0; } // 3144 "scanner.c" vv230: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv234; default: goto vv101; } vv231: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv232; default: goto vv101; } vv232: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv233; } vv233: // 225 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_FOR; return 0; } // 3235 "scanner.c" vv234: vvch = *++VVCURSOR; switch (vvch) { case 'S': case 's': goto vv235; default: goto vv101; } vv235: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv236; default: goto vv101; } vv236: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv237; } vv237: // 251 "scanner.re" { token->opcode = PHVOLT_T_FALSE; return 0; } // 3325 "scanner.c" vv238: vvch = *++VVCURSOR; switch (vvch) { case 'S': case 's': goto vv300; default: goto vv101; } vv239: vvch = *++VVCURSOR; switch (vvch) { case 'P': case 'p': goto vv296; default: goto vv101; } vv240: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv252; default: goto vv101; } vv241: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv249; default: goto vv101; } vv242: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv243; default: goto vv101; } vv243: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv244; default: goto vv101; } vv244: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv245; default: goto vv101; } vv245: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv246; default: goto vv101; } vv246: vvch = *++VVCURSOR; switch (vvch) { case 'S': case 's': goto vv247; default: goto vv101; } vv247: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv248; } vv248: // 314 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_EXTENDS; return 0; } // 3465 "scanner.c" vv249: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv250; default: goto vv101; } vv250: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv251; } vv251: // 362 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_EVEN; return 0; } // 3549 "scanner.c" vv252: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv253; case 'B': case 'b': goto vv254; case 'C': case 'c': goto vv255; case 'F': case 'f': goto vv256; case 'I': case 'i': goto vv257; case 'M': case 'm': goto vv258; case 'R': case 'r': goto vv259; default: goto vv101; } vv253: vvch = *++VVCURSOR; switch (vvch) { case 'U': case 'u': goto vv286; default: goto vv101; } vv254: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv281; default: goto vv101; } vv255: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv273; default: goto vv101; } vv256: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv270; default: goto vv101; } vv257: vvch = *++VVCURSOR; switch (vvch) { case 'F': case 'f': goto vv268; default: goto vv101; } vv258: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv263; default: goto vv101; } vv259: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv260; default: goto vv101; } vv260: vvch = *++VVCURSOR; switch (vvch) { case 'W': case 'w': goto vv261; default: goto vv101; } vv261: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv262; } vv262: // 439 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_ENDRAW; return 0; } // 3701 "scanner.c" vv263: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv264; default: goto vv101; } vv264: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv265; default: goto vv101; } vv265: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv266; default: goto vv101; } vv266: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv267; } vv267: // 288 "scanner.re" { token->opcode = PHVOLT_T_ENDMACRO; return 0; } // 3798 "scanner.c" vv268: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv269; } vv269: // 220 "scanner.re" { token->opcode = PHVOLT_T_ENDIF; return 0; } // 3874 "scanner.c" vv270: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv271; default: goto vv101; } vv271: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv272; } vv272: // 231 "scanner.re" { token->opcode = PHVOLT_T_ENDFOR; return 0; } // 3957 "scanner.c" vv273: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv274; case 'L': case 'l': goto vv275; default: goto vv101; } vv274: vvch = *++VVCURSOR; switch (vvch) { case 'H': case 'h': goto vv278; default: goto vv101; } vv275: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv276; default: goto vv101; } vv276: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv277; } vv277: // 299 "scanner.re" { token->opcode = PHVOLT_T_ENDCALL; return 0; } // 4056 "scanner.c" vv278: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv279; default: goto vv101; } vv279: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv280; } vv280: // 398 "scanner.re" { token->opcode = PHVOLT_T_ENDCACHE; return 0; } // 4139 "scanner.c" vv281: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv282; default: goto vv101; } vv282: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv283; default: goto vv101; } vv283: vvch = *++VVCURSOR; switch (vvch) { case 'K': case 'k': goto vv284; default: goto vv101; } vv284: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv285; } vv285: // 277 "scanner.re" { token->opcode = PHVOLT_T_ENDBLOCK; return 0; } // 4236 "scanner.c" vv286: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv287; default: goto vv101; } vv287: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv288; default: goto vv101; } vv288: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv289; default: goto vv101; } vv289: vvch = *++VVCURSOR; switch (vvch) { case 'S': case 's': goto vv290; default: goto vv101; } vv290: vvch = *++VVCURSOR; switch (vvch) { case 'C': case 'c': goto vv291; default: goto vv101; } vv291: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv292; default: goto vv101; } vv292: vvch = *++VVCURSOR; switch (vvch) { case 'P': case 'p': goto vv293; default: goto vv101; } vv293: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv294; default: goto vv101; } vv294: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv295; } vv295: // 415 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_ENDAUTOESCAPE; return 0; } // 4369 "scanner.c" vv296: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv297; default: goto vv101; } vv297: vvch = *++VVCURSOR; switch (vvch) { case 'Y': case 'y': goto vv298; default: goto vv101; } vv298: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv299; } vv299: // 356 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_EMPTY; return 0; } // 4460 "scanner.c" vv300: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv301; default: goto vv101; } vv301: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'G': case 'H': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'g': case 'h': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; case 'F': case 'f': goto vv303; case 'I': case 'i': goto vv304; default: goto vv302; } vv302: // 205 "scanner.re" { token->opcode = PHVOLT_T_ELSE; return 0; } // 4543 "scanner.c" vv303: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv307; default: goto vv101; } vv304: vvch = *++VVCURSOR; switch (vvch) { case 'F': case 'f': goto vv305; default: goto vv101; } vv305: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv306; } vv306: // 215 "scanner.re" { token->opcode = PHVOLT_T_ELSEIF; return 0; } // 4633 "scanner.c" vv307: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv308; default: goto vv101; } vv308: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv309; } vv309: // 210 "scanner.re" { token->opcode = PHVOLT_T_ELSEFOR; return 0; } // 4716 "scanner.c" vv310: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv311; } vv311: // 199 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_IF; return 0; } // 4793 "scanner.c" vv312: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; case 'C': case 'c': goto vv340; default: goto vv313; } vv313: // 236 "scanner.re" { token->opcode = PHVOLT_T_IN; return 0; } // 4869 "scanner.c" vv314: vvaccept = 3; vvch = *(VVMARKER = ++VVCURSOR); switch (vvch) { case ' ': goto vv339; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv315; } vv315: // 332 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_IS; return 0; } // 4948 "scanner.c" vv316: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv332; default: goto vv101; } vv317: vvaccept = 3; vvch = *(VVMARKER = ++VVCURSOR); switch (vvch) { case ' ': goto vv318; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv315; } vv318: vvch = *++VVCURSOR; switch (vvch) { case 'N': goto vv322; case 'n': goto vv319; default: goto vv321; } vv319: vvch = *++VVCURSOR; switch (vvch) { case 'O': goto vv323; case 'o': goto vv330; default: goto vv104; } vv320: ++VVCURSOR; vvch = *VVCURSOR; vv321: switch (vvch) { case ' ': goto vv320; case 'n': goto vv326; default: goto vv104; } vv322: vvch = *++VVCURSOR; switch (vvch) { case 'O': case 'o': goto vv323; default: goto vv104; } vv323: vvch = *++VVCURSOR; switch (vvch) { case 'T': case 't': goto vv324; default: goto vv104; } vv324: ++VVCURSOR; vv325: // 320 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_NOTEQUALS; return 0; } // 5073 "scanner.c" vv326: vvch = *++VVCURSOR; switch (vvch) { case 'o': goto vv327; default: goto vv104; } vv327: vvch = *++VVCURSOR; switch (vvch) { case 't': goto vv328; default: goto vv104; } vv328: ++VVCURSOR; // 326 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_NOTEQUALS; return 0; } // 5094 "scanner.c" vv330: vvch = *++VVCURSOR; switch (vvch) { case 'T': goto vv324; case 't': goto vv331; default: goto vv104; } vv331: vvch = *++VVCURSOR; goto vv325; vv332: vvch = *++VVCURSOR; switch (vvch) { case 'R': case 'r': goto vv333; default: goto vv101; } vv333: vvch = *++VVCURSOR; switch (vvch) { case 'A': case 'a': goto vv334; default: goto vv101; } vv334: vvch = *++VVCURSOR; switch (vvch) { case 'B': case 'b': goto vv335; default: goto vv101; } vv335: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv336; default: goto vv101; } vv336: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv337; default: goto vv101; } vv337: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv338; } vv338: // 386 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_ITERABLE; return 0; } // 5216 "scanner.c" vv339: vvch = *++VVCURSOR; switch (vvch) { case 'N': case 'n': goto vv322; default: goto vv104; } vv340: vvch = *++VVCURSOR; switch (vvch) { case 'L': case 'l': goto vv341; default: goto vv101; } vv341: vvch = *++VVCURSOR; switch (vvch) { case 'U': case 'u': goto vv342; default: goto vv101; } vv342: vvch = *++VVCURSOR; switch (vvch) { case 'D': case 'd': goto vv343; default: goto vv101; } vv343: vvch = *++VVCURSOR; switch (vvch) { case 'E': case 'e': goto vv344; default: goto vv101; } vv344: ++VVCURSOR; switch ((vvch = *VVCURSOR)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '\\': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': goto vv100; default: goto vv345; } vv345: // 350 "scanner.re" { s->statement_position++; token->opcode = PHVOLT_T_INCLUDE; return 0; } // 5328 "scanner.c" vv346: vvch = *++VVCURSOR; switch (vvch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto vv349; default: goto vv104; } vv347: vvaccept = 0; VVMARKER = ++VVCURSOR; vvch = *VVCURSOR; vv348: switch (vvch) { case '.': goto vv346; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto vv347; default: goto vv3; } vv349: ++VVCURSOR; vvch = *VVCURSOR; switch (vvch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto vv349; default: goto vv351; } vv351: // 191 "scanner.re" { token->opcode = PHVOLT_T_DOUBLE; token->value = estrndup(start, VVCURSOR - start); token->len = VVCURSOR - start; q = VVCURSOR; return 0; } // 5388 "scanner.c" } // 711 "scanner.re" } } return status; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Paginator, Adapter, phalcon, paginator_adapter, phalcon_paginator_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_paginator_adapter_ce, SL("_limitRows"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_paginator_adapter_ce, SL("_page"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Paginator_Adapter, setCurrentPage) { zval *page_param = NULL, *_0; int page; zephir_fetch_params(0, 1, 0, &page_param); page = zephir_get_intval(page_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, page); zephir_update_property_this(this_ptr, SL("_page"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Paginator_Adapter, setLimit) { zval *limitRows_param = NULL, *_0; int limitRows; zephir_fetch_params(0, 1, 0, &limitRows_param); limitRows = zephir_get_intval(limitRows_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, limitRows); zephir_update_property_this(this_ptr, SL("_limitRows"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Paginator_Adapter, getLimit) { RETURN_MEMBER(this_ptr, "_limitRows"); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Paginator, AdapterInterface, phalcon, paginator_adapterinterface, phalcon_paginator_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Paginator_AdapterInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Paginator_AdapterInterface, setCurrentPage); ZEPHIR_DOC_METHOD(Phalcon_Paginator_AdapterInterface, getPaginate); ZEPHIR_DOC_METHOD(Phalcon_Paginator_AdapterInterface, setLimit); ZEPHIR_DOC_METHOD(Phalcon_Paginator_AdapterInterface, getLimit); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator, Exception, phalcon, paginator_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_Model) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, Model, phalcon, paginator_adapter_model, phalcon_paginator_adapter_ce, phalcon_paginator_adapter_model_method_entry, 0); zend_declare_property_null(phalcon_paginator_adapter_model_ce, SL("_config"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_paginator_adapter_model_ce TSRMLS_CC, 1, phalcon_paginator_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Paginator_Adapter_Model, __construct) { zval *config_param = NULL, *page, *limit; zval *config = NULL; zephir_fetch_params(0, 1, 0, &config_param); config = config_param; zephir_update_property_this(this_ptr, SL("_config"), config TSRMLS_CC); if (zephir_array_isset_string_fetch(&limit, config, SS("limit"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_limitRows"), limit TSRMLS_CC); } if (zephir_array_isset_string_fetch(&page, config, SS("page"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_page"), page TSRMLS_CC); } } static PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate) { zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; int pageNumber, show, n, start, lastShowPage, i, next, totalPages, before, ZEPHIR_LAST_CALL_STATUS; zval *config, *items, *pageItems, *page, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_7; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_limitRows"), PH_NOISY_CC); show = zephir_get_intval(_0); ZEPHIR_OBS_VAR(config); zephir_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC); ZEPHIR_OBS_VAR(items); zephir_array_fetch_string(&items, config, SL("data"), PH_NOISY, "phalcon/paginator/adapter/model.zep", 80 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_page"), PH_NOISY_CC); pageNumber = zephir_get_intval(_1); if (Z_TYPE_P(items) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Invalid data for paginator", "phalcon/paginator/adapter/model.zep", 84); return; } if (pageNumber <= 0) { pageNumber = 1; } if (show <= 0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "The start page number is zero or less", "phalcon/paginator/adapter/model.zep", 94); return; } n = zephir_fast_count_int(items TSRMLS_CC); lastShowPage = (pageNumber - 1); start = (show * lastShowPage); ZEPHIR_INIT_VAR(pageItems); array_init(pageItems); if (zephir_safe_mod_long_long(n, show TSRMLS_CC) != 0) { totalPages = (int) ((zephir_safe_div_long_long(n, show TSRMLS_CC) + (double) (1))); } else { totalPages = (int) (zephir_safe_div_long_long(n, show TSRMLS_CC)); } if (n > 0) { if (start <= n) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, start); ZEPHIR_CALL_METHOD(NULL, items, "seek", NULL, 0, _2); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_CALL_METHOD(NULL, items, "seek", NULL, 0, _2); zephir_check_call_status(); pageNumber = 1; } i = 1; while (1) { ZEPHIR_CALL_METHOD(&_3, items, "valid", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_3))) { break; } ZEPHIR_CALL_METHOD(&_4, items, "current", &_5, 0); zephir_check_call_status(); zephir_array_append(&pageItems, _4, PH_SEPARATE, "phalcon/paginator/adapter/model.zep", 121); if (i >= show) { break; } i++; ZEPHIR_CALL_METHOD(NULL, items, "next", &_6, 0); zephir_check_call_status(); } } next = (pageNumber + 1); if (next > totalPages) { next = totalPages; } if (pageNumber > 1) { before = (pageNumber - 1); } else { before = 1; } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), pageItems TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, 1); zephir_update_property_zval(page, SL("first"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, before); zephir_update_property_zval(page, SL("before"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, pageNumber); zephir_update_property_zval(page, SL("current"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, totalPages); zephir_update_property_zval(page, SL("last"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, next); zephir_update_property_zval(page, SL("next"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, totalPages); zephir_update_property_zval(page, SL("total_pages"), _7 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_7); ZVAL_LONG(_7, n); zephir_update_property_zval(page, SL("total_items"), _7 TSRMLS_CC); _7 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _7 TSRMLS_CC); RETURN_CCTOR(page); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_NativeArray) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, NativeArray, phalcon, paginator_adapter_nativearray, phalcon_paginator_adapter_ce, phalcon_paginator_adapter_nativearray_method_entry, 0); zend_declare_property_null(phalcon_paginator_adapter_nativearray_ce, SL("_config"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_paginator_adapter_nativearray_ce TSRMLS_CC, 1, phalcon_paginator_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, __construct) { zval *config_param = NULL, *page, *limit; zval *config = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &config_param); zephir_get_arrval(config, config_param); zephir_update_property_this(this_ptr, SL("_config"), config TSRMLS_CC); if (zephir_array_isset_string_fetch(&limit, config, SS("limit"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_limitRows"), limit TSRMLS_CC); } if (zephir_array_isset_string_fetch(&page, config, SS("page"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_page"), page TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, getPaginate) { double roundedTotal; int show, pageNumber, totalPages, number, before, next, ZEPHIR_LAST_CALL_STATUS; zval *config, *items = NULL, *page, *_0, *_1, _2 = zval_used_for_init, *_3 = NULL, _4, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(config); zephir_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC); ZEPHIR_OBS_VAR(items); zephir_array_fetch_string(&items, config, SL("data"), PH_NOISY, "phalcon/paginator/adapter/nativearray.zep", 87 TSRMLS_CC); if (Z_TYPE_P(items) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Invalid data for paginator", "phalcon/paginator/adapter/nativearray.zep", 90); return; } ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_limitRows"), PH_NOISY_CC); show = zephir_get_intval(_0); ZEPHIR_OBS_VAR(_1); zephir_read_property_this(&_1, this_ptr, SL("_page"), PH_NOISY_CC); pageNumber = zephir_get_intval(_1); if (pageNumber <= 0) { pageNumber = 1; } number = zephir_fast_count_int(items TSRMLS_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, show); ZEPHIR_CALL_FUNCTION(&_3, "floatval", NULL, 304, &_2); zephir_check_call_status(); roundedTotal = zephir_safe_div_long_zval(number, _3 TSRMLS_CC); totalPages = (int) (roundedTotal); if (totalPages != roundedTotal) { totalPages++; } ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (show * ((pageNumber - 1)))); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, show); ZEPHIR_CALL_FUNCTION(&_5, "array_slice", NULL, 373, items, &_2, &_4); zephir_check_call_status(); ZEPHIR_CPY_WRT(items, _5); if (pageNumber < totalPages) { next = (pageNumber + 1); } else { next = totalPages; } if (pageNumber > 1) { before = (pageNumber - 1); } else { before = 1; } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), items TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, 1); zephir_update_property_zval(page, SL("first"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, before); zephir_update_property_zval(page, SL("before"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, pageNumber); zephir_update_property_zval(page, SL("current"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, totalPages); zephir_update_property_zval(page, SL("last"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, next); zephir_update_property_zval(page, SL("next"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, totalPages); zephir_update_property_zval(page, SL("total_pages"), _6 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_6); ZVAL_LONG(_6, number); zephir_update_property_zval(page, SL("total_items"), _6 TSRMLS_CC); _6 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _6 TSRMLS_CC); RETURN_CCTOR(page); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_QueryBuilder) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, QueryBuilder, phalcon, paginator_adapter_querybuilder, phalcon_paginator_adapter_ce, phalcon_paginator_adapter_querybuilder_method_entry, 0); zend_declare_property_null(phalcon_paginator_adapter_querybuilder_ce, SL("_config"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_paginator_adapter_querybuilder_ce, SL("_builder"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_paginator_adapter_querybuilder_ce TSRMLS_CC, 1, phalcon_paginator_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *config_param = NULL, *builder, *limit, *page; zval *config = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &config_param); zephir_get_arrval(config, config_param); zephir_update_property_this(this_ptr, SL("_config"), config TSRMLS_CC); ZEPHIR_OBS_VAR(builder); if (!(zephir_array_isset_string_fetch(&builder, config, SS("builder"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Parameter 'builder' is required", "phalcon/paginator/adapter/querybuilder.zep", 67); return; } ZEPHIR_OBS_VAR(limit); if (!(zephir_array_isset_string_fetch(&limit, config, SS("limit"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Parameter 'limit' is required", "phalcon/paginator/adapter/querybuilder.zep", 71); return; } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setquerybuilder", NULL, 0, builder); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setlimit", NULL, 0, limit); zephir_check_call_status(); ZEPHIR_OBS_VAR(page); if (zephir_array_isset_string_fetch(&page, config, SS("page"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcurrentpage", NULL, 0, page); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getCurrentPage) { RETURN_MEMBER(this_ptr, "_page"); } static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, setQueryBuilder) { zval *builder; zephir_fetch_params(0, 1, 0, &builder); zephir_update_property_this(this_ptr, SL("_builder"), builder TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getQueryBuilder) { RETURN_MEMBER(this_ptr, "_builder"); } static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getPaginate) { int numberPage, before, ZEPHIR_LAST_CALL_STATUS; zval *originalBuilder, *builder, *totalBuilder, *totalPages, *limit, *number, *query = NULL, *page, *items = NULL, *totalQuery = NULL, *result = NULL, *row = NULL, *rowcount, *next = NULL, *_0, *_1 = NULL, *_2, _3, _4, *_5; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(originalBuilder); zephir_read_property_this(&originalBuilder, this_ptr, SL("_builder"), PH_NOISY_CC); ZEPHIR_INIT_VAR(builder); if (zephir_clone(builder, originalBuilder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_INIT_VAR(totalBuilder); if (zephir_clone(totalBuilder, builder TSRMLS_CC) == FAILURE) { RETURN_MM(); } ZEPHIR_OBS_VAR(limit); zephir_read_property_this(&limit, this_ptr, SL("_limitRows"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_page"), PH_NOISY_CC); numberPage = zephir_get_intval(_0); if (!(numberPage)) { numberPage = 1; } ZEPHIR_INIT_VAR(number); ZVAL_LONG(number, (zephir_get_numberval(limit) * ((numberPage - 1)))); if (ZEPHIR_LT(number, limit)) { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit); zephir_check_call_status(); } else { ZEPHIR_CALL_METHOD(NULL, builder, "limit", NULL, 0, limit, number); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&query, builder, "getquery", NULL, 0); zephir_check_call_status(); if (numberPage == 1) { before = 1; } else { before = (numberPage - 1); } ZEPHIR_CALL_METHOD(&items, query, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "COUNT(*) [rowcount]", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "columns", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_NULL(_1); ZEPHIR_CALL_METHOD(NULL, totalBuilder, "orderby", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&totalQuery, totalBuilder, "getquery", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&result, totalQuery, "execute", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&row, result, "getfirst", NULL, 0); zephir_check_call_status(); ZEPHIR_OBS_VAR(_2); zephir_read_property(&_2, row, SL("rowcount"), PH_NOISY_CC); ZEPHIR_INIT_VAR(rowcount); ZVAL_LONG(rowcount, zephir_get_intval(_2)); ZEPHIR_SINIT_VAR(_3); div_function(&_3, rowcount, limit TSRMLS_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_DOUBLE(&_4, zephir_ceil(&_3 TSRMLS_CC)); ZEPHIR_INIT_VAR(totalPages); ZVAL_LONG(totalPages, zephir_get_intval(&_4)); if (ZEPHIR_GT_LONG(totalPages, numberPage)) { ZEPHIR_INIT_VAR(next); ZVAL_LONG(next, (numberPage + 1)); } else { ZEPHIR_CPY_WRT(next, totalPages); } ZEPHIR_INIT_VAR(page); object_init(page); zephir_update_property_zval(page, SL("items"), items TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, 1); zephir_update_property_zval(page, SL("first"), _5 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, before); zephir_update_property_zval(page, SL("before"), _5 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_5); ZVAL_LONG(_5, numberPage); zephir_update_property_zval(page, SL("current"), _5 TSRMLS_CC); zephir_update_property_zval(page, SL("last"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("next"), next TSRMLS_CC); zephir_update_property_zval(page, SL("total_pages"), totalPages TSRMLS_CC); zephir_update_property_zval(page, SL("total_items"), rowcount TSRMLS_CC); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC); zephir_update_property_zval(page, SL("limit"), _5 TSRMLS_CC); RETURN_CCTOR(page); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Queue_Beanstalk) { ZEPHIR_REGISTER_CLASS(Phalcon\\Queue, Beanstalk, phalcon, queue_beanstalk, phalcon_queue_beanstalk_method_entry, 0); zend_declare_property_null(phalcon_queue_beanstalk_ce, SL("_connection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_queue_beanstalk_ce, SL("_parameters"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Queue_Beanstalk, __construct) { zval *options = NULL, *parameters = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) != IS_ARRAY) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { ZEPHIR_CPY_WRT(parameters, options); } if (!(zephir_array_isset_string(parameters, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(¶meters, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(parameters, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 11300); zephir_array_update_string(¶meters, SL("port"), &_0, PH_COPY | PH_SEPARATE); } zephir_update_property_this(this_ptr, SL("_parameters"), parameters TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, connect) { int ZEPHIR_LAST_CALL_STATUS; zval *connection = NULL, *parameters, *_0, *_1, *_2, *_3, _4; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); if (Z_TYPE_P(connection) == IS_RESOURCE) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "disconnect", NULL, 0); zephir_check_call_status(); } ZEPHIR_OBS_VAR(parameters); zephir_read_property_this(¶meters, this_ptr, SL("_parameters"), PH_NOISY_CC); zephir_array_fetch_string(&_0, parameters, SL("host"), PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 78 TSRMLS_CC); zephir_array_fetch_string(&_1, parameters, SL("port"), PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 78 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); ZVAL_NULL(_3); ZEPHIR_MAKE_REF(_2); ZEPHIR_CALL_FUNCTION(&connection, "fsockopen", NULL, 384, _0, _1, _2, _3); ZEPHIR_UNREF(_2); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_RESOURCE) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_exception_ce, "Can't connect to Beanstalk server", "phalcon/queue/beanstalk.zep", 80); return; } ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, -1); ZEPHIR_CALL_FUNCTION(NULL, "stream_set_timeout", NULL, 385, connection, &_4, ZEPHIR_GLOBAL(global_null)); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_connection"), connection TSRMLS_CC); RETURN_CCTOR(connection); } static PHP_METHOD(Phalcon_Queue_Beanstalk, put) { zend_bool _2; zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *data, *options = NULL, *priority = NULL, *delay = NULL, *ttr = NULL, *serialized = NULL, *response = NULL, *status, *length, *_0, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &data, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(priority); if (!(zephir_array_isset_string_fetch(&priority, options, SS("priority"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(priority); ZVAL_LONG(priority, 100); } ZEPHIR_OBS_VAR(delay); if (!(zephir_array_isset_string_fetch(&delay, options, SS("delay"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(delay); ZVAL_LONG(delay, 0); } ZEPHIR_OBS_VAR(ttr); if (!(zephir_array_isset_string_fetch(&ttr, options, SS("ttr"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(ttr); ZVAL_LONG(ttr, 86400); } ZEPHIR_CALL_FUNCTION(&serialized, "serialize", NULL, 74, data); zephir_check_call_status(); ZEPHIR_INIT_VAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(serialized)); ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SVSVSVSV(_0, "put ", priority, " ", delay, " ", ttr, " ", length); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_1, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", &_1, 0, serialized); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&status, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 128 TSRMLS_CC); _2 = !ZEPHIR_IS_STRING(status, "INSERTED"); if (_2) { _2 = !ZEPHIR_IS_STRING(status, "BURIED"); } if (_2) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_3, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 134 TSRMLS_CC); RETURN_CTOR(_3); } static PHP_METHOD(Phalcon_Queue_Beanstalk, reserve) { int ZEPHIR_LAST_CALL_STATUS; zval *timeout = NULL, *command, *response = NULL, *_0, *_1, *_2 = NULL, *_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &timeout); if (!timeout) { timeout = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(command); if (Z_TYPE_P(timeout) != IS_NULL) { ZEPHIR_CONCAT_SV(command, "reserve-with-timeout ", timeout); } else { ZVAL_STRING(command, "reserve", 1); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, command); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&_0, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 153 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_0, "RESERVED")) { RETURN_MM_BOOL(0); } object_init_ex(return_value, phalcon_queue_beanstalk_job_ce); zephir_array_fetch_long(&_1, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 163 TSRMLS_CC); zephir_array_fetch_long(&_3, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 163 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_2, this_ptr, "read", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_4, "unserialize", NULL, 75, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 387, this_ptr, _1, _4); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, choose) { int ZEPHIR_LAST_CALL_STATUS; zval *tube_param = NULL, *response = NULL, *_1, *_2; zval *tube = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &tube_param); if (unlikely(Z_TYPE_P(tube_param) != IS_STRING && Z_TYPE_P(tube_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tube' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tube_param) == IS_STRING)) { zephir_get_strval(tube, tube_param); } else { ZEPHIR_INIT_VAR(tube); ZVAL_EMPTY_STRING(tube); } ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "use ", tube); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 176 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "USING")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_2, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 180 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Queue_Beanstalk, watch) { int ZEPHIR_LAST_CALL_STATUS; zval *tube_param = NULL, *response = NULL, *_1, *_2; zval *tube = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &tube_param); if (unlikely(Z_TYPE_P(tube_param) != IS_STRING && Z_TYPE_P(tube_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tube' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tube_param) == IS_STRING)) { zephir_get_strval(tube, tube_param); } else { ZEPHIR_INIT_VAR(tube); ZVAL_EMPTY_STRING(tube); } ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "watch ", tube); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 193 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "WATCHING")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_2, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 197 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Queue_Beanstalk, stats) { int ZEPHIR_LAST_CALL_STATUS; zval *response = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "stats", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readyaml", NULL, 388); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 210 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "OK")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_2, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 214 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Queue_Beanstalk, statsTube) { int ZEPHIR_LAST_CALL_STATUS; zval *tube_param = NULL, *response = NULL, *_1, *_2; zval *tube = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &tube_param); if (unlikely(Z_TYPE_P(tube_param) != IS_STRING && Z_TYPE_P(tube_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'tube' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(tube_param) == IS_STRING)) { zephir_get_strval(tube, tube_param); } else { ZEPHIR_INIT_VAR(tube); ZVAL_EMPTY_STRING(tube); } ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_SV(_0, "stats-tube ", tube); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readyaml", NULL, 388); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 227 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "OK")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_2, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 231 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Queue_Beanstalk, listTubes) { int ZEPHIR_LAST_CALL_STATUS; zval *response = NULL, *_0, *_1, *_2; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "list-tubes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readyaml", NULL, 388); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 244 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "OK")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_2, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 248 TSRMLS_CC); RETURN_CTOR(_2); } static PHP_METHOD(Phalcon_Queue_Beanstalk, peekReady) { int ZEPHIR_LAST_CALL_STATUS; zval *response = NULL, *_0, *_1, *_2, *_3 = NULL, *_4, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "peek-ready", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 261 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "FOUND")) { RETURN_MM_BOOL(0); } object_init_ex(return_value, phalcon_queue_beanstalk_job_ce); zephir_array_fetch_long(&_2, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 265 TSRMLS_CC); zephir_array_fetch_long(&_4, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 265 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, this_ptr, "read", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_5, "unserialize", NULL, 75, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 387, this_ptr, _2, _5); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, peekBuried) { int ZEPHIR_LAST_CALL_STATUS; zval *response = NULL, *_0, *_1, *_2, *_3 = NULL, *_4, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "peek-buried", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); zephir_array_fetch_long(&_1, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 278 TSRMLS_CC); if (!ZEPHIR_IS_STRING(_1, "FOUND")) { RETURN_MM_BOOL(0); } object_init_ex(return_value, phalcon_queue_beanstalk_job_ce); zephir_array_fetch_long(&_2, response, 1, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 282 TSRMLS_CC); zephir_array_fetch_long(&_4, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 282 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_3, this_ptr, "read", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_5, "unserialize", NULL, 75, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 387, this_ptr, _2, _5); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, readStatus) { int ZEPHIR_LAST_CALL_STATUS; zval *status = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&status, this_ptr, "read", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { array_init(return_value); RETURN_MM(); } zephir_fast_explode_str(return_value, SL(" "), status, LONG_MAX TSRMLS_CC); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, readYaml) { int ZEPHIR_LAST_CALL_STATUS; zval *response = NULL, *status, *numberOfBytes = NULL, *data = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&response, this_ptr, "readstatus", NULL, 386); zephir_check_call_status(); ZEPHIR_OBS_VAR(status); zephir_array_fetch_long(&status, response, 0, PH_NOISY, "phalcon/queue/beanstalk.zep", 307 TSRMLS_CC); if (zephir_fast_count_int(response TSRMLS_CC) > 1) { ZEPHIR_OBS_VAR(numberOfBytes); zephir_array_fetch_long(&numberOfBytes, response, 1, PH_NOISY, "phalcon/queue/beanstalk.zep", 310 TSRMLS_CC); ZEPHIR_CALL_METHOD(&response, this_ptr, "read", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&data, "yaml_parse", NULL, 0, response); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(numberOfBytes); ZVAL_LONG(numberOfBytes, 0); ZEPHIR_INIT_NVAR(data); array_init(data); } zephir_create_array(return_value, 3, 0 TSRMLS_CC); zephir_array_fast_append(return_value, status); zephir_array_fast_append(return_value, numberOfBytes); zephir_array_fast_append(return_value, data); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, read) { zval *length_param = NULL, *connection = NULL, *data = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2, _3; int length, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &length_param); if (!length_param) { length = 0; } else { length = zephir_get_intval(length_param); } ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); if (Z_TYPE_P(connection) != IS_RESOURCE) { ZEPHIR_CALL_METHOD(&connection, this_ptr, "connect", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_RESOURCE) { RETURN_MM_BOOL(0); } } if (length) { if (zephir_feof(connection TSRMLS_CC)) { RETURN_MM_BOOL(0); } ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, (length + 2)); ZEPHIR_CALL_FUNCTION(&data, "fread", NULL, 389, connection, &_0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_1, "stream_get_meta_data", NULL, 390, connection); zephir_check_call_status(); zephir_array_fetch_string(&_2, _1, SL("timed_out"), PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk.zep", 354 TSRMLS_CC); if (zephir_is_true(_2)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_exception_ce, "Connection timed out", "phalcon/queue/beanstalk.zep", 355); return; } ZEPHIR_SINIT_NVAR(_0); ZVAL_STRING(&_0, "\r\n", 0); zephir_fast_trim(return_value, data, &_0, ZEPHIR_TRIM_RIGHT TSRMLS_CC); RETURN_MM(); } ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 16384); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "\r\n", 0); ZEPHIR_RETURN_CALL_FUNCTION("stream_get_line", NULL, 391, connection, &_0, &_3); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, write) { int ZEPHIR_LAST_CALL_STATUS; zval *data_param = NULL, *connection = NULL, *packet = NULL, _1; zval *data = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &data_param); zephir_get_strval(data, data_param); ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); if (Z_TYPE_P(connection) != IS_RESOURCE) { ZEPHIR_CALL_METHOD(&connection, this_ptr, "connect", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(connection) != IS_RESOURCE) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VS(_0, data, "\r\n"); ZEPHIR_CPY_WRT(packet, _0); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, zephir_fast_strlen_ev(packet)); ZEPHIR_RETURN_CALL_FUNCTION("fwrite", NULL, 392, connection, packet, &_1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Queue_Beanstalk, disconnect) { zval *connection; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(connection); zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC); if (Z_TYPE_P(connection) != IS_RESOURCE) { RETURN_MM_BOOL(0); } zephir_fclose(connection TSRMLS_CC); RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Queue_Beanstalk_Job) { ZEPHIR_REGISTER_CLASS(Phalcon\\Queue\\Beanstalk, Job, phalcon, queue_beanstalk_job, phalcon_queue_beanstalk_job_method_entry, 0); zend_declare_property_null(phalcon_queue_beanstalk_job_ce, SL("_id"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_queue_beanstalk_job_ce, SL("_body"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_queue_beanstalk_job_ce, SL("_queue"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, getId) { RETURN_MEMBER(this_ptr, "_id"); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, getBody) { RETURN_MEMBER(this_ptr, "_body"); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, __construct) { zval *id = NULL; zval *queue, *id_param = NULL, *body; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &queue, &id_param, &body); zephir_get_strval(id, id_param); zephir_update_property_this(this_ptr, SL("_queue"), queue TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_id"), id TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_body"), body TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, delete) { int ZEPHIR_LAST_CALL_STATUS; zval *queue, *_0, *_1, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "delete ", _0); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, queue, "readstatus", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 57 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_3, "DELETED")); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, release) { zval *priority_param = NULL, *delay_param = NULL, *queue, *_0, _1, _2, *_3, *_4 = NULL, *_5; int priority, delay, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &priority_param, &delay_param); if (!priority_param) { priority = 100; } else { priority = zephir_get_intval(priority_param); } if (!delay_param) { delay = 0; } else { delay = zephir_get_intval(delay_param); } ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, priority); ZEPHIR_SINIT_VAR(_2); ZVAL_LONG(&_2, delay); ZEPHIR_INIT_VAR(_3); ZEPHIR_CONCAT_SVSVSV(_3, "release ", _0, " ", &_1, " ", &_2); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_4, queue, "readstatus", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_5, _4, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 71 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_5, "RELEASED")); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, bury) { zval *priority_param = NULL, *queue, *_0, _1, *_2, *_3 = NULL, *_4; int priority, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &priority_param); if (!priority_param) { priority = 100; } else { priority = zephir_get_intval(priority_param); } ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, priority); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVSV(_2, "bury ", _0, " ", &_1); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_3, queue, "readstatus", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_4, _3, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 85 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_4, "BURIED")); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, touch) { int ZEPHIR_LAST_CALL_STATUS; zval *queue, *_0, *_1, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "touch ", _0); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, queue, "readstatus", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 102 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_3, "TOUCHED")); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, kick) { int ZEPHIR_LAST_CALL_STATUS; zval *queue, *_0, *_1, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "kick-job ", _0); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_2, queue, "readstatus", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 114 TSRMLS_CC); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_3, "KICKED")); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, stats) { int ZEPHIR_LAST_CALL_STATUS; zval *queue, *response = NULL, *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(queue); zephir_read_property_this(&queue, this_ptr, SL("_queue"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_id"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SV(_1, "stats-job ", _0); ZEPHIR_CALL_METHOD(NULL, queue, "write", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&response, queue, "readyaml", NULL, 0); zephir_check_call_status(); zephir_array_fetch_long(&_2, response, 0, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 128 TSRMLS_CC); if (ZEPHIR_IS_STRING(_2, "NOT_FOUND")) { RETURN_MM_BOOL(0); } zephir_array_fetch_long(&_3, response, 2, PH_NOISY | PH_READONLY, "phalcon/queue/beanstalk/job.zep", 132 TSRMLS_CC); RETURN_CTOR(_3); } static PHP_METHOD(Phalcon_Queue_Beanstalk_Job, __wakeup) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(_0); zephir_read_property_this(&_0, this_ptr, SL("_id"), PH_NOISY_CC); if (Z_TYPE_P(_0) != IS_STRING) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_exception_ce); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "Unexpected inconsistency in %s - possible break-in attempt!", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Phalcon\\Queue\\Beanstalk\\Job::__wakeup()", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2, _3); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/queue/beanstalk/job.zep", 141 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Security_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Security, Exception, phalcon, security_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Security_Random) { ZEPHIR_REGISTER_CLASS(Phalcon\\Security, Random, phalcon, security_random, phalcon_security_random_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Security_Random, bytes) { zval *len_param = NULL, *handle = NULL, *ret = NULL, *_0 = NULL, _1, _2 = zval_used_for_init, _3; int len, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &len_param); if (!len_param) { len = 16; } else { len = zephir_get_intval(len_param); } if (len <= 0) { len = 16; } if ((zephir_function_exists_ex(SS("\\sodium\\randombytes_buf") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, len); ZEPHIR_RETURN_CALL_FUNCTION("\\sodium\\randombytes_buf", NULL, 0, _0); zephir_check_call_status(); RETURN_MM(); } if ((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, len); ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, 401, _0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "/dev/urandom", 0); if ((zephir_file_exists(&_1 TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "/dev/urandom", 0); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "rb", 0); ZEPHIR_CALL_FUNCTION(&handle, "fopen", NULL, 285, &_2, &_3); zephir_check_call_status(); if (!ZEPHIR_IS_FALSE_IDENTICAL(handle)) { ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 0); ZEPHIR_CALL_FUNCTION(NULL, "stream_set_read_buffer", NULL, 404, handle, &_2); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, len); ZEPHIR_CALL_FUNCTION(&ret, "fread", NULL, 389, handle, &_2); zephir_check_call_status(); zephir_fclose(handle TSRMLS_CC); if (zephir_fast_strlen_ev(ret) != len) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Unexpected partial read from random device", "phalcon/security/random.zep", 123); return; } RETURN_CCTOR(ret); } } ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "No random device", "phalcon/security/random.zep", 130); return; } static PHP_METHOD(Phalcon_Security_Random, hex) { zval *len_param = NULL, *_0 = NULL, *_1, _2, *_3 = NULL; int len, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &len_param); if (!len_param) { len = 0; } else { len = zephir_get_intval(len_param); } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, len); ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "H*", 0); ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 405, &_2, _0); zephir_check_call_status(); ZEPHIR_MAKE_REF(_3); ZEPHIR_RETURN_CALL_FUNCTION("array_shift", NULL, 122, _3); ZEPHIR_UNREF(_3); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Security_Random, base58) { unsigned char _8; zephir_fcall_cache_entry *_7 = NULL; double _5; HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; zval *byteString, *alphabet; zval *n = NULL, *bytes = NULL, *idx = NULL, *_0 = NULL, _1, **_4, *_6 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &n); if (!n) { n = ZEPHIR_GLOBAL(global_null); } ZEPHIR_INIT_VAR(byteString); ZVAL_STRING(byteString, "", 1); ZEPHIR_INIT_VAR(alphabet); ZVAL_STRING(alphabet, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", 1); ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, n); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "C*", 0); ZEPHIR_CALL_FUNCTION(&bytes, "unpack", NULL, 405, &_1, _0); zephir_check_call_status(); zephir_is_iterable(bytes, &_3, &_2, 0, 0, "phalcon/security/random.zep", 188); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(idx, _4); _5 = zephir_safe_mod_zval_long(idx, 64 TSRMLS_CC); ZEPHIR_INIT_NVAR(idx); ZVAL_DOUBLE(idx, _5); if (ZEPHIR_GE_LONG(idx, 58)) { ZEPHIR_INIT_NVAR(_6); ZVAL_LONG(_6, 57); ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_7, 0, _6); zephir_check_call_status(); } _8 = ZEPHIR_STRING_OFFSET(alphabet, zephir_get_intval(idx)); zephir_concat_self_char(&byteString, _8 TSRMLS_CC); } RETURN_CTOR(byteString); } static PHP_METHOD(Phalcon_Security_Random, base64) { zval *len_param = NULL, *_0 = NULL, *_1; int len, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &len_param); if (!len_param) { len = 0; } else { len = zephir_get_intval(len_param); } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, len); ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 115, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Security_Random, base64Safe) { zend_bool padding; zval *len_param = NULL, *padding_param = NULL, *s = NULL, *_0 = NULL, *_1 = NULL, *_2, _3; int len, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &len_param, &padding_param); if (!len_param) { len = 0; } else { len = zephir_get_intval(len_param); } if (!padding_param) { padding = 0; } else { padding = zephir_get_boolval(padding_param); } ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, len); ZEPHIR_CALL_METHOD(&_0, this_ptr, "base64", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "#[^a-z0-9_=-]+#i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_FUNCTION(&s, "preg_replace", NULL, 29, _1, _2, _0); zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (!(padding)) { ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "=", 0); zephir_fast_trim(return_value, s, &_3, ZEPHIR_TRIM_BOTH TSRMLS_CC); RETURN_MM(); } RETURN_CCTOR(s); } static PHP_METHOD(Phalcon_Security_Random, uuid) { int ZEPHIR_LAST_CALL_STATUS; zval *ary = NULL, *_0 = NULL, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL, *_4, *_5, *_6, *_7; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 16); ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "N1a/n1b/n1c/n1d/n1e/N1f", 0); ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 405, &_2, _0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&ary, "array_values", NULL, 215, _3); zephir_check_call_status(); zephir_array_fetch_long(&_4, ary, 2, PH_NOISY | PH_READONLY, "phalcon/security/random.zep", 268 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, ((((int) (zephir_get_numberval(_4)) & 0x0fff)) | 0x4000)); zephir_array_update_long(&ary, 2, &_1, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_fetch_long(&_5, ary, 3, PH_NOISY | PH_READONLY, "phalcon/security/random.zep", 269 TSRMLS_CC); ZEPHIR_INIT_VAR(_6); ZVAL_LONG(_6, ((((int) (zephir_get_numberval(_5)) & 0x3fff)) | 0x8000)); zephir_array_update_long(&ary, 3, &_6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "%08x-%04x-%04x-%04x-%04x%08x", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_MAKE_REF(ary); ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 380, ary, _7); zephir_check_temp_parameter(_7); ZEPHIR_UNREF(ary); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "sprintf", 0); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_2, ary); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Security_Random, number) { zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL, *_13 = NULL, *_17 = NULL; unsigned char _4; zval *bin; zval *len_param = NULL, *hex = NULL, *mask = NULL, *rnd = NULL, *ret = NULL, *_0 = NULL, _1 = zval_used_for_init, *_2, *_3 = NULL, _10 = zval_used_for_init, *_11 = NULL, _12 = zval_used_for_init, _14 = zval_used_for_init, _15 = zval_used_for_init, *_16 = NULL; int len, ZEPHIR_LAST_CALL_STATUS, _6, _7, _8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &len_param); len = zephir_get_intval(len_param); ZEPHIR_INIT_VAR(bin); ZVAL_STRING(bin, "", 1); if (len <= 0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_security_exception_ce, "Require a positive integer > 0", "phalcon/security/random.zep", 294); return; } if ((zephir_function_exists_ex(SS("\\sodium\\randombytes_uniform") TSRMLS_CC) == SUCCESS)) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, len); ZEPHIR_RETURN_CALL_FUNCTION("\\sodium\\randombytes_uniform", NULL, 0, _0); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, len); ZEPHIR_CALL_FUNCTION(&hex, "dechex", NULL, 406, &_1); zephir_check_call_status(); if (((zephir_fast_strlen_ev(hex) & 1)) == 1) { ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SV(_2, "0", hex); ZEPHIR_CPY_WRT(hex, _2); } ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "H*", 0); ZEPHIR_CALL_FUNCTION(&_3, "pack", NULL, 407, &_1, hex); zephir_check_call_status(); zephir_concat_self(&bin, _3 TSRMLS_CC); _4 = ZEPHIR_STRING_OFFSET(bin, 0); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, _4); ZEPHIR_CALL_FUNCTION(&mask, "ord", &_5, 133, &_1); zephir_check_call_status(); _6 = ((int) (zephir_get_numberval(mask)) | (((int) (zephir_get_numberval(mask)) >> 1))); ZEPHIR_INIT_NVAR(mask); ZVAL_LONG(mask, _6); _7 = ((int) (zephir_get_numberval(mask)) | (((int) (zephir_get_numberval(mask)) >> 2))); ZEPHIR_INIT_NVAR(mask); ZVAL_LONG(mask, _7); _8 = ((int) (zephir_get_numberval(mask)) | (((int) (zephir_get_numberval(mask)) >> 4))); ZEPHIR_INIT_NVAR(mask); ZVAL_LONG(mask, _8); do { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, zephir_fast_strlen_ev(bin)); ZEPHIR_CALL_METHOD(&rnd, this_ptr, "bytes", &_9, 0, _0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); ZEPHIR_SINIT_NVAR(_10); ZVAL_LONG(&_10, 1); ZEPHIR_INIT_NVAR(_0); zephir_substr(_0, rnd, 0 , 1 , 0); ZEPHIR_CALL_FUNCTION(&_11, "ord", &_5, 133, _0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_12); zephir_bitwise_and_function(&_12, _11, mask TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_11, "chr", &_13, 131, &_12); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_14); ZVAL_LONG(&_14, 0); ZEPHIR_SINIT_NVAR(_15); ZVAL_LONG(&_15, 1); ZEPHIR_CALL_FUNCTION(&_16, "substr_replace", &_17, 408, rnd, _11, &_14, &_15); zephir_check_call_status(); ZEPHIR_CPY_WRT(rnd, _16); } while (ZEPHIR_LT(bin, rnd)); ZEPHIR_SINIT_NVAR(_10); ZVAL_STRING(&_10, "H*", 0); ZEPHIR_CALL_FUNCTION(&ret, "unpack", NULL, 405, &_10, rnd); zephir_check_call_status(); ZEPHIR_MAKE_REF(ret); ZEPHIR_CALL_FUNCTION(&_11, "array_shift", NULL, 122, ret); ZEPHIR_UNREF(ret); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("hexdec", NULL, 409, _11); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Session, Adapter, phalcon, session_adapter, phalcon_session_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_session_adapter_ce, SL("_uniqueId"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_session_adapter_ce, SL("_started"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_adapter_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(phalcon_session_adapter_ce, SL("SESSION_ACTIVE"), 2 TSRMLS_CC); zend_declare_class_constant_long(phalcon_session_adapter_ce, SL("SESSION_NONE"), 1 TSRMLS_CC); zend_declare_class_constant_long(phalcon_session_adapter_ce, SL("SESSION_DISABLED"), 0 TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Session_Adapter, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "setoptions", NULL, 0, options); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter, start) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL, *_1, *_3 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 55); zephir_check_call_status(); if (!(zephir_is_true(_0))) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_started"), PH_NOISY_CC); _2 = !zephir_is_true(_1); if (_2) { ZEPHIR_CALL_METHOD(&_3, this_ptr, "status", NULL, 0); zephir_check_call_status(); _2 = !ZEPHIR_IS_LONG_IDENTICAL(_3, 2); } if (_2) { ZEPHIR_CALL_FUNCTION(NULL, "session_start", NULL, 56); zephir_check_call_status(); if (1) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_MM_BOOL(1); } } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Session_Adapter, setOptions) { zval *options_param = NULL, *uniqueId; zval *options = NULL; zephir_fetch_params(0, 1, 0, &options_param); options = options_param; if (zephir_array_isset_string_fetch(&uniqueId, options, SS("uniqueId"), 1 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_uniqueId"), uniqueId TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } static PHP_METHOD(Phalcon_Session_Adapter, getOptions) { RETURN_MEMBER(this_ptr, "_options"); } static PHP_METHOD(Phalcon_Session_Adapter, setName) { int ZEPHIR_LAST_CALL_STATUS; zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(name, name_param); ZEPHIR_CALL_FUNCTION(NULL, "session_name", NULL, 57, name); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter, getName) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("session_name", NULL, 57); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, regenerateId) { int ZEPHIR_LAST_CALL_STATUS; zval *deleteOldSession_param = NULL, _0; zend_bool deleteOldSession; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &deleteOldSession_param); if (!deleteOldSession_param) { deleteOldSession = 1; } else { deleteOldSession = zephir_get_boolval(deleteOldSession_param); } ZEPHIR_SINIT_VAR(_0); ZVAL_BOOL(&_0, (deleteOldSession ? 1 : 0)); ZEPHIR_CALL_FUNCTION(NULL, "session_regenerate_id", NULL, 58, &_0); zephir_check_call_status(); RETURN_THIS(); } static PHP_METHOD(Phalcon_Session_Adapter, get) { zend_bool remove; zval *index_param = NULL, *defaultValue = NULL, *remove_param = NULL, *value, *key = NULL, *uniqueId, *_SESSION; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 1, 2, &index_param, &defaultValue, &remove_param); zephir_get_strval(index, index_param); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } if (!remove_param) { remove = 0; } else { remove = zephir_get_boolval(remove_param); } uniqueId = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(key); ZEPHIR_CONCAT_VSV(key, uniqueId, "#", index); } else { ZEPHIR_CPY_WRT(key, index); } ZEPHIR_OBS_VAR(value); if (zephir_array_isset_fetch(&value, _SESSION, key, 0 TSRMLS_CC)) { if (remove) { zephir_array_unset(&_SESSION, key, PH_SEPARATE); } RETURN_CCTOR(value); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, set) { int _1; zval *index_param = NULL, *value, *uniqueId, *_SESSION, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &index_param, &value); zephir_get_strval(index, index_param); uniqueId = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, uniqueId, "#", index); _1 = zephir_maybe_separate_zval(&_SESSION); zephir_array_update_zval(&_SESSION, _0, &value, PH_COPY | PH_SEPARATE); if (_1) { ZEND_SET_SYMBOL(&EG(symbol_table), "_SESSION", _SESSION); } RETURN_MM_NULL(); } _1 = zephir_maybe_separate_zval(&_SESSION); zephir_array_update_zval(&_SESSION, index, &value, PH_COPY | PH_SEPARATE); if (_1) { ZEND_SET_SYMBOL(&EG(symbol_table), "_SESSION", _SESSION); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter, has) { zval *index_param = NULL, *uniqueId, *_SESSION, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); uniqueId = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, uniqueId, "#", index); RETURN_MM_BOOL(zephir_array_isset(_SESSION, _0)); } RETURN_MM_BOOL(zephir_array_isset(_SESSION, index)); } static PHP_METHOD(Phalcon_Session_Adapter, remove) { zval *index_param = NULL, *uniqueId, *_SESSION, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); uniqueId = zephir_fetch_nproperty_this(this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, uniqueId, "#", index); zephir_array_unset(&_SESSION, _0, PH_SEPARATE); RETURN_MM_NULL(); } zephir_array_unset(&_SESSION, index, PH_SEPARATE); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter, getId) { int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_FUNCTION("session_id", NULL, 59); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, setId) { int ZEPHIR_LAST_CALL_STATUS; zval *id_param = NULL; zval *id = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &id_param); zephir_get_strval(id, id_param); ZEPHIR_CALL_FUNCTION(NULL, "session_id", NULL, 59, id); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter, isStarted) { RETURN_MEMBER(this_ptr, "_started"); } static PHP_METHOD(Phalcon_Session_Adapter, destroy) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; zval *removeData_param = NULL, *uniqueId, *key = NULL, *_SESSION = NULL, *_0 = NULL, **_3, *_4 = NULL; zend_bool removeData; ZEPHIR_MM_GROW(); zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); zephir_fetch_params(1, 0, 1, &removeData_param); if (!removeData_param) { removeData = 0; } else { removeData = zephir_get_boolval(removeData_param); } if (removeData) { ZEPHIR_OBS_VAR(uniqueId); zephir_read_property_this(&uniqueId, this_ptr, SL("_uniqueId"), PH_NOISY_CC); if (!(ZEPHIR_IS_EMPTY(uniqueId))) { ZEPHIR_INIT_VAR(_0); zephir_is_iterable(_SESSION, &_2, &_1, 1, 0, "phalcon/session/adapter.zep", 265); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(_0, _3); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_VS(_4, uniqueId, "#"); if (zephir_start_with(key, _4, NULL)) { zephir_array_unset(&_SESSION, key, PH_SEPARATE); } } } else { ZEPHIR_INIT_NVAR(_SESSION); array_init(_SESSION); } } if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_RETURN_CALL_FUNCTION("session_destroy", NULL, 60); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, status) { int ZEPHIR_LAST_CALL_STATUS; zval *status = NULL; ZEPHIR_MM_GROW(); if (!(zephir_is_php_version(50300))) { ZEPHIR_CALL_FUNCTION(&status, "session_status", NULL, 61); zephir_check_call_status(); do { if (ZEPHIR_IS_LONG(status, 0)) { RETURN_MM_LONG(0); } if (ZEPHIR_IS_LONG(status, 2)) { RETURN_MM_LONG(2); } } while(0); } RETURN_MM_LONG(1); } static PHP_METHOD(Phalcon_Session_Adapter, __get) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, index); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, __set) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL, *value; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &index_param, &value); zephir_get_strval(index, index_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, index, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, __isset) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, index); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, __unset) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "remove", NULL, 0, index); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter, __destruct) { int ZEPHIR_LAST_CALL_STATUS; zval *_0; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_started"), PH_NOISY_CC); if (zephir_is_true(_0)) { ZEPHIR_CALL_FUNCTION(NULL, "session_write_close", NULL, 62); zephir_check_call_status(); if (0) { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Session_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Session, AdapterInterface, phalcon, session_adapterinterface, phalcon_session_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, start); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, setOptions); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, getOptions); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, set); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, has); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, remove); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, getId); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, isStarted); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, destroy); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, regenerateId); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, setName); ZEPHIR_DOC_METHOD(Phalcon_Session_AdapterInterface, getName); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Bag) { ZEPHIR_REGISTER_CLASS(Phalcon\\Session, Bag, phalcon, session_bag, phalcon_session_bag_method_entry, 0); zend_declare_property_null(phalcon_session_bag_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_session_bag_ce, SL("_initialized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_session"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 1, phalcon_session_baginterface_ce); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 1, zend_ce_aggregate); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 1, spl_ce_Countable); return SUCCESS; } static PHP_METHOD(Phalcon_Session_Bag, __construct) { zval *name_param = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &name_param); if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(name, name_param); } else { ZEPHIR_INIT_VAR(name); ZVAL_EMPTY_STRING(name); } zephir_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Bag, setDI) { zval *dependencyInjector; zephir_fetch_params(0, 1, 0, &dependencyInjector); zephir_update_property_this(this_ptr, SL("_dependencyInjector"), dependencyInjector TSRMLS_CC); } static PHP_METHOD(Phalcon_Session_Bag, getDI) { RETURN_MEMBER(this_ptr, "_dependencyInjector"); } static PHP_METHOD(Phalcon_Session_Bag, initialize) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *session = NULL, *dependencyInjector = NULL, *data = NULL, *_1, *_2; ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(session); zephir_read_property_this(&session, this_ptr, SL("_session"), PH_NOISY_CC); if (Z_TYPE_P(session) != IS_OBJECT) { ZEPHIR_OBS_VAR(dependencyInjector); zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_0, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_session_exception_ce, "A dependency injection object is required to access the 'session' service", "phalcon/session/bag.zep", 89); return; } } ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "session", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&session, dependencyInjector, "getshared", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_session"), session TSRMLS_CC); } _2 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&data, session, "get", NULL, 0, _2); zephir_check_call_status(); if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_INIT_NVAR(data); array_init(data); } zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); if (1) { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_initialized"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Bag, destroy) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1, *_2, *_3; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_data"), _1 TSRMLS_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _2, "remove", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Bag, set) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *value, *_0, *_1, *_2, *_3; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &property_param, &value); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } zephir_update_property_array(this_ptr, SL("_data"), property, value TSRMLS_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); _2 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, 0, _2, _3); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Bag, __set) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *value; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &property_param, &value); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, property, value); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Bag, get) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *defaultValue = NULL, *value, *_0, *_1; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &property_param, &defaultValue); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _1, property, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, __get) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, has) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *_0, *_1; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_1, property)); } static PHP_METHOD(Phalcon_Session_Bag, __isset) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, remove) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *data, *_0, *_1; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if (zephir_array_isset(data, property)) { zephir_array_unset(&data, property, PH_SEPARATE); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "set", NULL, 0, _1, data); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); } static PHP_METHOD(Phalcon_Session_Bag, __unset) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "remove", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, count) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } _1 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); RETURN_MM_LONG(zephir_fast_count_int(_1 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Session_Bag, getIterator) { int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_1; ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) { ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } object_init_ex(return_value, zephir_get_internal_ce(SS("arrayiterator") TSRMLS_CC)); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 412, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, offsetSet) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL, *value; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &property_param, &value); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, property, value); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, offsetExists) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, offsetUnset) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "remove", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Bag, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *property_param = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &property_param); if (unlikely(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(property_param) == IS_STRING)) { zephir_get_strval(property, property_param); } else { ZEPHIR_INIT_VAR(property); ZVAL_EMPTY_STRING(property); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, property); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Session_BagInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Session, BagInterface, phalcon, session_baginterface, phalcon_session_baginterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, initialize); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, destroy); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, set); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, get); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, has); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __set); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __get); ZEPHIR_DOC_METHOD(Phalcon_Session_BagInterface, __isset); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session, Exception, phalcon, session_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Files) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Files, phalcon, session_adapter_files, phalcon_session_adapter_ce, NULL, 0); zend_class_implements(phalcon_session_adapter_files_ce TSRMLS_CC, 1, phalcon_session_adapterinterface_ce); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Libmemcached) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Libmemcached, phalcon, session_adapter_libmemcached, phalcon_session_adapter_ce, phalcon_session_adapter_libmemcached_method_entry, 0); zend_declare_property_null(phalcon_session_adapter_libmemcached_ce, SL("_libmemcached"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_session_adapter_libmemcached_ce, SL("_lifetime"), 8600, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_session_adapter_libmemcached_ce TSRMLS_CC, 1, phalcon_session_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, getLibmemcached) { RETURN_MEMBER(this_ptr, "_libmemcached"); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, getLifetime) { RETURN_MEMBER(this_ptr, "_lifetime"); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, __construct) { zephir_fcall_cache_entry *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *servers, *client = NULL, *lifetime = NULL, *prefix = NULL, *statsKey = NULL, *_0, *_1, *_3, *_6 = NULL; zval *options = NULL, *_2, *_4, *_5, *_7, *_8, *_9, *_10, *_11; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); zephir_get_arrval(options, options_param); ZEPHIR_OBS_VAR(servers); if (!(zephir_array_isset_string_fetch(&servers, options, SS("servers"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_session_exception_ce, "No servers given in options", "phalcon/session/adapter/libmemcached.zep", 68); return; } ZEPHIR_OBS_VAR(client); if (!(zephir_array_isset_string_fetch(&client, options, SS("client"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(client); ZVAL_NULL(client); } ZEPHIR_OBS_VAR(lifetime); if (!(zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(lifetime); ZVAL_LONG(lifetime, 8600); } zephir_update_property_this(this_ptr, SL("_lifetime"), lifetime TSRMLS_CC); ZEPHIR_OBS_VAR(prefix); if (!(zephir_array_isset_string_fetch(&prefix, options, SS("prefix"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(prefix); ZVAL_NULL(prefix); } ZEPHIR_OBS_VAR(statsKey); if (!(zephir_array_isset_string_fetch(&statsKey, options, SS("statsKey"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(statsKey); ZVAL_NULL(statsKey); } ZEPHIR_INIT_VAR(_0); object_init_ex(_0, phalcon_cache_backend_libmemcached_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_lifetime"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 4, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL("servers"), &servers, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("client"), &client, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("prefix"), &prefix, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_4, SL("statsKey"), &statsKey, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 313, _1, _4); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_libmemcached"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_5); zephir_create_array(_5, 2, 0 TSRMLS_CC); zephir_array_fast_append(_5, this_ptr); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "open", 1); zephir_array_fast_append(_5, _6); ZEPHIR_INIT_VAR(_7); zephir_create_array(_7, 2, 0 TSRMLS_CC); zephir_array_fast_append(_7, this_ptr); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "close", 1); zephir_array_fast_append(_7, _6); ZEPHIR_INIT_VAR(_8); zephir_create_array(_8, 2, 0 TSRMLS_CC); zephir_array_fast_append(_8, this_ptr); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "read", 1); zephir_array_fast_append(_8, _6); ZEPHIR_INIT_VAR(_9); zephir_create_array(_9, 2, 0 TSRMLS_CC); zephir_array_fast_append(_9, this_ptr); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "write", 1); zephir_array_fast_append(_9, _6); ZEPHIR_INIT_VAR(_10); zephir_create_array(_10, 2, 0 TSRMLS_CC); zephir_array_fast_append(_10, this_ptr); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "destroy", 1); zephir_array_fast_append(_10, _6); ZEPHIR_INIT_VAR(_11); zephir_create_array(_11, 2, 0 TSRMLS_CC); zephir_array_fast_append(_11, this_ptr); ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "gc", 1); zephir_array_fast_append(_11, _6); ZEPHIR_CALL_FUNCTION(NULL, "session_set_save_handler", NULL, 410, _5, _7, _8, _9, _10, _11); zephir_check_call_status(); ZEPHIR_CALL_PARENT(NULL, phalcon_session_adapter_libmemcached_ce, this_ptr, "__construct", &_12, 411, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, open) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, close) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, read) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sessionId); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, sessionId, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, write) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *data, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sessionId, &data); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, sessionId, data, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, destroy) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sessionId); if (!sessionId) { ZEPHIR_CPY_WRT(sessionId, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(sessionId); } if (Z_TYPE_P(sessionId) == IS_NULL) { ZEPHIR_CALL_METHOD(&sessionId, this_ptr, "getid", NULL, 0); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_libmemcached"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "delete", NULL, 0, sessionId); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Libmemcached, gc) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Memcache) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Memcache, phalcon, session_adapter_memcache, phalcon_session_adapter_ce, phalcon_session_adapter_memcache_method_entry, 0); zend_declare_property_null(phalcon_session_adapter_memcache_ce, SL("_memcache"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_session_adapter_memcache_ce, SL("_lifetime"), 8600, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_session_adapter_memcache_ce TSRMLS_CC, 1, phalcon_session_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, getMemcache) { RETURN_MEMBER(this_ptr, "_memcache"); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, getLifetime) { RETURN_MEMBER(this_ptr, "_lifetime"); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, __construct) { zephir_fcall_cache_entry *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *lifetime, *_0 = NULL, *_1, *_3, *_5 = NULL; zval *options = NULL, *_2, *_4, *_6, *_7, *_8, *_9, *_10; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options_param); if (!options_param) { ZEPHIR_INIT_VAR(options); array_init(options); } else { zephir_get_arrval(options, options_param); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 11211); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 0); zephir_array_update_string(&options, SL("persistent"), &_0, PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(lifetime); if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_lifetime"), lifetime TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_cache_backend_memcache_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_lifetime"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 315, _1, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_memcache"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_fast_append(_4, this_ptr); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "open", 1); zephir_array_fast_append(_4, _5); ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_6, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "close", 1); zephir_array_fast_append(_6, _5); ZEPHIR_INIT_VAR(_7); zephir_create_array(_7, 2, 0 TSRMLS_CC); zephir_array_fast_append(_7, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "read", 1); zephir_array_fast_append(_7, _5); ZEPHIR_INIT_VAR(_8); zephir_create_array(_8, 2, 0 TSRMLS_CC); zephir_array_fast_append(_8, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "write", 1); zephir_array_fast_append(_8, _5); ZEPHIR_INIT_VAR(_9); zephir_create_array(_9, 2, 0 TSRMLS_CC); zephir_array_fast_append(_9, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "destroy", 1); zephir_array_fast_append(_9, _5); ZEPHIR_INIT_VAR(_10); zephir_create_array(_10, 2, 0 TSRMLS_CC); zephir_array_fast_append(_10, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "gc", 1); zephir_array_fast_append(_10, _5); ZEPHIR_CALL_FUNCTION(NULL, "session_set_save_handler", NULL, 410, _4, _6, _7, _8, _9, _10); zephir_check_call_status(); ZEPHIR_CALL_PARENT(NULL, phalcon_session_adapter_memcache_ce, this_ptr, "__construct", &_11, 411, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, open) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, close) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, read) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sessionId); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, sessionId, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, write) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *data, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sessionId, &data); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, sessionId, data, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, destroy) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sessionId); if (!sessionId) { ZEPHIR_CPY_WRT(sessionId, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(sessionId); } if (Z_TYPE_P(sessionId) == IS_NULL) { ZEPHIR_CALL_METHOD(&sessionId, this_ptr, "getid", NULL, 0); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_memcache"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "delete", NULL, 0, sessionId); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Memcache, gc) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Session_Adapter_Redis) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Session\\Adapter, Redis, phalcon, session_adapter_redis, phalcon_session_adapter_ce, phalcon_session_adapter_redis_method_entry, 0); zend_declare_property_null(phalcon_session_adapter_redis_ce, SL("_redis"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_session_adapter_redis_ce, SL("_lifetime"), 8600, ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_session_adapter_redis_ce TSRMLS_CC, 1, phalcon_session_adapterinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Session_Adapter_Redis, getRedis) { RETURN_MEMBER(this_ptr, "_redis"); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, getLifetime) { RETURN_MEMBER(this_ptr, "_lifetime"); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, __construct) { zephir_fcall_cache_entry *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *lifetime, *_0 = NULL, *_1, *_3, *_5 = NULL; zval *options = NULL, *_2, *_4, *_6, *_7, *_8, *_9, *_10; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options_param); if (!options_param) { ZEPHIR_INIT_VAR(options); array_init(options); } else { zephir_get_arrval(options, options_param); } if (!(zephir_array_isset_string(options, SS("host")))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "127.0.0.1", 1); zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("port")))) { ZEPHIR_INIT_NVAR(_0); ZVAL_LONG(_0, 6379); zephir_array_update_string(&options, SL("port"), &_0, PH_COPY | PH_SEPARATE); } if (!(zephir_array_isset_string(options, SS("persistent")))) { zephir_array_update_string(&options, SL("persistent"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); } ZEPHIR_OBS_VAR(lifetime); if (zephir_array_isset_string_fetch(&lifetime, options, SS("lifetime"), 0 TSRMLS_CC)) { zephir_update_property_this(this_ptr, SL("_lifetime"), lifetime TSRMLS_CC); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_cache_backend_redis_ce); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_cache_frontend_data_ce); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property_this(&_3, this_ptr, SL("_lifetime"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 312, _2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 316, _1, options); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_redis"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 2, 0 TSRMLS_CC); zephir_array_fast_append(_4, this_ptr); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "open", 1); zephir_array_fast_append(_4, _5); ZEPHIR_INIT_VAR(_6); zephir_create_array(_6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_6, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "close", 1); zephir_array_fast_append(_6, _5); ZEPHIR_INIT_VAR(_7); zephir_create_array(_7, 2, 0 TSRMLS_CC); zephir_array_fast_append(_7, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "read", 1); zephir_array_fast_append(_7, _5); ZEPHIR_INIT_VAR(_8); zephir_create_array(_8, 2, 0 TSRMLS_CC); zephir_array_fast_append(_8, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "write", 1); zephir_array_fast_append(_8, _5); ZEPHIR_INIT_VAR(_9); zephir_create_array(_9, 2, 0 TSRMLS_CC); zephir_array_fast_append(_9, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "destroy", 1); zephir_array_fast_append(_9, _5); ZEPHIR_INIT_VAR(_10); zephir_create_array(_10, 2, 0 TSRMLS_CC); zephir_array_fast_append(_10, this_ptr); ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "gc", 1); zephir_array_fast_append(_10, _5); ZEPHIR_CALL_FUNCTION(NULL, "session_set_save_handler", NULL, 410, _4, _6, _7, _8, _9, _10); zephir_check_call_status(); ZEPHIR_CALL_PARENT(NULL, phalcon_session_adapter_redis_ce, this_ptr, "__construct", &_11, 411, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, open) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, close) { RETURN_BOOL(1); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, read) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &sessionId); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, sessionId, _1); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, write) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId, *data, *_0, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &sessionId, &data); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_lifetime"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _0, "save", NULL, 0, sessionId, data, _1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, destroy) { int ZEPHIR_LAST_CALL_STATUS; zval *sessionId = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &sessionId); if (!sessionId) { ZEPHIR_CPY_WRT(sessionId, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(sessionId); } if (Z_TYPE_P(sessionId) == IS_NULL) { ZEPHIR_CALL_METHOD(&sessionId, this_ptr, "getid", NULL, 0); zephir_check_call_status(); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_redis"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "delete", NULL, 0, sessionId); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Session_Adapter_Redis, gc) { RETURN_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Tag_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Tag, Exception, phalcon, tag_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Tag_Select) { ZEPHIR_REGISTER_CLASS(Phalcon\\Tag, Select, phalcon, tag_select, phalcon_tag_select_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } static PHP_METHOD(Phalcon_Tag_Select, selectField) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL, *_4 = NULL, *_9 = NULL, *_10 = NULL; zval *parameters, *data = NULL, *params = NULL, *name, *id, *value = NULL, *useEmpty, *code, *emptyValue = NULL, *emptyText = NULL, *options = NULL, *using, *_0, *_3 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, ¶meters, &data); if (!data) { data = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(parameters) != IS_ARRAY) { ZEPHIR_INIT_VAR(params); zephir_create_array(params, 2, 0 TSRMLS_CC); zephir_array_fast_append(params, parameters); zephir_array_fast_append(params, data); } else { ZEPHIR_CPY_WRT(params, parameters); } ZEPHIR_OBS_VAR(id); if (!(zephir_array_isset_long_fetch(&id, params, 0, 0 TSRMLS_CC))) { zephir_array_fetch_string(&_0, params, SL("id"), PH_NOISY | PH_READONLY, "phalcon/tag/select.zep", 51 TSRMLS_CC); zephir_array_update_long(¶ms, 0, &_0, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } if (!(zephir_memnstr_str(id, SL("["), "phalcon/tag/select.zep", 57))) { if (!(zephir_array_isset_string(params, SS("id")))) { zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); } } ZEPHIR_OBS_VAR(name); if (!(zephir_array_isset_string_fetch(&name, params, SS("name"), 0 TSRMLS_CC))) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } else { if (!(zephir_is_true(name))) { zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } } ZEPHIR_OBS_VAR(value); if (!(zephir_array_isset_string_fetch(&value, params, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_CALL_CE_STATIC(&value, phalcon_tag_ce, "getvalue", &_1, 6, id, params); zephir_check_call_status(); } else { zephir_array_unset_string(¶ms, SS("value"), PH_SEPARATE); } ZEPHIR_OBS_VAR(useEmpty); if (zephir_array_isset_string_fetch(&useEmpty, params, SS("useEmpty"), 0 TSRMLS_CC)) { ZEPHIR_OBS_VAR(emptyValue); if (!(zephir_array_isset_string_fetch(&emptyValue, params, SS("emptyValue"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(emptyValue); ZVAL_STRING(emptyValue, "", 1); } else { zephir_array_unset_string(¶ms, SS("emptyValue"), PH_SEPARATE); } ZEPHIR_OBS_VAR(emptyText); if (!(zephir_array_isset_string_fetch(&emptyText, params, SS("emptyText"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(emptyText); ZVAL_STRING(emptyText, "Choose...", 1); } else { zephir_array_unset_string(¶ms, SS("emptyText"), PH_SEPARATE); } zephir_array_unset_string(¶ms, SS("useEmpty"), PH_SEPARATE); } ZEPHIR_OBS_VAR(options); if (!(zephir_array_isset_long_fetch(&options, params, 1, 0 TSRMLS_CC))) { ZEPHIR_CPY_WRT(options, data); } if (Z_TYPE_P(options) == IS_OBJECT) { ZEPHIR_OBS_VAR(using); if (!(zephir_array_isset_string_fetch(&using, params, SS("using"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter is required", "phalcon/tag/select.zep", 104); return; } else { _2 = Z_TYPE_P(using) != IS_ARRAY; if (_2) { _2 = Z_TYPE_P(using) != IS_OBJECT; } if (_2) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter should be an array", "phalcon/tag/select.zep", 107); return; } } } zephir_array_unset_string(¶ms, SS("using"), PH_SEPARATE); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "<select", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_CE_STATIC(&_3, phalcon_tag_ce, "renderattributes", &_4, 4, _5, params); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_5); ZEPHIR_GET_CONSTANT(_5, "PHP_EOL"); ZEPHIR_INIT_VAR(code); ZEPHIR_CONCAT_VSV(code, _3, ">", _5); if (zephir_is_true(useEmpty)) { ZEPHIR_INIT_VAR(_6); ZEPHIR_GET_CONSTANT(_6, "PHP_EOL"); ZEPHIR_INIT_VAR(_7); ZEPHIR_CONCAT_SVSVSV(_7, "\t<option value=\"", emptyValue, "\">", emptyText, "</option>", _6); zephir_concat_self(&code, _7 TSRMLS_CC); } if (Z_TYPE_P(options) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_6); ZEPHIR_GET_CONSTANT(_6, "PHP_EOL"); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "</option>", _6); ZEPHIR_CALL_SELF(&_8, "_optionsfromresultset", &_9, 416, options, using, value, _7); zephir_check_call_status(); zephir_concat_self(&code, _8 TSRMLS_CC); } else { if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_6); ZEPHIR_GET_CONSTANT(_6, "PHP_EOL"); ZEPHIR_INIT_LNVAR(_7); ZEPHIR_CONCAT_SV(_7, "</option>", _6); ZEPHIR_CALL_SELF(&_8, "_optionsfromarray", &_10, 417, options, value, _7); zephir_check_call_status(); zephir_concat_self(&code, _8 TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "Invalid data provided to SELECT helper", "phalcon/tag/select.zep", 138); return; } } zephir_concat_self_str(&code, SL("</select>") TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag_Select, _optionsFromResultset) { zval *_2 = NULL, *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_0; zval *resultset, *using, *value, *closeOption, *code, *params = NULL, *option = NULL, *usingZero, *usingOne, *optionValue = NULL, *optionText = NULL, *strValue = NULL, *strOptionValue = NULL, *_1 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &resultset, &using, &value, &closeOption); ZEPHIR_INIT_VAR(code); ZVAL_STRING(code, "", 1); ZEPHIR_INIT_VAR(params); ZVAL_NULL(params); if (Z_TYPE_P(using) == IS_ARRAY) { if (zephir_fast_count_int(using TSRMLS_CC) != 2) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "Parameter 'using' requires two values", "phalcon/tag/select.zep", 165); return; } ZEPHIR_OBS_VAR(usingZero); zephir_array_fetch_long(&usingZero, using, 0, PH_NOISY, "phalcon/tag/select.zep", 167 TSRMLS_CC); ZEPHIR_OBS_VAR(usingOne); zephir_array_fetch_long(&usingOne, using, 1, PH_NOISY, "phalcon/tag/select.zep", 167 TSRMLS_CC); } _0 = zephir_get_iterator(resultset TSRMLS_CC); _0->funcs->rewind(_0 TSRMLS_CC); for (;_0->funcs->valid(_0 TSRMLS_CC) == SUCCESS && !EG(exception); _0->funcs->move_forward(_0 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _0->funcs->get_current_data(_0, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(option, (*ZEPHIR_TMP_ITERATOR_PTR)); } if (Z_TYPE_P(using) == IS_ARRAY) { if (Z_TYPE_P(option) == IS_OBJECT) { if ((zephir_method_exists_ex(option, SS("readattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&optionValue, option, "readattribute", NULL, 0, usingZero); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&optionText, option, "readattribute", NULL, 0, usingOne); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(optionValue); zephir_read_property(&optionValue, option, SL("usingZero"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(optionText); zephir_read_property(&optionText, option, SL("usingOne"), PH_NOISY_CC); } } else { if (Z_TYPE_P(option) == IS_ARRAY) { ZEPHIR_OBS_NVAR(optionValue); zephir_array_fetch(&optionValue, option, usingZero, PH_NOISY, "phalcon/tag/select.zep", 184 TSRMLS_CC); ZEPHIR_OBS_NVAR(optionText); zephir_array_fetch(&optionText, option, usingOne, PH_NOISY, "phalcon/tag/select.zep", 185 TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "Resultset returned an invalid value", "phalcon/tag/select.zep", 187); return; } } if (Z_TYPE_P(value) == IS_ARRAY) { if (zephir_fast_in_array(optionValue, value TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVV(_1, "\t<option selected=\"selected\" value=\"", optionValue, "\">", optionText, closeOption); zephir_concat_self(&code, _1 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVV(_1, "\t<option value=\"", optionValue, "\">", optionText, closeOption); zephir_concat_self(&code, _1 TSRMLS_CC); } } else { zephir_get_strval(_2, optionValue); ZEPHIR_CPY_WRT(strOptionValue, _2); zephir_get_strval(_3, value); ZEPHIR_CPY_WRT(strValue, _3); if (ZEPHIR_IS_IDENTICAL(strOptionValue, strValue)) { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVV(_1, "\t<option selected=\"selected\" value=\"", strOptionValue, "\">", optionText, closeOption); zephir_concat_self(&code, _1 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_1); ZEPHIR_CONCAT_SVSVV(_1, "\t<option value=\"", strOptionValue, "\">", optionText, closeOption); zephir_concat_self(&code, _1 TSRMLS_CC); } } } else { if (Z_TYPE_P(using) == IS_OBJECT) { if (Z_TYPE_P(params) == IS_NULL) { ZEPHIR_INIT_NVAR(params); array_init(params); } zephir_array_update_long(¶ms, 0, &option, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_INIT_NVAR(_4); ZEPHIR_CALL_USER_FUNC_ARRAY(_4, using, params); zephir_check_call_status(); zephir_concat_self(&code, _4 TSRMLS_CC); } } } _0->funcs->dtor(_0 TSRMLS_CC); RETURN_CCTOR(code); } static PHP_METHOD(Phalcon_Tag_Select, _optionsFromArray) { zval *_10 = NULL, *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; HashTable *_1; HashPosition _0; zval *data, *value, *closeOption, *strValue = NULL, *strOptionValue = NULL, *code, *optionValue = NULL, *optionText = NULL, *escaped = NULL, **_2, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &data, &value, &closeOption); ZEPHIR_INIT_VAR(code); ZVAL_STRING(code, "", 1); zephir_is_iterable(data, &_1, &_0, 0, 0, "phalcon/tag/select.zep", 268); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(optionValue, _1, _0); ZEPHIR_GET_HVALUE(optionText, _2); ZEPHIR_CALL_FUNCTION(&escaped, "htmlspecialchars", &_3, 182, optionValue); zephir_check_call_status(); if (Z_TYPE_P(optionText) == IS_ARRAY) { ZEPHIR_INIT_NVAR(_4); ZEPHIR_GET_CONSTANT(_4, "PHP_EOL"); ZEPHIR_CALL_SELF(&_5, "_optionsfromarray", &_6, 417, optionText, value, closeOption); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_7); ZEPHIR_GET_CONSTANT(_7, "PHP_EOL"); ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVVSV(_8, "\t<optgroup label=\"", escaped, "\">", _4, _5, "\t</optgroup>", _7); zephir_concat_self(&code, _8 TSRMLS_CC); continue; } if (Z_TYPE_P(value) == IS_ARRAY) { if (zephir_fast_in_array(optionValue, value TSRMLS_CC)) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVV(_8, "\t<option selected=\"selected\" value=\"", escaped, "\">", optionText, closeOption); zephir_concat_self(&code, _8 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVV(_9, "\t<option value=\"", escaped, "\">", optionText, closeOption); zephir_concat_self(&code, _9 TSRMLS_CC); } } else { zephir_get_strval(_10, optionValue); ZEPHIR_CPY_WRT(strOptionValue, _10); zephir_get_strval(_11, value); ZEPHIR_CPY_WRT(strValue, _11); if (ZEPHIR_IS_IDENTICAL(strOptionValue, strValue)) { ZEPHIR_INIT_LNVAR(_8); ZEPHIR_CONCAT_SVSVV(_8, "\t<option selected=\"selected\" value=\"", escaped, "\">", optionText, closeOption); zephir_concat_self(&code, _8 TSRMLS_CC); } else { ZEPHIR_INIT_LNVAR(_9); ZEPHIR_CONCAT_SVSVV(_9, "\t<option value=\"", escaped, "\">", optionText, closeOption); zephir_concat_self(&code, _9 TSRMLS_CC); } } } RETURN_CCTOR(code); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter) { ZEPHIR_REGISTER_CLASS(Phalcon\\Translate, Adapter, phalcon, translate_adapter, phalcon_translate_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_translate_adapter_ce, SL("_interpolator"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Adapter, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *interpolator = NULL; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_OBS_VAR(interpolator); if (!(zephir_array_isset_string_fetch(&interpolator, options, SS("interpolator"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(interpolator); object_init_ex(interpolator, phalcon_translate_interpolator_associativearray_ce); if (zephir_has_constructor(interpolator TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, interpolator, "__construct", NULL, 0); zephir_check_call_status(); } } ZEPHIR_CALL_METHOD(NULL, this_ptr, "setinterpolator", NULL, 0, interpolator); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter, setInterpolator) { zval *interpolator; zephir_fetch_params(0, 1, 0, &interpolator); zephir_update_property_this(this_ptr, SL("_interpolator"), interpolator TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Translate_Adapter, t) { int ZEPHIR_LAST_CALL_STATUS; zval *translateKey_param = NULL, *placeholders = NULL; zval *translateKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders); if (unlikely(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translateKey_param) == IS_STRING)) { zephir_get_strval(translateKey, translateKey_param); } else { ZEPHIR_INIT_VAR(translateKey); ZVAL_EMPTY_STRING(translateKey); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, translateKey, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter, _) { int ZEPHIR_LAST_CALL_STATUS; zval *translateKey_param = NULL, *placeholders = NULL; zval *translateKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders); if (unlikely(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translateKey_param) == IS_STRING)) { zephir_get_strval(translateKey, translateKey_param); } else { ZEPHIR_INIT_VAR(translateKey); ZVAL_EMPTY_STRING(translateKey); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, translateKey, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter, offsetSet) { zval *offset, *value; zephir_fetch_params(0, 2, 0, &offset, &value); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_translate_exception_ce, "Translate is an immutable ArrayAccess object", "phalcon/translate/adapter.zep", 86); return; } static PHP_METHOD(Phalcon_Translate_Adapter, offsetExists) { int ZEPHIR_LAST_CALL_STATUS; zval *translateKey_param = NULL; zval *translateKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &translateKey_param); if (unlikely(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translateKey_param) == IS_STRING)) { zephir_get_strval(translateKey, translateKey_param); } else { ZEPHIR_INIT_VAR(translateKey); ZVAL_EMPTY_STRING(translateKey); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "exists", NULL, 0, translateKey); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter, offsetUnset) { zval *offset; zephir_fetch_params(0, 1, 0, &offset); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_translate_exception_ce, "Translate is an immutable ArrayAccess object", "phalcon/translate/adapter.zep", 104); return; } static PHP_METHOD(Phalcon_Translate_Adapter, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *translateKey_param = NULL, *_0; zval *translateKey = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &translateKey_param); if (unlikely(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translateKey_param) == IS_STRING)) { zephir_get_strval(translateKey, translateKey_param); } else { ZEPHIR_INIT_VAR(translateKey); ZVAL_EMPTY_STRING(translateKey); } ZEPHIR_INIT_VAR(_0); ZVAL_NULL(_0); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, translateKey, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter, replacePlaceholders) { int ZEPHIR_LAST_CALL_STATUS; zval *translation_param = NULL, *placeholders = NULL, *_0; zval *translation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &translation_param, &placeholders); if (unlikely(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translation_param) == IS_STRING)) { zephir_get_strval(translation, translation_param); } else { ZEPHIR_INIT_VAR(translation); ZVAL_EMPTY_STRING(translation); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_interpolator"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_0, "replaceplaceholders", NULL, 0, translation, placeholders); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_AdapterInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Translate, AdapterInterface, phalcon, translate_adapterinterface, phalcon_translate_adapterinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Translate_AdapterInterface, t); ZEPHIR_DOC_METHOD(Phalcon_Translate_AdapterInterface, query); ZEPHIR_DOC_METHOD(Phalcon_Translate_AdapterInterface, exists); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate, Exception, phalcon, translate_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_InterpolatorInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Translate, InterpolatorInterface, phalcon, translate_interpolatorinterface, phalcon_translate_interpolatorinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Translate_InterpolatorInterface, replacePlaceholders); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_Csv) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, Csv, phalcon, translate_adapter_csv, phalcon_translate_adapter_ce, phalcon_translate_adapter_csv_method_entry, 0); zend_declare_property_null(phalcon_translate_adapter_csv_ce, SL("_translate"), ZEND_ACC_PROTECTED TSRMLS_CC); phalcon_translate_adapter_csv_ce->create_object = zephir_init_properties_Phalcon_Translate_Adapter_Csv; zend_class_implements(phalcon_translate_adapter_csv_ce TSRMLS_CC, 1, phalcon_translate_adapterinterface_ce); zend_class_implements(phalcon_translate_adapter_csv_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Adapter_Csv, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *options_param = NULL, *_1, *_2, *_3, *_4; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_csv_ce, this_ptr, "__construct", &_0, 426, options); zephir_check_call_status(); if (!(zephir_array_isset_string(options, SS("content")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter 'content' is required", "phalcon/translate/adapter/csv.zep", 43); return; } zephir_array_fetch_string(&_1, options, SL("content"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 46 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, ";", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "\"", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_load", NULL, 427, _1, _2, _3, _4); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Csv, _load) { zend_bool _6; zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *file, *length, *delimiter, *enclosure, *data = NULL, *fileHandler = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2, *_4, _5 = zval_used_for_init, *_7, *_8 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 4, 0, &file, &length, &delimiter, &enclosure); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "rb", 0); ZEPHIR_CALL_FUNCTION(&fileHandler, "fopen", NULL, 285, file, &_0); zephir_check_call_status(); if (Z_TYPE_P(fileHandler) != IS_RESOURCE) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, phalcon_translate_exception_ce); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_SVS(_2, "Error opening translation file '", file, "'"); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2); zephir_check_call_status(); zephir_throw_exception_debug(_1, "phalcon/translate/adapter/csv.zep", 64 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } while (1) { ZEPHIR_CALL_FUNCTION(&data, "fgetcsv", &_3, 428, fileHandler, length, delimiter, enclosure); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(data)) { break; } zephir_array_fetch_long(&_4, data, 0, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 74 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 0); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 1); ZEPHIR_INIT_NVAR(_1); zephir_substr(_1, _4, 0 , 1 , 0); _6 = ZEPHIR_IS_STRING_IDENTICAL(_1, "#"); if (!(_6)) { _6 = !(zephir_array_isset_long(data, 1)); } if (_6) { continue; } zephir_array_fetch_long(&_7, data, 1, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 78 TSRMLS_CC); ZEPHIR_OBS_NVAR(_8); zephir_array_fetch_long(&_8, data, 0, PH_NOISY, "phalcon/translate/adapter/csv.zep", 78 TSRMLS_CC); zephir_update_property_array(this_ptr, SL("_translate"), _8, _7 TSRMLS_CC); } zephir_fclose(fileHandler TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Csv, query) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL, *placeholders = NULL, *translation = NULL, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &index_param, &placeholders); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(translation); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_translate"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&translation, _0, index, 0 TSRMLS_CC))) { ZEPHIR_CPY_WRT(translation, index); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, translation, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_Csv, exists) { zval *index_param = NULL, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_translate"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, index)); } static zend_object_value zephir_init_properties_Phalcon_Translate_Adapter_Csv(zend_class_entry *class_type TSRMLS_DC) { zval *_0, *_1; ZEPHIR_MM_GROW(); { zval *this_ptr = NULL; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_translate"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_NULL) { ZEPHIR_INIT_VAR(_1); array_init(_1); zephir_update_property_this(this_ptr, SL("_translate"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); return Z_OBJVAL_P(this_ptr); } } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_Gettext) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, Gettext, phalcon, translate_adapter_gettext, phalcon_translate_adapter_ce, phalcon_translate_adapter_gettext_method_entry, 0); zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("_directory"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("_defaultDomain"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("_locale"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("_category"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_translate_adapter_gettext_ce TSRMLS_CC, 1, phalcon_translate_adapterinterface_ce); zend_class_implements(phalcon_translate_adapter_gettext_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *options_param = NULL; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_gettext_ce, this_ptr, "__construct", &_0, 426, options); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, this_ptr, "prepareoptions", NULL, 0, options); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, query) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL, *placeholders = NULL, *translation = NULL, *domain = NULL, *_0 = NULL, _1; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &index_param, &placeholders); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_FUNCTION(&_0, "func_num_args", NULL, 421); zephir_check_call_status(); if (ZEPHIR_GT_LONG(_0, 2)) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 2); ZEPHIR_CALL_FUNCTION(&domain, "func_get_arg", NULL, 420, &_1); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(domain); ZVAL_NULL(domain); } if (!(zephir_is_true(domain))) { ZEPHIR_CALL_FUNCTION(&translation, "gettext", NULL, 429, index); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&translation, "dgettext", NULL, 430, domain, index); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, translation, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, exists) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL, *_0 = NULL; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "query", NULL, 0, index); zephir_check_call_status(); RETURN_MM_BOOL(zephir_fast_strlen_ev(_0) > 0); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, nquery) { int count, ZEPHIR_LAST_CALL_STATUS; zval *msgid1_param = NULL, *msgid2_param = NULL, *count_param = NULL, *placeholders = NULL, *domain_param = NULL, *translation = NULL, _0 = zval_used_for_init; zval *msgid1 = NULL, *msgid2 = NULL, *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 2, &msgid1_param, &msgid2_param, &count_param, &placeholders, &domain_param); if (unlikely(Z_TYPE_P(msgid1_param) != IS_STRING && Z_TYPE_P(msgid1_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'msgid1' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(msgid1_param) == IS_STRING)) { zephir_get_strval(msgid1, msgid1_param); } else { ZEPHIR_INIT_VAR(msgid1); ZVAL_EMPTY_STRING(msgid1); } if (unlikely(Z_TYPE_P(msgid2_param) != IS_STRING && Z_TYPE_P(msgid2_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'msgid2' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(msgid2_param) == IS_STRING)) { zephir_get_strval(msgid2, msgid2_param); } else { ZEPHIR_INIT_VAR(msgid2); ZVAL_EMPTY_STRING(msgid2); } if (unlikely(Z_TYPE_P(count_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'count' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } count = Z_LVAL_P(count_param); if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } if (!domain_param) { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } else { if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } } if (!(!(!domain) && Z_STRLEN_P(domain))) { ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, count); ZEPHIR_CALL_FUNCTION(&translation, "ngettext", NULL, 431, msgid1, msgid2, &_0); zephir_check_call_status(); } else { ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, count); ZEPHIR_CALL_FUNCTION(&translation, "dngettext", NULL, 432, domain, msgid1, msgid2, &_0); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, translation, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDomain) { int ZEPHIR_LAST_CALL_STATUS; zval *domain_param = NULL; zval *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &domain_param); if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } ZEPHIR_RETURN_CALL_FUNCTION("textdomain", NULL, 433, domain); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, resetDomain) { int ZEPHIR_LAST_CALL_STATUS; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdefaultdomain", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("textdomain", NULL, 433, _0); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDefaultDomain) { zval *domain_param = NULL; zval *domain = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &domain_param); if (unlikely(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(domain_param) == IS_STRING)) { zephir_get_strval(domain, domain_param); } else { ZEPHIR_INIT_VAR(domain); ZVAL_EMPTY_STRING(domain); } zephir_update_property_this(this_ptr, SL("_defaultDomain"), domain TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getDefaultDomain) { RETURN_MEMBER(this_ptr, "_defaultDomain"); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDirectory) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_3 = NULL; HashTable *_1; HashPosition _0; zval *directory, *key = NULL, *value = NULL, **_2, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &directory); zephir_update_property_this(this_ptr, SL("_directory"), directory TSRMLS_CC); if (Z_TYPE_P(directory) == IS_ARRAY) { if (zephir_fast_count_int(directory TSRMLS_CC)) { zephir_is_iterable(directory, &_1, &_0, 0, 0, "phalcon/translate/adapter/gettext.zep", 181); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_CALL_FUNCTION(NULL, "bindtextdomain", &_3, 434, key, value); zephir_check_call_status(); } } } else { ZEPHIR_CALL_METHOD(&_4, this_ptr, "getdefaultdomain", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "bindtextdomain", &_3, 434, _4, directory); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getDirectory) { zval *directory; zephir_fetch_params(0, 1, 0, &directory); RETURN_MEMBER(this_ptr, "_directory"); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setLocale) { zval *locale = NULL; zval *category_param = NULL, *locale_param = NULL, *_0, *_1 = NULL, _2, *_3, *_4, *_5, _6; int category, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &category_param, &locale_param); category = zephir_get_intval(category_param); if (unlikely(Z_TYPE_P(locale_param) != IS_STRING && Z_TYPE_P(locale_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'locale' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(locale_param) == IS_STRING)) { zephir_get_strval(locale, locale_param); } else { ZEPHIR_INIT_VAR(locale); ZVAL_EMPTY_STRING(locale); } ZEPHIR_INIT_VAR(_0); ZEPHIR_CALL_FUNCTION(&_1, "func_get_args", NULL, 167); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "setlocale", 0); ZEPHIR_CALL_USER_FUNC_ARRAY(_0, &_2, _1); zephir_check_call_status(); zephir_update_property_this(this_ptr, SL("_locale"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_LONG(_3, category); zephir_update_property_this(this_ptr, SL("_category"), _3 TSRMLS_CC); _3 = zephir_fetch_nproperty_this(this_ptr, SL("_locale"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_SV(_4, "LC_ALL=", _3); ZEPHIR_CALL_FUNCTION(NULL, "putenv", NULL, 435, _4); zephir_check_call_status(); _5 = zephir_fetch_nproperty_this(this_ptr, SL("_locale"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_6); ZVAL_LONG(&_6, 0); ZEPHIR_CALL_FUNCTION(NULL, "setlocale", NULL, 415, &_6, _5); zephir_check_call_status(); RETURN_MM_MEMBER(this_ptr, "_locale"); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getLocale) { RETURN_MEMBER(this_ptr, "_locale"); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getCategory) { RETURN_MEMBER(this_ptr, "_category"); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, prepareOptions) { int ZEPHIR_LAST_CALL_STATUS; zval *options_param = NULL, *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; if (!(zephir_array_isset_string(options, SS("locale")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter \"locale\" is required", "phalcon/translate/adapter/gettext.zep", 231); return; } if (!(zephir_array_isset_string(options, SS("directory")))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter \"directory\" is required", "phalcon/translate/adapter/gettext.zep", 235); return; } ZEPHIR_INIT_VAR(_0); ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoptionsdefault", NULL, 0); zephir_check_call_status(); zephir_fast_array_merge(_0, &(_1), &(options) TSRMLS_CC); ZEPHIR_CPY_WRT(options, _0); zephir_array_fetch_string(&_2, options, SL("category"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/gettext.zep", 240 TSRMLS_CC); zephir_array_fetch_string(&_3, options, SL("locale"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/gettext.zep", 240 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setlocale", NULL, 0, _2, _3); zephir_check_call_status(); zephir_array_fetch_string(&_4, options, SL("defaultDomain"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/gettext.zep", 241 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultdomain", NULL, 0, _4); zephir_check_call_status(); zephir_array_fetch_string(&_5, options, SL("directory"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/gettext.zep", 242 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdirectory", NULL, 0, _5); zephir_check_call_status(); zephir_array_fetch_string(&_6, options, SL("defaultDomain"), PH_NOISY | PH_READONLY, "phalcon/translate/adapter/gettext.zep", 243 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdomain", NULL, 0, _6); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getOptionsDefault) { zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_long_ex(return_value, SS("category"), 0); add_assoc_stringl_ex(return_value, SS("defaultDomain"), SL("message"), 1); return; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_NativeArray) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, NativeArray, phalcon, translate_adapter_nativearray, phalcon_translate_adapter_ce, phalcon_translate_adapter_nativearray_method_entry, 0); zend_declare_property_null(phalcon_translate_adapter_nativearray_ce, SL("_translate"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_translate_adapter_nativearray_ce TSRMLS_CC, 1, phalcon_translate_adapterinterface_ce); zend_class_implements(phalcon_translate_adapter_nativearray_ce TSRMLS_CC, 1, zend_ce_arrayaccess); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *options_param = NULL, *data; zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &options_param); options = options_param; ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_nativearray_ce, this_ptr, "__construct", &_0, 426, options); zephir_check_call_status(); ZEPHIR_OBS_VAR(data); if (!(zephir_array_isset_string_fetch(&data, options, SS("content"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Translation content was not provided", "phalcon/translate/adapter/nativearray.zep", 46); return; } if (Z_TYPE_P(data) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Translation data must be an array", "phalcon/translate/adapter/nativearray.zep", 50); return; } zephir_update_property_this(this_ptr, SL("_translate"), data TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, query) { int ZEPHIR_LAST_CALL_STATUS; zval *index_param = NULL, *placeholders = NULL, *translation = NULL, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &index_param, &placeholders); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(translation); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_translate"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&translation, _0, index, 0 TSRMLS_CC))) { ZEPHIR_CPY_WRT(translation, index); } ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, translation, placeholders); zephir_check_call_status(); RETURN_MM(); } static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, exists) { zval *index_param = NULL, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(index_param) == IS_STRING)) { zephir_get_strval(index, index_param); } else { ZEPHIR_INIT_VAR(index); ZVAL_EMPTY_STRING(index); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_translate"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, index)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Interpolator_AssociativeArray) { ZEPHIR_REGISTER_CLASS(Phalcon\\Translate\\Interpolator, AssociativeArray, phalcon, translate_interpolator_associativearray, phalcon_translate_interpolator_associativearray_method_entry, 0); zend_class_implements(phalcon_translate_interpolator_associativearray_ce TSRMLS_CC, 1, phalcon_translate_interpolatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Interpolator_AssociativeArray, replacePlaceholders) { HashTable *_2; HashPosition _1; zend_bool _0; zval *translation_param = NULL, *placeholders = NULL, *key = NULL, *value = NULL, **_3, *_4 = NULL, *_5 = NULL; zval *translation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &translation_param, &placeholders); if (unlikely(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translation_param) == IS_STRING)) { zephir_get_strval(translation, translation_param); } else { ZEPHIR_INIT_VAR(translation); ZVAL_EMPTY_STRING(translation); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(placeholders) == IS_ARRAY; if (_0) { _0 = (zephir_fast_count_int(placeholders TSRMLS_CC)) ? 1 : 0; } if (_0) { zephir_is_iterable(placeholders, &_2, &_1, 0, 0, "phalcon/translate/interpolator/associativearray.zep", 38); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); ZEPHIR_INIT_NVAR(_4); ZEPHIR_INIT_LNVAR(_5); ZEPHIR_CONCAT_SVS(_5, "%", key, "%"); zephir_fast_str_replace(&_4, _5, value, translation TSRMLS_CC); zephir_get_strval(translation, _4); } } RETURN_CTOR(translation); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Translate_Interpolator_IndexedArray) { ZEPHIR_REGISTER_CLASS(Phalcon\\Translate\\Interpolator, IndexedArray, phalcon, translate_interpolator_indexedarray, phalcon_translate_interpolator_indexedarray_method_entry, 0); zend_class_implements(phalcon_translate_interpolator_indexedarray_ce TSRMLS_CC, 1, phalcon_translate_interpolatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Translate_Interpolator_IndexedArray, replacePlaceholders) { int ZEPHIR_LAST_CALL_STATUS; zend_bool _0; zval *translation_param = NULL, *placeholders = NULL, _1; zval *translation = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &translation_param, &placeholders); if (unlikely(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(translation_param) == IS_STRING)) { zephir_get_strval(translation, translation_param); } else { ZEPHIR_INIT_VAR(translation); ZVAL_EMPTY_STRING(translation); } if (!placeholders) { placeholders = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(placeholders) == IS_ARRAY; if (_0) { _0 = (zephir_fast_count_int(placeholders TSRMLS_CC)) ? 1 : 0; } if (_0) { ZEPHIR_MAKE_REF(placeholders); ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 380, placeholders, translation); ZEPHIR_UNREF(placeholders); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "sprintf", 0); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_1, placeholders); zephir_check_call_status(); RETURN_MM(); } RETURN_CTOR(translation); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Exception) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation, Exception, phalcon, validation_exception, phalcon_exception_ce, NULL, 0); return SUCCESS; } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Message) { ZEPHIR_REGISTER_CLASS(Phalcon\\Validation, Message, phalcon, validation_message, phalcon_validation_message_method_entry, 0); zend_declare_property_null(phalcon_validation_message_ce, SL("_type"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_message_ce, SL("_message"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_message_ce, SL("_field"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_message_ce, SL("_code"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_validation_message_ce TSRMLS_CC, 1, phalcon_validation_messageinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Message, __construct) { int code; zval *message_param = NULL, *field_param = NULL, *type_param = NULL, *code_param = NULL, *_0; zval *message = NULL, *field = NULL, *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &message_param, &field_param, &type_param, &code_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } if (!field_param) { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } else { zephir_get_strval(field, field_param); } if (!type_param) { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } else { zephir_get_strval(type, type_param); } if (!code_param) { code = 0; } else { code = zephir_get_intval(code_param); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_field"), field TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, code); zephir_update_property_this(this_ptr, SL("_code"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Validation_Message, setType) { zval *type_param = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &type_param); if (unlikely(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } zephir_update_property_this(this_ptr, SL("_type"), type TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation_Message, getType) { RETURN_MEMBER(this_ptr, "_type"); } static PHP_METHOD(Phalcon_Validation_Message, setMessage) { zval *message_param = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); if (unlikely(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(message_param) == IS_STRING)) { zephir_get_strval(message, message_param); } else { ZEPHIR_INIT_VAR(message); ZVAL_EMPTY_STRING(message); } zephir_update_property_this(this_ptr, SL("_message"), message TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation_Message, getMessage) { RETURN_MEMBER(this_ptr, "_message"); } static PHP_METHOD(Phalcon_Validation_Message, setField) { zval *field_param = NULL; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } zephir_update_property_this(this_ptr, SL("_field"), field TSRMLS_CC); RETURN_THIS(); } static PHP_METHOD(Phalcon_Validation_Message, getField) { RETURN_MEMBER(this_ptr, "_field"); } static PHP_METHOD(Phalcon_Validation_Message, setCode) { zval *code_param = NULL, *_0; int code; zephir_fetch_params(0, 1, 0, &code_param); code = zephir_get_intval(code_param); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, code); zephir_update_property_this(this_ptr, SL("_code"), _0 TSRMLS_CC); RETURN_THISW(); } static PHP_METHOD(Phalcon_Validation_Message, getCode) { RETURN_MEMBER(this_ptr, "_code"); } static PHP_METHOD(Phalcon_Validation_Message, __toString) { RETURN_MEMBER(this_ptr, "_message"); } static PHP_METHOD(Phalcon_Validation_Message, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *message_param = NULL, *_0, *_1, *_2; zval *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &message_param); message = message_param; object_init_ex(return_value, phalcon_validation_message_ce); zephir_array_fetch_string(&_0, message, SL("_message"), PH_NOISY | PH_READONLY, "phalcon/validation/message.zep", 134 TSRMLS_CC); zephir_array_fetch_string(&_1, message, SL("_field"), PH_NOISY | PH_READONLY, "phalcon/validation/message.zep", 134 TSRMLS_CC); zephir_array_fetch_string(&_2, message, SL("_type"), PH_NOISY | PH_READONLY, "phalcon/validation/message.zep", 134 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 436, _0, _1, _2); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_MessageInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Validation, MessageInterface, phalcon, validation_messageinterface, phalcon_validation_messageinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, __construct); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, setType); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, getType); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, setMessage); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, getMessage); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, setField); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, getField); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, __toString); ZEPHIR_DOC_METHOD(Phalcon_Validation_MessageInterface, __set_state); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator) { ZEPHIR_REGISTER_CLASS(Phalcon\\Validation, Validator, phalcon, validation_validator, phalcon_validation_validator_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_declare_property_null(phalcon_validation_validator_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_validation_validator_ce TSRMLS_CC, 1, phalcon_validation_validatorinterface_ce); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator, __construct) { zend_bool _0; zval *options = NULL; zephir_fetch_params(0, 0, 1, &options); if (!options) { options = ZEPHIR_GLOBAL(global_null); } _0 = Z_TYPE_P(options) != IS_ARRAY; if (_0) { _0 = Z_TYPE_P(options) != IS_NULL; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_validation_exception_ce, "Options must be an array", "phalcon/validation/validator.zep", 40); return; } else { zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); } } static PHP_METHOD(Phalcon_Validation_Validator, isSetOption) { zval *key_param = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, key)); } static PHP_METHOD(Phalcon_Validation_Validator, hasOption) { zval *key_param = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, key)); } static PHP_METHOD(Phalcon_Validation_Validator, getOption) { zval *key_param = NULL, *defaultValue = NULL, *options, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (zephir_array_isset_fetch(&value, options, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } static PHP_METHOD(Phalcon_Validation_Validator, setOption) { zval *key_param = NULL, *value; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &key_param, &value); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } zephir_update_property_array(this_ptr, SL("_options"), key, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Validation_Validator, validate) { } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_exceptions.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_ValidatorInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Validation, ValidatorInterface, phalcon, validation_validatorinterface, phalcon_validation_validatorinterface_method_entry); return SUCCESS; } ZEPHIR_DOC_METHOD(Phalcon_Validation_ValidatorInterface, isSetOption); ZEPHIR_DOC_METHOD(Phalcon_Validation_ValidatorInterface, hasOption); ZEPHIR_DOC_METHOD(Phalcon_Validation_ValidatorInterface, getOption); ZEPHIR_DOC_METHOD(Phalcon_Validation_ValidatorInterface, validate); #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Message_Group) { ZEPHIR_REGISTER_CLASS(Phalcon\\Validation\\Message, Group, phalcon, validation_message_group, phalcon_validation_message_group_method_entry, 0); zend_declare_property_null(phalcon_validation_message_group_ce, SL("_position"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_validation_message_group_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_validation_message_group_ce TSRMLS_CC, 1, spl_ce_Countable); zend_class_implements(phalcon_validation_message_group_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(phalcon_validation_message_group_ce TSRMLS_CC, 1, zend_ce_iterator); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Message_Group, __construct) { zval *messages = NULL; zephir_fetch_params(0, 0, 1, &messages); if (!messages) { messages = ZEPHIR_GLOBAL(global_null); } if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_update_property_this(this_ptr, SL("_messages"), messages TSRMLS_CC); } } static PHP_METHOD(Phalcon_Validation_Message_Group, offsetGet) { zval *index_param = NULL, *message, *_0; int index; zephir_fetch_params(0, 1, 0, &index_param); if (unlikely(Z_TYPE_P(index_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a int") TSRMLS_CC); RETURN_NULL(); } index = Z_LVAL_P(index_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (zephir_array_isset_long_fetch(&message, _0, index, 1 TSRMLS_CC)) { RETURN_CTORW(message); } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Validation_Message_Group, offsetSet) { zval *index_param = NULL, *message, *_0; int index; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &index_param, &message); if (unlikely(Z_TYPE_P(index_param) != IS_LONG)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be a int") TSRMLS_CC); RETURN_MM_NULL(); } index = Z_LVAL_P(index_param); if (Z_TYPE_P(message) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The message must be an object", "phalcon/validation/message/group.zep", 83); return; } ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, index); zephir_update_property_array(this_ptr, SL("_messages"), _0, message TSRMLS_CC); ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Validation_Message_Group, offsetExists) { zval *index_param = NULL, *_0; zval *index = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index_param); zephir_get_strval(index, index_param); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_0, index)); } static PHP_METHOD(Phalcon_Validation_Message_Group, offsetUnset) { zval *index, *_0, *_1; zephir_fetch_params(0, 1, 0, &index); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); if (zephir_array_isset(_0, index)) { _1 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); zephir_array_unset(&_1, index, PH_SEPARATE); } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Validation_Message_Group, appendMessage) { zval *message; zephir_fetch_params(0, 1, 0, &message); zephir_update_property_array_append(this_ptr, SL("_messages"), message TSRMLS_CC); } static PHP_METHOD(Phalcon_Validation_Message_Group, appendMessages) { zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; zend_object_iterator *_1; zend_bool _0; zval *messages, *currentMessages, *finalMessages = NULL, *message = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &messages); _0 = Z_TYPE_P(messages) != IS_ARRAY; if (_0) { _0 = Z_TYPE_P(messages) != IS_OBJECT; } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "The messages must be array or object", "phalcon/validation/message/group.zep", 146); return; } ZEPHIR_OBS_VAR(currentMessages); zephir_read_property_this(¤tMessages, this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(messages) == IS_ARRAY) { if (ZEPHIR_IS_STRING(currentMessages, "array")) { ZEPHIR_INIT_VAR(finalMessages); zephir_fast_array_merge(finalMessages, &(currentMessages), &(messages) TSRMLS_CC); } else { ZEPHIR_CPY_WRT(finalMessages, messages); } zephir_update_property_this(this_ptr, SL("_messages"), finalMessages TSRMLS_CC); } else { _1 = zephir_get_iterator(messages TSRMLS_CC); _1->funcs->rewind(_1 TSRMLS_CC); for (;_1->funcs->valid(_1 TSRMLS_CC) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1 TSRMLS_CC)) { { zval **ZEPHIR_TMP_ITERATOR_PTR; _1->funcs->get_current_data(_1, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); ZEPHIR_CPY_WRT(message, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_2, 0, message); zephir_check_call_status(); } _1->funcs->dtor(_1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); } static PHP_METHOD(Phalcon_Validation_Message_Group, filter) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *fieldName_param = NULL, *filtered, *messages, *message = NULL, **_2, *_3 = NULL; zval *fieldName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &fieldName_param); if (unlikely(Z_TYPE_P(fieldName_param) != IS_STRING && Z_TYPE_P(fieldName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fieldName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(fieldName_param) == IS_STRING)) { zephir_get_strval(fieldName, fieldName_param); } else { ZEPHIR_INIT_VAR(fieldName); ZVAL_EMPTY_STRING(fieldName); } ZEPHIR_INIT_VAR(filtered); array_init(filtered); ZEPHIR_OBS_VAR(messages); zephir_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(messages) == IS_ARRAY) { zephir_is_iterable(messages, &_1, &_0, 0, 0, "phalcon/validation/message/group.zep", 200); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(message, _2); if ((zephir_method_exists_ex(message, SS("getfield") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_3, message, "getfield", NULL, 0); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(fieldName, _3)) { zephir_array_append(&filtered, message, PH_SEPARATE, "phalcon/validation/message/group.zep", 196); } } } } RETURN_CCTOR(filtered); } static PHP_METHOD(Phalcon_Validation_Message_Group, count) { zval *_0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); RETURN_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } static PHP_METHOD(Phalcon_Validation_Message_Group, rewind) { zval *_0; ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, 0); zephir_update_property_this(this_ptr, SL("_position"), _0 TSRMLS_CC); } static PHP_METHOD(Phalcon_Validation_Message_Group, current) { zval *message, *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); if (zephir_array_isset_fetch(&message, _0, _1, 1 TSRMLS_CC)) { RETURN_CTORW(message); } RETURN_BOOL(0); } static PHP_METHOD(Phalcon_Validation_Message_Group, key) { RETURN_MEMBER(this_ptr, "_position"); } static PHP_METHOD(Phalcon_Validation_Message_Group, next) { RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("_position") TSRMLS_CC)); } static PHP_METHOD(Phalcon_Validation_Message_Group, valid) { zval *_0, *_1; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_position"), PH_NOISY_CC); RETURN_BOOL(zephir_array_isset(_0, _1)); } static PHP_METHOD(Phalcon_Validation_Message_Group, __set_state) { int ZEPHIR_LAST_CALL_STATUS; zval *group, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &group); object_init_ex(return_value, phalcon_validation_message_group_ce); zephir_array_fetch_string(&_0, group, SL("_messages"), PH_NOISY | PH_READONLY, "phalcon/validation/message/group.zep", 267 TSRMLS_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 3, _0); zephir_check_call_status(); RETURN_MM(); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Alnum) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Alnum, phalcon, validation_validator_alnum, phalcon_validation_validator_ce, phalcon_validation_validator_alnum_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Alnum, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_CALL_FUNCTION(&_3, "ctype_alnum", NULL, 437, value); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Alnum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Alnum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _4, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Alpha) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Alpha, phalcon, validation_validator_alpha, phalcon_validation_validator_ce, phalcon_validation_validator_alpha_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Alpha, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_CALL_FUNCTION(&_3, "ctype_alpha", NULL, 438, value); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Alpha", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Alpha", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _4, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Between) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Between, phalcon, validation_validator_between, phalcon_validation_validator_ce, phalcon_validation_validator_between_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Between, validate) { zend_bool _2, _3; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *minimum = NULL, *maximum = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "minimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "maximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _2 = zephir_is_true(_1); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } _3 = ZEPHIR_LT(value, minimum); if (!(_3)) { _3 = ZEPHIR_GT(value, maximum); } if (_3) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 3, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Between", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _4, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Confirmation) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Confirmation, phalcon, validation_validator_confirmation, phalcon_validation_validator_ce, phalcon_validation_validator_confirmation_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Confirmation, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *fieldWith = NULL, *value = NULL, *valueWith = NULL, *message = NULL, *label = NULL, *labelWith = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "with", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, fieldWith); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, this_ptr, "compare", NULL, 439, value, valueWith); zephir_check_call_status(); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "labelWith", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(labelWith)) { ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, fieldWith); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":with"), &labelWith, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "Confirmation", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _2, field, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Validation_Validator_Confirmation, compare) { zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *a_param = NULL, *b_param = NULL, *_0 = NULL, *_1, *_2, _3 = zval_used_for_init, *_4 = NULL, *_6 = NULL; zval *a = NULL, *b = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &a_param, &b_param); zephir_get_strval(a, a_param); zephir_get_strval(b, b_param); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "ignoreCase", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_BOOL(_2, 0); ZEPHIR_CALL_METHOD(&_0, this_ptr, "getoption", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(_0)) { if (!((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Extension 'mbstring' is required", "phalcon/validation/validator/confirmation.zep", 92); return; } ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "utf-8", 0); ZEPHIR_CALL_FUNCTION(&_4, "mb_strtolower", &_5, 195, a, &_3); zephir_check_call_status(); zephir_get_strval(a, _4); ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "utf-8", 0); ZEPHIR_CALL_FUNCTION(&_6, "mb_strtolower", &_5, 195, b, &_3); zephir_check_call_status(); zephir_get_strval(b, _6); } RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(a, b)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_CreditCard) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, CreditCard, phalcon, validation_validator_creditcard, phalcon_validation_validator_ce, phalcon_validation_validator_creditcard_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_CreditCard, validate) { int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *message = NULL, *label = NULL, *replacePairs, *value = NULL, *valid = NULL, *_0 = NULL, *_1 = NULL, *_2; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valid, this_ptr, "verifybyluhnalgorithm", NULL, 440, value); zephir_check_call_status(); if (!(zephir_is_true(valid))) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "CreditCard", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_1, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "CreditCard", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _1, field, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } static PHP_METHOD(Phalcon_Validation_Validator_CreditCard, verifyByLuhnAlgorithm) { HashTable *_6; HashPosition _5; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_1 = NULL; zval *digits = NULL, *_2 = NULL; zval *number, *_0 = NULL, *digit = NULL, *position = NULL, *hash, *_3 = NULL, *_4 = NULL, **_7, *_8 = NULL, *result = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &number); ZEPHIR_INIT_VAR(hash); ZVAL_STRING(hash, "", 1); ZEPHIR_CALL_FUNCTION(&_0, "str_split", &_1, 70, number); zephir_check_call_status(); zephir_get_arrval(_2, _0); ZEPHIR_CPY_WRT(digits, _2); ZEPHIR_CALL_FUNCTION(&_4, "array_reverse", NULL, 441, digits); zephir_check_call_status(); zephir_is_iterable(_4, &_6, &_5, 0, 0, "phalcon/validation/validator/creditcard.zep", 87); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HMKEY(position, _6, _5); ZEPHIR_GET_HVALUE(digit, _7); ZEPHIR_INIT_LNVAR(_8); if (zephir_safe_mod_zval_long(position, 2 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_8); ZVAL_LONG(_8, (zephir_get_numberval(digit) * 2)); } else { ZEPHIR_CPY_WRT(_8, digit); } zephir_concat_self(&hash, _8 TSRMLS_CC); } ZEPHIR_CALL_FUNCTION(&_9, "str_split", &_1, 70, hash); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&result, "array_sum", NULL, 442, _9); zephir_check_call_status(); RETURN_MM_BOOL((zephir_safe_mod_zval_long(result, 10 TSRMLS_CC) == 0)); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Digit) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Digit, phalcon, validation_validator_digit, phalcon_validation_validator_ce, phalcon_validation_validator_digit_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Digit, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_CALL_FUNCTION(&_3, "ctype_digit", NULL, 443, value); zephir_check_call_status(); if (!(zephir_is_true(_3))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Digit", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "Digit", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _4, field, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Email) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Email, phalcon, validation_validator_email, phalcon_validation_validator_ce, phalcon_validation_validator_email_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Email, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 274); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 192, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "Email", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _5, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_ExclusionIn) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, ExclusionIn, phalcon, validation_validator_exclusionin, phalcon_validation_validator_ce, phalcon_validation_validator_exclusionin_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_ExclusionIn, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *domain = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'domain' must be an array", "phalcon/validation/validator/exclusionin.zep", 62); return; } if (zephir_fast_in_array(value, domain TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":domain"), &_1, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ExclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_3, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "ExclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _3, field, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_File) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, File, phalcon, validation_validator_file, phalcon_validation_validator_ce, phalcon_validation_validator_file_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_File, validate) { zephir_fcall_cache_entry *_10 = NULL, *_12 = NULL, *_29 = NULL; zend_bool _2, _3, _4, _6, _7, _13, _14, _15, _17, _18, _20, _24, _25, _37, _38, _40; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs = NULL, *types = NULL, *byteUnits, *unit = NULL, *maxSize = NULL, *matches, *bytes, *mime = NULL, *tmp = NULL, *width, *height, *minResolution, *maxResolution, *minWidth = NULL, *maxWidth, *minHeight = NULL, *maxHeight, *_0 = NULL, *_SERVER, *_1, *_POST, *_FILES, *_5, *_8, *_9 = NULL, *_11 = NULL, *_16, *_19, *_21, *_22 = NULL, *_23 = NULL, *_26 = NULL, *_27, *_28, *_30 = NULL, *_31, _32 = zval_used_for_init, *_33, *_34 = NULL, *_35 = NULL, *_36, *_39 = NULL, *_41 = NULL; ZEPHIR_MM_GROW(); zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } zephir_array_fetch_string(&_1, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _2 = ZEPHIR_IS_STRING(_1, "POST"); if (_2) { _2 = ZEPHIR_IS_EMPTY(_POST); } _3 = _2; if (_3) { _3 = ZEPHIR_IS_EMPTY(_FILES); } _4 = _3; if (_4) { zephir_array_fetch_string(&_5, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _4 = ZEPHIR_GT_LONG(_5, 0); } _6 = _4; if (!(_6)) { _7 = zephir_array_isset_string(value, SS("error")); if (_7) { zephir_array_fetch_string(&_8, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 62 TSRMLS_CC); _7 = ZEPHIR_IS_LONG_IDENTICAL(_8, 1); } _6 = _7; } if (_6) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_11); ZVAL_STRING(_11, "FileIniSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_12, 436, _9, field, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _13 = zephir_is_true(_9); if (_13) { _14 = ZEPHIR_IS_EMPTY(value); if (!(_14)) { _15 = zephir_array_isset_string(value, SS("error")); if (_15) { zephir_array_fetch_string(&_16, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 75 TSRMLS_CC); _15 = ZEPHIR_IS_LONG_IDENTICAL(_16, 4); } _14 = _15; } _13 = _14; } if (_13) { RETURN_MM_BOOL(1); } _17 = !(zephir_array_isset_string(value, SS("error"))); if (!(_17)) { _17 = !(zephir_array_isset_string(value, SS("tmp_name"))); } _18 = _17; if (!(_18)) { zephir_array_fetch_string(&_19, value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); _18 = !ZEPHIR_IS_LONG_IDENTICAL(_19, 0); } _20 = _18; if (!(_20)) { zephir_array_fetch_string(&_21, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 79 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_9, "is_uploaded_file", NULL, 233, _21); zephir_check_call_status(); _20 = !zephir_is_true(_9); } if (_20) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_23); ZVAL_STRING(_23, "FileEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } _24 = !(zephir_array_isset_string(value, SS("name"))); if (!(_24)) { _24 = !(zephir_array_isset_string(value, SS("type"))); } _25 = _24; if (!(_25)) { _25 = !(zephir_array_isset_string(value, SS("size"))); } if (_25) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileValid", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _9, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_VAR(byteUnits); zephir_create_array(byteUnits, 9, 0 TSRMLS_CC); add_assoc_long_ex(byteUnits, SS("B"), 0); add_assoc_long_ex(byteUnits, SS("K"), 10); add_assoc_long_ex(byteUnits, SS("M"), 20); add_assoc_long_ex(byteUnits, SS("G"), 30); add_assoc_long_ex(byteUnits, SS("T"), 40); add_assoc_long_ex(byteUnits, SS("KB"), 10); add_assoc_long_ex(byteUnits, SS("MB"), 20); add_assoc_long_ex(byteUnits, SS("GB"), 30); add_assoc_long_ex(byteUnits, SS("TB"), 40); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_INIT_VAR(unit); ZVAL_STRING(unit, "B", 1); ZEPHIR_INIT_NVAR(_11); ZEPHIR_INIT_NVAR(_23); ZEPHIR_INIT_VAR(_26); zephir_array_keys(_26, byteUnits TSRMLS_CC); zephir_fast_join_str(_23, SL("|"), _26 TSRMLS_CC); ZEPHIR_INIT_VAR(_27); ZEPHIR_CONCAT_SVS(_27, "/^([0-9]+(?:\\.[0-9]+)?)(", _23, ")?$/Di"); zephir_preg_match(_11, _27, maxSize, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_array_isset_long(matches, 2)) { ZEPHIR_OBS_NVAR(unit); zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "phalcon/validation/validator/file.zep", 115 TSRMLS_CC); } zephir_array_fetch_long(&_28, matches, 1, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 304, _28); zephir_check_call_status(); ZEPHIR_INIT_VAR(_30); zephir_array_fetch(&_31, byteUnits, unit, PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 118 TSRMLS_CC); ZEPHIR_SINIT_VAR(_32); ZVAL_LONG(&_32, 2); zephir_pow_function(_30, &_32, _31); ZEPHIR_INIT_VAR(bytes); mul_function(bytes, _22, _30 TSRMLS_CC); zephir_array_fetch_string(&_33, value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 120 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&_22, "floatval", &_29, 304, _33); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_34, "floatval", &_29, 304, bytes); zephir_check_call_status(); if (ZEPHIR_GT(_22, _34)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "messageSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_30); ZVAL_STRING(_30, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _30); zephir_check_temp_parameter(_30); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_30); object_init_ex(_30, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_36); ZVAL_STRING(_36, "FileSize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _30, "__construct", &_12, 436, _35, field, _36); zephir_check_temp_parameter(_36); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _30); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_9)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (Z_TYPE_P(types) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/validation/validator/file.zep", 138); return; } if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) { ZEPHIR_SINIT_NVAR(_32); ZVAL_LONG(&_32, 16); ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 230, &_32); zephir_check_call_status(); zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 143 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 231, tmp, _28); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 232, tmp); zephir_check_call_status(); } else { ZEPHIR_OBS_NVAR(mime); zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "phalcon/validation/validator/file.zep", 147 TSRMLS_CC); } if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); zephir_fast_join_str(_11, SL(", "), types TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":types"), &_11, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_22, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileType", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _22, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } } ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_9, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_9); if (!(_37)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_22, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); _37 = zephir_is_true(_22); } if (_37) { zephir_array_fetch_string(&_28, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/file.zep", 164 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 241, _28); zephir_check_call_status(); ZEPHIR_OBS_VAR(width); zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 165 TSRMLS_CC); ZEPHIR_OBS_VAR(height); zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 166 TSRMLS_CC); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_34, this_ptr, "issetoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); if (zephir_is_true(_34)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_VAR(minResolution); zephir_fast_explode_str(minResolution, SL("x"), _35, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(minWidth); zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 170 TSRMLS_CC); ZEPHIR_OBS_VAR(minHeight); zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 171 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(minWidth); ZVAL_LONG(minWidth, 1); ZEPHIR_INIT_NVAR(minHeight); ZVAL_LONG(minHeight, 1); } _38 = ZEPHIR_LT(width, minWidth); if (!(_38)) { _38 = ZEPHIR_LT(height, minHeight); } if (_38) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "minResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "getoption", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":min"), &_35, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_11); ZVAL_STRING(_11, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _11); zephir_check_temp_parameter(_11); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_35, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMinResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_12, 436, _35, field, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _11); zephir_check_call_status(); RETURN_MM_BOOL(0); } ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_35, this_ptr, "issetoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); if (zephir_is_true(_35)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_VAR(maxResolution); zephir_fast_explode_str(maxResolution, SL("x"), _39, LONG_MAX TSRMLS_CC); ZEPHIR_OBS_VAR(maxWidth); zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "phalcon/validation/validator/file.zep", 192 TSRMLS_CC); ZEPHIR_OBS_VAR(maxHeight); zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "phalcon/validation/validator/file.zep", 193 TSRMLS_CC); _40 = ZEPHIR_GT(width, maxWidth); if (!(_40)) { _40 = ZEPHIR_GT(height, maxHeight); } if (_40) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "maxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_41, this_ptr, "getoption", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); zephir_array_update_string(&replacePairs, SL(":max"), &_41, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_23); ZVAL_STRING(_23, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _23); zephir_check_temp_parameter(_23); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_23); object_init_ex(_23, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_41, "strtr", &_10, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_26); ZVAL_STRING(_26, "FileMaxResolution", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _23, "__construct", &_12, 436, _41, field, _26); zephir_check_temp_parameter(_26); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _23); zephir_check_call_status(); RETURN_MM_BOOL(0); } } } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Identical) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Identical, phalcon, validation_validator_identical, phalcon_validation_validator_ce, phalcon_validation_validator_identical_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Identical, validate) { int ZEPHIR_LAST_CALL_STATUS; zend_bool valid; zval *field = NULL; zval *validation, *field_param = NULL, *message = NULL, *label = NULL, *replacePairs, *value = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "accepted", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "accepted", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); valid = ZEPHIR_IS_EQUAL(value, _2); } else { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "value", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "hasoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(_2)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "value", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); valid = ZEPHIR_IS_EQUAL(value, _3); } } if (!(valid)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Identical", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "Identical", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _2, field, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_InclusionIn) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, InclusionIn, phalcon, validation_validator_inclusionin, phalcon_validation_validator_ce, phalcon_validation_validator_inclusionin_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_InclusionIn, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *domain = NULL, *message = NULL, *label = NULL, *replacePairs, *strict = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "domain", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(domain) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'domain' must be an array", "phalcon/validation/validator/inclusionin.zep", 62); return; } ZEPHIR_INIT_VAR(strict); ZVAL_BOOL(strict, 0); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(_3)) { if (Z_TYPE_P(strict) != IS_BOOL) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Option 'strict' must be a boolean", "phalcon/validation/validator/inclusionin.zep", 68); return; } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "strict", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_CALL_FUNCTION(&_4, "in_array", NULL, 359, value, domain, strict); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_1); zephir_fast_join_str(_1, SL(", "), domain TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":domain"), &_1, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "InclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "InclusionIn", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _5, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Numericality) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Numericality, phalcon, validation_validator_numericality, phalcon_validation_validator_ce, phalcon_validation_validator_numericality_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Numericality, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3, _4, *_5 = NULL, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_VAR(_3); ZEPHIR_INIT_NVAR(_1); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "/^-?\\d+\\.?\\d*$/", 0); zephir_preg_match(_1, &_4, value, _3, 0, 0 , 0 TSRMLS_CC); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_VAR(_5); ZVAL_STRING(_5, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "Numericality", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _5); zephir_check_temp_parameter(_5); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Numericality", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 436, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _5); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_PresenceOf) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, PresenceOf, phalcon, validation_validator_presenceof, phalcon_validation_validator_ce, phalcon_validation_validator_presenceof_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_PresenceOf, validate) { zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_1 = NULL, *_2 = NULL, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); _0 = Z_TYPE_P(value) == IS_NULL; if (!(_0)) { _0 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); } if (_0) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "PresenceOf", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "PresenceOf", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _2, field, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Regex) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Regex, phalcon, validation_validator_regex, phalcon_validation_validator_ce, phalcon_validation_validator_regex_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Regex, validate) { int ZEPHIR_LAST_CALL_STATUS; zend_bool failed, _2; zval *field = NULL; zval *validation, *field_param = NULL, *matches, *message = NULL, *value = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(matches); ZVAL_NULL(matches); ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "pattern", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); zephir_preg_match(_1, _3, value, matches, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_1)) { zephir_array_fetch_long(&_5, matches, 0, PH_NOISY | PH_READONLY, "phalcon/validation/validator/regex.zep", 62 TSRMLS_CC); failed = !ZEPHIR_IS_EQUAL(_5, value); } else { failed = 1; } if (failed == 1) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4); zephir_check_temp_parameter(_4); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_4); object_init_ex(_4, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Regex", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, 436, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _4); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_StringLength) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, StringLength, phalcon, validation_validator_stringlength, phalcon_validation_validator_ce, phalcon_validation_validator_stringlength_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_StringLength, validate) { zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; zend_bool _1, _3; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *isSetMin = NULL, *isSetMax = NULL, *value = NULL, *length = NULL, *message = NULL, *minimum = NULL, *maximum = NULL, *label = NULL, *replacePairs = NULL, *_0 = NULL, *_2 = NULL, *_4 = NULL, *_6 = NULL, *_8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMin, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&isSetMax, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _1 = !zephir_is_true(isSetMin); if (_1) { _1 = !zephir_is_true(isSetMax); } if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A minimum or maximum must be set", "phalcon/validation/validator/stringlength.zep", 62); return; } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_2, this_ptr, "issetoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); _3 = zephir_is_true(_2); if (_3) { _3 = ZEPHIR_IS_EMPTY(value); } if (_3) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 360, value); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(length); ZVAL_LONG(length, zephir_fast_strlen_ev(value)); } if (zephir_is_true(isSetMax)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "max", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_GT(length, maximum)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "messageMaximum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", &_5, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "TooLong", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_7, 436, _4, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } } if (zephir_is_true(isSetMin)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "min", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); if (ZEPHIR_LT(length, minimum)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "messageMinimum", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(replacePairs); zephir_create_array(replacePairs, 2, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_6); ZVAL_STRING(_6, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_4, "strtr", &_5, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_8); ZVAL_STRING(_8, "TooShort", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_7, 436, _4, field, _8); zephir_check_temp_parameter(_8); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _6); zephir_check_call_status(); RETURN_MM_BOOL(0); } } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Uniqueness) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Uniqueness, phalcon, validation_validator_uniqueness, phalcon_validation_validator_ce, phalcon_validation_validator_uniqueness_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Uniqueness, validate) { zend_class_entry *_4, *_5; zval *_1 = NULL, *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *attribute = NULL, *value = NULL, *model = NULL, *except = NULL, *number = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_2 = NULL, *_6 = NULL, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "model", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&model, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "attribute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "except", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&except, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(model)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Model must be set", "phalcon/validation/validator/uniqueness.zep", 65); return; } if (ZEPHIR_IS_EMPTY(attribute)) { ZEPHIR_CPY_WRT(attribute, field); } if (zephir_is_true(except)) { ZEPHIR_INIT_VAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSVS(_2, attribute, " = :value: AND ", attribute, " != :except:"); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("value"), &value, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_3, SL("except"), &except, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("bind"), &_3, PH_COPY | PH_SEPARATE); _4 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&number, _4, "count", NULL, 0, _1); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_2); ZEPHIR_CONCAT_VS(_2, attribute, " = :value:"); zephir_array_fast_append(_1, _2); ZEPHIR_INIT_NVAR(_3); zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("value"), &value, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_1, SL("bind"), &_3, PH_COPY | PH_SEPARATE); _5 = zephir_fetch_class(model TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&number, _5, "count", NULL, 0, _1); zephir_check_call_status(); } if (zephir_is_true(number)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Uniqueness", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_0); object_init_ex(_0, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "Uniqueness", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 436, _6, field, _7); zephir_check_temp_parameter(_7); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _0); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } #ifdef HAVE_CONFIG_H #endif #include <php.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> ZEPHIR_INIT_CLASS(Phalcon_Validation_Validator_Url) { ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Validation\\Validator, Url, phalcon, validation_validator_url, phalcon_validation_validator_ce, phalcon_validation_validator_url_method_entry, 0); return SUCCESS; } static PHP_METHOD(Phalcon_Validation_Validator_Url, validate) { zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; zval *field = NULL; zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *replacePairs, *_0 = NULL, *_1 = NULL, _3, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &validation, &field_param); if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(field_param) == IS_STRING)) { zephir_get_strval(field, field_param); } else { ZEPHIR_INIT_VAR(field); ZVAL_EMPTY_STRING(field); } ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_0, this_ptr, "issetoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { _2 = ZEPHIR_IS_EMPTY(value); } if (_2) { RETURN_MM_BOOL(1); } ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, 273); ZEPHIR_CALL_FUNCTION(&_4, "filter_var", NULL, 192, value, &_3); zephir_check_call_status(); if (!(zephir_is_true(_4))) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(label)) { ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, this_ptr, "getoption", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(replacePairs); zephir_create_array(replacePairs, 1, 0 TSRMLS_CC); zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); if (ZEPHIR_IS_EMPTY(message)) { ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, phalcon_validation_message_ce); ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 54, message, replacePairs); zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); ZVAL_STRING(_6, "Url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 436, _5, field, _6); zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, _1); zephir_check_call_status(); RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); } /* This file was generated automatically by Zephir do not modify it! */ #ifdef HAVE_CONFIG_H #endif #include <php.h> #if PHP_VERSION_ID < 50500 #include <locale.h> #endif #include <ext/standard/info.h> #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> zend_class_entry *phalcon_di_injectionawareinterface_ce; zend_class_entry *phalcon_events_eventsawareinterface_ce; zend_class_entry *phalcon_forms_elementinterface_ce; zend_class_entry *phalcon_validation_validatorinterface_ce; zend_class_entry *phalcon_mvc_model_validatorinterface_ce; zend_class_entry *phalcon_cache_backendinterface_ce; zend_class_entry *phalcon_mvc_model_metadatainterface_ce; zend_class_entry *phalcon_cache_frontendinterface_ce; zend_class_entry *phalcon_db_dialectinterface_ce; zend_class_entry *phalcon_dispatcherinterface_ce; zend_class_entry *phalcon_annotations_adapterinterface_ce; zend_class_entry *phalcon_db_adapterinterface_ce; zend_class_entry *phalcon_logger_adapterinterface_ce; zend_class_entry *phalcon_logger_formatterinterface_ce; zend_class_entry *phalcon_mvc_entityinterface_ce; zend_class_entry *phalcon_mvc_model_resultsetinterface_ce; zend_class_entry *phalcon_session_adapterinterface_ce; zend_class_entry *phalcon_assets_filterinterface_ce; zend_class_entry *phalcon_diinterface_ce; zend_class_entry *phalcon_mvc_viewbaseinterface_ce; zend_class_entry *phalcon_paginator_adapterinterface_ce; zend_class_entry *phalcon_translate_adapterinterface_ce; zend_class_entry *phalcon_acl_adapterinterface_ce; zend_class_entry *phalcon_flashinterface_ce; zend_class_entry *phalcon_image_adapterinterface_ce; zend_class_entry *phalcon_mvc_collection_behaviorinterface_ce; zend_class_entry *phalcon_mvc_model_behaviorinterface_ce; zend_class_entry *phalcon_mvc_model_metadata_strategyinterface_ce; zend_class_entry *phalcon_mvc_model_resultinterface_ce; zend_class_entry *phalcon_mvc_routerinterface_ce; zend_class_entry *phalcon_mvc_view_engineinterface_ce; zend_class_entry *phalcon_translate_interpolatorinterface_ce; zend_class_entry *phalcon_acl_roleinterface_ce; zend_class_entry *phalcon_annotations_readerinterface_ce; zend_class_entry *phalcon_cryptinterface_ce; zend_class_entry *phalcon_db_columninterface_ce; zend_class_entry *phalcon_db_indexinterface_ce; zend_class_entry *phalcon_db_referenceinterface_ce; zend_class_entry *phalcon_db_resultinterface_ce; zend_class_entry *phalcon_di_serviceinterface_ce; zend_class_entry *phalcon_escaperinterface_ce; zend_class_entry *phalcon_events_managerinterface_ce; zend_class_entry *phalcon_filterinterface_ce; zend_class_entry *phalcon_http_cookieinterface_ce; zend_class_entry *phalcon_http_request_fileinterface_ce; zend_class_entry *phalcon_http_requestinterface_ce; zend_class_entry *phalcon_http_response_cookiesinterface_ce; zend_class_entry *phalcon_http_response_headersinterface_ce; zend_class_entry *phalcon_http_responseinterface_ce; zend_class_entry *phalcon_mvc_collectioninterface_ce; zend_class_entry *phalcon_mvc_controllerinterface_ce; zend_class_entry *phalcon_mvc_dispatcherinterface_ce; zend_class_entry *phalcon_mvc_micro_collectioninterface_ce; zend_class_entry *phalcon_mvc_model_criteriainterface_ce; zend_class_entry *phalcon_mvc_model_managerinterface_ce; zend_class_entry *phalcon_mvc_model_messageinterface_ce; zend_class_entry *phalcon_mvc_model_query_builderinterface_ce; zend_class_entry *phalcon_mvc_model_query_statusinterface_ce; zend_class_entry *phalcon_mvc_model_queryinterface_ce; zend_class_entry *phalcon_mvc_model_relationinterface_ce; zend_class_entry *phalcon_mvc_model_transaction_managerinterface_ce; zend_class_entry *phalcon_mvc_model_transactioninterface_ce; zend_class_entry *phalcon_mvc_modelinterface_ce; zend_class_entry *phalcon_mvc_router_groupinterface_ce; zend_class_entry *phalcon_mvc_router_routeinterface_ce; zend_class_entry *phalcon_mvc_urlinterface_ce; zend_class_entry *phalcon_mvc_viewinterface_ce; zend_class_entry *phalcon_session_baginterface_ce; zend_class_entry *phalcon_validation_messageinterface_ce; zend_class_entry *phalcon_acl_resourceinterface_ce; zend_class_entry *phalcon_filter_userfilterinterface_ce; zend_class_entry *phalcon_mvc_collection_managerinterface_ce; zend_class_entry *phalcon_mvc_micro_middlewareinterface_ce; zend_class_entry *phalcon_mvc_moduledefinitioninterface_ce; zend_class_entry *phalcon_exception_ce; zend_class_entry *phalcon_validation_validator_ce; zend_class_entry *phalcon_di_injectable_ce; zend_class_entry *phalcon_forms_element_ce; zend_class_entry *phalcon_mvc_model_validator_ce; zend_class_entry *phalcon_cache_backend_ce; zend_class_entry *phalcon_mvc_model_metadata_ce; zend_class_entry *phalcon_db_adapter_ce; zend_class_entry *phalcon_annotations_adapter_ce; zend_class_entry *phalcon_config_ce; zend_class_entry *phalcon_db_adapter_pdo_ce; zend_class_entry *phalcon_db_dialect_ce; zend_class_entry *phalcon_logger_adapter_ce; zend_class_entry *phalcon_logger_formatter_ce; zend_class_entry *phalcon_session_adapter_ce; zend_class_entry *phalcon_mvc_model_exception_ce; zend_class_entry *phalcon_paginator_adapter_ce; zend_class_entry *phalcon_translate_adapter_ce; zend_class_entry *phalcon_assets_inline_ce; zend_class_entry *phalcon_assets_resource_ce; zend_class_entry *phalcon_di_ce; zend_class_entry *phalcon_dispatcher_ce; zend_class_entry *phalcon_flash_ce; zend_class_entry *phalcon_image_adapter_ce; zend_class_entry *phalcon_mvc_collection_behavior_ce; zend_class_entry *phalcon_mvc_model_behavior_ce; zend_class_entry *phalcon_mvc_model_resultset_ce; zend_class_entry *phalcon_mvc_view_engine_ce; zend_class_entry *phalcon_acl_adapter_ce; zend_class_entry *phalcon_cache_frontend_data_ce; zend_class_entry *phalcon_di_factorydefault_ce; zend_class_entry *phalcon_mvc_model_transaction_exception_ce; zend_class_entry *phalcon_mvc_router_ce; zend_class_entry *phalcon_mvc_view_exception_ce; zend_class_entry *phalcon_0__closure_ce; zend_class_entry *phalcon_acl_adapter_memory_ce; zend_class_entry *phalcon_acl_ce; zend_class_entry *phalcon_acl_exception_ce; zend_class_entry *phalcon_acl_resource_ce; zend_class_entry *phalcon_acl_role_ce; zend_class_entry *phalcon_annotations_adapter_apc_ce; zend_class_entry *phalcon_annotations_adapter_files_ce; zend_class_entry *phalcon_annotations_adapter_memory_ce; zend_class_entry *phalcon_annotations_adapter_xcache_ce; zend_class_entry *phalcon_annotations_annotation_ce; zend_class_entry *phalcon_annotations_collection_ce; zend_class_entry *phalcon_annotations_exception_ce; zend_class_entry *phalcon_annotations_reader_ce; zend_class_entry *phalcon_annotations_reflection_ce; zend_class_entry *phalcon_assets_collection_ce; zend_class_entry *phalcon_assets_exception_ce; zend_class_entry *phalcon_assets_filters_cssmin_ce; zend_class_entry *phalcon_assets_filters_jsmin_ce; zend_class_entry *phalcon_assets_filters_none_ce; zend_class_entry *phalcon_assets_inline_css_ce; zend_class_entry *phalcon_assets_inline_js_ce; zend_class_entry *phalcon_assets_manager_ce; zend_class_entry *phalcon_assets_resource_css_ce; zend_class_entry *phalcon_assets_resource_js_ce; zend_class_entry *phalcon_cache_backend_apc_ce; zend_class_entry *phalcon_cache_backend_file_ce; zend_class_entry *phalcon_cache_backend_libmemcached_ce; zend_class_entry *phalcon_cache_backend_memcache_ce; zend_class_entry *phalcon_cache_backend_memory_ce; zend_class_entry *phalcon_cache_backend_mongo_ce; zend_class_entry *phalcon_cache_backend_redis_ce; zend_class_entry *phalcon_cache_backend_xcache_ce; zend_class_entry *phalcon_cache_exception_ce; zend_class_entry *phalcon_cache_frontend_base64_ce; zend_class_entry *phalcon_cache_frontend_igbinary_ce; zend_class_entry *phalcon_cache_frontend_json_ce; zend_class_entry *phalcon_cache_frontend_none_ce; zend_class_entry *phalcon_cache_frontend_output_ce; zend_class_entry *phalcon_cache_multiple_ce; zend_class_entry *phalcon_cli_console_ce; zend_class_entry *phalcon_cli_console_exception_ce; zend_class_entry *phalcon_cli_dispatcher_ce; zend_class_entry *phalcon_cli_dispatcher_exception_ce; zend_class_entry *phalcon_cli_router_ce; zend_class_entry *phalcon_cli_router_exception_ce; zend_class_entry *phalcon_cli_router_route_ce; zend_class_entry *phalcon_cli_task_ce; zend_class_entry *phalcon_config_adapter_ini_ce; zend_class_entry *phalcon_config_adapter_json_ce; zend_class_entry *phalcon_config_adapter_php_ce; zend_class_entry *phalcon_config_adapter_yaml_ce; zend_class_entry *phalcon_config_exception_ce; zend_class_entry *phalcon_crypt_ce; zend_class_entry *phalcon_crypt_exception_ce; zend_class_entry *phalcon_db_adapter_pdo_mysql_ce; zend_class_entry *phalcon_db_adapter_pdo_oracle_ce; zend_class_entry *phalcon_db_adapter_pdo_postgresql_ce; zend_class_entry *phalcon_db_adapter_pdo_sqlite_ce; zend_class_entry *phalcon_db_ce; zend_class_entry *phalcon_db_column_ce; zend_class_entry *phalcon_db_dialect_mysql_ce; zend_class_entry *phalcon_db_dialect_oracle_ce; zend_class_entry *phalcon_db_dialect_postgresql_ce; zend_class_entry *phalcon_db_dialect_sqlite_ce; zend_class_entry *phalcon_db_exception_ce; zend_class_entry *phalcon_db_index_ce; zend_class_entry *phalcon_db_profiler_ce; zend_class_entry *phalcon_db_profiler_item_ce; zend_class_entry *phalcon_db_rawvalue_ce; zend_class_entry *phalcon_db_reference_ce; zend_class_entry *phalcon_db_result_pdo_ce; zend_class_entry *phalcon_debug_ce; zend_class_entry *phalcon_debug_dump_ce; zend_class_entry *phalcon_debug_exception_ce; zend_class_entry *phalcon_di_exception_ce; zend_class_entry *phalcon_di_factorydefault_cli_ce; zend_class_entry *phalcon_di_service_builder_ce; zend_class_entry *phalcon_di_service_ce; zend_class_entry *phalcon_escaper_ce; zend_class_entry *phalcon_escaper_exception_ce; zend_class_entry *phalcon_events_event_ce; zend_class_entry *phalcon_events_exception_ce; zend_class_entry *phalcon_events_manager_ce; zend_class_entry *phalcon_filter_ce; zend_class_entry *phalcon_filter_exception_ce; zend_class_entry *phalcon_flash_direct_ce; zend_class_entry *phalcon_flash_exception_ce; zend_class_entry *phalcon_flash_session_ce; zend_class_entry *phalcon_forms_element_check_ce; zend_class_entry *phalcon_forms_element_date_ce; zend_class_entry *phalcon_forms_element_email_ce; zend_class_entry *phalcon_forms_element_file_ce; zend_class_entry *phalcon_forms_element_hidden_ce; zend_class_entry *phalcon_forms_element_numeric_ce; zend_class_entry *phalcon_forms_element_password_ce; zend_class_entry *phalcon_forms_element_radio_ce; zend_class_entry *phalcon_forms_element_select_ce; zend_class_entry *phalcon_forms_element_submit_ce; zend_class_entry *phalcon_forms_element_text_ce; zend_class_entry *phalcon_forms_element_textarea_ce; zend_class_entry *phalcon_forms_exception_ce; zend_class_entry *phalcon_forms_form_ce; zend_class_entry *phalcon_forms_manager_ce; zend_class_entry *phalcon_http_cookie_ce; zend_class_entry *phalcon_http_cookie_exception_ce; zend_class_entry *phalcon_http_request_ce; zend_class_entry *phalcon_http_request_exception_ce; zend_class_entry *phalcon_http_request_file_ce; zend_class_entry *phalcon_http_response_ce; zend_class_entry *phalcon_http_response_cookies_ce; zend_class_entry *phalcon_http_response_exception_ce; zend_class_entry *phalcon_http_response_headers_ce; zend_class_entry *phalcon_image_adapter_gd_ce; zend_class_entry *phalcon_image_adapter_imagick_ce; zend_class_entry *phalcon_image_ce; zend_class_entry *phalcon_image_exception_ce; zend_class_entry *phalcon_kernel_ce; zend_class_entry *phalcon_loader_ce; zend_class_entry *phalcon_loader_exception_ce; zend_class_entry *phalcon_logger_adapter_file_ce; zend_class_entry *phalcon_logger_adapter_firephp_ce; zend_class_entry *phalcon_logger_adapter_stream_ce; zend_class_entry *phalcon_logger_adapter_syslog_ce; zend_class_entry *phalcon_logger_ce; zend_class_entry *phalcon_logger_exception_ce; zend_class_entry *phalcon_logger_formatter_firephp_ce; zend_class_entry *phalcon_logger_formatter_json_ce; zend_class_entry *phalcon_logger_formatter_line_ce; zend_class_entry *phalcon_logger_formatter_syslog_ce; zend_class_entry *phalcon_logger_item_ce; zend_class_entry *phalcon_logger_multiple_ce; zend_class_entry *phalcon_mvc_application_ce; zend_class_entry *phalcon_mvc_application_exception_ce; zend_class_entry *phalcon_mvc_collection_behavior_softdelete_ce; zend_class_entry *phalcon_mvc_collection_behavior_timestampable_ce; zend_class_entry *phalcon_mvc_collection_ce; zend_class_entry *phalcon_mvc_collection_document_ce; zend_class_entry *phalcon_mvc_collection_exception_ce; zend_class_entry *phalcon_mvc_collection_manager_ce; zend_class_entry *phalcon_mvc_controller_ce; zend_class_entry *phalcon_mvc_dispatcher_ce; zend_class_entry *phalcon_mvc_dispatcher_exception_ce; zend_class_entry *phalcon_mvc_micro_ce; zend_class_entry *phalcon_mvc_micro_collection_ce; zend_class_entry *phalcon_mvc_micro_exception_ce; zend_class_entry *phalcon_mvc_micro_lazyloader_ce; zend_class_entry *phalcon_mvc_model_behavior_softdelete_ce; zend_class_entry *phalcon_mvc_model_behavior_timestampable_ce; zend_class_entry *phalcon_mvc_model_ce; zend_class_entry *phalcon_mvc_model_criteria_ce; zend_class_entry *phalcon_mvc_model_manager_ce; zend_class_entry *phalcon_mvc_model_message_ce; zend_class_entry *phalcon_mvc_model_metadata_apc_ce; zend_class_entry *phalcon_mvc_model_metadata_files_ce; zend_class_entry *phalcon_mvc_model_metadata_libmemcached_ce; zend_class_entry *phalcon_mvc_model_metadata_memcache_ce; zend_class_entry *phalcon_mvc_model_metadata_memory_ce; zend_class_entry *phalcon_mvc_model_metadata_redis_ce; zend_class_entry *phalcon_mvc_model_metadata_session_ce; zend_class_entry *phalcon_mvc_model_metadata_strategy_annotations_ce; zend_class_entry *phalcon_mvc_model_metadata_strategy_introspection_ce; zend_class_entry *phalcon_mvc_model_metadata_xcache_ce; zend_class_entry *phalcon_mvc_model_query_builder_ce; zend_class_entry *phalcon_mvc_model_query_ce; zend_class_entry *phalcon_mvc_model_query_lang_ce; zend_class_entry *phalcon_mvc_model_query_status_ce; zend_class_entry *phalcon_mvc_model_relation_ce; zend_class_entry *phalcon_mvc_model_resultset_complex_ce; zend_class_entry *phalcon_mvc_model_resultset_simple_ce; zend_class_entry *phalcon_mvc_model_row_ce; zend_class_entry *phalcon_mvc_model_transaction_ce; zend_class_entry *phalcon_mvc_model_transaction_failed_ce; zend_class_entry *phalcon_mvc_model_transaction_manager_ce; zend_class_entry *phalcon_mvc_model_validationfailed_ce; zend_class_entry *phalcon_mvc_model_validator_email_ce; zend_class_entry *phalcon_mvc_model_validator_exclusionin_ce; zend_class_entry *phalcon_mvc_model_validator_inclusionin_ce; zend_class_entry *phalcon_mvc_model_validator_ip_ce; zend_class_entry *phalcon_mvc_model_validator_numericality_ce; zend_class_entry *phalcon_mvc_model_validator_presenceof_ce; zend_class_entry *phalcon_mvc_model_validator_regex_ce; zend_class_entry *phalcon_mvc_model_validator_stringlength_ce; zend_class_entry *phalcon_mvc_model_validator_uniqueness_ce; zend_class_entry *phalcon_mvc_model_validator_url_ce; zend_class_entry *phalcon_mvc_router_annotations_ce; zend_class_entry *phalcon_mvc_router_exception_ce; zend_class_entry *phalcon_mvc_router_group_ce; zend_class_entry *phalcon_mvc_router_route_ce; zend_class_entry *phalcon_mvc_url_ce; zend_class_entry *phalcon_mvc_url_exception_ce; zend_class_entry *phalcon_mvc_user_component_ce; zend_class_entry *phalcon_mvc_user_module_ce; zend_class_entry *phalcon_mvc_user_plugin_ce; zend_class_entry *phalcon_mvc_view_ce; zend_class_entry *phalcon_mvc_view_engine_php_ce; zend_class_entry *phalcon_mvc_view_engine_volt_ce; zend_class_entry *phalcon_mvc_view_engine_volt_compiler_ce; zend_class_entry *phalcon_mvc_view_engine_volt_exception_ce; zend_class_entry *phalcon_mvc_view_simple_ce; zend_class_entry *phalcon_paginator_adapter_model_ce; zend_class_entry *phalcon_paginator_adapter_nativearray_ce; zend_class_entry *phalcon_paginator_adapter_querybuilder_ce; zend_class_entry *phalcon_paginator_exception_ce; zend_class_entry *phalcon_queue_beanstalk_ce; zend_class_entry *phalcon_queue_beanstalk_job_ce; zend_class_entry *phalcon_registry_ce; zend_class_entry *phalcon_security_ce; zend_class_entry *phalcon_security_exception_ce; zend_class_entry *phalcon_security_random_ce; zend_class_entry *phalcon_session_adapter_files_ce; zend_class_entry *phalcon_session_adapter_libmemcached_ce; zend_class_entry *phalcon_session_adapter_memcache_ce; zend_class_entry *phalcon_session_adapter_redis_ce; zend_class_entry *phalcon_session_bag_ce; zend_class_entry *phalcon_session_ce; zend_class_entry *phalcon_session_exception_ce; zend_class_entry *phalcon_tag_ce; zend_class_entry *phalcon_tag_exception_ce; zend_class_entry *phalcon_tag_select_ce; zend_class_entry *phalcon_text_ce; zend_class_entry *phalcon_translate_adapter_csv_ce; zend_class_entry *phalcon_translate_adapter_gettext_ce; zend_class_entry *phalcon_translate_adapter_nativearray_ce; zend_class_entry *phalcon_translate_ce; zend_class_entry *phalcon_translate_exception_ce; zend_class_entry *phalcon_translate_interpolator_associativearray_ce; zend_class_entry *phalcon_translate_interpolator_indexedarray_ce; zend_class_entry *phalcon_validation_ce; zend_class_entry *phalcon_validation_exception_ce; zend_class_entry *phalcon_validation_message_ce; zend_class_entry *phalcon_validation_message_group_ce; zend_class_entry *phalcon_validation_validator_alnum_ce; zend_class_entry *phalcon_validation_validator_alpha_ce; zend_class_entry *phalcon_validation_validator_between_ce; zend_class_entry *phalcon_validation_validator_confirmation_ce; zend_class_entry *phalcon_validation_validator_creditcard_ce; zend_class_entry *phalcon_validation_validator_digit_ce; zend_class_entry *phalcon_validation_validator_email_ce; zend_class_entry *phalcon_validation_validator_exclusionin_ce; zend_class_entry *phalcon_validation_validator_file_ce; zend_class_entry *phalcon_validation_validator_identical_ce; zend_class_entry *phalcon_validation_validator_inclusionin_ce; zend_class_entry *phalcon_validation_validator_numericality_ce; zend_class_entry *phalcon_validation_validator_presenceof_ce; zend_class_entry *phalcon_validation_validator_regex_ce; zend_class_entry *phalcon_validation_validator_stringlength_ce; zend_class_entry *phalcon_validation_validator_uniqueness_ce; zend_class_entry *phalcon_validation_validator_url_ce; zend_class_entry *phalcon_version_ce; ZEND_DECLARE_MODULE_GLOBALS(phalcon) PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("phalcon.db.escape_identifiers", "1", PHP_INI_ALL, OnUpdateBool, db.escape_identifiers, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.db.force_casting", "0", PHP_INI_ALL, OnUpdateBool, db.force_casting, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.events", "1", PHP_INI_ALL, OnUpdateBool, orm.events, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.virtual_foreign_keys", "1", PHP_INI_ALL, OnUpdateBool, orm.virtual_foreign_keys, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.column_renaming", "1", PHP_INI_ALL, OnUpdateBool, orm.column_renaming, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.not_null_validations", "1", PHP_INI_ALL, OnUpdateBool, orm.not_null_validations, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.exception_on_failed_save", "0", PHP_INI_ALL, OnUpdateBool, orm.exception_on_failed_save, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.enable_literals", "1", PHP_INI_ALL, OnUpdateBool, orm.enable_literals, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.late_state_binding", "0", PHP_INI_ALL, OnUpdateBool, orm.late_state_binding, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.enable_implicit_joins", "1", PHP_INI_ALL, OnUpdateBool, orm.enable_implicit_joins, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.cast_on_hydrate", "0", PHP_INI_ALL, OnUpdateBool, orm.cast_on_hydrate, zend_phalcon_globals, phalcon_globals) STD_PHP_INI_BOOLEAN("phalcon.orm.ignore_unknown_columns", "0", PHP_INI_ALL, OnUpdateBool, orm.ignore_unknown_columns, zend_phalcon_globals, phalcon_globals) PHP_INI_END() static PHP_MINIT_FUNCTION(phalcon) { #if PHP_VERSION_ID < 50500 char* old_lc_all = setlocale(LC_ALL, NULL); if (old_lc_all) { size_t len = strlen(old_lc_all); char *tmp = calloc(len+1, 1); if (UNEXPECTED(!tmp)) { return FAILURE; } memcpy(tmp, old_lc_all, len); old_lc_all = tmp; } setlocale(LC_ALL, "C"); #endif REGISTER_INI_ENTRIES(); ZEPHIR_INIT(Phalcon_Di_InjectionAwareInterface); ZEPHIR_INIT(Phalcon_Events_EventsAwareInterface); ZEPHIR_INIT(Phalcon_Forms_ElementInterface); ZEPHIR_INIT(Phalcon_Validation_ValidatorInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_ValidatorInterface); ZEPHIR_INIT(Phalcon_Cache_BackendInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaDataInterface); ZEPHIR_INIT(Phalcon_Cache_FrontendInterface); ZEPHIR_INIT(Phalcon_Db_DialectInterface); ZEPHIR_INIT(Phalcon_DispatcherInterface); ZEPHIR_INIT(Phalcon_Annotations_AdapterInterface); ZEPHIR_INIT(Phalcon_Db_AdapterInterface); ZEPHIR_INIT(Phalcon_Logger_AdapterInterface); ZEPHIR_INIT(Phalcon_Logger_FormatterInterface); ZEPHIR_INIT(Phalcon_Mvc_EntityInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_ResultsetInterface); ZEPHIR_INIT(Phalcon_Session_AdapterInterface); ZEPHIR_INIT(Phalcon_Assets_FilterInterface); ZEPHIR_INIT(Phalcon_DiInterface); ZEPHIR_INIT(Phalcon_Mvc_ViewBaseInterface); ZEPHIR_INIT(Phalcon_Paginator_AdapterInterface); ZEPHIR_INIT(Phalcon_Translate_AdapterInterface); ZEPHIR_INIT(Phalcon_Acl_AdapterInterface); ZEPHIR_INIT(Phalcon_FlashInterface); ZEPHIR_INIT(Phalcon_Image_AdapterInterface); ZEPHIR_INIT(Phalcon_Mvc_Collection_BehaviorInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_BehaviorInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_StrategyInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_ResultInterface); ZEPHIR_INIT(Phalcon_Mvc_RouterInterface); ZEPHIR_INIT(Phalcon_Mvc_View_EngineInterface); ZEPHIR_INIT(Phalcon_Translate_InterpolatorInterface); ZEPHIR_INIT(Phalcon_Acl_RoleInterface); ZEPHIR_INIT(Phalcon_Annotations_ReaderInterface); ZEPHIR_INIT(Phalcon_CryptInterface); ZEPHIR_INIT(Phalcon_Db_ColumnInterface); ZEPHIR_INIT(Phalcon_Db_IndexInterface); ZEPHIR_INIT(Phalcon_Db_ReferenceInterface); ZEPHIR_INIT(Phalcon_Db_ResultInterface); ZEPHIR_INIT(Phalcon_Di_ServiceInterface); ZEPHIR_INIT(Phalcon_EscaperInterface); ZEPHIR_INIT(Phalcon_Events_ManagerInterface); ZEPHIR_INIT(Phalcon_FilterInterface); ZEPHIR_INIT(Phalcon_Http_CookieInterface); ZEPHIR_INIT(Phalcon_Http_RequestInterface); ZEPHIR_INIT(Phalcon_Http_Request_FileInterface); ZEPHIR_INIT(Phalcon_Http_ResponseInterface); ZEPHIR_INIT(Phalcon_Http_Response_CookiesInterface); ZEPHIR_INIT(Phalcon_Http_Response_HeadersInterface); ZEPHIR_INIT(Phalcon_Mvc_CollectionInterface); ZEPHIR_INIT(Phalcon_Mvc_ControllerInterface); ZEPHIR_INIT(Phalcon_Mvc_DispatcherInterface); ZEPHIR_INIT(Phalcon_Mvc_Micro_CollectionInterface); ZEPHIR_INIT(Phalcon_Mvc_ModelInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_CriteriaInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_ManagerInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_MessageInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_QueryInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_Query_BuilderInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_Query_StatusInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_RelationInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_TransactionInterface); ZEPHIR_INIT(Phalcon_Mvc_Model_Transaction_ManagerInterface); ZEPHIR_INIT(Phalcon_Mvc_Router_GroupInterface); ZEPHIR_INIT(Phalcon_Mvc_Router_RouteInterface); ZEPHIR_INIT(Phalcon_Mvc_UrlInterface); ZEPHIR_INIT(Phalcon_Mvc_ViewInterface); ZEPHIR_INIT(Phalcon_Session_BagInterface); ZEPHIR_INIT(Phalcon_Validation_MessageInterface); ZEPHIR_INIT(Phalcon_Acl_ResourceInterface); ZEPHIR_INIT(Phalcon_Filter_UserFilterInterface); ZEPHIR_INIT(Phalcon_Mvc_Collection_ManagerInterface); ZEPHIR_INIT(Phalcon_Mvc_Micro_MiddlewareInterface); ZEPHIR_INIT(Phalcon_Mvc_ModuleDefinitionInterface); ZEPHIR_INIT(Phalcon_Exception); ZEPHIR_INIT(Phalcon_Validation_Validator); ZEPHIR_INIT(Phalcon_Di_Injectable); ZEPHIR_INIT(Phalcon_Forms_Element); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator); ZEPHIR_INIT(Phalcon_Cache_Backend); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData); ZEPHIR_INIT(Phalcon_Db_Adapter); ZEPHIR_INIT(Phalcon_Annotations_Adapter); ZEPHIR_INIT(Phalcon_Config); ZEPHIR_INIT(Phalcon_Db_Adapter_Pdo); ZEPHIR_INIT(Phalcon_Db_Dialect); ZEPHIR_INIT(Phalcon_Logger_Adapter); ZEPHIR_INIT(Phalcon_Logger_Formatter); ZEPHIR_INIT(Phalcon_Session_Adapter); ZEPHIR_INIT(Phalcon_Mvc_Model_Exception); ZEPHIR_INIT(Phalcon_Paginator_Adapter); ZEPHIR_INIT(Phalcon_Translate_Adapter); ZEPHIR_INIT(Phalcon_Assets_Inline); ZEPHIR_INIT(Phalcon_Assets_Resource); ZEPHIR_INIT(Phalcon_Di); ZEPHIR_INIT(Phalcon_Dispatcher); ZEPHIR_INIT(Phalcon_Flash); ZEPHIR_INIT(Phalcon_Image_Adapter); ZEPHIR_INIT(Phalcon_Mvc_Collection_Behavior); ZEPHIR_INIT(Phalcon_Mvc_Model_Behavior); ZEPHIR_INIT(Phalcon_Mvc_Model_Resultset); ZEPHIR_INIT(Phalcon_Mvc_View_Engine); ZEPHIR_INIT(Phalcon_Acl_Adapter); ZEPHIR_INIT(Phalcon_Cache_Frontend_Data); ZEPHIR_INIT(Phalcon_Di_FactoryDefault); ZEPHIR_INIT(Phalcon_Mvc_Model_Transaction_Exception); ZEPHIR_INIT(Phalcon_Mvc_Router); ZEPHIR_INIT(Phalcon_Mvc_View_Exception); ZEPHIR_INIT(Phalcon_Acl); ZEPHIR_INIT(Phalcon_Acl_Adapter_Memory); ZEPHIR_INIT(Phalcon_Acl_Exception); ZEPHIR_INIT(Phalcon_Acl_Resource); ZEPHIR_INIT(Phalcon_Acl_Role); ZEPHIR_INIT(Phalcon_Annotations_Adapter_Apc); ZEPHIR_INIT(Phalcon_Annotations_Adapter_Files); ZEPHIR_INIT(Phalcon_Annotations_Adapter_Memory); ZEPHIR_INIT(Phalcon_Annotations_Adapter_Xcache); ZEPHIR_INIT(Phalcon_Annotations_Annotation); ZEPHIR_INIT(Phalcon_Annotations_Collection); ZEPHIR_INIT(Phalcon_Annotations_Exception); ZEPHIR_INIT(Phalcon_Annotations_Reader); ZEPHIR_INIT(Phalcon_Annotations_Reflection); ZEPHIR_INIT(Phalcon_Assets_Collection); ZEPHIR_INIT(Phalcon_Assets_Exception); ZEPHIR_INIT(Phalcon_Assets_Filters_Cssmin); ZEPHIR_INIT(Phalcon_Assets_Filters_Jsmin); ZEPHIR_INIT(Phalcon_Assets_Filters_None); ZEPHIR_INIT(Phalcon_Assets_Inline_Css); ZEPHIR_INIT(Phalcon_Assets_Inline_Js); ZEPHIR_INIT(Phalcon_Assets_Manager); ZEPHIR_INIT(Phalcon_Assets_Resource_Css); ZEPHIR_INIT(Phalcon_Assets_Resource_Js); ZEPHIR_INIT(Phalcon_Cache_Backend_Apc); ZEPHIR_INIT(Phalcon_Cache_Backend_File); ZEPHIR_INIT(Phalcon_Cache_Backend_Libmemcached); ZEPHIR_INIT(Phalcon_Cache_Backend_Memcache); ZEPHIR_INIT(Phalcon_Cache_Backend_Memory); ZEPHIR_INIT(Phalcon_Cache_Backend_Mongo); ZEPHIR_INIT(Phalcon_Cache_Backend_Redis); ZEPHIR_INIT(Phalcon_Cache_Backend_Xcache); ZEPHIR_INIT(Phalcon_Cache_Exception); ZEPHIR_INIT(Phalcon_Cache_Frontend_Base64); ZEPHIR_INIT(Phalcon_Cache_Frontend_Igbinary); ZEPHIR_INIT(Phalcon_Cache_Frontend_Json); ZEPHIR_INIT(Phalcon_Cache_Frontend_None); ZEPHIR_INIT(Phalcon_Cache_Frontend_Output); ZEPHIR_INIT(Phalcon_Cache_Multiple); ZEPHIR_INIT(Phalcon_Cli_Console); ZEPHIR_INIT(Phalcon_Cli_Console_Exception); ZEPHIR_INIT(Phalcon_Cli_Dispatcher); ZEPHIR_INIT(Phalcon_Cli_Dispatcher_Exception); ZEPHIR_INIT(Phalcon_Cli_Router); ZEPHIR_INIT(Phalcon_Cli_Router_Exception); ZEPHIR_INIT(Phalcon_Cli_Router_Route); ZEPHIR_INIT(Phalcon_Cli_Task); ZEPHIR_INIT(Phalcon_Config_Adapter_Ini); ZEPHIR_INIT(Phalcon_Config_Adapter_Json); ZEPHIR_INIT(Phalcon_Config_Adapter_Php); ZEPHIR_INIT(Phalcon_Config_Adapter_Yaml); ZEPHIR_INIT(Phalcon_Config_Exception); ZEPHIR_INIT(Phalcon_Crypt); ZEPHIR_INIT(Phalcon_Crypt_Exception); ZEPHIR_INIT(Phalcon_Db); ZEPHIR_INIT(Phalcon_Db_Adapter_Pdo_Mysql); ZEPHIR_INIT(Phalcon_Db_Adapter_Pdo_Oracle); ZEPHIR_INIT(Phalcon_Db_Adapter_Pdo_Postgresql); ZEPHIR_INIT(Phalcon_Db_Adapter_Pdo_Sqlite); ZEPHIR_INIT(Phalcon_Db_Column); ZEPHIR_INIT(Phalcon_Db_Dialect_MySQL); ZEPHIR_INIT(Phalcon_Db_Dialect_Oracle); ZEPHIR_INIT(Phalcon_Db_Dialect_Postgresql); ZEPHIR_INIT(Phalcon_Db_Dialect_Sqlite); ZEPHIR_INIT(Phalcon_Db_Exception); ZEPHIR_INIT(Phalcon_Db_Index); ZEPHIR_INIT(Phalcon_Db_Profiler); ZEPHIR_INIT(Phalcon_Db_Profiler_Item); ZEPHIR_INIT(Phalcon_Db_RawValue); ZEPHIR_INIT(Phalcon_Db_Reference); ZEPHIR_INIT(Phalcon_Db_Result_Pdo); ZEPHIR_INIT(Phalcon_Debug); ZEPHIR_INIT(Phalcon_Debug_Dump); ZEPHIR_INIT(Phalcon_Debug_Exception); ZEPHIR_INIT(Phalcon_Di_Exception); ZEPHIR_INIT(Phalcon_Di_FactoryDefault_Cli); ZEPHIR_INIT(Phalcon_Di_Service); ZEPHIR_INIT(Phalcon_Di_Service_Builder); ZEPHIR_INIT(Phalcon_Escaper); ZEPHIR_INIT(Phalcon_Escaper_Exception); ZEPHIR_INIT(Phalcon_Events_Event); ZEPHIR_INIT(Phalcon_Events_Exception); ZEPHIR_INIT(Phalcon_Events_Manager); ZEPHIR_INIT(Phalcon_Filter); ZEPHIR_INIT(Phalcon_Filter_Exception); ZEPHIR_INIT(Phalcon_Flash_Direct); ZEPHIR_INIT(Phalcon_Flash_Exception); ZEPHIR_INIT(Phalcon_Flash_Session); ZEPHIR_INIT(Phalcon_Forms_Element_Check); ZEPHIR_INIT(Phalcon_Forms_Element_Date); ZEPHIR_INIT(Phalcon_Forms_Element_Email); ZEPHIR_INIT(Phalcon_Forms_Element_File); ZEPHIR_INIT(Phalcon_Forms_Element_Hidden); ZEPHIR_INIT(Phalcon_Forms_Element_Numeric); ZEPHIR_INIT(Phalcon_Forms_Element_Password); ZEPHIR_INIT(Phalcon_Forms_Element_Radio); ZEPHIR_INIT(Phalcon_Forms_Element_Select); ZEPHIR_INIT(Phalcon_Forms_Element_Submit); ZEPHIR_INIT(Phalcon_Forms_Element_Text); ZEPHIR_INIT(Phalcon_Forms_Element_TextArea); ZEPHIR_INIT(Phalcon_Forms_Exception); ZEPHIR_INIT(Phalcon_Forms_Form); ZEPHIR_INIT(Phalcon_Forms_Manager); ZEPHIR_INIT(Phalcon_Http_Cookie); ZEPHIR_INIT(Phalcon_Http_Cookie_Exception); ZEPHIR_INIT(Phalcon_Http_Request); ZEPHIR_INIT(Phalcon_Http_Request_Exception); ZEPHIR_INIT(Phalcon_Http_Request_File); ZEPHIR_INIT(Phalcon_Http_Response); ZEPHIR_INIT(Phalcon_Http_Response_Cookies); ZEPHIR_INIT(Phalcon_Http_Response_Exception); ZEPHIR_INIT(Phalcon_Http_Response_Headers); ZEPHIR_INIT(Phalcon_Image); ZEPHIR_INIT(Phalcon_Image_Adapter_Gd); ZEPHIR_INIT(Phalcon_Image_Adapter_Imagick); ZEPHIR_INIT(Phalcon_Image_Exception); ZEPHIR_INIT(Phalcon_Kernel); ZEPHIR_INIT(Phalcon_Loader); ZEPHIR_INIT(Phalcon_Loader_Exception); ZEPHIR_INIT(Phalcon_Logger); ZEPHIR_INIT(Phalcon_Logger_Adapter_File); ZEPHIR_INIT(Phalcon_Logger_Adapter_Firephp); ZEPHIR_INIT(Phalcon_Logger_Adapter_Stream); ZEPHIR_INIT(Phalcon_Logger_Adapter_Syslog); ZEPHIR_INIT(Phalcon_Logger_Exception); ZEPHIR_INIT(Phalcon_Logger_Formatter_Firephp); ZEPHIR_INIT(Phalcon_Logger_Formatter_Json); ZEPHIR_INIT(Phalcon_Logger_Formatter_Line); ZEPHIR_INIT(Phalcon_Logger_Formatter_Syslog); ZEPHIR_INIT(Phalcon_Logger_Item); ZEPHIR_INIT(Phalcon_Logger_Multiple); ZEPHIR_INIT(Phalcon_Mvc_Application); ZEPHIR_INIT(Phalcon_Mvc_Application_Exception); ZEPHIR_INIT(Phalcon_Mvc_Collection); ZEPHIR_INIT(Phalcon_Mvc_Collection_Behavior_SoftDelete); ZEPHIR_INIT(Phalcon_Mvc_Collection_Behavior_Timestampable); ZEPHIR_INIT(Phalcon_Mvc_Collection_Document); ZEPHIR_INIT(Phalcon_Mvc_Collection_Exception); ZEPHIR_INIT(Phalcon_Mvc_Collection_Manager); ZEPHIR_INIT(Phalcon_Mvc_Controller); ZEPHIR_INIT(Phalcon_Mvc_Dispatcher); ZEPHIR_INIT(Phalcon_Mvc_Dispatcher_Exception); ZEPHIR_INIT(Phalcon_Mvc_Micro); ZEPHIR_INIT(Phalcon_Mvc_Micro_Collection); ZEPHIR_INIT(Phalcon_Mvc_Micro_Exception); ZEPHIR_INIT(Phalcon_Mvc_Micro_LazyLoader); ZEPHIR_INIT(Phalcon_Mvc_Model); ZEPHIR_INIT(Phalcon_Mvc_Model_Behavior_SoftDelete); ZEPHIR_INIT(Phalcon_Mvc_Model_Behavior_Timestampable); ZEPHIR_INIT(Phalcon_Mvc_Model_Criteria); ZEPHIR_INIT(Phalcon_Mvc_Model_Manager); ZEPHIR_INIT(Phalcon_Mvc_Model_Message); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Apc); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Files); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Libmemcached); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Memcache); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Memory); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Redis); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Session); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Strategy_Annotations); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Strategy_Introspection); ZEPHIR_INIT(Phalcon_Mvc_Model_MetaData_Xcache); ZEPHIR_INIT(Phalcon_Mvc_Model_Query); ZEPHIR_INIT(Phalcon_Mvc_Model_Query_Builder); ZEPHIR_INIT(Phalcon_Mvc_Model_Query_Lang); ZEPHIR_INIT(Phalcon_Mvc_Model_Query_Status); ZEPHIR_INIT(Phalcon_Mvc_Model_Relation); ZEPHIR_INIT(Phalcon_Mvc_Model_Resultset_Complex); ZEPHIR_INIT(Phalcon_Mvc_Model_Resultset_Simple); ZEPHIR_INIT(Phalcon_Mvc_Model_Row); ZEPHIR_INIT(Phalcon_Mvc_Model_Transaction); ZEPHIR_INIT(Phalcon_Mvc_Model_Transaction_Failed); ZEPHIR_INIT(Phalcon_Mvc_Model_Transaction_Manager); ZEPHIR_INIT(Phalcon_Mvc_Model_ValidationFailed); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Email); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Exclusionin); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Inclusionin); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Ip); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Numericality); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_PresenceOf); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Regex); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_StringLength); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Uniqueness); ZEPHIR_INIT(Phalcon_Mvc_Model_Validator_Url); ZEPHIR_INIT(Phalcon_Mvc_Router_Annotations); ZEPHIR_INIT(Phalcon_Mvc_Router_Exception); ZEPHIR_INIT(Phalcon_Mvc_Router_Group); ZEPHIR_INIT(Phalcon_Mvc_Router_Route); ZEPHIR_INIT(Phalcon_Mvc_Url); ZEPHIR_INIT(Phalcon_Mvc_Url_Exception); ZEPHIR_INIT(Phalcon_Mvc_User_Component); ZEPHIR_INIT(Phalcon_Mvc_User_Module); ZEPHIR_INIT(Phalcon_Mvc_User_Plugin); ZEPHIR_INIT(Phalcon_Mvc_View); ZEPHIR_INIT(Phalcon_Mvc_View_Engine_Php); ZEPHIR_INIT(Phalcon_Mvc_View_Engine_Volt); ZEPHIR_INIT(Phalcon_Mvc_View_Engine_Volt_Compiler); ZEPHIR_INIT(Phalcon_Mvc_View_Engine_Volt_Exception); ZEPHIR_INIT(Phalcon_Mvc_View_Simple); ZEPHIR_INIT(Phalcon_Paginator_Adapter_Model); ZEPHIR_INIT(Phalcon_Paginator_Adapter_NativeArray); ZEPHIR_INIT(Phalcon_Paginator_Adapter_QueryBuilder); ZEPHIR_INIT(Phalcon_Paginator_Exception); ZEPHIR_INIT(Phalcon_Queue_Beanstalk); ZEPHIR_INIT(Phalcon_Queue_Beanstalk_Job); ZEPHIR_INIT(Phalcon_Registry); ZEPHIR_INIT(Phalcon_Security); ZEPHIR_INIT(Phalcon_Security_Exception); ZEPHIR_INIT(Phalcon_Security_Random); ZEPHIR_INIT(Phalcon_Session); ZEPHIR_INIT(Phalcon_Session_Adapter_Files); ZEPHIR_INIT(Phalcon_Session_Adapter_Libmemcached); ZEPHIR_INIT(Phalcon_Session_Adapter_Memcache); ZEPHIR_INIT(Phalcon_Session_Adapter_Redis); ZEPHIR_INIT(Phalcon_Session_Bag); ZEPHIR_INIT(Phalcon_Session_Exception); ZEPHIR_INIT(Phalcon_Tag); ZEPHIR_INIT(Phalcon_Tag_Exception); ZEPHIR_INIT(Phalcon_Tag_Select); ZEPHIR_INIT(Phalcon_Text); ZEPHIR_INIT(Phalcon_Translate); ZEPHIR_INIT(Phalcon_Translate_Adapter_Csv); ZEPHIR_INIT(Phalcon_Translate_Adapter_Gettext); ZEPHIR_INIT(Phalcon_Translate_Adapter_NativeArray); ZEPHIR_INIT(Phalcon_Translate_Exception); ZEPHIR_INIT(Phalcon_Translate_Interpolator_AssociativeArray); ZEPHIR_INIT(Phalcon_Translate_Interpolator_IndexedArray); ZEPHIR_INIT(Phalcon_Validation); ZEPHIR_INIT(Phalcon_Validation_Exception); ZEPHIR_INIT(Phalcon_Validation_Message); ZEPHIR_INIT(Phalcon_Validation_Message_Group); ZEPHIR_INIT(Phalcon_Validation_Validator_Alnum); ZEPHIR_INIT(Phalcon_Validation_Validator_Alpha); ZEPHIR_INIT(Phalcon_Validation_Validator_Between); ZEPHIR_INIT(Phalcon_Validation_Validator_Confirmation); ZEPHIR_INIT(Phalcon_Validation_Validator_CreditCard); ZEPHIR_INIT(Phalcon_Validation_Validator_Digit); ZEPHIR_INIT(Phalcon_Validation_Validator_Email); ZEPHIR_INIT(Phalcon_Validation_Validator_ExclusionIn); ZEPHIR_INIT(Phalcon_Validation_Validator_File); ZEPHIR_INIT(Phalcon_Validation_Validator_Identical); ZEPHIR_INIT(Phalcon_Validation_Validator_InclusionIn); ZEPHIR_INIT(Phalcon_Validation_Validator_Numericality); ZEPHIR_INIT(Phalcon_Validation_Validator_PresenceOf); ZEPHIR_INIT(Phalcon_Validation_Validator_Regex); ZEPHIR_INIT(Phalcon_Validation_Validator_StringLength); ZEPHIR_INIT(Phalcon_Validation_Validator_Uniqueness); ZEPHIR_INIT(Phalcon_Validation_Validator_Url); ZEPHIR_INIT(Phalcon_Version); ZEPHIR_INIT(phalcon_0__closure); #if PHP_VERSION_ID < 50500 setlocale(LC_ALL, old_lc_all); free(old_lc_all); #endif return SUCCESS; } #ifndef ZEPHIR_RELEASE static PHP_MSHUTDOWN_FUNCTION(phalcon) { zephir_deinitialize_memory(TSRMLS_C); UNREGISTER_INI_ENTRIES(); return SUCCESS; } #endif static void php_zephir_init_globals(zend_phalcon_globals *phalcon_globals TSRMLS_DC) { phalcon_globals->initialized = 0; /* Memory options */ phalcon_globals->active_memory = NULL; /* Virtual Symbol Tables */ phalcon_globals->active_symbol_table = NULL; /* Cache Enabled */ phalcon_globals->cache_enabled = 1; /* Recursive Lock */ phalcon_globals->recursive_lock = 0; /* Static cache */ memset(phalcon_globals->scache, '\0', sizeof(zephir_fcall_cache_entry*) * ZEPHIR_MAX_CACHE_SLOTS); phalcon_globals->orm.parser_cache = NULL; phalcon_globals->orm.ast_cache = NULL; phalcon_globals->orm.cache_level = 3; phalcon_globals->orm.unique_cache_id = 3; } static PHP_RINIT_FUNCTION(phalcon) { zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; php_zephir_init_globals(phalcon_globals_ptr TSRMLS_CC); //zephir_init_interned_strings(TSRMLS_C); zephir_initialize_memory(phalcon_globals_ptr TSRMLS_CC); return SUCCESS; } static PHP_RSHUTDOWN_FUNCTION(phalcon) { phalcon_orm_destroy_cache(TSRMLS_C); zephir_deinitialize_memory(TSRMLS_C); return SUCCESS; } static PHP_MINFO_FUNCTION(phalcon) { php_info_print_box_start(0); php_printf("%s", PHP_PHALCON_DESCRIPTION); php_info_print_box_end(); php_info_print_table_start(); php_info_print_table_header(2, PHP_PHALCON_NAME, "enabled"); php_info_print_table_row(2, "Author", PHP_PHALCON_AUTHOR); php_info_print_table_row(2, "Version", PHP_PHALCON_VERSION); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ ); php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_PHALCON_ZEPVERSION); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } static PHP_GINIT_FUNCTION(phalcon) { php_zephir_init_globals(phalcon_globals TSRMLS_CC); } static PHP_GSHUTDOWN_FUNCTION(phalcon) { } zend_function_entry php_phalcon_functions[] = { ZEND_FE_END }; zend_module_entry phalcon_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, NULL, PHP_PHALCON_EXTNAME, php_phalcon_functions, PHP_MINIT(phalcon), #ifndef ZEPHIR_RELEASE PHP_MSHUTDOWN(phalcon), #else NULL, #endif PHP_RINIT(phalcon), PHP_RSHUTDOWN(phalcon), PHP_MINFO(phalcon), PHP_PHALCON_VERSION, ZEND_MODULE_GLOBALS(phalcon), PHP_GINIT(phalcon), PHP_GSHUTDOWN(phalcon), NULL, STANDARD_MODULE_PROPERTIES_EX }; #ifdef COMPILE_DL_PHALCON ZEND_GET_MODULE(phalcon) #endif