« first day (3417 days earlier)      last day (1514 days later) » 

1:13 AM
Dumb question but is the strlcat function defined in php-src just strncat?
Or meant to be a "safe" version of it?
(Also trying to fix the couple of strict aliasing warnings at 1AM ain't a good idea especially as I have no clue how about to type pun correctly a unsigned char * to a uint64_t or unit32_t)
 
2:05 AM
(Spoiler it's maybe just the super old GCC version on Travis which flags a false positive)
 
2:30 AM
(It is indeed the god damn old GCC version the issue)
 
 
2 hours later…
4:04 AM
@Girgias You mean strcmp?
No idea what strncat or strlcat are.
 
 
5 hours later…
9:30 AM
KeytVarne ・ *General Issues ・ #79298
 
9:50 AM
questions about potential attributes RFC revival changes,

1. allow to declare attribute multiple times on same struct? Yes, No (dmitrys rfc didn'T allow multiple, C# makes this configurable per attribute)

2. which structure to return from Reflection*::getAttributtes()? 1. only arrays 2. optionally to objects (<<@Attr>> instead of <<Attr>>) 3. always to object?
my gut feeling is that mapping should be to objects, because that improves IDE support massively, but only arrays will probably get enough votes
 
10:13 AM
@Sherif yes, see also: linux.die.net/man/3/strlcat
 
10:31 AM
Attributes RFC again: 3. how much would the inclusion of <<deprecated>> attribute hurt or improve the case for attributes in core
 
Madainn mhath
 
10:45 AM
morning
@beberlei 1. Yes the same attribute multiple times makes a lot of sense. If I wanted to add a set of filters (say permissions) to something it makes a lot of sense to be able to specify them multiple times rather than have to specify them once, then use arrays, which might not have the relevant type protection.

2. Not sure what you mean by this.... I think an Attribute(type, value) would make sense. If you did a getAttributesByType(...) then return an array of only those Attributes too?

3. Depends what it would do.
 
2. in <<@Entity("foo", "bar")>>, the @Entity would resolve according to import rules, for example to Doctrine\ORM\Mapping\Entity and then have two "values" 0 => "foo", and 1 => "bar". you could automatically use them as constructor arguments when fetching.
3. it would trigger a deprecation when the method/function is called by injecting a trigger_error(E_USER_DEPRECATED) into the body as the first statement of the function. Benefit would be that IDEs could also use this
 
So the Q is if it should return an Entity, or if it should return something like... [ 'type' => '\Doctrine\ORM\Mapping\Entity', 'args' => [ 0 => 'foo', '1' => 'bar' ]]; ?
 
or only @Entity even, leaving the import resolving to userland
(which is what doctrine does at the moment by parsing the file and caching the result)
 
That sounds like a terribad idea IMHO, considering the only way to know would be to inspect and parse the file it came from
 
yes, dmitry even said 2016 that an optional way to resolving would be nice but never updated the RFC and stas says that the proposal has problems without having a way to resolve to namespaces because of clashes
 
10:59 AM
I think full resolution would be mandatory
 
the problem i see when we "just" return the full qualified class name is, that it leaves open how they get constructed, which makes it harder for IDEs to validate the requires values and their structure while typing them
 
I'm not sure I follow what you mean there. You't thinking of autocomplete for annotations?
 
but to make it really good with objects, we would need some kind of named argument support, which is another beast that introduces potential division on the RFC
yes autocomplete for available attributes, and then what "options" each attribute has
 
Sounds like a job for... dare I say it, even more annotations
 
hm! right, that could be it
i like C#s approach to how they map to objects: docs.microsoft.com/en-us/dotnet/csharp/programming-guide/…
essentially [Author("foo", version=1.1)] is a = new Author("foo"); a.version=1.1;
 
11:04 AM
I could see how that would make sense, provided no additional validation steps were required
 
with typed properties it would be much safer than without
 
For sure, although then it gets into the realm of nesting and the likes.
I think an array to the constructor would be the most flexible, provided it could handle exceptions being thrown
 
attribute only get constructed during Reflection*::getAttributes(), where zend_ast_evaluate is used to resolve the IS_CONSTANT_AST zval
its like a const $foo = <expr>;
 
How would you handle internal engine-specific annotations, or would they not be covered?
 
good question. Each zend_class_entry, zend_property_info, zend_op_array has a new HashTable *attributes, so for deprecated for example i would obviously like to do zend_hash_exists_str(op_array->attributes, "deprecated", sizeof("deprecated")-1) - maybe if we always resolve "PHP\Deprecated" instead
 
11:16 AM
O_O You suggest the unholy use of namespace... Quick, burn him!
 
yeah now the politics get into play, what to do to get it passing :D
 
Srsly though PHP\Annotations\Depreciated ;O
 
but internally the attributes HashTable should be 1-st level keys: Resolved name of the attribute, then a list of values
for the multi attribute support
 
So you would do [ 'attrkey' => [ attr, attr, attr ] ]?
rather than a non-key-indexed set that had to be enumerated
 
example: ["App\Validation\Attributes\Filter" => [ ["name", "string"], ["email", "int"] ]
 
11:20 AM
I think that makes sense yeah
 
11:49 AM
how to loop through dates in PHP on a hourly basis till midnight for a particular day
The date started at 23 FEB 10am to 25FEB 9am


23 FEB 10 am to 24 FEB 12am
24 FEB 12am to 25 FEB 12am
25 FEB 12am to 25 FEB 9am
 
$last_time = strtotime('+1 hour', $last_time);
 
12:12 PM
.... or just add 3600 facepalms myself
 
12:32 PM
@MarkR for 1st date calculate hours TO midnight and last date calculate hours passed FROM midnight
 
 
2 hours later…
2:24 PM
Morngin bitches (m/f)
 
2:36 PM
@PeeHaa (m/f/d)
(no idea what the d stands for)
 
dragons?
 
No.. you want to use the DatePeriod and DateInterval classes
@AbhijitBorkakoty
 
2:59 PM
27 messages moved to Trash can
 
3:13 PM
!!packagist amphp/http-server
 
[ amphp/http-server ] | A non-blocking HTTP application server for PHP based on Amp. (★ 1043)
 
3:25 PM
@AbhijitBorkakoty Something like this: 3v4l.org/XbLRG ?
And 3v4l.org/iJQW0 shows why you should use this approach and not just add 3600 seconds....
 
3:56 PM
I get the second, but what was the point of the first? It doesn't demonstrate anything edgey.
 
 
1 hour later…
5:09 PM
@Sherif The first shouldn'T show anything edgey. That was just a solution for how to loop through hours...
 
6:02 PM
com_print_typeinfo prints duplicate variables ・ COM related ・ #79299
 
3
Q: Find the year with the highest population (most efficient solution)

SherifGiven two arrays; $births containing a list of birth years indicating when someone was born, and `$deaths containing a list of death years indicating when someone died, how can we find the year on which the population was highest? For example given the following arrays: $births = [1984, 1981, 1...

@NikiC you're good at this kind of stuff. Is there a more efficient solution? ^
 
6:42 PM
@Sherif a pure O(n) solution: 3v4l.org/Gi1Zi
And note, more efficient is vague. Do you care about runtime or memory or both, and do you care about actual runtime, or just O(...) runtime?
and 3v4l.org/X939S without the extra write back into $years, which just saves a few writes but doesn't affect the solution
 
@ircmaxell Computational complexity, mostly.
@ircmaxell Wouldn't that be the same though? The only difference here is a bit of added memory and an extra loop, but it's more or less the same Big O for time.
I guess I didn't really clarify that I'm looking for improvements in Big O of the algorithm and not necessarily runtime.
 
7:00 PM
I guess the best thing about your solution is that it doesn't require sorting.
At least not of the input arrays.
 

« first day (3417 days earlier)      last day (1514 days later) »