Skip to content

generate arginfo from stub for PHP 7 and 8 #463

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

Merged
merged 3 commits into from
Oct 9, 2020

Conversation

remicollet
Copy link
Collaborator

@remicollet remicollet commented Oct 8, 2020

Pros:

  • Take benefit of PHP 8 feature, easier to maintain a simple stub file
  • Generate both arginfo for PHP 7 and PHP 8

Cons:

  • Requires (php 8-master or >= RC2) to generate (but not needed at build/runtime)
  • Lost some type hinting (array) introduce in previous versions

@remicollet
Copy link
Collaborator Author

remicollet commented Oct 8, 2020

Diff of reflection with PHP 7

@@ -242,9 +242,10 @@
       - Methods [58] {
         Method [ <internal:memcached, ctor> public method __construct ] {
 
-          - Parameters [2] {
+          - Parameters [3] {
             Parameter #0 [ <optional> $persistent_id ]
             Parameter #1 [ <optional> $callback ]
+            Parameter #2 [ <optional> $connection_str ]
           }
         }
 
@@ -282,7 +283,7 @@
         Method [ <internal:memcached> public method getMulti ] {
 
           - Parameters [2] {
-            Parameter #0 [ <required> array $keys ]
+            Parameter #0 [ <required> $keys ]
             Parameter #1 [ <optional> $get_flags ]
           }
         }
@@ -291,7 +292,7 @@
 
           - Parameters [3] {
             Parameter #0 [ <required> $server_key ]
-            Parameter #1 [ <required> array $keys ]
+            Parameter #1 [ <required> $keys ]
             Parameter #2 [ <optional> $get_flags ]
           }
         }
@@ -299,7 +300,7 @@
         Method [ <internal:memcached> public method getDelayed ] {
 
           - Parameters [3] {
-            Parameter #0 [ <required> array $keys ]
+            Parameter #0 [ <required> $keys ]
             Parameter #1 [ <optional> $with_cas ]
             Parameter #2 [ <optional> $value_cb ]
           }
@@ -309,7 +310,7 @@
 
           - Parameters [4] {
             Parameter #0 [ <required> $server_key ]
-            Parameter #1 [ <required> array $keys ]
+            Parameter #1 [ <required> $keys ]
             Parameter #2 [ <optional> $with_cas ]
             Parameter #3 [ <optional> $value_cb ]
           }
@@ -350,7 +351,7 @@
 
           - Parameters [2] {
             Parameter #0 [ <required> $key ]
-            Parameter #1 [ <required> $expiration ]
+            Parameter #1 [ <optional> $expiration ]
           }
         }
 
@@ -359,14 +360,14 @@
           - Parameters [3] {
             Parameter #0 [ <required> $server_key ]
             Parameter #1 [ <required> $key ]
-            Parameter #2 [ <required> $expiration ]
+            Parameter #2 [ <optional> $expiration ]
           }
         }
 
         Method [ <internal:memcached> public method setMulti ] {
 
           - Parameters [2] {
-            Parameter #0 [ <required> array $items ]
+            Parameter #0 [ <required> $items ]
             Parameter #1 [ <optional> $expiration ]
           }
         }
@@ -375,7 +376,7 @@
 
           - Parameters [3] {
             Parameter #0 [ <required> $server_key ]
-            Parameter #1 [ <required> array $items ]
+            Parameter #1 [ <required> $items ]
             Parameter #2 [ <optional> $expiration ]
           }
         }
@@ -561,7 +562,7 @@
         Method [ <internal:memcached> public method addServers ] {
 
           - Parameters [1] {
-            Parameter #0 [ <required> array $servers ]
+            Parameter #0 [ <required> $servers ]
           }
         }
 
@@ -722,9 +723,18 @@
 
       - Methods [2] {
         Method [ <internal:memcached> public method run ] {
+
+          - Parameters [1] {
+            Parameter #0 [ <required> $address ]
+          }
         }
 
         Method [ <internal:memcached> public method on ] {
+
+          - Parameters [2] {
+            Parameter #0 [ <required> $event ]
+            Parameter #1 [ <required> $callback ]
+          }
         }
       }
     }

Notices:

  • missing conn_str for Memcached::__construct
  • expiration is always optional
  • add missing arginfo for MemcachedServer methods (mandatory for 8)
  • array type hinting lost by "legacy" file

@@ -1867,15 +1867,13 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke
Z_PARAM_ARRAY(entries)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(expiration)
Z_PARAM_LONG(ignored)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in arginfo, and not used

ZEND_PARSE_PARAMETERS_END();
} else {
/* "a|ll" */
ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_ARRAY(entries)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(expiration)
Z_PARAM_LONG(ignored)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in arginfo, and not used

@remicollet
Copy link
Collaborator Author

remicollet commented Oct 8, 2020

Fix also fix the test suite (only tests/*phpt)

Pass with 7.3 and 8.0.0RC1

=====================================================================
Number of tests :   95                86
Tests skipped   :    9 (  9.5%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Tests passed    :   86 ( 90.5%) (100.0%)
---------------------------------------------------------------------
Time taken      :    5 seconds
=====================================================================

@remicollet
Copy link
Collaborator Author

remicollet commented Oct 8, 2020

Reflection with PHP 8 - need to be carefully reviewed

Extension [ <persistent> extension #18 memcached version 3.1.5 ] {

  - Dependencies {
    Dependency [ session (Required) ]
    Dependency [ igbinary (Required) ]
    Dependency [ msgpack (Required) ]
  }

  - INI {
    Entry [ memcached.sess_locking <ALL> ]
      Current = '1'
    }
    Entry [ memcached.sess_lock_wait_min <ALL> ]
      Current = '150'
    }
    Entry [ memcached.sess_lock_wait_max <ALL> ]
      Current = '150'
    }
    Entry [ memcached.sess_lock_retries <ALL> ]
      Current = '5'
    }
    Entry [ memcached.sess_lock_expire <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_binary_protocol <ALL> ]
      Current = '1'
    }
    Entry [ memcached.sess_consistent_hash <ALL> ]
      Current = '1'
    }
    Entry [ memcached.sess_consistent_hash_type <ALL> ]
      Current = 'ketama'
    }
    Entry [ memcached.sess_number_of_replicas <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_randomize_replica_read <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_remove_failed_servers <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_server_failure_limit <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_connect_timeout <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_sasl_username <ALL> ]
      Current = ''
    }
    Entry [ memcached.sess_sasl_password <ALL> ]
      Current = ''
    }
    Entry [ memcached.sess_persistent <ALL> ]
      Current = '0'
    }
    Entry [ memcached.sess_prefix <ALL> ]
      Current = 'memc.sess.key.'
    }
    Entry [ memcached.sess_lock_wait <ALL> ]
      Current = 'not set'
    }
    Entry [ memcached.sess_lock_max_wait <ALL> ]
      Current = 'not set'
    }
    Entry [ memcached.compression_type <ALL> ]
      Current = 'fastlz'
    }
    Entry [ memcached.compression_factor <ALL> ]
      Current = '1.3'
    }
    Entry [ memcached.compression_threshold <ALL> ]
      Current = '2000'
    }
    Entry [ memcached.serializer <ALL> ]
      Current = 'igbinary'
    }
    Entry [ memcached.store_retry_count <ALL> ]
      Current = '2'
    }
    Entry [ memcached.default_consistent_hash <ALL> ]
      Current = '0'
    }
    Entry [ memcached.default_binary_protocol <ALL> ]
      Current = '0'
    }
    Entry [ memcached.default_connect_timeout <ALL> ]
      Current = '0'
    }
  }

  - Classes [3] {
    Class [ <internal:memcached> class Memcached ] {

      - Constants [133] {
        Constant [ public int LIBMEMCACHED_VERSION_HEX ] { 16777240 }
        Constant [ public int OPT_COMPRESSION ] { -1001 }
        Constant [ public int OPT_COMPRESSION_TYPE ] { -1004 }
        Constant [ public int OPT_PREFIX_KEY ] { -1002 }
        Constant [ public int OPT_SERIALIZER ] { -1003 }
        Constant [ public int OPT_USER_FLAGS ] { -1006 }
        Constant [ public int OPT_STORE_RETRY_COUNT ] { -1005 }
        Constant [ public bool HAVE_IGBINARY ] { 1 }
        Constant [ public bool HAVE_JSON ] { 1 }
        Constant [ public bool HAVE_MSGPACK ] { 1 }
        Constant [ public bool HAVE_ENCODING ] { 1 }
        Constant [ public bool HAVE_SESSION ] { 1 }
        Constant [ public bool HAVE_SASL ] { 1 }
        Constant [ public int OPT_HASH ] { 2 }
        Constant [ public int HASH_DEFAULT ] { 0 }
        Constant [ public int HASH_MD5 ] { 1 }
        Constant [ public int HASH_CRC ] { 2 }
        Constant [ public int HASH_FNV1_64 ] { 3 }
        Constant [ public int HASH_FNV1A_64 ] { 4 }
        Constant [ public int HASH_FNV1_32 ] { 5 }
        Constant [ public int HASH_FNV1A_32 ] { 6 }
        Constant [ public int HASH_HSIEH ] { 7 }
        Constant [ public int HASH_MURMUR ] { 8 }
        Constant [ public int OPT_DISTRIBUTION ] { 9 }
        Constant [ public int DISTRIBUTION_MODULA ] { 0 }
        Constant [ public int DISTRIBUTION_CONSISTENT ] { 1 }
        Constant [ public int DISTRIBUTION_VIRTUAL_BUCKET ] { 6 }
        Constant [ public int OPT_LIBKETAMA_COMPATIBLE ] { 16 }
        Constant [ public int OPT_LIBKETAMA_HASH ] { 17 }
        Constant [ public int OPT_TCP_KEEPALIVE ] { 32 }
        Constant [ public int OPT_BUFFER_WRITES ] { 10 }
        Constant [ public int OPT_BINARY_PROTOCOL ] { 18 }
        Constant [ public int OPT_NO_BLOCK ] { 0 }
        Constant [ public int OPT_TCP_NODELAY ] { 1 }
        Constant [ public int OPT_SOCKET_SEND_SIZE ] { 4 }
        Constant [ public int OPT_SOCKET_RECV_SIZE ] { 5 }
        Constant [ public int OPT_CONNECT_TIMEOUT ] { 14 }
        Constant [ public int OPT_RETRY_TIMEOUT ] { 15 }
        Constant [ public int OPT_DEAD_TIMEOUT ] { 36 }
        Constant [ public int OPT_SEND_TIMEOUT ] { 19 }
        Constant [ public int OPT_RECV_TIMEOUT ] { 20 }
        Constant [ public int OPT_POLL_TIMEOUT ] { 8 }
        Constant [ public int OPT_CACHE_LOOKUPS ] { 6 }
        Constant [ public int OPT_SERVER_FAILURE_LIMIT ] { 21 }
        Constant [ public int OPT_AUTO_EJECT_HOSTS ] { 28 }
        Constant [ public int OPT_HASH_WITH_PREFIX_KEY ] { 25 }
        Constant [ public int OPT_NOREPLY ] { 26 }
        Constant [ public int OPT_SORT_HOSTS ] { 12 }
        Constant [ public int OPT_VERIFY_KEY ] { 13 }
        Constant [ public int OPT_USE_UDP ] { 27 }
        Constant [ public int OPT_NUMBER_OF_REPLICAS ] { 29 }
        Constant [ public int OPT_RANDOMIZE_REPLICA_READ ] { 30 }
        Constant [ public int OPT_REMOVE_FAILED_SERVERS ] { 35 }
        Constant [ public int OPT_SERVER_TIMEOUT_LIMIT ] { 37 }
        Constant [ public int RES_SUCCESS ] { 0 }
        Constant [ public int RES_FAILURE ] { 1 }
        Constant [ public int RES_HOST_LOOKUP_FAILURE ] { 2 }
        Constant [ public int RES_UNKNOWN_READ_FAILURE ] { 7 }
        Constant [ public int RES_PROTOCOL_ERROR ] { 8 }
        Constant [ public int RES_CLIENT_ERROR ] { 9 }
        Constant [ public int RES_SERVER_ERROR ] { 10 }
        Constant [ public int RES_WRITE_FAILURE ] { 5 }
        Constant [ public int RES_DATA_EXISTS ] { 12 }
        Constant [ public int RES_NOTSTORED ] { 14 }
        Constant [ public int RES_NOTFOUND ] { 16 }
        Constant [ public int RES_PARTIAL_READ ] { 18 }
        Constant [ public int RES_SOME_ERRORS ] { 19 }
        Constant [ public int RES_NO_SERVERS ] { 20 }
        Constant [ public int RES_END ] { 21 }
        Constant [ public int RES_ERRNO ] { 26 }
        Constant [ public int RES_BUFFERED ] { 32 }
        Constant [ public int RES_TIMEOUT ] { 31 }
        Constant [ public int RES_BAD_KEY_PROVIDED ] { 33 }
        Constant [ public int RES_STORED ] { 15 }
        Constant [ public int RES_DELETED ] { 22 }
        Constant [ public int RES_STAT ] { 24 }
        Constant [ public int RES_ITEM ] { 25 }
        Constant [ public int RES_NOT_SUPPORTED ] { 28 }
        Constant [ public int RES_FETCH_NOTFINISHED ] { 30 }
        Constant [ public int RES_SERVER_MARKED_DEAD ] { 35 }
        Constant [ public int RES_UNKNOWN_STAT_KEY ] { 36 }
        Constant [ public int RES_INVALID_HOST_PROTOCOL ] { 34 }
        Constant [ public int RES_MEMORY_ALLOCATION_FAILURE ] { 17 }
        Constant [ public int RES_CONNECTION_SOCKET_CREATE_FAILURE ] { 11 }
        Constant [ public int RES_E2BIG ] { 37 }
        Constant [ public int RES_KEY_TOO_BIG ] { 39 }
        Constant [ public int RES_SERVER_TEMPORARILY_DISABLED ] { 47 }
        Constant [ public int RES_SERVER_MEMORY_ALLOCATION_FAILURE ] { 48 }
        Constant [ public int RES_AUTH_PROBLEM ] { 40 }
        Constant [ public int RES_AUTH_FAILURE ] { 41 }
        Constant [ public int RES_AUTH_CONTINUE ] { 42 }
        Constant [ public int RES_PAYLOAD_FAILURE ] { -1001 }
        Constant [ public int SERIALIZER_PHP ] { 1 }
        Constant [ public int SERIALIZER_IGBINARY ] { 2 }
        Constant [ public int SERIALIZER_JSON ] { 3 }
        Constant [ public int SERIALIZER_JSON_ARRAY ] { 4 }
        Constant [ public int SERIALIZER_MSGPACK ] { 5 }
        Constant [ public int COMPRESSION_FASTLZ ] { 2 }
        Constant [ public int COMPRESSION_ZLIB ] { 1 }
        Constant [ public int GET_PRESERVE_ORDER ] { 1 }
        Constant [ public int GET_EXTENDED ] { 2 }
        Constant [ public int ON_CONNECT ] { 0 }
        Constant [ public int ON_ADD ] { 1 }
        Constant [ public int ON_APPEND ] { 2 }
        Constant [ public int ON_DECREMENT ] { 3 }
        Constant [ public int ON_DELETE ] { 4 }
        Constant [ public int ON_FLUSH ] { 5 }
        Constant [ public int ON_GET ] { 6 }
        Constant [ public int ON_INCREMENT ] { 7 }
        Constant [ public int ON_NOOP ] { 8 }
        Constant [ public int ON_PREPEND ] { 9 }
        Constant [ public int ON_QUIT ] { 10 }
        Constant [ public int ON_REPLACE ] { 11 }
        Constant [ public int ON_SET ] { 12 }
        Constant [ public int ON_STAT ] { 13 }
        Constant [ public int ON_VERSION ] { 14 }
        Constant [ public int RESPONSE_SUCCESS ] { 0 }
        Constant [ public int RESPONSE_KEY_ENOENT ] { 1 }
        Constant [ public int RESPONSE_KEY_EEXISTS ] { 2 }
        Constant [ public int RESPONSE_E2BIG ] { 3 }
        Constant [ public int RESPONSE_EINVAL ] { 4 }
        Constant [ public int RESPONSE_NOT_STORED ] { 5 }
        Constant [ public int RESPONSE_DELTA_BADVAL ] { 6 }
        Constant [ public int RESPONSE_NOT_MY_VBUCKET ] { 7 }
        Constant [ public int RESPONSE_AUTH_ERROR ] { 32 }
        Constant [ public int RESPONSE_AUTH_CONTINUE ] { 33 }
        Constant [ public int RESPONSE_UNKNOWN_COMMAND ] { 129 }
        Constant [ public int RESPONSE_ENOMEM ] { 130 }
        Constant [ public int RESPONSE_NOT_SUPPORTED ] { 131 }
        Constant [ public int RESPONSE_EINTERNAL ] { 132 }
        Constant [ public int RESPONSE_EBUSY ] { 133 }
        Constant [ public int RESPONSE_ETMPFAIL ] { 134 }
        Constant [ public bool GET_ERROR_RETURN_VALUE ] {  }
      }

      - Static properties [0] {
      }

      - Static methods [0] {
      }

      - Properties [0] {
      }

      - Methods [58] {
        Method [ <internal:memcached, ctor> public method __construct ] {

          - Parameters [3] {
            Parameter #0 [ <optional> string $persistent_id = NULL ]
            Parameter #1 [ <optional> callable $callback = NULL ]
            Parameter #2 [ <optional> string $connection_str = NULL ]
          }
        }

        Method [ <internal:memcached> public method getResultCode ] {

          - Parameters [0] {
          }
          - Return [ int ]
        }

        Method [ <internal:memcached> public method getResultMessage ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }

        Method [ <internal:memcached> public method get ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <optional> callable $cache_cb = NULL ]
            Parameter #2 [ <optional> int $get_flags = 0 ]
          }
          - Return [ mixed ]
        }

        Method [ <internal:memcached> public method getByKey ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <optional> callable $cache_cb = NULL ]
            Parameter #3 [ <optional> int $get_flags = 0 ]
          }
          - Return [ mixed ]
        }

        Method [ <internal:memcached> public method getMulti ] {

          - Parameters [2] {
            Parameter #0 [ <required> array $keys ]
            Parameter #1 [ <optional> int $get_flags = 0 ]
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method getMultiByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> array $keys ]
            Parameter #2 [ <optional> int $get_flags = 0 ]
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method getDelayed ] {

          - Parameters [3] {
            Parameter #0 [ <required> array $keys ]
            Parameter #1 [ <optional> bool $with_cas = 0 ]
            Parameter #2 [ <optional> callable $value_cb = NULL ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method getDelayedByKey ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> array $keys ]
            Parameter #2 [ <optional> bool $with_cas = 0 ]
            Parameter #3 [ <optional> callable $value_cb = NULL ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method fetch ] {

          - Parameters [0] {
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method fetchAll ] {

          - Parameters [0] {
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method set ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <required> mixed $value ]
            Parameter #2 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setByKey ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> mixed $value ]
            Parameter #3 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method touch ] {

          - Parameters [2] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method touchByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setMulti ] {

          - Parameters [2] {
            Parameter #0 [ <required> array $items ]
            Parameter #1 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setMultiByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> array $items ]
            Parameter #2 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method cas ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $cas_token ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> mixed $value ]
            Parameter #3 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method casByKey ] {

          - Parameters [5] {
            Parameter #0 [ <required> string $cas_token ]
            Parameter #1 [ <required> string $server_key ]
            Parameter #2 [ <required> string $key ]
            Parameter #3 [ <required> mixed $value ]
            Parameter #4 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method add ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <required> mixed $value ]
            Parameter #2 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method addByKey ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> mixed $value ]
            Parameter #3 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method append ] {

          - Parameters [2] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <required> string $value ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method appendByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> string $value ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method prepend ] {

          - Parameters [2] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <required> string $value ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method prependByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> string $value ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method replace ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <required> mixed $value ]
            Parameter #2 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method replaceByKey ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <required> mixed $value ]
            Parameter #3 [ <optional> int $expiration = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method delete ] {

          - Parameters [2] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <optional> int $time = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method deleteMulti ] {

          - Parameters [2] {
            Parameter #0 [ <required> array $keys ]
            Parameter #1 [ <optional> int $time = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method deleteByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <optional> int $time = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method deleteMultiByKey ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> array $keys ]
            Parameter #2 [ <optional> int $time = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method increment ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <optional> int $offset = 1 ]
            Parameter #2 [ <optional> int $initial_value = 0 ]
            Parameter #3 [ <optional> int $expiry = 0 ]
          }
          - Return [ int|false ]
        }

        Method [ <internal:memcached> public method decrement ] {

          - Parameters [4] {
            Parameter #0 [ <required> string $key ]
            Parameter #1 [ <optional> int $offset = 1 ]
            Parameter #2 [ <optional> int $initial_value = 0 ]
            Parameter #3 [ <optional> int $expiry = 0 ]
          }
          - Return [ int|false ]
        }

        Method [ <internal:memcached> public method incrementByKey ] {

          - Parameters [5] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <optional> int $offset = 1 ]
            Parameter #3 [ <optional> int $initial_value = 0 ]
            Parameter #4 [ <optional> int $expiry = 0 ]
          }
          - Return [ int|false ]
        }

        Method [ <internal:memcached> public method decrementByKey ] {

          - Parameters [5] {
            Parameter #0 [ <required> string $server_key ]
            Parameter #1 [ <required> string $key ]
            Parameter #2 [ <optional> int $offset = 1 ]
            Parameter #3 [ <optional> int $initial_value = 0 ]
            Parameter #4 [ <optional> int $expiry = 0 ]
          }
          - Return [ int|false ]
        }

        Method [ <internal:memcached> public method addServer ] {

          - Parameters [3] {
            Parameter #0 [ <required> string $host ]
            Parameter #1 [ <required> int $port ]
            Parameter #2 [ <optional> int $weight = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method addServers ] {

          - Parameters [1] {
            Parameter #0 [ <required> array $servers ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method getServerList ] {

          - Parameters [0] {
          }
          - Return [ array ]
        }

        Method [ <internal:memcached> public method getServerByKey ] {

          - Parameters [1] {
            Parameter #0 [ <required> string $server_key ]
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method resetServerList ] {

          - Parameters [0] {
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method quit ] {

          - Parameters [0] {
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method flushBuffers ] {

          - Parameters [0] {
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method getLastErrorMessage ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }

        Method [ <internal:memcached> public method getLastErrorCode ] {

          - Parameters [0] {
          }
          - Return [ int ]
        }

        Method [ <internal:memcached> public method getLastErrorErrno ] {

          - Parameters [0] {
          }
          - Return [ int ]
        }

        Method [ <internal:memcached> public method getLastDisconnectedServer ] {

          - Parameters [0] {
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method getStats ] {

          - Parameters [1] {
            Parameter #0 [ <optional> string $type = NULL ]
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method getVersion ] {

          - Parameters [0] {
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method getAllKeys ] {

          - Parameters [0] {
          }
          - Return [ array|false ]
        }

        Method [ <internal:memcached> public method flush ] {

          - Parameters [1] {
            Parameter #0 [ <optional> int $delay = 0 ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method getOption ] {

          - Parameters [1] {
            Parameter #0 [ <required> int $option ]
          }
          - Return [ mixed ]
        }

        Method [ <internal:memcached> public method setOption ] {

          - Parameters [2] {
            Parameter #0 [ <required> int $option ]
            Parameter #1 [ <required> mixed $value ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setOptions ] {

          - Parameters [1] {
            Parameter #0 [ <required> array $options ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setBucket ] {

          - Parameters [3] {
            Parameter #0 [ <required> array $host_map ]
            Parameter #1 [ <required> array $forward_map ]
            Parameter #2 [ <required> int $replicas ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setSaslAuthData ] {

          - Parameters [2] {
            Parameter #0 [ <required> string $username ]
            Parameter #1 [ <required> string $password ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method setEncodingKey ] {

          - Parameters [1] {
            Parameter #0 [ <required> string $key ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method isPersistent ] {

          - Parameters [0] {
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method isPristine ] {

          - Parameters [0] {
          }
          - Return [ bool ]
        }
      }
    }

    Class [ <internal:memcached> class MemcachedServer ] {

      - Constants [0] {
      }

      - Static properties [0] {
      }

      - Static methods [0] {
      }

      - Properties [0] {
      }

      - Methods [2] {
        Method [ <internal:memcached> public method run ] {

          - Parameters [1] {
            Parameter #0 [ <required> string $address ]
          }
          - Return [ bool ]
        }

        Method [ <internal:memcached> public method on ] {

          - Parameters [2] {
            Parameter #0 [ <required> int $event ]
            Parameter #1 [ <required> callable $callback ]
          }
          - Return [ bool ]
        }
      }
    }

    Class [ <internal:memcached> class MemcachedException extends Exception implements Stringable, Throwable ] {

      - Constants [0] {
      }

      - Static properties [0] {
      }

      - Static methods [0] {
      }

      - Properties [4] {
        Property [ protected $message = '' ]
        Property [ protected $code = 0 ]
        Property [ protected $file = NULL ]
        Property [ protected $line = NULL ]
      }

      - Methods [10] {
        Method [ <internal:Core, inherits Exception, ctor> public method __construct ] {

          - Parameters [3] {
            Parameter #0 [ <optional> string $message = "" ]
            Parameter #1 [ <optional> int $code = 0 ]
            Parameter #2 [ <optional> ?Throwable $previous = null ]
          }
        }

        Method [ <internal:Core, inherits Exception> public method __wakeup ] {

          - Parameters [0] {
          }
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getMessage ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getCode ] {

          - Parameters [0] {
          }
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getFile ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getLine ] {

          - Parameters [0] {
          }
          - Return [ int ]
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getTrace ] {

          - Parameters [0] {
          }
          - Return [ array ]
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getPrevious ] {

          - Parameters [0] {
          }
          - Return [ ?Throwable ]
        }

        Method [ <internal:Core, inherits Exception, prototype Throwable> final public method getTraceAsString ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }

        Method [ <internal:Core, inherits Exception, prototype Stringable> public method __toString ] {

          - Parameters [0] {
          }
          - Return [ string ]
        }
      }
    }
  }
}


@remicollet
Copy link
Collaborator Author

Still TODO (not planed for this PR): check need to promote some warning to exception, for consistency with php-src

@sodabrew
Copy link
Collaborator

sodabrew commented Oct 8, 2020

This is great! How do the stub files get regenerated on changes?

@remicollet
Copy link
Collaborator Author

remicollet commented Oct 9, 2020

This is great! How do the stub files get regenerated on changes?

$ make

;)

But you have to use PHP 8.

You can also generate it manually using (this should work with PHP 7.2+, using gen_stub.php from php-src tree)

$ php build/gen_stub.php [ -f ] php_memcached.stub.php

P.S. rather, the stub file is manually edited, the arginfo headers are generated.

@sodabrew
Copy link
Collaborator

sodabrew commented Oct 9, 2020

I buy it! Thanks for making this improvement!

@sodabrew sodabrew merged commit 6d6c6f4 into php-memcached-dev:master Oct 9, 2020
@remicollet remicollet deleted the issue-arginfo branch October 9, 2020 09:56
@remicollet
Copy link
Collaborator Author

I buy it!

:)

Thanks for making this improvement!

welcome

Can you please add the "hacktoberfest-accepted" label to this PR (even If my challenge is already completed for a few days... only for posterity)


public function get(string $key, callable $cache_cb=NULL, int $get_flags=0): mixed {}
public function getByKey(string $server_key, string $key, callable $cache_cb=NULL, int $get_flags=0): mixed {}
public function getMulti(array $keys, int $get_flags=0): false|array {}

Choose a reason for hiding this comment

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

I've just accidentally come across this PR, and noticed the MEMC_METHOD_FETCH_OBJECT macro (mostly because PHP 8 throws an Error for most uninitialized objects, e.g.: https://github.com/php/php-src/blob/74fe9170b65740bcdc41c9706ec38c31654c12f6/ext/pdo/pdo_stmt.c#L37).

So the reason why I'm writing is that it seems to me that the return in MEMC_METHOD_FETCH_OBJECT is not reflected in the return types in the stubs. Unless I'm missing something, the macro can result in a null return value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Your are right and I think memcached should also raise an exception in such case (and thus, don't pollute arginfo with null case)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kocsismate see pr #465

Choose a reason for hiding this comment

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

@remicollet Looks good, I agree that it's the best thing to do :)

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

Successfully merging this pull request may close these issues.

4 participants