Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new 'use function' sequence for importing namespaced functions #388

Closed
wants to merge 1,705 commits into from

Conversation

igorw
Copy link
Contributor

@igorw igorw commented Jul 19, 2013

This is specified as the use_function RFC:

@jippi
Copy link

jippi commented Aug 17, 2013

❤️

@weltling
Copy link
Contributor

The functionality looks good so far and the tests on windows and linux pass. Prosit!

@@ -0,0 +1,18 @@
--TEST--
use and use function with the same alias
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit s/use function/use const

@nikic
Copy link
Member

nikic commented Aug 25, 2013

Patch looks pretty good. Some comments:

  • Constants are not always case-insensitive (actually they are case-sensitive by default), so just doing lcs without checking CONST_CS will not work correctly. Maybe use zend_get_constant to do the lookups? It also handles special const names, but I don't think those are important in this context.
  • The filename for functions is stored in their op_array, so there is no need to track it in an additional HT.
  • Because the function filenames are tracked in a separate HT and not via the op_array they will be always added, even if registration of the function is delayed to runtime. E.g. the following code throws an error, whereas the same code using classes does not:
<?php

if (0) {
    function foo() {

    }
}

use function bar\foo;

// Fatal error: Cannot use function bar\foo as foo because the name is already in use in /home/nikic/dev/php-src/t59.php on line 9

Edit: Don't know whether the last point is actually important, just noticed that it behaves differently from class uses ;)

@igorw
Copy link
Contributor Author

igorw commented Aug 29, 2013

TODOs:

  • Replace the function_filenames hash-table with a lookup to the op_array. Zend/tests/use_function/conditional_function_declaration.phpt should pass after that.
  • Figure out why Zend/tests/use_function/define_imported_before.phpt is failing on travis. It works locally.

Help on either of those would be appreciated.

datibbaw and others added 20 commits September 23, 2013 23:42
* 'master' of https://git.php.net/repository/php-src:
  Fix typo: HTTP_ROW_POST_DATA → HTTP_RAW_POST_DATA.
* PHP-5.5:
  Fixed issue php#135 (segfault in interned strings if initial memory is too low)

Conflicts:
	NEWS
* PHP-5.5:
  Added function opcache_compile_file() to load PHP scripts into cache without execution.

Conflicts:
	NEWS
* 'master' of https://git.php.net/repository/php-src:
  Added function opcache_compile_file() to load PHP scripts into cache without execution.
  Fixed issue php#135 (segfault in interned strings if initial memory is too low)
While running these on HHVM I've run into a lot of parallelism issues.
I'm backporting all the fixes I had to do in
https://github.com/facebook/hiphop-php/blob/master/hphp/tools/import_zend_test.py#L650
to php core.

Most of these changes were just filenames that were shared between
tests, but I did more surgery on the fixed ports. I can apreciate port
31337 as much as the next nerd, but random ports are better for tests.
# By Adam Harvey (2) and others
# Via Adam Harvey (2) and others
* 'master' of https://git.php.net/repository/php-src:
  Implement variadic function syntax
  Added function opcache_compile_file() to load PHP scripts into cache without execution.
  Fixed issue php#135 (segfault in interned strings if initial memory is too low)
  Fix typo: HTTP_ROW_POST_DATA → HTTP_RAW_POST_DATA.
  Make message and format arguments const char * to avoid build warning about invalid cast.
  Copy dba_*() keys before converting to string.
We already track it in the op array already.
* 'master' of https://git.php.net/repository/php-src:
  Don't track parameter number in separate znode
  fix missing change from 'tcp_socket' to the more common 'server'
  fix many parallel test issues
Change php.ini-* doc to match an earlier change to config.w32
* PHP-5.5:
  Added support for GNU Hurd. (Svante Signell)

Conflicts:
	NEWS
* PHP-5.5:
  Removed references to "Zend Support"
rlerdorf and others added 26 commits October 31, 2013 03:18
* PHP-5.5:
  Fix bug #66008
- update libzip to version 1.11.1. We don't use any private symbol anymore
- new method ZipArchive::setPassword($password)
- add --with-libzip option to build with system libzip
# By Remi Collet (2) and Xinchen Hui (2)
# Via Xinchen Hui (5) and Remi Collet (1)
* 'master' of git.php.net:php-src:
  NEWS + UPGRADING
  Sync ext/zip with pecl/zip version 1.3.2 - update libzip to version 1.11.1. We don't use any private symbol anymore - new method ZipArchive::setPassword($password) - add --with-libzip option to build with system libzip
  Fixed coredump due to abnormal implemention of phar
  remove "PHP 6" staff
Conflicts:
	ext/phar/phar_internal.h
	ext/phar/stream.c
	ext/phar/util.c
* pull-request/500:
  limit virtual_cwd_activate() duplicated call to ZTS only
  reverted the previous commit, both calls are needed in TS mode
  virtual_cwd_activate() should be called only in one place
  back to do_alloca()
  removed unnecessary call
  simplify the state free macros
  compact the code to preserve the error info after state freeing
  back to do_alloca(), reverted the wrong replacement
  enabled windows to use stack in both ts/nts mode, some more fixes
  moved to do_alloca() usage where appropriate
  fixed invalid free
  fixed virtual cwd header in phar
  updated NEWS
  fixed all the places where last error could be lost
  preserve the error code
  applied and fixed the original patch
  initial move on renaming files and fixing includes

Conflicts:
	ext/opcache/ZendAccelerator.c
Conflicts:
	ext/opcache/ZendAccelerator.c
* PHP-5.5:
  Fix bug #65946 - pdo_sql_parser.c permanently converts values bound to strings
* PHP-5.5:
  Added tests for PHAR/OPCahce incompatibilities
  Update NEWS
  Fixed bug #65947 (basename is no more working after fgetcsv in certain situation)
  Update NEWS
  Fixed Bug #66043 (Segfault calling bind_param() on mysqli)
  NEWS entry
  NEWS entry

Conflicts:
	NEWS
* PHP-5.5:
  Fixed issue php#115 (path issue when using phar). Fixed issue php#149 (Phar mount points not working with OPcache enabled).

Conflicts:
	NEWS
* upstream/PHP-5.6: (399 commits)
  Fixed issue php#115 (path issue when using phar). Fixed issue php#149 (Phar mount points not working with OPcache enabled).
  Added tests for PHAR/OPCahce incompatibilities
  Update NEWS
  Fixed bug #65947 (basename is no more working after fgetcsv in certain situation)
  Update NEWS
  Fixed Bug #66043 (Segfault calling bind_param() on mysqli)
  NEWS entry
  NEWS entry
  Fix bug #65946 - pdo_sql_parser.c permanently converts values bound to strings
  bump API versions
  Add a couple more test cases to parse_url() tests
  fix missing change from 'tcp_socket' to the more common 'server'
  fix many parallel test issues
  Cleanup temp test file
  Revert "Fixed issue php#115 (path issue when using phar)."
  Update LiteSpeed SAPI code to V6.4
  Fixed typo in Makefile.frag
  updated NEWS
  Remove outdate codes, make it clearer, although just a bit..
  Update NEWS
  ...

Conflicts:
	Zend/zend_compile.h
@igorw
Copy link
Contributor Author

igorw commented Nov 9, 2013

Re-opening against PHP-5.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.